am 7a789817: (-s ours) Merge "Fixed runtime linkage problems for libOpenSLES and libOpenMAXAL"
* commit '7a78981743646776bb96a80a45900e53d2cc6ab8':
Fixed runtime linkage problems for libOpenSLES and libOpenMAXAL
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 2422a69..1096f5d 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -51,6 +51,8 @@
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/filterpack_ui_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/filterpack_videosrc_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libaudioutils_intermediates)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/filterfw_intermediates)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/framework/filterfw.jar)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/audio_effects/include/audio_effects/effect_downmix.h b/audio_effects/include/audio_effects/effect_downmix.h
new file mode 100644
index 0000000..0f6b073
--- /dev/null
+++ b/audio_effects/include/audio_effects/effect_downmix.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_DOWNMIX_H_
+#define ANDROID_EFFECT_DOWNMIX_H_
+
+#include <hardware/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#define EFFECT_UIID_DOWNMIX__ { 0x381e49cc, 0xa858, 0x4aa2, 0x87f6, \
+ { 0xe8, 0x38, 0x8e, 0x76, 0x01, 0xb2 } }
+static const effect_uuid_t EFFECT_UIID_DOWNMIX_ = EFFECT_UIID_DOWNMIX__;
+const effect_uuid_t * const EFFECT_UIID_DOWNMIX = &EFFECT_UIID_DOWNMIX_;
+
+
+/* enumerated parameter settings for downmix effect */
+typedef enum {
+ DOWNMIX_PARAM_TYPE
+} downmix_params_t;
+
+
+typedef enum {
+ DOWNMIX_TYPE_INVALID = -1,
+ // throw away the extra channels
+ DOWNMIX_TYPE_STRIP = 0,
+ // mix the extra channels with FL/FR
+ DOWNMIX_TYPE_FOLD = 1,
+ DOWNMIX_TYPE_CNT,
+ DOWNMIX_TYPE_LAST = DOWNMIX_TYPE_CNT - 1
+} downmix_type_t;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+
+#endif /*ANDROID_EFFECT_DOWNMIX_H_*/
diff --git a/audio_effects/include/audio_effects/effect_visualizer.h b/audio_effects/include/audio_effects/effect_visualizer.h
index 96a63b3..45bac5a 100644
--- a/audio_effects/include/audio_effects/effect_visualizer.h
+++ b/audio_effects/include/audio_effects/effect_visualizer.h
@@ -32,10 +32,15 @@
#define VISUALIZER_CAPTURE_SIZE_MAX 1024 // maximum capture size in samples
#define VISUALIZER_CAPTURE_SIZE_MIN 128 // minimum capture size in samples
+// to keep in sync with frameworks/base/media/java/android/media/audiofx/Visualizer.java
+#define VISUALIZER_SCALING_MODE_NORMALIZED 0
+#define VISUALIZER_SCALING_MODE_AS_PLAYED 1
+
/* enumerated parameters for Visualizer effect */
typedef enum
{
- VISUALIZER_PARAM_CAPTURE_SIZE, // Sets the number PCM samples in the capture.
+ VISUALIZER_PARAM_CAPTURE_SIZE, // Sets the number PCM samples in the capture.
+ VISUALIZER_PARAM_SCALING_MODE, // Sets the way the captured data is scaled
} t_visualizer_params;
/* commands */
diff --git a/audio_utils/Android.mk b/audio_utils/Android.mk
index 8cdde41..e3f3e5e 100644
--- a/audio_utils/Android.mk
+++ b/audio_utils/Android.mk
@@ -6,13 +6,15 @@
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
+ fixedfft.cpp.arm \
+ primitives.c \
resampler.c \
echo_reference.c
LOCAL_C_INCLUDES += $(call include-path-for, speex)
LOCAL_C_INCLUDES += \
$(call include-path-for, speex) \
- system/media/audio_utils/include
+ $(call include-path-for, audio-utils)
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/audio_utils/echo_reference.c b/audio_utils/echo_reference.c
index 3c6f4d1..c05a60f 100644
--- a/audio_utils/echo_reference.c
+++ b/audio_utils/echo_reference.c
@@ -50,13 +50,17 @@
void *wr_buf; // buffer for input conversions
size_t wr_buf_size; // size of conversion buffer in frames
size_t wr_frames_in; // number of frames in conversion buffer
+ size_t wr_curr_frame_size; // number of frames given to current write() function
void *wr_src_buf; // resampler input buf (either wr_buf or buffer used by write())
struct timespec wr_render_time; // latest render time indicated by write()
// default ALSA gettimeofday() format
int32_t playback_delay; // playback buffer delay indicated by last write()
+ int16_t prev_delta_sign; // sign of previous delay difference:
+ // 1: positive, -1: negative, 0: unknown
+ uint16_t delta_count; // number of consecutive delay differences with same sign
pthread_mutex_t lock; // mutex protecting read/write concurrency
pthread_cond_t cond; // condition signaled when data is ready to read
- struct resampler_itfe *down_sampler; // input resampler
+ struct resampler_itfe *resampler; // input resampler
struct resampler_buffer_provider provider; // resampler buffer provider
};
@@ -81,7 +85,7 @@
buffer->frame_count = (buffer->frame_count > er->wr_frames_in) ? er->wr_frames_in : buffer->frame_count;
// this is er->rd_channel_count here as we resample after stereo to mono conversion if any
- buffer->i16 = (int16_t *)er->wr_src_buf + (er->wr_buf_size - er->wr_frames_in) * er->rd_channel_count;
+ buffer->i16 = (int16_t *)er->wr_src_buf + (er->wr_curr_frame_size - er->wr_frames_in) * er->rd_channel_count;
return 0;
}
@@ -103,7 +107,7 @@
static void echo_reference_reset_l(struct echo_reference *er)
{
- LOGV("echo_reference_reset_l()");
+ ALOGV("echo_reference_reset_l()");
free(er->buffer);
er->buffer = NULL;
er->buf_size = 0;
@@ -113,8 +117,15 @@
er->wr_buf_size = 0;
er->wr_render_time.tv_sec = 0;
er->wr_render_time.tv_nsec = 0;
+ er->delta_count = 0;
+ er->prev_delta_sign = 0;
}
+/* additional space in resampler buffer allowing for extra samples to be returned
+ * by speex resampler when sample rates ratio is not an integer.
+ */
+#define RESAMPLER_HEADROOM_SAMPLES 10
+
static int echo_reference_write(struct echo_reference_itfe *echo_reference,
struct echo_reference_buffer *buffer)
{
@@ -128,18 +139,18 @@
pthread_mutex_lock(&er->lock);
if (buffer == NULL) {
- LOGV("echo_reference_write() stop write");
+ ALOGV("echo_reference_write() stop write");
er->state &= ~ECHOREF_WRITING;
echo_reference_reset_l(er);
goto exit;
}
- LOGV("echo_reference_write() START trying to write %d frames", buffer->frame_count);
- LOGV("echo_reference_write() playbackTimestamp:[%d].[%d], er->playback_delay:[%d]",
+ ALOGV("echo_reference_write() START trying to write %d frames", buffer->frame_count);
+ ALOGV("echo_reference_write() playbackTimestamp:[%d].[%d], er->playback_delay:[%d]",
(int)buffer->time_stamp.tv_sec,
(int)buffer->time_stamp.tv_nsec, er->playback_delay);
- //LOGV("echo_reference_write() %d frames", buffer->frame_count);
+ //ALOGV("echo_reference_write() %d frames", buffer->frame_count);
// discard writes until a valid time stamp is provided.
if ((buffer->time_stamp.tv_sec == 0) && (buffer->time_stamp.tv_nsec == 0) &&
@@ -148,9 +159,9 @@
}
if ((er->state & ECHOREF_WRITING) == 0) {
- LOGV("echo_reference_write() start write");
- if (er->down_sampler != NULL) {
- er->down_sampler->reset(er->down_sampler);
+ ALOGV("echo_reference_write() start write");
+ if (er->resampler != NULL) {
+ er->resampler->reset(er->resampler);
}
er->state |= ECHOREF_WRITING;
}
@@ -164,19 +175,35 @@
er->playback_delay = buffer->delay_ns;
+ // this will be used in the get_next_buffer, to support variable input buffer sizes
+ er->wr_curr_frame_size = buffer->frame_count;
+
void *srcBuf;
size_t inFrames;
// do stereo to mono and down sampling if necessary
if (er->rd_channel_count != er->wr_channel_count ||
er->rd_sampling_rate != er->wr_sampling_rate) {
- if (er->wr_buf_size < buffer->frame_count) {
- er->wr_buf_size = buffer->frame_count;
- //max buffer size is normally function of read sampling rate but as write sampling rate
- //is always more than read sampling rate this works
+ size_t wrBufSize = buffer->frame_count;
+
+ inFrames = buffer->frame_count;
+
+ if (er->rd_sampling_rate != er->wr_sampling_rate) {
+ inFrames = (buffer->frame_count * er->rd_sampling_rate) / er->wr_sampling_rate +
+ RESAMPLER_HEADROOM_SAMPLES;
+ // wr_buf is not only used as resampler output but also for stereo to mono conversion
+ // output so buffer size is driven by both write and read sample rates
+ if (inFrames > wrBufSize) {
+ wrBufSize = inFrames;
+ }
+ }
+
+ if (er->wr_buf_size < wrBufSize) {
+ ALOGV("echo_reference_write() increasing write buffer size from %d to %d",
+ er->wr_buf_size, wrBufSize);
+ er->wr_buf_size = wrBufSize;
er->wr_buf = realloc(er->wr_buf, er->wr_buf_size * er->rd_frame_size);
}
- inFrames = buffer->frame_count;
if (er->rd_channel_count != er->wr_channel_count) {
// must be stereo to mono
int16_t *src16 = (int16_t *)buffer->raw;
@@ -188,21 +215,21 @@
}
}
if (er->wr_sampling_rate != er->rd_sampling_rate) {
- if (er->down_sampler == NULL) {
+ if (er->resampler == NULL) {
int rc;
- LOGV("echo_reference_write() new ReSampler(%d, %d)",
+ ALOGV("echo_reference_write() new ReSampler(%d, %d)",
er->wr_sampling_rate, er->rd_sampling_rate);
er->provider.get_next_buffer = echo_reference_get_next_buffer;
er->provider.release_buffer = echo_reference_release_buffer;
rc = create_resampler(er->wr_sampling_rate,
er->rd_sampling_rate,
er->rd_channel_count,
- RESAMPLER_QUALITY_VOIP,
+ RESAMPLER_QUALITY_DEFAULT,
&er->provider,
- &er->down_sampler);
+ &er->resampler);
if (rc != 0) {
- er->down_sampler = NULL;
- LOGV("echo_reference_write() failure to create resampler %d", rc);
+ er->resampler = NULL;
+ ALOGV("echo_reference_write() failure to create resampler %d", rc);
status = -ENODEV;
goto exit;
}
@@ -217,11 +244,11 @@
er->wr_frames_in = buffer->frame_count;
// inFrames is always more than we need here to get frames remaining from previous runs
// inFrames is updated by resample() with the number of frames produced
- LOGV("echo_reference_write() ReSampling(%d, %d)",
+ ALOGV("echo_reference_write() ReSampling(%d, %d)",
er->wr_sampling_rate, er->rd_sampling_rate);
- er->down_sampler->resample_from_provider(er->down_sampler,
+ er->resampler->resample_from_provider(er->resampler,
(int16_t *)er->wr_buf, &inFrames);
- LOGV_IF(er->wr_frames_in != 0,
+ ALOGV_IF(er->wr_frames_in != 0,
"echo_reference_write() er->wr_frames_in not 0 (%d) after resampler",
er->wr_frames_in);
}
@@ -232,7 +259,7 @@
}
if (er->frames_in + inFrames > er->buf_size) {
- LOGV("echo_reference_write() increasing buffer size from %d to %d",
+ ALOGV("echo_reference_write() increasing buffer size from %d to %d",
er->buf_size, er->frames_in + inFrames);
er->buf_size = er->frames_in + inFrames;
er->buffer = realloc(er->buffer, er->buf_size * er->rd_frame_size);
@@ -242,22 +269,23 @@
inFrames * er->rd_frame_size);
er->frames_in += inFrames;
- LOGV("EchoReference::write_log() inFrames:[%d], mFramesInOld:[%d], "\
- "mFramesInNew:[%d], er->buf_size:[%d], er->wr_render_time:[%d].[%d],"
- "er->playback_delay:[%d]",
- inFrames, er->frames_in - inFrames, er->frames_in, er->buf_size,
- (int)er->wr_render_time.tv_sec,
- (int)er->wr_render_time.tv_nsec, er->playback_delay);
+ ALOGV("echo_reference_write() frames written:[%d], frames total:[%d] buffer size:[%d]\n"
+ " er->wr_render_time:[%d].[%d], er->playback_delay:[%d]",
+ inFrames, er->frames_in, er->buf_size,
+ (int)er->wr_render_time.tv_sec, (int)er->wr_render_time.tv_nsec, er->playback_delay);
pthread_cond_signal(&er->cond);
exit:
pthread_mutex_unlock(&er->lock);
- LOGV("echo_reference_write() END");
+ ALOGV("echo_reference_write() END");
return status;
}
-#define MIN_DELAY_UPDATE_NS 62500 // delay jump threshold to update ref buffer
- // 0.5 samples at 8kHz in nsecs
+// delay jump threshold to update ref buffer: 6 samples at 8kHz in nsecs
+#define MIN_DELAY_DELTA_NS (375000*2)
+// number of consecutive delta with same sign between expected and actual delay before adjusting
+// the buffer
+#define MIN_DELTA_NUM 4
static int echo_reference_read(struct echo_reference_itfe *echo_reference,
@@ -272,16 +300,17 @@
pthread_mutex_lock(&er->lock);
if (buffer == NULL) {
- LOGV("EchoReference::read() stop read");
+ ALOGV("echo_reference_read() stop read");
er->state &= ~ECHOREF_READING;
goto exit;
}
- LOGV("EchoReference::read() START, delayCapture:[%d],er->frames_in:[%d],buffer->frame_count:[%d]",
+ ALOGV("echo_reference_read() START, delayCapture:[%d], "
+ "er->frames_in:[%d],buffer->frame_count:[%d]",
buffer->delay_ns, er->frames_in, buffer->frame_count);
if ((er->state & ECHOREF_READING) == 0) {
- LOGV("EchoReference::read() start read");
+ ALOGV("echo_reference_read() start read");
echo_reference_reset_l(er);
er->state |= ECHOREF_READING;
}
@@ -292,7 +321,7 @@
goto exit;
}
-// LOGV("EchoReference::read() %d frames", buffer->frame_count);
+// ALOGV("echo_reference_read() %d frames", buffer->frame_count);
// allow some time for new frames to arrive if not enough frames are ready for read
if (er->frames_in < buffer->frame_count) {
@@ -303,12 +332,10 @@
ts.tv_nsec = timeoutMs%1000;
pthread_cond_timedwait_relative_np(&er->cond, &er->lock, &ts);
- if (er->frames_in < buffer->frame_count) {
- LOGV("EchoReference::read() waited %d ms but still not enough frames"\
+ ALOGV_IF((er->frames_in < buffer->frame_count),
+ "echo_reference_read() waited %d ms but still not enough frames"\
" er->frames_in: %d, buffer->frame_count = %d",
- timeoutMs, er->frames_in, buffer->frame_count);
- buffer->frame_count = er->frames_in;
- }
+ timeoutMs, er->frames_in, buffer->frame_count);
}
int64_t timeDiff;
@@ -316,7 +343,7 @@
if ((er->wr_render_time.tv_sec == 0 && er->wr_render_time.tv_nsec == 0) ||
(buffer->time_stamp.tv_sec == 0 && buffer->time_stamp.tv_nsec == 0)) {
- LOGV("read: NEW:timestamp is zero---------setting timeDiff = 0, "\
+ ALOGV("echo_reference_read(): NEW:timestamp is zero---------setting timeDiff = 0, "\
"not updating delay this time");
timeDiff = 0;
} else {
@@ -331,71 +358,93 @@
int64_t expectedDelayNs = er->playback_delay + buffer->delay_ns - timeDiff;
- LOGV("expectedDelayNs[%lld] = er->playback_delay[%d] + delayCapture[%d] - timeDiff[%lld]",
- expectedDelayNs, er->playback_delay, buffer->delay_ns, timeDiff);
+ if (er->resampler != NULL) {
+ // Resampler already compensates part of the delay
+ int32_t rsmp_delay = er->resampler->delay_ns(er->resampler);
+ expectedDelayNs -= rsmp_delay;
+ }
+
+ ALOGV("echo_reference_read(): expectedDelayNs[%lld] = "
+ "er->playback_delay[%d] + delayCapture[%d] - timeDiff[%lld]",
+ expectedDelayNs, er->playback_delay, buffer->delay_ns, timeDiff);
if (expectedDelayNs > 0) {
int64_t delayNs = ((int64_t)er->frames_in * 1000000000) / er->rd_sampling_rate;
- delayNs -= expectedDelayNs;
+ int64_t deltaNs = delayNs - expectedDelayNs;
- if (abs(delayNs) >= MIN_DELAY_UPDATE_NS) {
- if (delayNs < 0) {
- size_t previousFrameIn = er->frames_in;
- er->frames_in = (expectedDelayNs * er->rd_sampling_rate)/1000000000;
- int offset = er->frames_in - previousFrameIn;
- LOGV("EchoReference::readlog: delayNs = NEGATIVE and ENOUGH : "\
- "setting %d frames to zero er->frames_in: %d, previousFrameIn = %d",
- offset, er->frames_in, previousFrameIn);
-
- if (er->frames_in > er->buf_size) {
- er->buf_size = er->frames_in;
- er->buffer = realloc(er->buffer, er->frames_in * er->rd_frame_size);
- LOGV("EchoReference::read: increasing buffer size to %d", er->buf_size);
- }
-
- if (offset > 0)
- memset((char *)er->buffer + previousFrameIn * er->rd_frame_size,
- 0, offset * er->rd_frame_size);
+ ALOGV("echo_reference_read(): EchoPathDelayDeviation between reference and DMA [%lld]", deltaNs);
+ if (abs(deltaNs) >= MIN_DELAY_DELTA_NS) {
+ // smooth the variation and update the reference buffer only
+ // if a deviation in the same direction is observed for more than MIN_DELTA_NUM
+ // consecutive reads.
+ int16_t delay_sign = (deltaNs >= 0) ? 1 : -1;
+ if (delay_sign == er->prev_delta_sign) {
+ er->delta_count++;
} else {
- size_t previousFrameIn = er->frames_in;
- int framesInInt = (int)(((int64_t)expectedDelayNs *
- (int64_t)er->rd_sampling_rate)/1000000000);
- int offset = previousFrameIn - framesInInt;
+ er->delta_count = 1;
+ }
+ er->prev_delta_sign = delay_sign;
- LOGV("EchoReference::readlog: delayNs = POSITIVE/ENOUGH :previousFrameIn: %d,"\
- "framesInInt: [%d], offset:[%d], buffer->frame_count:[%d]",
- previousFrameIn, framesInInt, offset, buffer->frame_count);
+ if (er->delta_count > MIN_DELTA_NUM) {
+ size_t previousFrameIn = er->frames_in;
+ er->frames_in = (size_t)((expectedDelayNs * er->rd_sampling_rate)/1000000000);
+ int offset = er->frames_in - previousFrameIn;
- if (framesInInt < (int)buffer->frame_count) {
- if (framesInInt > 0) {
- memset((char *)er->buffer + framesInInt * er->rd_frame_size,
- 0, (buffer->frame_count-framesInInt) * er->rd_frame_size);
- LOGV("EchoReference::read: pushing [%d] zeros into ref buffer",
- (buffer->frame_count-framesInInt));
- } else {
- LOGV("framesInInt = %d", framesInInt);
+ ALOGV("echo_reference_read(): deltaNs ENOUGH and %s: "
+ "er->frames_in: %d, previousFrameIn = %d",
+ delay_sign ? "positive" : "negative", er->frames_in, previousFrameIn);
+
+ if (deltaNs < 0) {
+ // Less data available in the reference buffer than expected
+ if (er->frames_in > er->buf_size) {
+ er->buf_size = er->frames_in;
+ er->buffer = realloc(er->buffer, er->buf_size * er->rd_frame_size);
+ ALOGV("echo_reference_read(): increasing buffer size to %d",
+ er->buf_size);
}
- framesInInt = buffer->frame_count;
+
+ if (offset > 0) {
+ memset((char *)er->buffer + previousFrameIn * er->rd_frame_size,
+ 0, offset * er->rd_frame_size);
+ ALOGV("echo_reference_read(): pushing ref buffer by [%d]", offset);
+ }
} else {
+ // More data available in the reference buffer than expected
+ offset = -offset;
if (offset > 0) {
memcpy(er->buffer, (char *)er->buffer + (offset * er->rd_frame_size),
- framesInInt * er->rd_frame_size);
- LOGV("EchoReference::read: shifting ref buffer by [%d]",framesInInt);
+ er->frames_in * er->rd_frame_size);
+ ALOGV("echo_reference_read(): shifting ref buffer by [%d]",
+ er->frames_in);
}
}
- er->frames_in = (size_t)framesInInt;
}
} else {
- LOGV("EchoReference::read: NOT ENOUGH samples to update %lld", delayNs);
+ er->delta_count = 0;
+ er->prev_delta_sign = 0;
+ ALOGV("echo_reference_read(): Constant EchoPathDelay - difference "
+ "between reference and DMA %lld", deltaNs);
}
} else {
- LOGV("NEGATIVE expectedDelayNs[%lld] = "\
+ ALOGV("echo_reference_read(): NEGATIVE expectedDelayNs[%lld] = "\
"er->playback_delay[%d] + delayCapture[%d] - timeDiff[%lld]",
expectedDelayNs, er->playback_delay, buffer->delay_ns, timeDiff);
}
}
+ if (er->frames_in < buffer->frame_count) {
+ if (buffer->frame_count > er->buf_size) {
+ er->buf_size = buffer->frame_count;
+ er->buffer = realloc(er->buffer, er->buf_size * er->rd_frame_size);
+ ALOGV("echo_reference_read(): increasing buffer size to %d", er->buf_size);
+ }
+ // filling up the reference buffer with 0s to match the expected delay.
+ memset((char *)er->buffer + er->frames_in * er->rd_frame_size,
+ 0, (buffer->frame_count - er->frames_in) * er->rd_frame_size);
+ er->frames_in = buffer->frame_count;
+ }
+
memcpy(buffer->raw,
(char *)er->buffer,
buffer->frame_count * er->rd_frame_size);
@@ -408,7 +457,7 @@
// As the reference buffer is now time aligned to the microphone signal there is a zero delay
buffer->delay_ns = 0;
- LOGV("EchoReference::read() END %d frames, total frames in %d",
+ ALOGV("echo_reference_read() END %d frames, total frames in %d",
buffer->frame_count, er->frames_in);
pthread_cond_signal(&er->cond);
@@ -429,7 +478,7 @@
{
struct echo_reference *er;
- LOGV("create_echo_reference()");
+ ALOGV("create_echo_reference()");
if (echo_reference == NULL) {
return -EINVAL;
@@ -439,17 +488,12 @@
if (rdFormat != AUDIO_FORMAT_PCM_16_BIT ||
rdFormat != wrFormat) {
- LOGW("create_echo_reference bad format rd %d, wr %d", rdFormat, wrFormat);
+ ALOGW("create_echo_reference bad format rd %d, wr %d", rdFormat, wrFormat);
return -EINVAL;
}
if ((rdChannelCount != 1 && rdChannelCount != 2) ||
wrChannelCount != 2) {
- LOGW("create_echo_reference bad channel count rd %d, wr %d", rdChannelCount, wrChannelCount);
- return -EINVAL;
- }
-
- if (wrSamplingRate < rdSamplingRate) {
- LOGW("create_echo_reference bad smp rate rd %d, wr %d", rdSamplingRate, wrSamplingRate);
+ ALOGW("create_echo_reference bad channel count rd %d, wr %d", rdChannelCount, wrChannelCount);
return -EINVAL;
}
@@ -478,10 +522,10 @@
return;
}
- LOGV("EchoReference dstor");
+ ALOGV("EchoReference dstor");
echo_reference_reset_l(er);
- if (er->down_sampler != NULL) {
- release_resampler(er->down_sampler);
+ if (er->resampler != NULL) {
+ release_resampler(er->resampler);
}
free(er);
}
diff --git a/audio_utils/fixedfft.cpp b/audio_utils/fixedfft.cpp
new file mode 100644
index 0000000..2c92e74
--- /dev/null
+++ b/audio_utils/fixedfft.cpp
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* A Fixed point implementation of Fast Fourier Transform (FFT). Complex numbers
+ * are represented by 32-bit integers, where higher 16 bits are real part and
+ * lower ones are imaginary part. Few compromises are made between efficiency,
+ * accuracy, and maintainability. To make it fast, arithmetic shifts are used
+ * instead of divisions, and bitwise inverses are used instead of negates. To
+ * keep it small, only radix-2 Cooley-Tukey algorithm is implemented, and only
+ * half of the twiddle factors are stored. Although there are still ways to make
+ * it even faster or smaller, it costs too much on one of the aspects.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#ifdef __arm__
+#include <machine/cpu-features.h>
+#endif
+
+#include <audio_utils/fixedfft.h>
+
+#define LOG_FFT_SIZE 10
+#define MAX_FFT_SIZE (1 << LOG_FFT_SIZE)
+
+static const int32_t twiddle[MAX_FFT_SIZE / 4] = {
+ 0x00008000, 0xff378001, 0xfe6e8002, 0xfda58006, 0xfcdc800a, 0xfc13800f,
+ 0xfb4a8016, 0xfa81801e, 0xf9b88027, 0xf8ef8032, 0xf827803e, 0xf75e804b,
+ 0xf6958059, 0xf5cd8068, 0xf5058079, 0xf43c808b, 0xf374809e, 0xf2ac80b2,
+ 0xf1e480c8, 0xf11c80de, 0xf05580f6, 0xef8d8110, 0xeec6812a, 0xedff8146,
+ 0xed388163, 0xec718181, 0xebab81a0, 0xeae481c1, 0xea1e81e2, 0xe9588205,
+ 0xe892822a, 0xe7cd824f, 0xe7078276, 0xe642829d, 0xe57d82c6, 0xe4b982f1,
+ 0xe3f4831c, 0xe3308349, 0xe26d8377, 0xe1a983a6, 0xe0e683d6, 0xe0238407,
+ 0xdf61843a, 0xde9e846e, 0xdddc84a3, 0xdd1b84d9, 0xdc598511, 0xdb998549,
+ 0xdad88583, 0xda1885be, 0xd95885fa, 0xd8988637, 0xd7d98676, 0xd71b86b6,
+ 0xd65c86f6, 0xd59e8738, 0xd4e1877b, 0xd42487c0, 0xd3678805, 0xd2ab884c,
+ 0xd1ef8894, 0xd13488dd, 0xd0798927, 0xcfbe8972, 0xcf0489be, 0xce4b8a0c,
+ 0xcd928a5a, 0xccd98aaa, 0xcc218afb, 0xcb698b4d, 0xcab28ba0, 0xc9fc8bf5,
+ 0xc9468c4a, 0xc8908ca1, 0xc7db8cf8, 0xc7278d51, 0xc6738dab, 0xc5c08e06,
+ 0xc50d8e62, 0xc45b8ebf, 0xc3a98f1d, 0xc2f88f7d, 0xc2488fdd, 0xc198903e,
+ 0xc0e990a1, 0xc03a9105, 0xbf8c9169, 0xbedf91cf, 0xbe329236, 0xbd86929e,
+ 0xbcda9307, 0xbc2f9371, 0xbb8593dc, 0xbadc9448, 0xba3394b5, 0xb98b9523,
+ 0xb8e39592, 0xb83c9603, 0xb7969674, 0xb6f196e6, 0xb64c9759, 0xb5a897ce,
+ 0xb5059843, 0xb46298b9, 0xb3c09930, 0xb31f99a9, 0xb27f9a22, 0xb1df9a9c,
+ 0xb1409b17, 0xb0a29b94, 0xb0059c11, 0xaf689c8f, 0xaecc9d0e, 0xae319d8e,
+ 0xad979e0f, 0xacfd9e91, 0xac659f14, 0xabcd9f98, 0xab36a01c, 0xaaa0a0a2,
+ 0xaa0aa129, 0xa976a1b0, 0xa8e2a238, 0xa84fa2c2, 0xa7bda34c, 0xa72ca3d7,
+ 0xa69ca463, 0xa60ca4f0, 0xa57ea57e, 0xa4f0a60c, 0xa463a69c, 0xa3d7a72c,
+ 0xa34ca7bd, 0xa2c2a84f, 0xa238a8e2, 0xa1b0a976, 0xa129aa0a, 0xa0a2aaa0,
+ 0xa01cab36, 0x9f98abcd, 0x9f14ac65, 0x9e91acfd, 0x9e0fad97, 0x9d8eae31,
+ 0x9d0eaecc, 0x9c8faf68, 0x9c11b005, 0x9b94b0a2, 0x9b17b140, 0x9a9cb1df,
+ 0x9a22b27f, 0x99a9b31f, 0x9930b3c0, 0x98b9b462, 0x9843b505, 0x97ceb5a8,
+ 0x9759b64c, 0x96e6b6f1, 0x9674b796, 0x9603b83c, 0x9592b8e3, 0x9523b98b,
+ 0x94b5ba33, 0x9448badc, 0x93dcbb85, 0x9371bc2f, 0x9307bcda, 0x929ebd86,
+ 0x9236be32, 0x91cfbedf, 0x9169bf8c, 0x9105c03a, 0x90a1c0e9, 0x903ec198,
+ 0x8fddc248, 0x8f7dc2f8, 0x8f1dc3a9, 0x8ebfc45b, 0x8e62c50d, 0x8e06c5c0,
+ 0x8dabc673, 0x8d51c727, 0x8cf8c7db, 0x8ca1c890, 0x8c4ac946, 0x8bf5c9fc,
+ 0x8ba0cab2, 0x8b4dcb69, 0x8afbcc21, 0x8aaaccd9, 0x8a5acd92, 0x8a0cce4b,
+ 0x89becf04, 0x8972cfbe, 0x8927d079, 0x88ddd134, 0x8894d1ef, 0x884cd2ab,
+ 0x8805d367, 0x87c0d424, 0x877bd4e1, 0x8738d59e, 0x86f6d65c, 0x86b6d71b,
+ 0x8676d7d9, 0x8637d898, 0x85fad958, 0x85beda18, 0x8583dad8, 0x8549db99,
+ 0x8511dc59, 0x84d9dd1b, 0x84a3dddc, 0x846ede9e, 0x843adf61, 0x8407e023,
+ 0x83d6e0e6, 0x83a6e1a9, 0x8377e26d, 0x8349e330, 0x831ce3f4, 0x82f1e4b9,
+ 0x82c6e57d, 0x829de642, 0x8276e707, 0x824fe7cd, 0x822ae892, 0x8205e958,
+ 0x81e2ea1e, 0x81c1eae4, 0x81a0ebab, 0x8181ec71, 0x8163ed38, 0x8146edff,
+ 0x812aeec6, 0x8110ef8d, 0x80f6f055, 0x80def11c, 0x80c8f1e4, 0x80b2f2ac,
+ 0x809ef374, 0x808bf43c, 0x8079f505, 0x8068f5cd, 0x8059f695, 0x804bf75e,
+ 0x803ef827, 0x8032f8ef, 0x8027f9b8, 0x801efa81, 0x8016fb4a, 0x800ffc13,
+ 0x800afcdc, 0x8006fda5, 0x8002fe6e, 0x8001ff37,
+};
+
+/* Returns the multiplication of \conj{a} and {b}. */
+static inline int32_t mult(int32_t a, int32_t b)
+{
+#if __ARM_ARCH__ >= 6
+ int32_t t = b;
+ __asm__("smuad %0, %0, %1" : "+r" (t) : "r" (a));
+ __asm__("smusdx %0, %0, %1" : "+r" (b) : "r" (a));
+ __asm__("pkhtb %0, %0, %1, ASR #16" : "+r" (t) : "r" (b));
+ return t;
+#else
+ return (((a >> 16) * (b >> 16) + (int16_t)a * (int16_t)b) & ~0xFFFF) |
+ ((((a >> 16) * (int16_t)b - (int16_t)a * (b >> 16)) >> 16) & 0xFFFF);
+#endif
+}
+
+static inline int32_t half(int32_t a)
+{
+#if __ARM_ARCH__ >= 6
+ __asm__("shadd16 %0, %0, %1" : "+r" (a) : "r" (0));
+ return a;
+#else
+ return ((a >> 1) & ~0x8000) | (a & 0x8000);
+#endif
+}
+
+void fixed_fft(int n, int32_t *v)
+{
+ int scale = LOG_FFT_SIZE, i, p, r;
+
+ for (r = 0, i = 1; i < n; ++i) {
+ for (p = n; !(p & r); p >>= 1, r ^= p);
+ if (i < r) {
+ int32_t t = v[i];
+ v[i] = v[r];
+ v[r] = t;
+ }
+ }
+
+ for (p = 1; p < n; p <<= 1) {
+ --scale;
+
+ for (i = 0; i < n; i += p << 1) {
+ int32_t x = half(v[i]);
+ int32_t y = half(v[i + p]);
+ v[i] = x + y;
+ v[i + p] = x - y;
+ }
+
+ for (r = 1; r < p; ++r) {
+ int32_t w = MAX_FFT_SIZE / 4 - (r << scale);
+ i = w >> 31;
+ w = twiddle[(w ^ i) - i] ^ (i << 16);
+ for (i = r; i < n; i += p << 1) {
+ int32_t x = half(v[i]);
+ int32_t y = mult(w, v[i + p]);
+ v[i] = x - y;
+ v[i + p] = x + y;
+ }
+ }
+ }
+}
+
+void fixed_fft_real(int n, int32_t *v)
+{
+ int scale = LOG_FFT_SIZE, m = n >> 1, i;
+
+ fixed_fft(n, v);
+ for (i = 1; i <= n; i <<= 1, --scale);
+ v[0] = mult(~v[0], 0x80008000);
+ v[m] = half(v[m]);
+
+ for (i = 1; i < n >> 1; ++i) {
+ int32_t x = half(v[i]);
+ int32_t z = half(v[n - i]);
+ int32_t y = z - (x ^ 0xFFFF);
+ x = half(x + (z ^ 0xFFFF));
+ y = mult(y, twiddle[i << scale]);
+ v[i] = x - y;
+ v[n - i] = (x + y) ^ 0xFFFF;
+ }
+}
diff --git a/audio_utils/include/audio_utils/fixedfft.h b/audio_utils/include/audio_utils/fixedfft.h
new file mode 100644
index 0000000..5903619
--- /dev/null
+++ b/audio_utils/include/audio_utils/fixedfft.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_FIXEDFFT_H
+#define ANDROID_AUDIO_FIXEDFFT_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* See description in fixedfft.cpp */
+extern void fixed_fft_real(int n, int32_t *v);
+
+__END_DECLS
+
+#endif // ANDROID_AUDIO_FIXEDFFT_H
diff --git a/audio_utils/include/audio_utils/primitives.h b/audio_utils/include/audio_utils/primitives.h
new file mode 100644
index 0000000..16adbff
--- /dev/null
+++ b/audio_utils/include/audio_utils/primitives.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_PRIMITIVES_H
+#define ANDROID_AUDIO_PRIMITIVES_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/**
+ * Dither and clamp pairs of 32-bit input samples (sums) to 16-bit output samples (out).
+ * Each 32-bit input sample is a signed fixed-point Q19.12.
+ * The .12 fraction is dithered, and the integer portion is then clamped to Q15.
+ * For interleaved stereo, c is the number of sample pairs,
+ * and out is an array of interleaved pairs of 16-bit samples per channel.
+ * For mono, c is the number of samples / 2, and out is an array of 16-bit samples.
+ * The name "dither" is a misnomer; the current implementation does not actually dither
+ * but uses truncation. This may change.
+ */
+void ditherAndClamp(int32_t* out, const int32_t *sums, size_t c);
+
+/* Expand and copy samples from unsigned 8-bit offset by 0x80 to signed 16-bit.
+ * Parameters:
+ * dst Destination buffer
+ * src Source buffer
+ * count Number of samples to copy
+ * The destination and source buffers must either be completely separate (non-overlapping), or
+ * they must both start at the same address. Partially overlapping buffers are not supported.
+ */
+void memcpy_to_i16_from_u8(int16_t *dst, const uint8_t *src, size_t count);
+
+/**
+ * Clamp (aka hard limit or clip) a signed 32-bit sample to 16-bit range.
+ */
+static inline int16_t clamp16(int32_t sample)
+{
+ if ((sample>>15) ^ (sample>>31))
+ sample = 0x7FFF ^ (sample>>31);
+ return sample;
+}
+
+/**
+ * Multiply-accumulate 16-bit terms with 32-bit result: return a + in*v.
+ */
+static inline
+int32_t mulAdd(int16_t in, int16_t v, int32_t a)
+{
+#if defined(__arm__) && !defined(__thumb__)
+ int32_t out;
+ asm( "smlabb %[out], %[in], %[v], %[a] \n"
+ : [out]"=r"(out)
+ : [in]"%r"(in), [v]"r"(v), [a]"r"(a)
+ : );
+ return out;
+#else
+ return a + in * (int32_t)v;
+#endif
+}
+
+/**
+ * Multiply 16-bit terms with 32-bit result: return in*v.
+ */
+static inline
+int32_t mul(int16_t in, int16_t v)
+{
+#if defined(__arm__) && !defined(__thumb__)
+ int32_t out;
+ asm( "smulbb %[out], %[in], %[v] \n"
+ : [out]"=r"(out)
+ : [in]"%r"(in), [v]"r"(v)
+ : );
+ return out;
+#else
+ return in * (int32_t)v;
+#endif
+}
+
+/**
+ * Similar to mulAdd, but the 16-bit terms are extracted from a 32-bit interleaved stereo pair.
+ */
+static inline
+int32_t mulAddRL(int left, uint32_t inRL, uint32_t vRL, int32_t a)
+{
+#if defined(__arm__) && !defined(__thumb__)
+ int32_t out;
+ if (left) {
+ asm( "smlabb %[out], %[inRL], %[vRL], %[a] \n"
+ : [out]"=r"(out)
+ : [inRL]"%r"(inRL), [vRL]"r"(vRL), [a]"r"(a)
+ : );
+ } else {
+ asm( "smlatt %[out], %[inRL], %[vRL], %[a] \n"
+ : [out]"=r"(out)
+ : [inRL]"%r"(inRL), [vRL]"r"(vRL), [a]"r"(a)
+ : );
+ }
+ return out;
+#else
+ if (left) {
+ return a + (int16_t)(inRL&0xFFFF) * (int16_t)(vRL&0xFFFF);
+ } else {
+ return a + (int16_t)(inRL>>16) * (int16_t)(vRL>>16);
+ }
+#endif
+}
+
+/**
+ * Similar to mul, but the 16-bit terms are extracted from a 32-bit interleaved stereo pair.
+ */
+static inline
+int32_t mulRL(int left, uint32_t inRL, uint32_t vRL)
+{
+#if defined(__arm__) && !defined(__thumb__)
+ int32_t out;
+ if (left) {
+ asm( "smulbb %[out], %[inRL], %[vRL] \n"
+ : [out]"=r"(out)
+ : [inRL]"%r"(inRL), [vRL]"r"(vRL)
+ : );
+ } else {
+ asm( "smultt %[out], %[inRL], %[vRL] \n"
+ : [out]"=r"(out)
+ : [inRL]"%r"(inRL), [vRL]"r"(vRL)
+ : );
+ }
+ return out;
+#else
+ if (left) {
+ return (int16_t)(inRL&0xFFFF) * (int16_t)(vRL&0xFFFF);
+ } else {
+ return (int16_t)(inRL>>16) * (int16_t)(vRL>>16);
+ }
+#endif
+}
+
+__END_DECLS
+
+#endif // ANDROID_AUDIO_PRIMITIVES_H
diff --git a/audio_utils/primitives.c b/audio_utils/primitives.c
new file mode 100644
index 0000000..8697ea1
--- /dev/null
+++ b/audio_utils/primitives.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <audio_utils/primitives.h>
+
+void ditherAndClamp(int32_t* out, int32_t const *sums, size_t c)
+{
+ size_t i;
+ for (i=0 ; i<c ; i++) {
+ int32_t l = *sums++;
+ int32_t r = *sums++;
+ int32_t nl = l >> 12;
+ int32_t nr = r >> 12;
+ l = clamp16(nl);
+ r = clamp16(nr);
+ *out++ = (r<<16) | (l & 0xFFFF);
+ }
+}
+
+void memcpy_to_i16_from_u8(int16_t *dst, const uint8_t *src, size_t count)
+{
+ dst += count;
+ src += count;
+ while (count--) {
+ *--dst = (int16_t)(*--src - 0x80) << 8;
+ }
+}
diff --git a/audio_utils/resampler.c b/audio_utils/resampler.c
index d41dd42..f2e8ee1 100644
--- a/audio_utils/resampler.c
+++ b/audio_utils/resampler.c
@@ -88,7 +88,7 @@
// update and cache the number of frames needed at the input sampling rate to produce
// the number of frames requested at the output sampling rate
if (framesRq != rsmp->frames_rq) {
- rsmp->frames_needed = (framesRq * rsmp->out_sample_rate) / rsmp->in_sample_rate + 1;
+ rsmp->frames_needed = (framesRq * rsmp->in_sample_rate) / rsmp->out_sample_rate + 1;
rsmp->frames_rq = framesRq;
}
@@ -135,7 +135,7 @@
}
framesWr += outFrames;
rsmp->frames_in -= inFrames;
- LOGW_IF((framesWr != framesRq) && (rsmp->frames_in != 0),
+ ALOGW_IF((framesWr != framesRq) && (rsmp->frames_in != 0),
"ReSampler::resample() remaining %d frames in and %d frames out",
rsmp->frames_in, (framesRq - framesWr));
}
@@ -181,7 +181,7 @@
outFrameCount);
}
- LOGV("resampler_resample_from_input() DONE in %d out % d", *inFrameCount, *outFrameCount);
+ ALOGV("resampler_resample_from_input() DONE in %d out % d", *inFrameCount, *outFrameCount);
return 0;
}
@@ -196,7 +196,7 @@
int error;
struct resampler *rsmp;
- LOGV("create_resampler() In SR %d Out SR %d channels %d",
+ ALOGV("create_resampler() In SR %d Out SR %d channels %d",
inSampleRate, outSampleRate, channelCount);
if (resampler == NULL) {
@@ -217,7 +217,8 @@
quality,
&error);
if (rsmp->speex_resampler == NULL) {
- LOGW("ReSampler: Cannot create speex resampler: %s", speex_resampler_strerror(error));
+ ALOGW("ReSampler: Cannot create speex resampler: %s", speex_resampler_strerror(error));
+ free(rsmp);
return -ENODEV;
}
@@ -241,7 +242,7 @@
rsmp->speex_delay_ns += (int32_t)((1000000000 * (int64_t)frames) / rsmp->out_sample_rate);
*resampler = &rsmp->itfe;
- LOGV("create_resampler() DONE rsmp %p &rsmp->itfe %p speex %p",
+ ALOGV("create_resampler() DONE rsmp %p &rsmp->itfe %p speex %p",
rsmp, &rsmp->itfe, rsmp->speex_resampler);
return 0;
}
diff --git a/camera/include/system/camera_metadata.h b/camera/include/system/camera_metadata.h
new file mode 100644
index 0000000..6a11cfb
--- /dev/null
+++ b/camera/include/system/camera_metadata.h
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_METADATA_H
+#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_METADATA_H
+
+#include <string.h>
+#include <stdint.h>
+#include <cutils/compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Tag hierarchy and enum definitions for camera_metadata_entry
+ * =============================================================================
+ */
+
+/**
+ * Main enum definitions are in a separate file to make it easy to
+ * maintain
+ */
+#include "camera_metadata_tags.h"
+
+/**
+ * Enum range for each top-level category
+ */
+ANDROID_API
+extern unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2];
+ANDROID_API
+extern const char *camera_metadata_section_names[ANDROID_SECTION_COUNT];
+
+/**
+ * Type definitions for camera_metadata_entry
+ * =============================================================================
+ */
+enum {
+ // Unsigned 8-bit integer (uint8_t)
+ TYPE_BYTE = 0,
+ // Signed 32-bit integer (int32_t)
+ TYPE_INT32 = 1,
+ // 32-bit float (float)
+ TYPE_FLOAT = 2,
+ // Signed 64-bit integer (int64_t)
+ TYPE_INT64 = 3,
+ // 64-bit float (double)
+ TYPE_DOUBLE = 4,
+ // A 64-bit fraction (camera_metadata_rational_t)
+ TYPE_RATIONAL = 5,
+ // Number of type fields
+ NUM_TYPES
+};
+
+typedef struct camera_metadata_rational {
+ int32_t numerator;
+ int32_t denominator;
+} camera_metadata_rational_t;
+
+/**
+ * Size in bytes of each entry type
+ */
+ANDROID_API
+extern size_t camera_metadata_type_sizes[NUM_TYPES];
+
+/**
+ * Main definitions for the metadata entry and array structures
+ * =============================================================================
+ */
+
+/**
+ * A packet of metadata. This is a list of metadata entries, each of which has
+ * an integer tag to identify its meaning, 'type' and 'count' field, and the
+ * data, which contains a 'count' number of entries of type 'type'. The packet
+ * has a fixed capacity for entries and for extra data. A new entry uses up one
+ * entry slot, and possibly some amount of data capacity; the function
+ * calculate_camera_metadata_entry_data_size() provides the amount of data
+ * capacity that would be used up by an entry.
+ *
+ * Entries are not sorted, and are not forced to be unique - multiple entries
+ * with the same tag are allowed. The packet will not dynamically resize when
+ * full.
+ *
+ * The packet is contiguous in memory, with size in bytes given by
+ * get_camera_metadata_size(). Therefore, it can be copied safely with memcpy()
+ * to a buffer of sufficient size. The copy_camera_metadata() function is
+ * intended for eliminating unused capacity in the destination packet.
+ */
+struct camera_metadata;
+typedef struct camera_metadata camera_metadata_t;
+
+/**
+ * Functions for manipulating camera metadata
+ * =============================================================================
+ */
+
+/**
+ * Allocate a new camera_metadata structure, with some initial space for entries
+ * and extra data. The entry_capacity is measured in entry counts, and
+ * data_capacity in bytes. The resulting structure is all contiguous in memory,
+ * and can be freed with free_camera_metadata().
+ */
+ANDROID_API
+camera_metadata_t *allocate_camera_metadata(size_t entry_capacity,
+ size_t data_capacity);
+
+/**
+ * Place a camera metadata structure into an existing buffer. Returns NULL if
+ * the buffer is too small for the requested number of reserved entries and
+ * bytes of data. The entry_capacity is measured in entry counts, and
+ * data_capacity in bytes. If the buffer is larger than the required space,
+ * unused space will be left at the end. If successful, returns a pointer to the
+ * metadata header placed at the start of the buffer. It is the caller's
+ * responsibility to free the original buffer; do not call
+ * free_camera_metadata() with the returned pointer.
+ */
+ANDROID_API
+camera_metadata_t *place_camera_metadata(void *dst, size_t dst_size,
+ size_t entry_capacity,
+ size_t data_capacity);
+
+/**
+ * Free a camera_metadata structure. Should only be used with structures
+ * allocated with allocate_camera_metadata().
+ */
+ANDROID_API
+void free_camera_metadata(camera_metadata_t *metadata);
+
+/**
+ * Calculate the buffer size needed for a metadata structure of entry_count
+ * metadata entries, needing a total of data_count bytes of extra data storage.
+ */
+ANDROID_API
+size_t calculate_camera_metadata_size(size_t entry_count,
+ size_t data_count);
+
+/**
+ * Get current size of entire metadata structure in bytes, including reserved
+ * but unused space.
+ */
+ANDROID_API
+size_t get_camera_metadata_size(const camera_metadata_t *metadata);
+
+/**
+ * Get size of entire metadata buffer in bytes, not including reserved but
+ * unused space. This is the amount of space needed by copy_camera_metadata for
+ * its dst buffer.
+ */
+ANDROID_API
+size_t get_camera_metadata_compact_size(const camera_metadata_t *metadata);
+
+/**
+ * Get the current number of entries in the metadata packet.
+ */
+ANDROID_API
+size_t get_camera_metadata_entry_count(const camera_metadata_t *metadata);
+
+/**
+ * Get the maximum number of entries that could fit in the metadata packet.
+ */
+ANDROID_API
+size_t get_camera_metadata_entry_capacity(const camera_metadata_t *metadata);
+
+/**
+ * Get the current count of bytes used for value storage in the metadata packet.
+ */
+ANDROID_API
+size_t get_camera_metadata_data_count(const camera_metadata_t *metadata);
+
+/**
+ * Get the maximum count of bytes that could be used for value storage in the
+ * metadata packet.
+ */
+ANDROID_API
+size_t get_camera_metadata_data_capacity(const camera_metadata_t *metadata);
+
+/**
+ * Copy a metadata structure to a memory buffer, compacting it along the
+ * way. That is, in the copied structure, entry_count == entry_capacity, and
+ * data_count == data_capacity.
+ *
+ * If dst_size > get_camera_metadata_compact_size(), the unused bytes are at the
+ * end of the buffer. If dst_size < get_camera_metadata_compact_size(), returns
+ * NULL. Otherwise returns a pointer to the metadata structure header placed at
+ * the start of dst.
+ *
+ * Since the buffer was not allocated by allocate_camera_metadata, the caller is
+ * responsible for freeing the underlying buffer when needed; do not call
+ * free_camera_metadata.
+ */
+ANDROID_API
+camera_metadata_t *copy_camera_metadata(void *dst, size_t dst_size,
+ const camera_metadata_t *src);
+
+/**
+ * Append camera metadata in src to an existing metadata structure in dst. This
+ * does not resize the destination structure, so if it is too small, a non-zero
+ * value is returned. On success, 0 is returned. Appending onto a sorted
+ * structure results in a non-sorted combined structure.
+ */
+ANDROID_API
+int append_camera_metadata(camera_metadata_t *dst, const camera_metadata_t *src);
+
+/**
+ * Calculate the number of bytes of extra data a given metadata entry will take
+ * up. That is, if entry of 'type' with a payload of 'data_count' values is
+ * added, how much will the value returned by get_camera_metadata_data_count()
+ * be increased? This value may be zero, if no extra data storage is needed.
+ */
+ANDROID_API
+size_t calculate_camera_metadata_entry_data_size(uint8_t type,
+ size_t data_count);
+
+/**
+ * Add a metadata entry to a metadata structure. Returns 0 if the addition
+ * succeeded. Returns a non-zero value if there is insufficient reserved space
+ * left to add the entry, or if the tag is unknown. data_count is the number of
+ * entries in the data array of the tag's type, not a count of
+ * bytes. Vendor-defined tags can not be added using this method, unless
+ * set_vendor_tag_query_ops() has been called first. Entries are always added to
+ * the end of the structure (highest index), so after addition, a
+ * previously-sorted array will be marked as unsorted.
+ */
+ANDROID_API
+int add_camera_metadata_entry(camera_metadata_t *dst,
+ uint32_t tag,
+ const void *data,
+ size_t data_count);
+
+/**
+ * Sort the metadata buffer for fast searching. If already sorted, does
+ * nothing. Adding or appending entries to the buffer will place the buffer back
+ * into an unsorted state.
+ */
+ANDROID_API
+int sort_camera_metadata(camera_metadata_t *dst);
+
+/**
+ * Get pointers to the fields for a metadata entry at position index in the
+ * entry array. The data pointer points either to the entry's data.value field
+ * or to the right offset in camera_metadata_t.data. Returns 0 on
+ * success. Data_count is the number of entries in the data array when cast to
+ * the tag's type, not a count of bytes.
+ *
+ * src and index are inputs; tag, type, data, and data_count are outputs. Any of
+ * the outputs can be set to NULL to skip reading that value.
+ */
+ANDROID_API
+int get_camera_metadata_entry(camera_metadata_t *src,
+ uint32_t index,
+ uint32_t *tag,
+ uint8_t *type,
+ void **data,
+ size_t *data_count);
+
+/**
+ * Find an entry with given tag value. If not found, returns -ENOENT. Otherwise,
+ * returns entry contents like get_camera_metadata_entry. Any of
+ * the outputs can be set to NULL to skip reading that value.
+ *
+ * Note: Returns only the first entry with a given tag. To speed up searching
+ * for tags, sort the metadata structure first by calling
+ * sort_camera_metadata().
+ */
+ANDROID_API
+int find_camera_metadata_entry(camera_metadata_t *src,
+ uint32_t tag,
+ uint8_t *type,
+ void **data,
+ size_t *data_count);
+
+/**
+ * Retrieve human-readable name of section the tag is in. Returns NULL if
+ * no such tag is defined. Returns NULL for tags in the vendor section, unless
+ * set_vendor_tag_query_ops() has been used.
+ */
+ANDROID_API
+const char *get_camera_metadata_section_name(uint32_t tag);
+
+/**
+ * Retrieve human-readable name of tag (not including section). Returns NULL if
+ * no such tag is defined. Returns NULL for tags in the vendor section, unless
+ * set_vendor_tag_query_ops() has been used.
+ */
+ANDROID_API
+const char *get_camera_metadata_tag_name(uint32_t tag);
+
+/**
+ * Retrieve the type of a tag. Returns -1 if no such tag is defined. Returns -1
+ * for tags in the vendor section, unless set_vendor_tag_query_ops() has been
+ * used.
+ */
+ANDROID_API
+int get_camera_metadata_tag_type(uint32_t tag);
+
+/**
+ * Set up vendor-specific tag query methods. These are needed to properly add
+ * entries with vendor-specified tags and to use the
+ * get_camera_metadata_section_name, _tag_name, and _tag_type methods with
+ * vendor tags. Returns 0 on success.
+ */
+typedef struct vendor_tag_query_ops vendor_tag_query_ops_t;
+struct vendor_tag_query_ops {
+ /**
+ * Get vendor section name for a vendor-specified entry tag. Only called for
+ * tags >= 0x80000000. The section name must start with the name of the
+ * vendor in the Java package style. For example, CameraZoom inc must prefix
+ * their sections with "com.camerazoom." Must return NULL if the tag is
+ * outside the bounds of vendor-defined sections.
+ */
+ const char *(*get_camera_vendor_section_name)(
+ const vendor_tag_query_ops_t *v,
+ uint32_t tag);
+ /**
+ * Get tag name for a vendor-specified entry tag. Only called for tags >=
+ * 0x80000000. Must return NULL if the tag is outside the bounds of
+ * vendor-defined sections.
+ */
+ const char *(*get_camera_vendor_tag_name)(
+ const vendor_tag_query_ops_t *v,
+ uint32_t tag);
+ /**
+ * Get tag type for a vendor-specified entry tag. Only called for tags >=
+ * 0x80000000. Must return -1 if the tag is outside the bounds of
+ * vendor-defined sections.
+ */
+ int (*get_camera_vendor_tag_type)(
+ const vendor_tag_query_ops_t *v,
+ uint32_t tag);
+};
+
+ANDROID_API
+int set_camera_metadata_vendor_tag_ops(const vendor_tag_query_ops_t *query_ops);
+
+/**
+ * Print fields in the metadata to the log.
+ * verbosity = 0: Only tag entry information
+ * verbosity = 1: Tag entry information plus at most 16 data values
+ * verbosity = 2: All information
+ */
+ANDROID_API
+void dump_camera_metadata(const camera_metadata_t *metadata,
+ int fd,
+ int verbosity);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/camera/include/system/camera_metadata_tags.h b/camera/include/system/camera_metadata_tags.h
new file mode 100644
index 0000000..bfb4fe3
--- /dev/null
+++ b/camera/include/system/camera_metadata_tags.h
@@ -0,0 +1,313 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * !! Do not include this file directly !!
+ *
+ * Include camera_metadata.h instead.
+ */
+
+/**
+ * Top level hierarchy definitions for camera metadata. *_INFO sections are for
+ * the static metadata that can be retrived without opening the camera device.
+ * New sections must be added right before ANDROID_SECTION_COUNT to maintain
+ * existing enumerations.
+ */
+enum {
+ ANDROID_REQUEST = 0,
+ ANDROID_LENS,
+ ANDROID_LENS_INFO,
+ ANDROID_SENSOR,
+ ANDROID_SENSOR_INFO,
+ ANDROID_FLASH,
+ ANDROID_FLASH_INFO,
+ ANDROID_HOT_PIXEL,
+ ANDROID_HOT_PIXEL_INFO,
+ ANDROID_DEMOSAIC,
+ ANDROID_DEMOSAIC_INFO,
+ ANDROID_NOISE,
+ ANDROID_NOISE_INFO,
+ ANDROID_SHADING,
+ ANDROID_SHADING_INFO,
+ ANDROID_GEOMETRIC,
+ ANDROID_GEOMETRIC_INFO,
+ ANDROID_COLOR,
+ ANDROID_COLOR_INFO,
+ ANDROID_TONEMAP,
+ ANDROID_TONEMAP_INFO,
+ ANDROID_EDGE,
+ ANDROID_EDGE_INFO,
+ ANDROID_SCALER,
+ ANDROID_SCALER_INFO,
+ ANDROID_JPEG,
+ ANDROID_JPEG_INFO,
+ ANDROID_STATS,
+ ANDROID_STATS_INFO,
+ ANDROID_CONTROL,
+ ANDROID_CONTROL_INFO,
+ ANDROID_SECTION_COUNT,
+
+ VENDOR_SECTION = 0x8000
+};
+
+/**
+ * Hierarchy positions in enum space. All vendor extension tags must be
+ * defined with tag >= VENDOR_SECTION_START
+ */
+enum {
+ ANDROID_REQUEST_START = ANDROID_REQUEST << 16,
+ ANDROID_LENS_START = ANDROID_LENS << 16,
+ ANDROID_LENS_INFO_START = ANDROID_LENS_INFO << 16,
+ ANDROID_SENSOR_START = ANDROID_SENSOR << 16,
+ ANDROID_SENSOR_INFO_START = ANDROID_SENSOR_INFO << 16,
+ ANDROID_FLASH_START = ANDROID_FLASH << 16,
+ ANDROID_FLASH_INFO_START = ANDROID_FLASH_INFO << 16,
+ ANDROID_HOT_PIXEL_START = ANDROID_HOT_PIXEL << 16,
+ ANDROID_HOT_PIXEL_INFO_START = ANDROID_HOT_PIXEL_INFO << 16,
+ ANDROID_DEMOSAIC_START = ANDROID_DEMOSAIC << 16,
+ ANDROID_DEMOSAIC_INFO_START = ANDROID_DEMOSAIC_INFO << 16,
+ ANDROID_NOISE_START = ANDROID_NOISE << 16,
+ ANDROID_NOISE_INFO_START = ANDROID_NOISE_INFO << 16,
+ ANDROID_SHADING_START = ANDROID_SHADING << 16,
+ ANDROID_SHADING_INFO_START = ANDROID_SHADING_INFO << 16,
+ ANDROID_GEOMETRIC_START = ANDROID_GEOMETRIC << 16,
+ ANDROID_GEOMETRIC_INFO_START = ANDROID_GEOMETRIC_INFO << 16,
+ ANDROID_COLOR_START = ANDROID_COLOR << 16,
+ ANDROID_COLOR_INFO_START = ANDROID_COLOR_INFO << 16,
+ ANDROID_TONEMAP_START = ANDROID_TONEMAP << 16,
+ ANDROID_TONEMAP_INFO_START = ANDROID_TONEMAP_INFO << 16,
+ ANDROID_EDGE_START = ANDROID_EDGE << 16,
+ ANDROID_EDGE_INFO_START = ANDROID_EDGE_INFO << 16,
+ ANDROID_SCALER_START = ANDROID_SCALER << 16,
+ ANDROID_SCALER_INFO_START = ANDROID_SCALER_INFO << 16,
+ ANDROID_JPEG_START = ANDROID_JPEG << 16,
+ ANDROID_JPEG_INFO_START = ANDROID_JPEG_INFO << 16,
+ ANDROID_STATS_START = ANDROID_STATS << 16,
+ ANDROID_STATS_INFO_START = ANDROID_STATS_INFO << 16,
+ ANDROID_CONTROL_START = ANDROID_CONTROL << 16,
+ ANDROID_CONTROL_INFO_START = ANDROID_CONTROL_INFO << 16,
+ VENDOR_SECTION_START = VENDOR_SECTION << 16
+};
+
+/**
+ * Main enum for defining camera metadata tags. New entries must always go
+ * before the section _END tag to preserve existing enumeration values. In
+ * addition, the name and type of the tag needs to be added to
+ * system/media/camera/src/camera_metadata_tag_info.c
+ */
+enum {
+ ANDROID_REQUEST_ID = ANDROID_REQUEST_START,
+ ANDROID_REQUEST_METADATA_MODE,
+ ANDROID_REQUEST_OUTPUT_STREAMS,
+ ANDROID_REQUEST_FRAME_COUNT,
+ ANDROID_REQUEST_END,
+
+ ANDROID_LENS_FOCUS_DISTANCE = ANDROID_LENS_START,
+ ANDROID_LENS_APERTURE,
+ ANDROID_LENS_FOCAL_LENGTH,
+ ANDROID_LENS_FILTER_DENSITY,
+ ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
+ ANDROID_LENS_FOCUS_RANGE,
+ ANDROID_LENS_END,
+
+ ANDROID_LENS_MINIMUM_FOCUS_DISTANCE = ANDROID_LENS_INFO_START,
+ ANDROID_LENS_AVAILABLE_FOCAL_LENGTHS,
+ ANDROID_LENS_AVAILABLE_APERTURES,
+ ANDROID_LENS_AVAILABLE_FILTER_DENSITY,
+ ANDROID_LENS_AVAILABLE_OPTICAL_STABILIZATION,
+ ANDROID_LENS_SHADING_MAP,
+ ANDROID_LENS_GEOMETRIC_CORRECTION_MAP,
+ ANDROID_LENS_FACING,
+ ANDROID_LENS_POSITION,
+ ANDROID_LENS_INFO_END,
+
+ ANDROID_SENSOR_EXPOSURE_TIME = ANDROID_SENSOR_START,
+ ANDROID_SENSOR_FRAME_DURATION,
+ ANDROID_SENSOR_SENSITIVITY,
+ ANDROID_SENSOR_TIMESTAMP,
+ ANDROID_SENSOR_END,
+
+ ANDROID_SENSOR_EXPOSURE_TIME_RANGE = ANDROID_SENSOR_INFO_START,
+ ANDROID_SENSOR_MAX_FRAME_DURATION,
+ ANDROID_SENSOR_AVAILABLE_SENSITIVITIES,
+ ANDROID_SENSOR_COLOR_FILTER_ARRANGEMENT,
+ ANDROID_SENSOR_PIXEL_ARRAY_SIZE,
+ ANDROID_SENSOR_ACTIVE_ARRAY_SIZE,
+ ANDROID_SENSOR_WHITE_LEVEL,
+ ANDROID_SENSOR_BLACK_LEVEL_PATTERN,
+ ANDROID_SENSOR_COLOR_TRANSFORM_1,
+ ANDROID_SENSOR_COLOR_TRANSFORM_2,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT_1,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT_2,
+ ANDROID_SENSOR_FORWARD_MATRIX_1,
+ ANDROID_SENSOR_FORWARD_MATRIX_2,
+ ANDROID_SENSOR_CALIBRATION_TRANSFORM_1,
+ ANDROID_SENSOR_CALIBRATION_TRANSFORM_2,
+ ANDROID_SENSOR_BASE_GAIN_FACTOR,
+ ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY,
+ ANDROID_SENSOR_NOISE_MODEL_COEFFICIENTS,
+ ANDROID_SENSOR_ORIENTATION,
+ ANDROID_SENSOR_INFO_END,
+
+ ANDROID_FLASH_MODE = ANDROID_FLASH_START,
+ ANDROID_FLASH_FIRING_POWER,
+ ANDROID_FLASH_FIRING_TIME,
+ ANDROID_FLASH_END,
+
+ ANDROID_FLASH_AVAILABLE_MODES = ANDROID_FLASH_INFO_START,
+ ANDROID_FLASH_CHARGE_DURATION,
+ ANDROID_FLASH_INFO_END,
+
+ ANDROID_HOT_PIXEL_MODE = ANDROID_HOT_PIXEL_START,
+ ANDROID_HOT_PIXEL_END,
+
+ ANDROID_HOT_PIXEL_INFO_END = ANDROID_HOT_PIXEL_INFO_START,
+
+ ANDROID_DEMOSAIC_MODE = ANDROID_DEMOSAIC_START,
+ ANDROID_DEMOSAIC_END,
+
+ ANDROID_DEMOSAIC_INFO_END = ANDROID_DEMOSAIC_INFO_START,
+
+ ANDROID_NOISE_MODE = ANDROID_NOISE_START,
+ ANDROID_NOISE_STRENGTH,
+ ANDROID_NOISE_END,
+
+ ANDROID_NOISE_INFO_END = ANDROID_NOISE_INFO_START,
+
+ ANDROID_SHADING_MODE = ANDROID_SHADING_START,
+ ANDROID_SHADING_END,
+
+ ANDROID_SHADING_INFO_END = ANDROID_SHADING_INFO_START,
+
+ ANDROID_GEOMETRIC_MODE = ANDROID_GEOMETRIC_START,
+ ANDROID_GEOMETRIC_END,
+
+ ANDROID_GEOMETRIC_INFO_END = ANDROID_GEOMETRIC_INFO_START,
+
+ ANDROID_COLOR_MODE = ANDROID_COLOR_START,
+ ANDROID_COLOR_TRANSFORM,
+ ANDROID_COLOR_END,
+
+ ANDROID_COLOR_AVAILABLE_MODES = ANDROID_COLOR_INFO_START,
+ ANDROID_COLOR_INFO_END,
+
+ ANDROID_TONEMAP_MODE = ANDROID_TONEMAP_START,
+ ANDROID_TONEMAP_CURVE_RED,
+ ANDROID_TONEMAP_CURVE_GREEN,
+ ANDROID_TONEMAP_CURVE_BLUE,
+ ANDROID_TONEMAP_END,
+
+ ANDROID_TONEMAP_MAX_CURVE_POINTS = ANDROID_TONEMAP_INFO_START,
+ ANDROID_TONEMAP_INFO_END,
+
+ ANDROID_EDGE_MODE = ANDROID_EDGE_START,
+ ANDROID_EDGE_STRENGTH,
+ ANDROID_EDGE_END,
+
+ ANDROID_EDGE_INFO_END = ANDROID_EDGE_INFO_START,
+
+ ANDROID_SCALER_SIZE = ANDROID_SCALER_START,
+ ANDROID_SCALER_FORMAT,
+ ANDROID_SCALER_CROP_REGION,
+ ANDROID_SCALER_ROTATION,
+ ANDROID_SCALER_END,
+
+ ANDROID_SCALER_AVAILABLE_FORMATS = ANDROID_SCALER_INFO_START,
+ ANDROID_SCALER_AVAILABLE_SIZES_PER_FORMAT,
+ ANDROID_SCALER_AVAILABLE_SIZES,
+ ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,
+ ANDROID_SCALER_AVAILABLE_MAX_ZOOM,
+ ANDROID_SCALER_INFO_END,
+
+ ANDROID_JPEG_QUALITY = ANDROID_JPEG_START,
+ ANDROID_JPEG_THUMBNAIL_SIZE,
+ ANDROID_JPEG_THUMBNAIL_QUALITY,
+ ANDROID_JPEG_GPS_COORDINATES,
+ ANDROID_JPEG_GPS_PROCESSING_METHOD,
+ ANDROID_JPEG_GPS_TIMESTAMP,
+ ANDROID_JPEG_ORIENTATION,
+ ANDROID_JPEG_END,
+
+ ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES = ANDROID_JPEG_INFO_START,
+ ANDROID_JPEG_INFO_END,
+
+ ANDROID_STATS_FACE_DETECT_MODE = ANDROID_STATS_START,
+ ANDROID_STATS_FACE_RECTANGLES,
+ ANDROID_STATS_FACE_SCORES,
+ ANDROID_STATS_FACE_LANDMARKS,
+ ANDROID_STATS_FACE_IDS,
+ ANDROID_STATS_HISTOGRAM_MODE,
+ ANDROID_STATS_HISTOGRAM,
+ ANDROID_STATS_SHARPNESS_MAP_MODE,
+ ANDROID_STATS_SHARPNESS_MAP,
+ ANDROID_STATS_END,
+
+ ANDROID_STATS_AVAILABLE_FACE_DETECT_MODES = ANDROID_STATS_INFO_START,
+ ANDROID_STATS_MAX_FACE_COUNT,
+ ANDROID_STATS_HISTOGRAM_BUCKET_COUNT,
+ ANDROID_STATS_MAX_HISTOGRAM_COUNT,
+ ANDROID_STATS_SHARPNESS_MAP_SIZE,
+ ANDROID_STATS_MAX_SHARPNESS_MAP_VALUE,
+ ANDROID_STATS_INFO_END,
+
+ ANDROID_CONTROL_MODE = ANDROID_CONTROL_START,
+ ANDROID_CONTROL_AE_MODE,
+ ANDROID_CONTROL_AE_REGIONS,
+ ANDROID_CONTROL_AE_EXP_COMPENSATION,
+ ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
+ ANDROID_CONTROL_AE_ANTIBANDING_MODE,
+ ANDROID_CONTROL_AWB_MODE,
+ ANDROID_CONTROL_AWB_REGIONS,
+ ANDROID_CONTROL_AF_MODE,
+ ANDROID_CONTROL_AF_REGIONS,
+ ANDROID_CONTROL_AF_TRIGGER,
+ ANDROID_CONTROL_AF_STATE,
+ ANDROID_CONTROL_VIDEO_STABILIZATION_MODE,
+ ANDROID_CONTROL_END,
+
+ ANDROID_CONTROL_AVAILABLE_MODES = ANDROID_CONTROL_INFO_START,
+ ANDROID_CONTROL_MAX_REGIONS,
+ ANDROID_CONTROL_AE_AVAILABLE_MODES,
+ ANDROID_CONTROL_AE_EXP_COMPENSATION_STEP,
+ ANDROID_CONTROL_AE_EXP_COMPENSATION_RANGE,
+ ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
+ ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
+ ANDROID_CONTROL_AWB_AVAILABLE_MODES,
+ ANDROID_CONTROL_AF_AVAILABLE_MODES,
+ ANDROID_CONTROL_INFO_END
+};
+
+/**
+ * Enumeration definitions for the various entries that need them
+ */
+
+// ANDROID_REQUEST_METADATA_MODE
+enum {
+ ANDROID_REQUEST_METADATA_NONE = 0,
+ ANDROID_REQUEST_METADATA_FULL
+};
+
+// ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT
+enum {
+ ANDROID_SENSOR_RGGB = 0,
+ ANDROID_SENSOR_GRBG,
+ ANDROID_SENSOR_GBRG,
+ ANDROID_SENSOR_BGGR,
+ ANDROID_SENSOR_RGB
+};
+
+// ANDROID_SCALER_AVAILABLE_FORMATS uses HAL_PIXEL_FORMAT_* from
+// system/graphics.h
diff --git a/camera/src/Android.mk b/camera/src/Android.mk
new file mode 100644
index 0000000..19a6f5b
--- /dev/null
+++ b/camera/src/Android.mk
@@ -0,0 +1,24 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ camera_metadata.c
+
+LOCAL_C_INCLUDES:= \
+ system/media/camera/include
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE := libcamera_metadata
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_CFLAGS += \
+ -Wall \
+ -fvisibility=hidden \
+
+
+include $(BUILD_SHARED_LIBRARY)
+
+
diff --git a/camera/src/camera_metadata.c b/camera/src/camera_metadata.c
new file mode 100644
index 0000000..1991835
--- /dev/null
+++ b/camera/src/camera_metadata.c
@@ -0,0 +1,587 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#define _GNU_SOURCE // for fdprintf
+#include <system/camera_metadata.h>
+#include <cutils/log.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#define OK 0
+#define ERROR 1
+#define NOT_FOUND -ENOENT
+/**
+ * A single metadata entry, storing an array of values of a given type. If the
+ * array is no larger than 4 bytes in size, it is stored in the data.value[]
+ * array; otherwise, it can found in the parent's data array at index
+ * data.offset.
+ */
+typedef struct camera_metadata_entry {
+ uint32_t tag;
+ size_t count;
+ union {
+ size_t offset;
+ uint8_t value[4];
+ } data;
+ uint8_t type;
+ uint8_t reserved[3];
+} __attribute__((packed)) camera_metadata_entry_t;
+
+/**
+ * A packet of metadata. This is a list of entries, each of which may point to
+ * its values stored at an offset in data.
+ *
+ * It is assumed by the utility functions that the memory layout of the packet
+ * is as follows:
+ *
+ * |----------------------------------------|
+ * | camera_metadata_t |
+ * | |
+ * |----------------------------------------|
+ * | reserved for future expansion |
+ * |----------------------------------------|
+ * | camera_metadata_entry_t #0 |
+ * |----------------------------------------|
+ * | .... |
+ * |----------------------------------------|
+ * | camera_metadata_entry_t #entry_count-1 |
+ * |----------------------------------------|
+ * | free space for |
+ * | (entry_capacity-entry_count) entries |
+ * |----------------------------------------|
+ * | start of camera_metadata.data |
+ * | |
+ * |----------------------------------------|
+ * | free space for |
+ * | (data_capacity-data_count) bytes |
+ * |----------------------------------------|
+ *
+ * With the total length of the whole packet being camera_metadata.size bytes.
+ *
+ * In short, the entries and data are contiguous in memory after the metadata
+ * header.
+ */
+struct camera_metadata {
+ size_t size;
+ uint32_t version;
+ uint32_t flags;
+ size_t entry_count;
+ size_t entry_capacity;
+ camera_metadata_entry_t *entries;
+ size_t data_count;
+ size_t data_capacity;
+ uint8_t *data;
+ uint8_t reserved[0];
+};
+
+/** Versioning information */
+#define CURRENT_METADATA_VERSION 1
+
+/** Flag definitions */
+#define FLAG_SORTED 0x00000001
+
+/** Tag information */
+
+typedef struct tag_info {
+ const char *tag_name;
+ uint8_t tag_type;
+} tag_info_t;
+
+#include "camera_metadata_tag_info.c"
+
+size_t camera_metadata_type_size[NUM_TYPES] = {
+ [TYPE_BYTE] = sizeof(uint8_t),
+ [TYPE_INT32] = sizeof(int32_t),
+ [TYPE_FLOAT] = sizeof(float),
+ [TYPE_INT64] = sizeof(int64_t),
+ [TYPE_DOUBLE] = sizeof(double),
+ [TYPE_RATIONAL] = sizeof(camera_metadata_rational_t)
+};
+
+char *camera_metadata_type_names[NUM_TYPES] = {
+ [TYPE_BYTE] = "byte",
+ [TYPE_INT32] = "int32",
+ [TYPE_FLOAT] = "float",
+ [TYPE_INT64] = "int64",
+ [TYPE_RATIONAL] = "rational"
+};
+
+camera_metadata_t *allocate_camera_metadata(size_t entry_capacity,
+ size_t data_capacity) {
+ size_t memory_needed = calculate_camera_metadata_size(entry_capacity,
+ data_capacity);
+ void *buffer = malloc(memory_needed);
+ return place_camera_metadata(buffer, memory_needed,
+ entry_capacity,
+ data_capacity);
+}
+
+camera_metadata_t *place_camera_metadata(void *dst,
+ size_t dst_size,
+ size_t entry_capacity,
+ size_t data_capacity) {
+ if (dst == NULL) return NULL;
+ if (entry_capacity == 0) return NULL;
+
+ size_t memory_needed = calculate_camera_metadata_size(entry_capacity,
+ data_capacity);
+ if (memory_needed > dst_size) return NULL;
+
+ camera_metadata_t *metadata = (camera_metadata_t*)dst;
+ metadata->version = CURRENT_METADATA_VERSION;
+ metadata->flags = 0;
+ metadata->entry_count = 0;
+ metadata->entry_capacity = entry_capacity;
+ metadata->entries = (camera_metadata_entry_t*)(metadata + 1);
+ metadata->data_count = 0;
+ metadata->data_capacity = data_capacity;
+ metadata->size = memory_needed;
+ if (metadata->data_capacity != 0) {
+ metadata->data =
+ (uint8_t*)(metadata->entries + metadata->entry_capacity);
+ } else {
+ metadata->data = NULL;
+ }
+
+ return metadata;
+}
+void free_camera_metadata(camera_metadata_t *metadata) {
+ free(metadata);
+}
+
+size_t calculate_camera_metadata_size(size_t entry_count,
+ size_t data_count) {
+ size_t memory_needed = sizeof(camera_metadata_t);
+ memory_needed += sizeof(camera_metadata_entry_t[entry_count]);
+ memory_needed += sizeof(uint8_t[data_count]);
+ return memory_needed;
+}
+
+size_t get_camera_metadata_size(const camera_metadata_t *metadata) {
+ if (metadata == NULL) return ERROR;
+
+ return metadata->size;
+}
+
+size_t get_camera_metadata_compact_size(const camera_metadata_t *metadata) {
+ if (metadata == NULL) return ERROR;
+
+ ptrdiff_t reserved_size = metadata->size -
+ calculate_camera_metadata_size(metadata->entry_capacity,
+ metadata->data_capacity);
+
+ return calculate_camera_metadata_size(metadata->entry_count,
+ metadata->data_count) + reserved_size;
+}
+
+size_t get_camera_metadata_entry_count(const camera_metadata_t *metadata) {
+ return metadata->entry_count;
+}
+
+size_t get_camera_metadata_entry_capacity(const camera_metadata_t *metadata) {
+ return metadata->entry_capacity;
+}
+
+size_t get_camera_metadata_data_count(const camera_metadata_t *metadata) {
+ return metadata->data_count;
+}
+
+size_t get_camera_metadata_data_capacity(const camera_metadata_t *metadata) {
+ return metadata->data_capacity;
+}
+
+camera_metadata_t* copy_camera_metadata(void *dst, size_t dst_size,
+ const camera_metadata_t *src) {
+ size_t memory_needed = get_camera_metadata_compact_size(src);
+
+ if (dst == NULL) return NULL;
+ if (dst_size < memory_needed) return NULL;
+
+ // If copying a newer version of the structure, there may be additional
+ // header fields we don't know about but need to copy
+ ptrdiff_t reserved_size = src->size -
+ calculate_camera_metadata_size(src->entry_capacity,
+ src->data_capacity);
+
+ camera_metadata_t *metadata = (camera_metadata_t*)dst;
+ metadata->version = CURRENT_METADATA_VERSION;
+ metadata->flags = src->flags;
+ metadata->entry_count = src->entry_count;
+ metadata->entry_capacity = src->entry_count;
+ metadata->entries = (camera_metadata_entry_t*)
+ ((uint8_t *)(metadata + 1) + reserved_size);
+ metadata->data_count = src->data_count;
+ metadata->data_capacity = src->data_count;
+ metadata->data = (uint8_t *)(metadata->entries + metadata->entry_capacity);
+ metadata->size = memory_needed;
+
+ if (reserved_size > 0) {
+ memcpy(metadata->reserved, src->reserved, reserved_size);
+ }
+ memcpy(metadata->entries, src->entries,
+ sizeof(camera_metadata_entry_t[metadata->entry_count]));
+ memcpy(metadata->data, src->data,
+ sizeof(uint8_t[metadata->data_count]));
+
+ return metadata;
+}
+
+int append_camera_metadata(camera_metadata_t *dst,
+ const camera_metadata_t *src) {
+ if (dst == NULL || src == NULL ) return ERROR;
+
+ if (dst->entry_capacity < src->entry_count + dst->entry_count) return ERROR;
+ if (dst->data_capacity < src->data_count + dst->data_count) return ERROR;
+
+ memcpy(dst->entries + dst->entry_count, src->entries,
+ sizeof(camera_metadata_entry_t[src->entry_count]));
+ memcpy(dst->data + dst->data_count, src->data,
+ sizeof(uint8_t[src->data_count]));
+ if (dst->data_count != 0) {
+ unsigned int i;
+ for (i = dst->entry_count;
+ i < dst->entry_count + src->entry_count;
+ i++) {
+ camera_metadata_entry_t *entry = dst->entries + i;
+ if ( camera_metadata_type_size[entry->type] * entry->count > 4 ) {
+ entry->data.offset += dst->data_count;
+ }
+ }
+ }
+ dst->entry_count += src->entry_count;
+ dst->data_count += src->data_count;
+ dst->flags &= ~FLAG_SORTED;
+
+ return OK;
+}
+
+size_t calculate_camera_metadata_entry_data_size(uint8_t type,
+ size_t data_count) {
+ if (type >= NUM_TYPES) return 0;
+ size_t data_bytes = data_count *
+ camera_metadata_type_size[type];
+ return data_bytes <= 4 ? 0 : data_bytes;
+}
+
+static int add_camera_metadata_entry_raw(camera_metadata_t *dst,
+ uint32_t tag,
+ uint8_t type,
+ const void *data,
+ size_t data_count) {
+
+ if (dst == NULL) return ERROR;
+ if (dst->entry_count == dst->entry_capacity) return ERROR;
+ if (data == NULL) return ERROR;
+
+ size_t data_bytes =
+ calculate_camera_metadata_entry_data_size(type, data_count);
+
+ camera_metadata_entry_t *entry = dst->entries + dst->entry_count;
+ entry->tag = tag;
+ entry->type = type;
+ entry->count = data_count;
+
+ if (data_bytes == 0) {
+ memcpy(entry->data.value, data,
+ data_count * camera_metadata_type_size[type] );
+ } else {
+ entry->data.offset = dst->data_count;
+ memcpy(dst->data + entry->data.offset, data, data_bytes);
+ dst->data_count += data_bytes;
+ }
+ dst->entry_count++;
+ dst->flags &= ~FLAG_SORTED;
+ return OK;
+}
+
+int add_camera_metadata_entry(camera_metadata_t *dst,
+ uint32_t tag,
+ const void *data,
+ size_t data_count) {
+
+ int type = get_camera_metadata_tag_type(tag);
+ if (type == -1) {
+ ALOGE("%s: Unknown tag %04x.", __FUNCTION__, tag);
+ return ERROR;
+ }
+
+ return add_camera_metadata_entry_raw(dst,
+ tag,
+ type,
+ data,
+ data_count);
+}
+
+static int compare_entry_tags(const void *p1, const void *p2) {
+ uint32_t tag1 = ((camera_metadata_entry_t*)p1)->tag;
+ uint32_t tag2 = ((camera_metadata_entry_t*)p2)->tag;
+ return tag1 < tag2 ? -1 :
+ tag1 == tag2 ? 0 :
+ 1;
+}
+
+int sort_camera_metadata(camera_metadata_t *dst) {
+ if (dst == NULL) return ERROR;
+ if (dst->flags & FLAG_SORTED) return OK;
+
+ qsort(dst->entries, dst->entry_count,
+ sizeof(camera_metadata_entry_t),
+ compare_entry_tags);
+ dst->flags |= FLAG_SORTED;
+
+ return OK;
+}
+
+int get_camera_metadata_entry(camera_metadata_t *src,
+ uint32_t index,
+ uint32_t *tag,
+ uint8_t *type,
+ void **data,
+ size_t *data_count) {
+ if (src == NULL ) return ERROR;
+ if (index >= src->entry_count) return ERROR;
+
+ camera_metadata_entry_t *entry = src->entries + index;
+
+ if (tag != NULL) *tag = entry->tag;
+ if (type != NULL) *type = entry->type;
+ if (data_count != NULL) *data_count = entry->count;
+ if (data != NULL) {
+ if (entry->count * camera_metadata_type_size[entry->type] > 4) {
+ *data = src->data + entry->data.offset;
+ } else {
+ *data = entry->data.value;
+ }
+ }
+ return OK;
+}
+
+int find_camera_metadata_entry(camera_metadata_t *src,
+ uint32_t tag,
+ uint8_t *type,
+ void **data,
+ size_t *data_count) {
+ if (src == NULL) return ERROR;
+
+ camera_metadata_entry_t *entry = NULL;
+ if (src->flags & FLAG_SORTED) {
+ // Sorted entries, do a binary search
+ camera_metadata_entry_t key;
+ key.tag = tag;
+ entry = bsearch(&key,
+ src->entries,
+ src->entry_count,
+ sizeof(camera_metadata_entry_t),
+ compare_entry_tags);
+ } else {
+ // Not sorted, linear search
+ unsigned int i;
+ for (i = 0; i < src->entry_count; i++) {
+ if (src->entries[i].tag == tag) {
+ entry = src->entries + i;
+ break;
+ }
+ }
+ }
+ if (entry == NULL) return NOT_FOUND;
+
+ if (type != NULL) *type = entry->type;
+ if (data_count != NULL) *data_count = entry->count;
+ if (data != NULL) {
+ if (entry->count * camera_metadata_type_size[entry->type] > 4) {
+ *data = src->data + entry->data.offset;
+ } else {
+ *data = entry->data.value;
+ }
+ }
+ return OK;
+}
+
+static const vendor_tag_query_ops_t *vendor_tag_ops = NULL;
+
+const char *get_camera_metadata_section_name(uint32_t tag) {
+ uint32_t tag_section = tag >> 16;
+ if (tag_section >= VENDOR_SECTION && vendor_tag_ops != NULL) {
+ return vendor_tag_ops->get_camera_vendor_section_name(
+ vendor_tag_ops,
+ tag);
+ }
+ if (tag_section >= ANDROID_SECTION_COUNT) {
+ return NULL;
+ }
+ return camera_metadata_section_names[tag_section];
+}
+
+const char *get_camera_metadata_tag_name(uint32_t tag) {
+ uint32_t tag_section = tag >> 16;
+ if (tag_section >= VENDOR_SECTION && vendor_tag_ops != NULL) {
+ return vendor_tag_ops->get_camera_vendor_tag_name(
+ vendor_tag_ops,
+ tag);
+ }
+ if (tag_section >= ANDROID_SECTION_COUNT ||
+ tag >= camera_metadata_section_bounds[tag_section][1] ) {
+ return NULL;
+ }
+ uint32_t tag_index = tag & 0xFFFF;
+ return tag_info[tag_section][tag_index].tag_name;
+}
+
+int get_camera_metadata_tag_type(uint32_t tag) {
+ uint32_t tag_section = tag >> 16;
+ if (tag_section >= VENDOR_SECTION && vendor_tag_ops != NULL) {
+ return vendor_tag_ops->get_camera_vendor_tag_type(
+ vendor_tag_ops,
+ tag);
+ }
+ if (tag_section >= ANDROID_SECTION_COUNT ||
+ tag >= camera_metadata_section_bounds[tag_section][1] ) {
+ return -1;
+ }
+ uint32_t tag_index = tag & 0xFFFF;
+ return tag_info[tag_section][tag_index].tag_type;
+}
+
+int set_camera_metadata_vendor_tag_ops(const vendor_tag_query_ops_t *query_ops) {
+ vendor_tag_ops = query_ops;
+ return OK;
+}
+
+static void print_data(int fd, const uint8_t *data_ptr, int type, int count);
+
+void dump_camera_metadata(const camera_metadata_t *metadata,
+ int fd,
+ int verbosity) {
+ if (metadata == NULL) {
+ ALOGE("%s: Metadata is null.", __FUNCTION__);
+ return;
+ }
+ unsigned int i;
+ fdprintf(fd,
+ "Dumping camera metadata array. %d entries, "
+ "%d bytes of extra data.\n",
+ metadata->entry_count, metadata->data_count);
+ fdprintf(fd, " (%d entries and %d bytes data reserved)\n",
+ metadata->entry_capacity, metadata->data_capacity);
+ fdprintf(fd, " Version: %d, Flags: %08x\n",
+ metadata->version, metadata->flags);
+ for (i=0; i < metadata->entry_count; i++) {
+ camera_metadata_entry_t *entry = metadata->entries + i;
+
+ const char *tag_name, *tag_section;
+ tag_section = get_camera_metadata_section_name(entry->tag);
+ if (tag_section == NULL) {
+ tag_section = "unknownSection";
+ }
+ tag_name = get_camera_metadata_tag_name(entry->tag);
+ if (tag_name == NULL) {
+ tag_name = "unknownTag";
+ }
+ const char *type_name;
+ if (entry->type >= NUM_TYPES) {
+ type_name = "unknown";
+ } else {
+ type_name = camera_metadata_type_names[entry->type];
+ }
+ fdprintf(fd, "Tag: %s.%s (%05x): %s[%d]\n",
+ tag_section,
+ tag_name,
+ entry->tag,
+ type_name,
+ entry->count);
+
+ if (verbosity < 1) continue;
+
+ if (entry->type >= NUM_TYPES) continue;
+
+ size_t type_size = camera_metadata_type_size[entry->type];
+ uint8_t *data_ptr;
+ if ( type_size * entry->count > 4 ) {
+ if (entry->data.offset >= metadata->data_count) {
+ ALOGE("%s: Malformed entry data offset: %d (max %d)",
+ __FUNCTION__,
+ entry->data.offset,
+ metadata->data_count);
+ continue;
+ }
+ data_ptr = metadata->data + entry->data.offset;
+ } else {
+ data_ptr = entry->data.value;
+ }
+ int count = entry->count;
+ if (verbosity < 2 && count > 16) count = 16;
+
+ print_data(fd, data_ptr, entry->type, count);
+ }
+}
+
+static void print_data(int fd, const uint8_t *data_ptr, int type, int count) {
+ static int values_per_line[NUM_TYPES] = {
+ [TYPE_BYTE] = 16,
+ [TYPE_INT32] = 4,
+ [TYPE_FLOAT] = 8,
+ [TYPE_INT64] = 2,
+ [TYPE_DOUBLE] = 4,
+ [TYPE_RATIONAL] = 2,
+ };
+ size_t type_size = camera_metadata_type_size[type];
+
+ int lines = count / values_per_line[type];
+ if (count % values_per_line[type] != 0) lines++;
+
+ int index = 0;
+ int j, k;
+ for (j = 0; j < lines; j++) {
+ fdprintf(fd, " [");
+ for (k = 0;
+ k < values_per_line[type] && count > 0;
+ k++, count--, index += type_size) {
+
+ switch (type) {
+ case TYPE_BYTE:
+ fdprintf(fd, "%hhu ",
+ *(data_ptr + index));
+ break;
+ case TYPE_INT32:
+ fdprintf(fd, "%d ",
+ *(int32_t*)(data_ptr + index));
+ break;
+ case TYPE_FLOAT:
+ fdprintf(fd, "%0.2f ",
+ *(float*)(data_ptr + index));
+ break;
+ case TYPE_INT64:
+ fdprintf(fd, "%lld ",
+ *(int64_t*)(data_ptr + index));
+ break;
+ case TYPE_DOUBLE:
+ fdprintf(fd, "%0.2f ",
+ *(float*)(data_ptr + index));
+ break;
+ case TYPE_RATIONAL: {
+ int32_t numerator = *(int32_t*)(data_ptr + index);
+ int32_t denominator = *(int32_t*)(data_ptr + index + 4);
+ fdprintf(fd, "(%d / %d) ",
+ numerator, denominator);
+ break;
+ }
+ default:
+ fdprintf(fd, "??? ");
+ }
+ }
+ fdprintf(fd, "]\n");
+ }
+}
diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c
new file mode 100644
index 0000000..0481eb5
--- /dev/null
+++ b/camera/src/camera_metadata_tag_info.c
@@ -0,0 +1,523 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * !! Do not reference this file directly !!
+ *
+ * It is logically a part of camera_metadata.c. It is broken out for ease of
+ * maintaining the tag info.
+ *
+ * Array assignments are done using specified-index syntax to keep things in
+ * sync with camera_metadata_tags.h
+ */
+
+const char *camera_metadata_section_names[ANDROID_SECTION_COUNT] = {
+ [ANDROID_REQUEST] = "android.request",
+ [ANDROID_LENS] = "android.lens",
+ [ANDROID_LENS_INFO] = "android.lens.info",
+ [ANDROID_SENSOR] = "android.sensor",
+ [ANDROID_SENSOR_INFO] = "android.sensor.info",
+ [ANDROID_FLASH] = "android.flash",
+ [ANDROID_FLASH_INFO] = "android.flash.info",
+ [ANDROID_HOT_PIXEL] = "android.hotPixel",
+ [ANDROID_HOT_PIXEL_INFO] = "android.hotPixel.info",
+ [ANDROID_DEMOSAIC] = "android.demosaic",
+ [ANDROID_DEMOSAIC_INFO] = "android.demosaic.info",
+ [ANDROID_NOISE] = "android.noiseReduction",
+ [ANDROID_NOISE_INFO] = "android.noiseReduction.info",
+ [ANDROID_SHADING] = "android.shadingCorrection",
+ [ANDROID_SHADING_INFO] = "android.shadingCorrection.info",
+ [ANDROID_GEOMETRIC] = "android.geometricCorrection",
+ [ANDROID_GEOMETRIC_INFO] = "android.geometricCorrection.info",
+ [ANDROID_COLOR] = "android.colorCorrection",
+ [ANDROID_COLOR_INFO] = "android.colorCorrection.info",
+ [ANDROID_TONEMAP] = "android.tonemap",
+ [ANDROID_TONEMAP_INFO] = "android.tonemap.info",
+ [ANDROID_EDGE] = "android.edge",
+ [ANDROID_EDGE_INFO] = "android.edge.info",
+ [ANDROID_SCALER] = "android.scaler",
+ [ANDROID_SCALER_INFO] = "android.scaler.info",
+ [ANDROID_JPEG] = "android.jpeg",
+ [ANDROID_JPEG_INFO] = "android.jpeg.info",
+ [ANDROID_STATS] = "android.statistics",
+ [ANDROID_STATS_INFO] = "android.statistics.info",
+ [ANDROID_CONTROL] = "android.control",
+ [ANDROID_CONTROL_INFO] = "android.control.info"
+};
+
+unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2] = {
+ [ANDROID_REQUEST] = { ANDROID_REQUEST_START,
+ ANDROID_REQUEST_END },
+ [ANDROID_LENS] = { ANDROID_LENS_START,
+ ANDROID_LENS_END },
+ [ANDROID_LENS_INFO] = { ANDROID_LENS_INFO_START,
+ ANDROID_LENS_INFO_END },
+ [ANDROID_SENSOR] = { ANDROID_SENSOR_START,
+ ANDROID_SENSOR_END },
+ [ANDROID_SENSOR_INFO] = { ANDROID_SENSOR_INFO_START,
+ ANDROID_SENSOR_INFO_END },
+ [ANDROID_FLASH] = { ANDROID_FLASH_START,
+ ANDROID_FLASH_END },
+ [ANDROID_FLASH_INFO] = { ANDROID_FLASH_INFO_START,
+ ANDROID_FLASH_INFO_END },
+ [ANDROID_HOT_PIXEL] = { ANDROID_HOT_PIXEL_START,
+ ANDROID_HOT_PIXEL_END },
+ [ANDROID_HOT_PIXEL_INFO] = { ANDROID_HOT_PIXEL_INFO_START,
+ ANDROID_HOT_PIXEL_INFO_END },
+ [ANDROID_DEMOSAIC] = { ANDROID_DEMOSAIC_START,
+ ANDROID_DEMOSAIC_END },
+ [ANDROID_DEMOSAIC_INFO] = { ANDROID_DEMOSAIC_INFO_START,
+ ANDROID_DEMOSAIC_INFO_END },
+ [ANDROID_NOISE] = { ANDROID_NOISE_START,
+ ANDROID_NOISE_END },
+ [ANDROID_NOISE_INFO] = { ANDROID_NOISE_INFO_START,
+ ANDROID_NOISE_INFO_END },
+ [ANDROID_SHADING] = { ANDROID_SHADING_START,
+ ANDROID_SHADING_END },
+ [ANDROID_SHADING_INFO] = { ANDROID_SHADING_INFO_START,
+ ANDROID_SHADING_INFO_END },
+ [ANDROID_GEOMETRIC] = { ANDROID_GEOMETRIC_START,
+ ANDROID_GEOMETRIC_END },
+ [ANDROID_GEOMETRIC_INFO] = { ANDROID_GEOMETRIC_INFO_START,
+ ANDROID_GEOMETRIC_INFO_END },
+ [ANDROID_COLOR] = { ANDROID_COLOR_START,
+ ANDROID_COLOR_END },
+ [ANDROID_COLOR_INFO] = { ANDROID_COLOR_INFO_START,
+ ANDROID_COLOR_INFO_END },
+ [ANDROID_TONEMAP] = { ANDROID_TONEMAP_START,
+ ANDROID_TONEMAP_END },
+ [ANDROID_TONEMAP_INFO] = { ANDROID_TONEMAP_INFO_START,
+ ANDROID_TONEMAP_INFO_END },
+ [ANDROID_EDGE] = { ANDROID_EDGE_START,
+ ANDROID_EDGE_END },
+ [ANDROID_EDGE_INFO] = { ANDROID_EDGE_INFO_START,
+ ANDROID_EDGE_INFO_END },
+ [ANDROID_SCALER] = { ANDROID_SCALER_START,
+ ANDROID_SCALER_END },
+ [ANDROID_SCALER_INFO] = { ANDROID_SCALER_INFO_START,
+ ANDROID_SCALER_INFO_END },
+ [ANDROID_JPEG] = { ANDROID_JPEG_START,
+ ANDROID_JPEG_END },
+ [ANDROID_JPEG_INFO] = { ANDROID_JPEG_INFO_START,
+ ANDROID_JPEG_INFO_END },
+ [ANDROID_STATS] = { ANDROID_STATS_START,
+ ANDROID_STATS_END },
+ [ANDROID_STATS_INFO] = { ANDROID_STATS_INFO_START,
+ ANDROID_STATS_INFO_END },
+ [ANDROID_CONTROL] = { ANDROID_CONTROL_START,
+ ANDROID_CONTROL_END },
+ [ANDROID_CONTROL_INFO] = { ANDROID_CONTROL_INFO_START,
+ ANDROID_CONTROL_INFO_END }
+};
+
+// Shortcut defines to make succint names for field definitions
+#define TIDX(section, tag) \
+ [ ANDROID_ ## section ## _ ## tag - ANDROID_ ## section ## _START ]
+
+#define TIIDX(section, tag) \
+ [ ANDROID_ ## section ## _ ## tag - ANDROID_ ## section ## _INFO_START ]
+
+tag_info_t android_request[ANDROID_REQUEST_END -
+ ANDROID_REQUEST_START] = {
+ TIDX(REQUEST, ID) =
+ { "id", TYPE_INT32 },
+ TIDX(REQUEST, METADATA_MODE) =
+ { "metadataMode", TYPE_BYTE },
+ TIDX(REQUEST, OUTPUT_STREAMS) =
+ { "outputStreams", TYPE_BYTE },
+ TIDX(REQUEST, FRAME_COUNT) =
+ { "frameCount", TYPE_INT32 }
+};
+
+tag_info_t android_lens[ANDROID_LENS_END -
+ ANDROID_LENS_START] = {
+ TIDX(LENS, FOCUS_DISTANCE) =
+ { "focusDistance", TYPE_FLOAT },
+ TIDX(LENS, APERTURE) =
+ { "aperture", TYPE_FLOAT },
+ TIDX(LENS, FOCAL_LENGTH) =
+ { "focalLength", TYPE_FLOAT },
+ TIDX(LENS, FILTER_DENSITY) =
+ { "filterDensity", TYPE_FLOAT },
+ TIDX(LENS, OPTICAL_STABILIZATION_MODE) =
+ { "opticalStabilizationMode", TYPE_BYTE },
+ TIDX(LENS, FOCUS_RANGE) =
+ { "focusRange", TYPE_FLOAT }
+};
+
+tag_info_t android_lens_info[ANDROID_LENS_INFO_END -
+ ANDROID_LENS_INFO_START] = {
+ TIIDX(LENS, MINIMUM_FOCUS_DISTANCE) =
+ { "minimumFocusDistance", TYPE_FLOAT },
+ TIIDX(LENS, AVAILABLE_FOCAL_LENGTHS) =
+ { "availableFocalLengths", TYPE_FLOAT },
+ TIIDX(LENS, AVAILABLE_APERTURES) =
+ { "availableApertures", TYPE_FLOAT },
+ TIIDX(LENS, AVAILABLE_FILTER_DENSITY) =
+ { "availableFilterDensities", TYPE_FLOAT },
+ TIIDX(LENS, AVAILABLE_OPTICAL_STABILIZATION) =
+ { "availableOpticalStabilizationModes", TYPE_BYTE },
+ TIIDX(LENS, SHADING_MAP) =
+ { "shadingMap", TYPE_FLOAT },
+ TIIDX(LENS, GEOMETRIC_CORRECTION_MAP) =
+ { "geometricCorrectionMap", TYPE_FLOAT },
+ TIIDX(LENS, FACING) =
+ { "facing", TYPE_BYTE },
+ TIIDX(LENS, POSITION) =
+ { "position", TYPE_FLOAT }
+};
+
+tag_info_t android_sensor[ANDROID_SENSOR_END -
+ ANDROID_SENSOR_START] = {
+ TIDX(SENSOR, EXPOSURE_TIME) =
+ { "exposureTime", TYPE_INT64 },
+ TIDX(SENSOR, FRAME_DURATION) =
+ { "frameDuration", TYPE_INT64 },
+ TIDX(SENSOR, SENSITIVITY) =
+ { "sensitivity", TYPE_INT32 },
+ TIDX(SENSOR, TIMESTAMP) =
+ { "timestamp", TYPE_INT64 }
+};
+
+tag_info_t android_sensor_info[ANDROID_SENSOR_INFO_END -
+ ANDROID_SENSOR_INFO_START] = {
+ TIIDX(SENSOR, EXPOSURE_TIME_RANGE) =
+ { "exposureTimeRange", TYPE_INT64 },
+ TIIDX(SENSOR, MAX_FRAME_DURATION) =
+ { "maxFrameDuration", TYPE_INT64 },
+ TIIDX(SENSOR, AVAILABLE_SENSITIVITIES) =
+ { "availableSensitivities", TYPE_INT32 },
+ TIIDX(SENSOR, COLOR_FILTER_ARRANGEMENT) =
+ { "colorFilterArrangement", TYPE_BYTE },
+ TIIDX(SENSOR, PIXEL_ARRAY_SIZE) =
+ { "pixelArraySize", TYPE_INT32 },
+ TIIDX(SENSOR, ACTIVE_ARRAY_SIZE) =
+ { "activeArraySize", TYPE_INT32 },
+ TIIDX(SENSOR, WHITE_LEVEL) =
+ { "whiteLevel", TYPE_INT32 },
+ TIIDX(SENSOR, BLACK_LEVEL_PATTERN) =
+ { "blackLevelPattern", TYPE_INT32 },
+ TIIDX(SENSOR, COLOR_TRANSFORM_1) =
+ { "colorTransform1", TYPE_RATIONAL },
+ TIIDX(SENSOR, COLOR_TRANSFORM_2) =
+ { "colorTransform2", TYPE_RATIONAL },
+ TIIDX(SENSOR, REFERENCE_ILLUMINANT_1) =
+ { "referenceIlluminant1", TYPE_BYTE },
+ TIIDX(SENSOR, REFERENCE_ILLUMINANT_2) =
+ { "referenceIlluminant2", TYPE_BYTE },
+ TIIDX(SENSOR, FORWARD_MATRIX_1) =
+ { "forwardMatrix1", TYPE_RATIONAL },
+ TIIDX(SENSOR, FORWARD_MATRIX_2) =
+ { "forwardMatrix2", TYPE_RATIONAL },
+ TIIDX(SENSOR, CALIBRATION_TRANSFORM_1) =
+ { "calibrationTransform1", TYPE_RATIONAL },
+ TIIDX(SENSOR, CALIBRATION_TRANSFORM_2) =
+ { "calibrationTransform2", TYPE_RATIONAL },
+ TIIDX(SENSOR, BASE_GAIN_FACTOR) =
+ { "baseGainFactor", TYPE_RATIONAL },
+ TIIDX(SENSOR, MAX_ANALOG_SENSITIVITY) =
+ { "maxAnalogSensitivity", TYPE_INT32 },
+ TIIDX(SENSOR, NOISE_MODEL_COEFFICIENTS) =
+ { "noiseModelCoefficients", TYPE_FLOAT },
+ TIIDX(SENSOR, ORIENTATION) =
+ { "orientation", TYPE_INT32 }
+};
+
+tag_info_t android_flash[ANDROID_FLASH_END -
+ ANDROID_FLASH_START] = {
+ TIDX(FLASH, MODE) =
+ { "mode", TYPE_BYTE },
+ TIDX(FLASH, FIRING_POWER) =
+ { "firingPower", TYPE_BYTE },
+ TIDX(FLASH, FIRING_TIME) =
+ { "firingTime", TYPE_INT64 }
+};
+
+tag_info_t android_flash_info[ANDROID_FLASH_INFO_END -
+ ANDROID_FLASH_INFO_START] = {
+ TIIDX(FLASH, AVAILABLE_MODES) =
+ { "available", TYPE_BYTE },
+ TIIDX(FLASH, CHARGE_DURATION) =
+ { "chargeDuration", TYPE_INT64 },
+};
+
+tag_info_t android_hot_pixel[ANDROID_HOT_PIXEL_END -
+ ANDROID_HOT_PIXEL_START] = {
+ TIDX(HOT_PIXEL, MODE) =
+ { "mode", TYPE_BYTE }
+};
+
+tag_info_t android_hot_pixel_info[ANDROID_HOT_PIXEL_INFO_END -
+ ANDROID_HOT_PIXEL_INFO_START];
+
+tag_info_t android_demosaic[ANDROID_DEMOSAIC_END -
+ ANDROID_DEMOSAIC_START] = {
+ TIDX(DEMOSAIC, MODE) =
+ { "mode", TYPE_BYTE }
+};
+
+tag_info_t android_demosaic_info[ANDROID_DEMOSAIC_INFO_END -
+ ANDROID_DEMOSAIC_INFO_START];
+
+tag_info_t android_noise[ANDROID_NOISE_END -
+ ANDROID_NOISE_START] = {
+ TIDX(NOISE, MODE) =
+ { "mode", TYPE_BYTE },
+ TIDX(NOISE, STRENGTH) =
+ { "strength", TYPE_BYTE }
+};
+
+tag_info_t android_noise_info[ANDROID_NOISE_INFO_END -
+ ANDROID_NOISE_INFO_START];
+
+tag_info_t android_shading[ANDROID_SHADING_END -
+ ANDROID_SHADING_START] = {
+ TIDX(SHADING, MODE) =
+ { "mode", TYPE_BYTE }
+};
+
+tag_info_t android_shading_info[ANDROID_SHADING_INFO_END -
+ ANDROID_SHADING_INFO_START];
+
+tag_info_t android_geometric[ANDROID_GEOMETRIC_END -
+ ANDROID_GEOMETRIC_START] = {
+ TIDX(GEOMETRIC, MODE) =
+ { "mode", TYPE_BYTE }
+};
+
+tag_info_t android_geometric_info[ANDROID_GEOMETRIC_INFO_END -
+ ANDROID_GEOMETRIC_INFO_START];
+
+tag_info_t android_color[ANDROID_COLOR_END -
+ ANDROID_COLOR_START] = {
+ TIDX(COLOR, MODE) =
+ { "mode", TYPE_BYTE },
+ TIDX(COLOR, TRANSFORM) =
+ { "transform", TYPE_FLOAT }
+};
+
+tag_info_t android_color_info[ANDROID_COLOR_INFO_END -
+ ANDROID_COLOR_INFO_START] = {
+ TIIDX(COLOR, AVAILABLE_MODES) =
+ { "availableModes", TYPE_INT32 }
+};
+
+tag_info_t android_tonemap[ANDROID_TONEMAP_END -
+ ANDROID_TONEMAP_START] = {
+ TIDX(TONEMAP, MODE) =
+ { "mode", TYPE_BYTE },
+ TIDX(TONEMAP, CURVE_RED) =
+ { "curveRed", TYPE_FLOAT },
+ TIDX(TONEMAP, CURVE_GREEN) =
+ { "curveGreen", TYPE_FLOAT },
+ TIDX(TONEMAP, CURVE_BLUE) =
+ { "curveBlue", TYPE_FLOAT }
+};
+
+tag_info_t android_tonemap_info[ANDROID_TONEMAP_INFO_END -
+ ANDROID_TONEMAP_INFO_START] = {
+ TIIDX(TONEMAP, MAX_CURVE_POINTS) =
+ { "maxCurvePoints", TYPE_INT32 }
+};
+
+tag_info_t android_edge[ANDROID_EDGE_END -
+ ANDROID_EDGE_START] = {
+ TIDX(EDGE, MODE) =
+ { "mode", TYPE_BYTE },
+ TIDX(EDGE, STRENGTH) =
+ { "strength", TYPE_BYTE }
+};
+
+tag_info_t android_edge_info[ANDROID_EDGE_INFO_END -
+ ANDROID_EDGE_INFO_START];
+
+tag_info_t android_scaler[ANDROID_SCALER_END -
+ ANDROID_SCALER_START] = {
+ TIDX(SCALER, SIZE) =
+ { "size", TYPE_INT32 },
+ TIDX(SCALER, FORMAT) =
+ { "format", TYPE_BYTE },
+ TIDX(SCALER, CROP_REGION) =
+ { "cropRegion", TYPE_INT32 },
+ TIDX(SCALER, ROTATION) =
+ { "rotation", TYPE_INT32 },
+};
+
+tag_info_t android_scaler_info[ANDROID_SCALER_INFO_END -
+ ANDROID_SCALER_INFO_START] = {
+ TIIDX(SCALER, AVAILABLE_FORMATS) =
+ { "availableFormats", TYPE_INT32 },
+ TIIDX(SCALER, AVAILABLE_SIZES_PER_FORMAT) =
+ { "availableSizesPerFormat", TYPE_INT32 },
+ TIIDX(SCALER, AVAILABLE_SIZES) =
+ { "availableSizes", TYPE_INT32 },
+ TIIDX(SCALER, AVAILABLE_MIN_FRAME_DURATIONS) =
+ { "availableMinFrameDurations", TYPE_INT64 },
+ TIIDX(SCALER, AVAILABLE_MAX_ZOOM) =
+ { "availableMaxDigitalZoom", TYPE_INT32 }
+};
+
+tag_info_t android_jpeg[ANDROID_JPEG_END -
+ ANDROID_JPEG_START] = {
+ TIDX(JPEG, QUALITY) =
+ { "quality", TYPE_INT32 },
+ TIDX(JPEG, THUMBNAIL_SIZE) =
+ { "thumbnailSize", TYPE_INT32 },
+ TIDX(JPEG, THUMBNAIL_QUALITY) =
+ { "thumbnailQuality", TYPE_INT32 },
+ TIDX(JPEG, GPS_COORDINATES) =
+ { "gpsCoordinates", TYPE_DOUBLE },
+ TIDX(JPEG, GPS_PROCESSING_METHOD) =
+ { "gpsProcessingMethod", TYPE_BYTE },
+ TIDX(JPEG, GPS_TIMESTAMP) =
+ { "gpsTimestamp", TYPE_INT64 },
+ TIDX(JPEG, ORIENTATION) =
+ { "orientation", TYPE_INT32 }
+};
+
+tag_info_t android_jpeg_info[ANDROID_JPEG_INFO_END -
+ ANDROID_JPEG_INFO_START] = {
+ TIIDX(JPEG, AVAILABLE_THUMBNAIL_SIZES) =
+ { "availableThumbnailSizes", TYPE_INT32 }
+};
+
+tag_info_t android_stats[ANDROID_STATS_END -
+ ANDROID_STATS_START] = {
+ TIDX(STATS, FACE_DETECT_MODE) =
+ { "faceDetectMode", TYPE_BYTE },
+ TIDX(STATS, FACE_RECTANGLES) =
+ { "faceRectangles", TYPE_INT32 },
+ TIDX(STATS, FACE_SCORES) =
+ { "faceScores", TYPE_BYTE },
+ TIDX(STATS, FACE_LANDMARKS) =
+ { "faceLandmarks", TYPE_INT32 },
+ TIDX(STATS, FACE_IDS) =
+ { "faceIds", TYPE_INT32 },
+ TIDX(STATS, HISTOGRAM_MODE) =
+ { "histogramMode", TYPE_BYTE },
+ TIDX(STATS, HISTOGRAM) =
+ { "histogram", TYPE_INT32 },
+ TIDX(STATS, SHARPNESS_MAP_MODE) =
+ { "sharpnessMapMode", TYPE_BYTE },
+ TIDX(STATS, SHARPNESS_MAP) =
+ { "sharpnessMap", TYPE_INT32 }
+};
+
+tag_info_t android_stats_info[ANDROID_STATS_INFO_END -
+ ANDROID_STATS_INFO_START] = {
+ TIIDX(STATS, AVAILABLE_FACE_DETECT_MODES) =
+ { "availableFaceDetectModes", TYPE_BYTE },
+ TIIDX(STATS, MAX_FACE_COUNT) =
+ { "maxFaceCount", TYPE_INT32 },
+ TIIDX(STATS, HISTOGRAM_BUCKET_COUNT) =
+ { "histogramBucketCount", TYPE_INT32 },
+ TIIDX(STATS, MAX_HISTOGRAM_COUNT) =
+ { "maxHistogramCount", TYPE_INT32 },
+ TIIDX(STATS, SHARPNESS_MAP_SIZE) =
+ { "sharpnessMapSize", TYPE_INT32 },
+ TIIDX(STATS, MAX_SHARPNESS_MAP_VALUE) =
+ { "maxSharpnessMapValue", TYPE_INT32 }
+};
+
+
+tag_info_t android_control[ANDROID_CONTROL_END -
+ ANDROID_CONTROL_START] = {
+ TIDX(CONTROL, MODE) =
+ { "mode", TYPE_BYTE },
+ TIDX(CONTROL, AE_MODE) =
+ { "aeMode", TYPE_BYTE },
+ TIDX(CONTROL, AE_REGIONS) =
+ { "aeRegions", TYPE_INT32 },
+ TIDX(CONTROL, AE_EXP_COMPENSATION) =
+ { "aeExposureCompensation", TYPE_INT32 },
+ TIDX(CONTROL, AE_TARGET_FPS_RANGE) =
+ { "aeTargetFpsRange", TYPE_INT32 },
+ TIDX(CONTROL, AE_ANTIBANDING_MODE) =
+ { "aeAntibandingMode", TYPE_BYTE },
+ TIDX(CONTROL, AWB_MODE) =
+ { "awbMode", TYPE_BYTE },
+ TIDX(CONTROL, AWB_REGIONS) =
+ { "awbRegions", TYPE_INT32 },
+ TIDX(CONTROL, AF_MODE) =
+ { "afMode", TYPE_BYTE },
+ TIDX(CONTROL, AF_REGIONS) =
+ { "afRegions", TYPE_INT32 },
+ TIDX(CONTROL, AF_TRIGGER) =
+ { "afTrigger", TYPE_BYTE },
+ TIDX(CONTROL, AF_STATE) =
+ { "afState", TYPE_BYTE },
+ TIDX(CONTROL, VIDEO_STABILIZATION_MODE) =
+ { "videoStabilizationMode", TYPE_BYTE }
+};
+
+tag_info_t android_control_info[ANDROID_CONTROL_INFO_END -
+ ANDROID_CONTROL_INFO_START] = {
+ TIIDX(CONTROL, AVAILABLE_MODES) =
+ { "availableModes", TYPE_BYTE },
+ TIIDX(CONTROL, MAX_REGIONS) =
+ { "maxRegions", TYPE_INT32 },
+ TIIDX(CONTROL, AE_AVAILABLE_MODES) =
+ { "aeAvailableModes", TYPE_BYTE },
+ TIIDX(CONTROL, AE_EXP_COMPENSATION_STEP) =
+ { "aeCompensationStep", TYPE_RATIONAL },
+ TIIDX(CONTROL, AE_EXP_COMPENSATION_RANGE) =
+ { "aeCompensationRange", TYPE_INT32 },
+ TIIDX(CONTROL, AE_AVAILABLE_TARGET_FPS_RANGES) =
+ { "aeAvailableTargetFpsRanges", TYPE_INT32 },
+ TIIDX(CONTROL, AE_AVAILABLE_ANTIBANDING_MODES) =
+ { "aeAvailableAntibandingModes", TYPE_BYTE },
+ TIIDX(CONTROL, AWB_AVAILABLE_MODES) =
+ { "awbAvailableModes", TYPE_BYTE },
+ TIIDX(CONTROL, AF_AVAILABLE_MODES) =
+ { "afAvailableModes", TYPE_BYTE }
+};
+
+#undef TIDX
+#undef TIIDX
+
+tag_info_t *tag_info[ANDROID_SECTION_COUNT] = {
+ android_request,
+ android_lens,
+ android_lens_info,
+ android_sensor,
+ android_sensor_info,
+ android_flash,
+ android_flash_info,
+ android_hot_pixel,
+ android_hot_pixel_info,
+ android_demosaic,
+ android_demosaic_info,
+ android_noise,
+ android_noise_info,
+ android_shading,
+ android_shading_info,
+ android_geometric,
+ android_geometric_info,
+ android_color,
+ android_color_info,
+ android_tonemap,
+ android_tonemap_info,
+ android_edge,
+ android_edge_info,
+ android_scaler,
+ android_scaler_info,
+ android_jpeg,
+ android_jpeg_info,
+ android_stats,
+ android_stats_info,
+ android_control,
+ android_control_info
+};
diff --git a/camera/tests/Android.mk b/camera/tests/Android.mk
new file mode 100644
index 0000000..d7a53de
--- /dev/null
+++ b/camera/tests/Android.mk
@@ -0,0 +1,27 @@
+# Build the unit tests.
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SHARED_LIBRARIES := \
+ libutils \
+ libstlport \
+ libcamera_metadata
+
+LOCAL_STATIC_LIBRARIES := \
+ libgtest \
+ libgtest_main
+
+LOCAL_C_INCLUDES := \
+ bionic \
+ bionic/libstdc++/include \
+ external/gtest/include \
+ external/stlport/stlport \
+ system/media/camera/include \
+
+LOCAL_SRC_FILES := \
+ camera_metadata_tests.cpp
+
+LOCAL_MODULE := camera_metadata_tests
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_EXECUTABLE)
diff --git a/camera/tests/camera_metadata_tests.cpp b/camera/tests/camera_metadata_tests.cpp
new file mode 100644
index 0000000..53a4c45
--- /dev/null
+++ b/camera/tests/camera_metadata_tests.cpp
@@ -0,0 +1,925 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+
+#include "gtest/gtest.h"
+#include "system/camera_metadata.h"
+
+#include "camera_metadata_tests_fake_vendor.h"
+
+#define EXPECT_NULL(x) EXPECT_EQ((void*)0, x)
+#define EXPECT_NOT_NULL(x) EXPECT_NE((void*)0, x)
+
+#define OK 0
+#define ERROR 1
+#define NOT_FOUND (-ENOENT)
+
+TEST(camera_metadata, allocate_normal) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 32;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ EXPECT_NOT_NULL(m);
+ EXPECT_EQ((size_t)0, get_camera_metadata_entry_count(m));
+ EXPECT_EQ(entry_capacity, get_camera_metadata_entry_capacity(m));
+ EXPECT_EQ((size_t)0, get_camera_metadata_data_count(m));
+ EXPECT_EQ(data_capacity, get_camera_metadata_data_capacity(m));
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, allocate_nodata) {
+ camera_metadata_t *m = NULL;
+
+ m = allocate_camera_metadata(1, 0);
+
+ EXPECT_NOT_NULL(m);
+ EXPECT_EQ((size_t)0, get_camera_metadata_entry_count(m));
+ EXPECT_EQ((size_t)1, get_camera_metadata_entry_capacity(m));
+ EXPECT_EQ((size_t)0, get_camera_metadata_data_count(m));
+ EXPECT_EQ((size_t)0, get_camera_metadata_data_capacity(m));
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, allocate_nothing) {
+ camera_metadata_t *m = NULL;
+
+ m = allocate_camera_metadata(0, 0);
+
+ EXPECT_NULL(m);
+}
+
+TEST(camera_metadata, place_normal) {
+ camera_metadata_t *m = NULL;
+ void *buf = NULL;
+
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 32;
+
+ size_t buf_size = calculate_camera_metadata_size(entry_capacity,
+ data_capacity);
+
+ EXPECT_TRUE(buf_size > 0);
+
+ buf = malloc(buf_size);
+
+ EXPECT_NOT_NULL(buf);
+
+ m = place_camera_metadata(buf, buf_size, entry_capacity, data_capacity);
+
+ EXPECT_EQ(buf, (uint8_t*)m);
+ EXPECT_EQ((size_t)0, get_camera_metadata_entry_count(m));
+ EXPECT_EQ(entry_capacity, get_camera_metadata_entry_capacity(m));
+ EXPECT_EQ((size_t)0, get_camera_metadata_data_count(m));
+ EXPECT_EQ(data_capacity, get_camera_metadata_data_capacity(m));
+
+ free(buf);
+}
+
+TEST(camera_metadata, place_nospace) {
+ camera_metadata_t *m = NULL;
+ void *buf = NULL;
+
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 32;
+
+ size_t buf_size = calculate_camera_metadata_size(entry_capacity,
+ data_capacity);
+
+ EXPECT_GT(buf_size, (size_t)0);
+
+ buf_size--;
+
+ buf = malloc(buf_size);
+
+ EXPECT_NOT_NULL(buf);
+
+ m = place_camera_metadata(buf, buf_size, entry_capacity, data_capacity);
+
+ EXPECT_NULL(m);
+
+ free(buf);
+}
+
+TEST(camera_metadata, place_extraspace) {
+ camera_metadata_t *m = NULL;
+ uint8_t *buf = NULL;
+
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 32;
+ const size_t extra_space = 10;
+
+ size_t buf_size = calculate_camera_metadata_size(entry_capacity,
+ data_capacity);
+
+ EXPECT_GT(buf_size, (size_t)0);
+
+ buf_size += extra_space;
+
+ buf = (uint8_t*)malloc(buf_size);
+
+ EXPECT_NOT_NULL(buf);
+
+ m = place_camera_metadata(buf, buf_size, entry_capacity, data_capacity);
+
+ EXPECT_EQ((uint8_t*)m, buf);
+ EXPECT_EQ((size_t)0, get_camera_metadata_entry_count(m));
+ EXPECT_EQ(entry_capacity, get_camera_metadata_entry_capacity(m));
+ EXPECT_EQ((size_t)0, get_camera_metadata_data_count(m));
+ EXPECT_EQ(data_capacity, get_camera_metadata_data_capacity(m));
+ EXPECT_EQ(buf + buf_size - extra_space, (uint8_t*)m + get_camera_metadata_size(m));
+
+ free(buf);
+}
+
+TEST(camera_metadata, get_size) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 32;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ EXPECT_EQ(calculate_camera_metadata_size(entry_capacity, data_capacity),
+ get_camera_metadata_size(m) );
+
+ EXPECT_EQ(calculate_camera_metadata_size(0,0),
+ get_camera_metadata_compact_size(m) );
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, add_get_normal) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 80;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ int result;
+ size_t data_used = 0;
+ size_t entries_used = 0;
+
+ // INT64
+
+ int64_t exposure_time = 1000000000;
+ result = add_camera_metadata_entry(m,
+ ANDROID_SENSOR_EXPOSURE_TIME,
+ &exposure_time, 1);
+ EXPECT_EQ(OK, result);
+ data_used += calculate_camera_metadata_entry_data_size(
+ get_camera_metadata_tag_type(ANDROID_SENSOR_EXPOSURE_TIME), 1);
+ entries_used++;
+
+ // INT32
+
+ int32_t sensitivity = 800;
+ result = add_camera_metadata_entry(m,
+ ANDROID_SENSOR_SENSITIVITY,
+ &sensitivity, 1);
+ EXPECT_EQ(OK, result);
+ data_used += calculate_camera_metadata_entry_data_size(
+ get_camera_metadata_tag_type(ANDROID_SENSOR_SENSITIVITY), 1);
+ entries_used++;
+
+ // FLOAT
+
+ float focusDistance = 0.5f;
+ result = add_camera_metadata_entry(m,
+ ANDROID_LENS_FOCUS_DISTANCE,
+ &focusDistance, 1);
+ EXPECT_EQ(OK, result);
+ data_used += calculate_camera_metadata_entry_data_size(
+ get_camera_metadata_tag_type(ANDROID_LENS_FOCUS_DISTANCE), 1);
+ entries_used++;
+
+ // Array of FLOAT
+
+ float colorTransform[9] = {
+ 0.9f, 0.0f, 0.0f,
+ 0.2f, 0.5f, 0.0f,
+ 0.0f, 0.1f, 0.7f
+ };
+ result = add_camera_metadata_entry(m,
+ ANDROID_COLOR_TRANSFORM,
+ colorTransform, 9);
+ EXPECT_EQ(OK, result);
+ data_used += calculate_camera_metadata_entry_data_size(
+ get_camera_metadata_tag_type(ANDROID_COLOR_TRANSFORM), 9);
+ entries_used++;
+
+ // Check added entries
+
+ uint32_t tag = 0;
+ uint8_t type = 0;
+ int32_t *data_int32;
+ int64_t *data_int64;
+ float *data_float;
+ size_t data_count = 0;
+
+ result = get_camera_metadata_entry(m,
+ 0, &tag, &type, (void**)&data_int64, &data_count);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(ANDROID_SENSOR_EXPOSURE_TIME, tag);
+ EXPECT_EQ(TYPE_INT64, type);
+ EXPECT_EQ((size_t)1, data_count);
+ EXPECT_EQ(exposure_time, *data_int64);
+
+ result = get_camera_metadata_entry(m,
+ 1, &tag, &type, (void**)&data_int32, &data_count);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(ANDROID_SENSOR_SENSITIVITY, tag);
+ EXPECT_EQ(TYPE_INT32, type);
+ EXPECT_EQ((size_t)1, data_count);
+ EXPECT_EQ(sensitivity, *data_int32);
+
+ result = get_camera_metadata_entry(m,
+ 2, &tag, &type, (void**)&data_float, &data_count);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(ANDROID_LENS_FOCUS_DISTANCE, tag);
+ EXPECT_EQ(TYPE_FLOAT, type);
+ EXPECT_EQ((size_t)1, data_count);
+ EXPECT_EQ(focusDistance, *data_float);
+
+ result = get_camera_metadata_entry(m,
+ 3, &tag, &type, (void**)&data_float, &data_count);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(ANDROID_COLOR_TRANSFORM, tag);
+ EXPECT_EQ(TYPE_FLOAT, type);
+ EXPECT_EQ((size_t)9, data_count);
+ for (unsigned int i=0; i < data_count; i++) {
+ EXPECT_EQ(colorTransform[i], data_float[i] );
+ }
+
+ EXPECT_EQ(calculate_camera_metadata_size(entry_capacity, data_capacity),
+ get_camera_metadata_size(m) );
+
+ EXPECT_EQ(calculate_camera_metadata_size(entries_used, data_used),
+ get_camera_metadata_compact_size(m) );
+
+ dump_camera_metadata(m, 0, 2);
+
+ free_camera_metadata(m);
+}
+
+void add_test_metadata(camera_metadata_t *m, int entry_count) {
+
+ EXPECT_NOT_NULL(m);
+
+ int result;
+ size_t data_used = 0;
+ size_t entries_used = 0;
+ int64_t exposure_time;
+ for (int i=0; i < entry_count; i++ ) {
+ exposure_time = 100 + i * 100;
+ result = add_camera_metadata_entry(m,
+ ANDROID_SENSOR_EXPOSURE_TIME,
+ &exposure_time, 1);
+ EXPECT_EQ(OK, result);
+ data_used += calculate_camera_metadata_entry_data_size(
+ get_camera_metadata_tag_type(ANDROID_SENSOR_EXPOSURE_TIME), 1);
+ entries_used++;
+ }
+ EXPECT_EQ(data_used, get_camera_metadata_data_count(m));
+ EXPECT_EQ(entries_used, get_camera_metadata_entry_count(m));
+ EXPECT_GT(get_camera_metadata_data_capacity(m),
+ get_camera_metadata_data_count(m));
+}
+
+TEST(camera_metadata, add_get_toomany) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 50;
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ add_test_metadata(m, entry_capacity);
+
+ int32_t sensitivity = 100;
+ result = add_camera_metadata_entry(m,
+ ANDROID_SENSOR_SENSITIVITY,
+ &sensitivity, 1);
+
+ EXPECT_EQ(ERROR, result);
+
+ uint32_t tag = 0;
+ uint8_t type = 0;
+ int32_t *data_int32;
+ size_t data_count = 0;
+ for (unsigned int i=0; i < entry_capacity; i++) {
+ int64_t exposure_time = 100 + i * 100;
+ result = get_camera_metadata_entry(m,
+ i, &tag, &type, (void**)&data_int32, &data_count);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(ANDROID_SENSOR_EXPOSURE_TIME, tag);
+ EXPECT_EQ(TYPE_INT64, type);
+ EXPECT_EQ((size_t)1, data_count);
+ EXPECT_EQ(exposure_time, *data_int32);
+ }
+ tag = 0;
+ type = 0;
+ data_int32 = NULL;
+ data_count = 0;
+ result = get_camera_metadata_entry(m,
+ entry_capacity, &tag, &type, (void**)&data_int32, &data_count);
+ EXPECT_EQ(ERROR, result);
+ EXPECT_EQ((uint32_t)0, tag);
+ EXPECT_EQ((uint8_t)0, type);
+ EXPECT_EQ((size_t)0, data_count);
+ EXPECT_EQ(NULL, data_int32);
+
+ dump_camera_metadata(m, 0, 2);
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, copy_metadata) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 50;
+ const size_t data_capacity = 450;
+
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ add_test_metadata(m, entry_capacity);
+
+ size_t buf_size = get_camera_metadata_compact_size(m);
+ EXPECT_LT((size_t)0, buf_size);
+
+ uint8_t *buf = (uint8_t*)malloc(buf_size);
+ EXPECT_NOT_NULL(buf);
+
+ camera_metadata_t *m2 = copy_camera_metadata(buf, buf_size, m);
+ EXPECT_NOT_NULL(m2);
+ EXPECT_EQ(buf, (uint8_t*)m2);
+ EXPECT_EQ(get_camera_metadata_entry_count(m),
+ get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_count(m),
+ get_camera_metadata_data_count(m2));
+ EXPECT_EQ(get_camera_metadata_entry_capacity(m2),
+ get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_capacity(m2),
+ get_camera_metadata_data_count(m2));
+
+ for (unsigned int i=0; i < get_camera_metadata_entry_count(m); i++) {
+ uint32_t tag, tag2;
+ uint8_t type, type2;
+ uint8_t *data, *data2;
+ size_t data_count, data_count2;
+
+ int result;
+ result = get_camera_metadata_entry(m,
+ i, &tag, &type, (void**)&data, &data_count);
+ EXPECT_EQ(OK, result);
+ result = get_camera_metadata_entry(m2,
+ i, &tag2, &type2, (void**)&data2, &data_count2);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(tag, tag2);
+ EXPECT_EQ(type, type2);
+ EXPECT_EQ(data_count, data_count2);
+ for (unsigned int j=0; j < data_count; j++) {
+ EXPECT_EQ(data[j], data2[j]);
+ }
+ }
+
+ free(buf);
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, copy_metadata_extraspace) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 12;
+ const size_t data_capacity = 100;
+
+ const size_t extra_space = 10;
+
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ add_test_metadata(m, entry_capacity);
+
+ size_t buf_size = get_camera_metadata_compact_size(m);
+ EXPECT_LT((size_t)0, buf_size);
+ buf_size += extra_space;
+
+ uint8_t *buf = (uint8_t*)malloc(buf_size);
+ EXPECT_NOT_NULL(buf);
+
+ camera_metadata_t *m2 = copy_camera_metadata(buf, buf_size, m);
+ EXPECT_NOT_NULL(m2);
+ EXPECT_EQ(buf, (uint8_t*)m2);
+ EXPECT_EQ(get_camera_metadata_entry_count(m),
+ get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_count(m),
+ get_camera_metadata_data_count(m2));
+ EXPECT_EQ(get_camera_metadata_entry_capacity(m2),
+ get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_capacity(m2),
+ get_camera_metadata_data_count(m2));
+ EXPECT_EQ(buf + buf_size - extra_space,
+ (uint8_t*)m2 + get_camera_metadata_size(m2) );
+
+ for (unsigned int i=0; i < get_camera_metadata_entry_count(m); i++) {
+ uint32_t tag, tag2;
+ uint8_t type, type2;
+ uint8_t *data, *data2;
+ size_t data_count, data_count2;
+
+ int result;
+ result = get_camera_metadata_entry(m,
+ i, &tag, &type, (void**)&data, &data_count);
+ EXPECT_EQ(OK, result);
+ result = get_camera_metadata_entry(m2,
+ i, &tag2, &type2, (void**)&data2, &data_count2);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(tag, tag2);
+ EXPECT_EQ(type, type2);
+ EXPECT_EQ(data_count, data_count2);
+ for (unsigned int j=0; j < data_count; j++) {
+ EXPECT_EQ(data[j], data2[j]);
+ }
+ }
+
+ free(buf);
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, copy_metadata_nospace) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 50;
+
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ add_test_metadata(m, entry_capacity);
+
+ size_t buf_size = get_camera_metadata_compact_size(m);
+ EXPECT_LT((size_t)0, buf_size);
+
+ buf_size--;
+
+ uint8_t *buf = (uint8_t*)malloc(buf_size);
+ EXPECT_NOT_NULL(buf);
+
+ camera_metadata_t *m2 = copy_camera_metadata(buf, buf_size, m);
+ EXPECT_NULL(m2);
+
+ free(buf);
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, append_metadata) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 50;
+
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ add_test_metadata(m, entry_capacity);
+
+ camera_metadata_t *m2 = NULL;
+
+ m2 = allocate_camera_metadata(entry_capacity*2, data_capacity*2);
+ EXPECT_NOT_NULL(m2);
+
+ result = append_camera_metadata(m2, m);
+
+ EXPECT_EQ(OK, result);
+
+ EXPECT_EQ(get_camera_metadata_entry_count(m), get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_count(m), get_camera_metadata_data_count(m2));
+ EXPECT_EQ(entry_capacity*2, get_camera_metadata_entry_capacity(m2));
+ EXPECT_EQ(data_capacity*2, get_camera_metadata_data_capacity(m2));
+
+ for (unsigned int i=0; i < get_camera_metadata_entry_count(m); i++) {
+ uint32_t tag, tag2;
+ uint8_t type, type2;
+ uint8_t *data, *data2;
+ size_t data_count, data_count2;
+
+ int result;
+ result = get_camera_metadata_entry(m,
+ i, &tag, &type, (void**)&data, &data_count);
+ EXPECT_EQ(OK, result);
+ result = get_camera_metadata_entry(m2,
+ i, &tag2, &type2, (void**)&data2, &data_count2);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(tag, tag2);
+ EXPECT_EQ(type, type2);
+ EXPECT_EQ(data_count, data_count2);
+ for (unsigned int j=0; j < data_count; j++) {
+ EXPECT_EQ(data[j], data2[j]);
+ }
+ }
+
+ result = append_camera_metadata(m2, m);
+
+ EXPECT_EQ(OK, result);
+
+ EXPECT_EQ(get_camera_metadata_entry_count(m)*2, get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_count(m)*2, get_camera_metadata_data_count(m2));
+ EXPECT_EQ(entry_capacity*2, get_camera_metadata_entry_capacity(m2));
+ EXPECT_EQ(data_capacity*2, get_camera_metadata_data_capacity(m2));
+
+ for (unsigned int i=0; i < get_camera_metadata_entry_count(m2); i++) {
+ uint32_t tag, tag2;
+ uint8_t type, type2;
+ uint8_t *data, *data2;
+ size_t data_count, data_count2;
+
+ int result;
+ result = get_camera_metadata_entry(m,
+ i % entry_capacity, &tag, &type, (void**)&data, &data_count);
+ EXPECT_EQ(OK, result);
+ result = get_camera_metadata_entry(m2,
+ i, &tag2, &type2, (void**)&data2, &data_count2);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(tag, tag2);
+ EXPECT_EQ(type, type2);
+ EXPECT_EQ(data_count, data_count2);
+ for (unsigned int j=0; j < data_count; j++) {
+ EXPECT_EQ(data[j], data2[j]);
+ }
+ }
+
+ free_camera_metadata(m);
+ free_camera_metadata(m2);
+}
+
+TEST(camera_metadata, append_metadata_nospace) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 50;
+
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ add_test_metadata(m, entry_capacity);
+
+ camera_metadata_t *m2 = NULL;
+
+ m2 = allocate_camera_metadata(entry_capacity-1, data_capacity);
+ EXPECT_NOT_NULL(m2);
+
+ result = append_camera_metadata(m2, m);
+
+ EXPECT_EQ(ERROR, result);
+ EXPECT_EQ((size_t)0, get_camera_metadata_entry_count(m2));
+ EXPECT_EQ((size_t)0, get_camera_metadata_data_count(m2));
+
+ free_camera_metadata(m);
+ free_camera_metadata(m2);
+}
+
+TEST(camera_metadata, append_metadata_onespace) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 50;
+ const size_t entry_capacity2 = entry_capacity * 2 - 2;
+ const size_t data_capacity2 = data_capacity * 2;
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ add_test_metadata(m, entry_capacity);
+
+ camera_metadata_t *m2 = NULL;
+
+ m2 = allocate_camera_metadata(entry_capacity2, data_capacity2);
+ EXPECT_NOT_NULL(m2);
+
+ result = append_camera_metadata(m2, m);
+
+ EXPECT_EQ(OK, result);
+
+ EXPECT_EQ(get_camera_metadata_entry_count(m), get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_count(m), get_camera_metadata_data_count(m2));
+ EXPECT_EQ(entry_capacity2, get_camera_metadata_entry_capacity(m2));
+ EXPECT_EQ(data_capacity2, get_camera_metadata_data_capacity(m2));
+
+ for (unsigned int i=0; i < get_camera_metadata_entry_count(m); i++) {
+ uint32_t tag, tag2;
+ uint8_t type, type2;
+ uint8_t *data, *data2;
+ size_t data_count, data_count2;
+
+ int result;
+ result = get_camera_metadata_entry(m,
+ i, &tag, &type, (void**)&data, &data_count);
+ EXPECT_EQ(OK, result);
+ result = get_camera_metadata_entry(m2,
+ i, &tag2, &type2, (void**)&data2, &data_count2);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(tag, tag2);
+ EXPECT_EQ(type, type2);
+ EXPECT_EQ(data_count, data_count2);
+ for (unsigned int j=0; j < data_count; j++) {
+ EXPECT_EQ(data[j], data2[j]);
+ }
+ }
+
+ result = append_camera_metadata(m2, m);
+
+ EXPECT_EQ(ERROR, result);
+ EXPECT_EQ(entry_capacity, get_camera_metadata_entry_count(m2));
+ EXPECT_EQ(get_camera_metadata_data_count(m),
+ get_camera_metadata_data_count(m2));
+ EXPECT_EQ(entry_capacity2, get_camera_metadata_entry_capacity(m2));
+ EXPECT_EQ(data_capacity2, get_camera_metadata_data_capacity(m2));
+
+ for (unsigned int i=0; i < get_camera_metadata_entry_count(m2); i++) {
+ uint32_t tag, tag2;
+ uint8_t type, type2;
+ uint8_t *data, *data2;
+ size_t data_count, data_count2;
+
+ int result;
+ result = get_camera_metadata_entry(m,
+ i % entry_capacity, &tag, &type, (void**)&data, &data_count);
+ EXPECT_EQ(OK, result);
+ result = get_camera_metadata_entry(m2,
+ i, &tag2, &type2, (void**)&data2, &data_count2);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(tag, tag2);
+ EXPECT_EQ(type, type2);
+ EXPECT_EQ(data_count, data_count2);
+ for (unsigned int j=0; j < data_count; j++) {
+ EXPECT_EQ(data[j], data2[j]);
+ }
+ }
+
+ free_camera_metadata(m);
+ free_camera_metadata(m2);
+}
+
+TEST(camera_metadata, vendor_tags) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 50;
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ uint8_t superMode = 5;
+ result = add_camera_metadata_entry(m,
+ FAKEVENDOR_SENSOR_SUPERMODE,
+ &superMode, 1);
+ EXPECT_EQ(ERROR, result);
+
+ result = add_camera_metadata_entry(m,
+ ANDROID_REQUEST_METADATA_MODE,
+ &superMode, 1);
+ EXPECT_EQ(OK, result);
+
+ EXPECT_NULL(get_camera_metadata_section_name(FAKEVENDOR_SENSOR_SUPERMODE));
+ EXPECT_NULL(get_camera_metadata_tag_name(FAKEVENDOR_SENSOR_SUPERMODE));
+ EXPECT_EQ(-1, get_camera_metadata_tag_type(FAKEVENDOR_SENSOR_SUPERMODE));
+
+ set_camera_metadata_vendor_tag_ops(&fakevendor_query_ops);
+
+ result = add_camera_metadata_entry(m,
+ FAKEVENDOR_SENSOR_SUPERMODE,
+ &superMode, 1);
+ EXPECT_EQ(OK, result);
+
+ result = add_camera_metadata_entry(m,
+ ANDROID_REQUEST_METADATA_MODE,
+ &superMode, 1);
+ EXPECT_EQ(OK, result);
+
+ result = add_camera_metadata_entry(m,
+ FAKEVENDOR_SCALER_END,
+ &superMode, 1);
+ EXPECT_EQ(ERROR, result);
+
+ EXPECT_STREQ("com.fakevendor.sensor",
+ get_camera_metadata_section_name(FAKEVENDOR_SENSOR_SUPERMODE));
+ EXPECT_STREQ("superMode",
+ get_camera_metadata_tag_name(FAKEVENDOR_SENSOR_SUPERMODE));
+ EXPECT_EQ(TYPE_BYTE,
+ get_camera_metadata_tag_type(FAKEVENDOR_SENSOR_SUPERMODE));
+
+ EXPECT_STREQ("com.fakevendor.scaler",
+ get_camera_metadata_section_name(FAKEVENDOR_SCALER_END));
+ EXPECT_NULL(get_camera_metadata_tag_name(FAKEVENDOR_SCALER_END));
+ EXPECT_EQ(-1, get_camera_metadata_tag_type(FAKEVENDOR_SCALER_END));
+
+ set_camera_metadata_vendor_tag_ops(NULL);
+
+ result = add_camera_metadata_entry(m,
+ FAKEVENDOR_SENSOR_SUPERMODE,
+ &superMode, 1);
+ EXPECT_EQ(ERROR, result);
+
+ result = add_camera_metadata_entry(m,
+ ANDROID_REQUEST_METADATA_MODE,
+ &superMode, 1);
+ EXPECT_EQ(OK, result);
+
+ EXPECT_NULL(get_camera_metadata_section_name(FAKEVENDOR_SENSOR_SUPERMODE));
+ EXPECT_NULL(get_camera_metadata_tag_name(FAKEVENDOR_SENSOR_SUPERMODE));
+ EXPECT_EQ(-1, get_camera_metadata_tag_type(FAKEVENDOR_SENSOR_SUPERMODE));
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, add_all_tags) {
+ int total_tag_count = 0;
+ for (int i = 0; i < ANDROID_SECTION_COUNT; i++) {
+ total_tag_count += camera_metadata_section_bounds[i][1] -
+ camera_metadata_section_bounds[i][0];
+ }
+ int entry_data_count = 3;
+ int conservative_data_space = total_tag_count * entry_data_count * 8;
+ uint8_t data[entry_data_count * 8];
+ int32_t *data_int32 = (int32_t *)data;
+ float *data_float = (float *)data;
+ int64_t *data_int64 = (int64_t *)data;
+ double *data_double = (double *)data;
+ camera_metadata_rational_t *data_rational = (camera_metadata_rational_t *)data;
+
+ camera_metadata_t *m = allocate_camera_metadata(total_tag_count, conservative_data_space);
+
+ ASSERT_NE((void*)NULL, (void*)m);
+
+ int result;
+
+ int counter = 0;
+ for (int i = 0; i < ANDROID_SECTION_COUNT; i++) {
+ for (uint32_t tag = camera_metadata_section_bounds[i][0];
+ tag < camera_metadata_section_bounds[i][1];
+ tag++, counter++) {
+ int type = get_camera_metadata_tag_type(tag);
+ ASSERT_NE(-1, type);
+
+ switch (type) {
+ case TYPE_BYTE:
+ data[0] = tag & 0xFF;
+ data[1] = (tag >> 8) & 0xFF;
+ data[2] = (tag >> 16) & 0xFF;
+ break;
+ case TYPE_INT32:
+ data_int32[0] = tag;
+ data_int32[1] = i;
+ data_int32[2] = counter;
+ break;
+ case TYPE_FLOAT:
+ data_float[0] = tag;
+ data_float[1] = i;
+ data_float[2] = counter / (float)total_tag_count;
+ break;
+ case TYPE_INT64:
+ data_int64[0] = (int64_t)tag | ( (int64_t)tag << 32);
+ data_int64[1] = i;
+ data_int64[2] = counter;
+ break;
+ case TYPE_DOUBLE:
+ data_double[0] = tag;
+ data_double[1] = i;
+ data_double[2] = counter / (double)total_tag_count;
+ break;
+ case TYPE_RATIONAL:
+ data_rational[0].numerator = tag;
+ data_rational[0].denominator = 1;
+ data_rational[1].numerator = i;
+ data_rational[1].denominator = 1;
+ data_rational[2].numerator = counter;
+ data_rational[2].denominator = total_tag_count;
+ break;
+ default:
+ FAIL() << "Unknown type field encountered:" << type;
+ break;
+ }
+ result = add_camera_metadata_entry(m,
+ tag,
+ data,
+ entry_data_count);
+ ASSERT_EQ(OK, result);
+
+ }
+ }
+
+ dump_camera_metadata(m, 0, 2);
+
+ free_camera_metadata(m);
+}
+
+TEST(camera_metadata, sort_metadata) {
+ camera_metadata_t *m = NULL;
+ const size_t entry_capacity = 5;
+ const size_t data_capacity = 100;
+
+ int result;
+
+ m = allocate_camera_metadata(entry_capacity, data_capacity);
+
+ // Add several unique entries in non-sorted order
+
+ float colorTransform[9] = {
+ 0.9f, 0.0f, 0.0f,
+ 0.2f, 0.5f, 0.0f,
+ 0.0f, 0.1f, 0.7f
+ };
+ result = add_camera_metadata_entry(m,
+ ANDROID_COLOR_TRANSFORM,
+ colorTransform, 9);
+ EXPECT_EQ(OK, result);
+
+ float focus_distance = 0.5f;
+ result = add_camera_metadata_entry(m,
+ ANDROID_LENS_FOCUS_DISTANCE,
+ &focus_distance, 1);
+ EXPECT_EQ(OK, result);
+
+ int64_t exposure_time = 1000000000;
+ result = add_camera_metadata_entry(m,
+ ANDROID_SENSOR_EXPOSURE_TIME,
+ &exposure_time, 1);
+ EXPECT_EQ(OK, result);
+
+ int32_t sensitivity = 800;
+ result = add_camera_metadata_entry(m,
+ ANDROID_SENSOR_SENSITIVITY,
+ &sensitivity, 1);
+ EXPECT_EQ(OK, result);
+
+ // Test unsorted find
+ uint8_t type;
+ float *f;
+ size_t data_count;
+ result = find_camera_metadata_entry(m,
+ ANDROID_LENS_FOCUS_DISTANCE,
+ &type,
+ (void**)&f,
+ &data_count);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(TYPE_FLOAT, type);
+ EXPECT_EQ(1, (int)data_count);
+ EXPECT_EQ(focus_distance, *f);
+
+ result = find_camera_metadata_entry(m,
+ ANDROID_NOISE_STRENGTH,
+ &type,
+ (void**)&f,
+ &data_count);
+ EXPECT_EQ(NOT_FOUND, result);
+
+ // Sort
+ std::cout << "Pre-sorted metadata" << std::endl;
+ dump_camera_metadata(m, 0, 2);
+
+ result = sort_camera_metadata(m);
+ EXPECT_EQ(OK, result);
+
+ std::cout << "Sorted metadata" << std::endl;
+ dump_camera_metadata(m, 0, 2);
+
+ // Test sorted find
+
+ result = find_camera_metadata_entry(m,
+ ANDROID_LENS_FOCUS_DISTANCE,
+ &type,
+ (void**)&f,
+ &data_count);
+ EXPECT_EQ(OK, result);
+ EXPECT_EQ(TYPE_FLOAT, type);
+ EXPECT_EQ(1, (int)data_count);
+ EXPECT_EQ(focus_distance, *f);
+
+ result = find_camera_metadata_entry(m,
+ ANDROID_NOISE_STRENGTH,
+ &type,
+ (void**)&f,
+ &data_count);
+ EXPECT_EQ(NOT_FOUND, result);
+
+
+ free_camera_metadata(m);
+}
diff --git a/camera/tests/camera_metadata_tests_fake_vendor.h b/camera/tests/camera_metadata_tests_fake_vendor.h
new file mode 100644
index 0000000..8e08776
--- /dev/null
+++ b/camera/tests/camera_metadata_tests_fake_vendor.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Fake vendor extensions for testing
+ */
+
+#ifndef TESTING_CAMERA_METADATA_FAKEVENDOR_H
+#define TESTING_CAMERA_METADATA_FAKEVENDOR_H
+
+enum vendor_extension_section {
+ FAKEVENDOR_SENSOR = VENDOR_SECTION,
+ FAKEVENDOR_SENSOR_INFO,
+ FAKEVENDOR_COLORCORRECTION,
+ FAKEVENDOR_SCALER,
+ FAKEVENDOR_SECTION_END
+};
+
+const int FAKEVENDOR_SECTION_COUNT = FAKEVENDOR_SECTION_END - VENDOR_SECTION;
+
+enum vendor_extension_section_ranges {
+ FAKEVENDOR_SENSOR_START = FAKEVENDOR_SENSOR << 16,
+ FAKEVENDOR_SENSOR_I_START = FAKEVENDOR_SENSOR_INFO << 16,
+ FAKEVENDOR_COLORCORRECTION_START = FAKEVENDOR_COLORCORRECTION << 16,
+ FAKEVENDOR_SCALER_START = FAKEVENDOR_SCALER << 16
+};
+
+enum vendor_extension_tags {
+ FAKEVENDOR_SENSOR_SUPERMODE = FAKEVENDOR_SENSOR_START,
+ FAKEVENDOR_SENSOR_DOUBLE_EXPOSURE,
+ FAKEVENDOR_SENSOR_END,
+
+ FAKEVENDOR_SENSOR_AVAILABLE_SUPERMODES = FAKEVENDOR_SENSOR_I_START,
+ FAKEVENDOR_SENSOR_I_END,
+
+ FAKEVENDOR_COLORCORRECTION_3DLUT_MODE = FAKEVENDOR_COLORCORRECTION_START,
+ FAKEVENDOR_COLORCORRECTION_3DLUT_TABLES,
+ FAKEVENDOR_COLORCORRECTION_END,
+
+ FAKEVENDOR_SCALER_DOWNSCALE_MODE = FAKEVENDOR_SCALER_START,
+ FAKEVENDOR_SCALER_DOWNSCALE_COEFF,
+ FAKEVENDOR_SCALER_END
+};
+
+typedef struct vendor_tag_info {
+ const char *tag_name;
+ uint8_t tag_type;
+} vendor_tag_info_t;
+
+const char *fakevendor_section_names[FAKEVENDOR_SECTION_COUNT] = {
+ "com.fakevendor.sensor",
+ "com.fakevendor.sensor.info",
+ "com.fakevendor.colorCorrection",
+ "com.fakevendor.scaler"
+};
+
+unsigned int fakevendor_section_bounds[FAKEVENDOR_SECTION_COUNT][2] = {
+ { FAKEVENDOR_SENSOR_START, FAKEVENDOR_SENSOR_END },
+ { FAKEVENDOR_SENSOR_I_START, FAKEVENDOR_SENSOR_I_END },
+ { FAKEVENDOR_COLORCORRECTION_START, FAKEVENDOR_COLORCORRECTION_END },
+ { FAKEVENDOR_SCALER_START, FAKEVENDOR_SCALER_END}
+};
+
+vendor_tag_info_t fakevendor_sensor[FAKEVENDOR_SENSOR_END -
+ FAKEVENDOR_SENSOR_START] = {
+ { "superMode", TYPE_BYTE },
+ { "doubleExposure", TYPE_INT64 }
+};
+
+vendor_tag_info_t fakevendor_sensor_info[FAKEVENDOR_SENSOR_I_END -
+ FAKEVENDOR_SENSOR_I_START] = {
+ { "availableSuperModes", TYPE_BYTE }
+};
+
+vendor_tag_info_t fakevendor_color_correction[FAKEVENDOR_COLORCORRECTION_END -
+ FAKEVENDOR_COLORCORRECTION_START] = {
+ { "3dLutMode", TYPE_BYTE },
+ { "3dLutTables", TYPE_FLOAT }
+};
+
+vendor_tag_info_t fakevendor_scaler[FAKEVENDOR_SCALER_END -
+ FAKEVENDOR_SCALER_START] = {
+ { "downscaleMode", TYPE_BYTE },
+ { "downscaleCoefficients", TYPE_FLOAT }
+};
+
+vendor_tag_info_t *fakevendor_tag_info[FAKEVENDOR_SECTION_COUNT] = {
+ fakevendor_sensor,
+ fakevendor_sensor_info,
+ fakevendor_color_correction,
+ fakevendor_scaler
+};
+
+const char *get_fakevendor_section_name(const vendor_tag_query_ops_t *v,
+ uint32_t tag);
+const char *get_fakevendor_tag_name(const vendor_tag_query_ops_t *v,
+ uint32_t tag);
+int get_fakevendor_tag_type(const vendor_tag_query_ops_t *v,
+ uint32_t tag);
+
+static const vendor_tag_query_ops_t fakevendor_query_ops = {
+ get_fakevendor_section_name,
+ get_fakevendor_tag_name,
+ get_fakevendor_tag_type
+};
+
+const char *get_fakevendor_section_name(const vendor_tag_query_ops_t *v,
+ uint32_t tag) {
+ if (v != &fakevendor_query_ops) return NULL;
+ int tag_section = (tag >> 16) - VENDOR_SECTION;
+ if (tag_section < 0 ||
+ tag_section >= FAKEVENDOR_SECTION_COUNT) return NULL;
+
+ return fakevendor_section_names[tag_section];
+}
+
+const char *get_fakevendor_tag_name(const vendor_tag_query_ops_t *v,
+ uint32_t tag) {
+ if (v != &fakevendor_query_ops) return NULL;
+ int tag_section = (tag >> 16) - VENDOR_SECTION;
+ if (tag_section < 0
+ || tag_section >= FAKEVENDOR_SECTION_COUNT
+ || tag >= fakevendor_section_bounds[tag_section][1]) return NULL;
+ int tag_index = tag & 0xFFFF;
+ return fakevendor_tag_info[tag_section][tag_index].tag_name;
+}
+
+int get_fakevendor_tag_type(const vendor_tag_query_ops_t *v,
+ uint32_t tag) {
+ if (v != &fakevendor_query_ops) return -1;
+ int tag_section = (tag >> 16) - VENDOR_SECTION;
+ if (tag_section < 0
+ || tag_section >= FAKEVENDOR_SECTION_COUNT
+ || tag >= fakevendor_section_bounds[tag_section][1]) return -1;
+ int tag_index = tag & 0xFFFF;
+ return fakevendor_tag_info[tag_section][tag_index].tag_type;
+}
+
+
+#endif
diff --git a/mca/Android.mk b/mca/Android.mk
deleted file mode 100644
index fcb81cc..0000000
--- a/mca/Android.mk
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-FILTERFW_PATH:= $(call my-dir)
-
-# for shared defintion of libfilterfw_to_document
-include $(FILTERFW_PATH)/Docs.mk
-
-#
-# Build all native libraries
-#
-include $(call all-subdir-makefiles)
-
-#
-# Build Java library from filterfw core and all open-source filterpacks
-#
-
-LOCAL_PATH := $(FILTERFW_PATH)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call libfilterfw_to_document,$(LOCAL_PATH))
-
-LOCAL_MODULE := filterfw
-
-LOCAL_JNI_SHARED_LIBRARIES := libfilterfw libfilterpack_imageproc
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := core core-junit ext framework # to avoid circular dependency
-
-include $(BUILD_JAVA_LIBRARY)
-
-#
-# Local droiddoc for faster libfilterfw docs testing
-#
-#
-# Run with:
-# m libfilterfw-docs
-#
-# Main output:
-# out/target/common/docs/libfilterfw/reference/packages.html
-#
-# All text for proofreading (or running tools over):
-# out/target/common/docs/libfilterfw-proofread.txt
-#
-# TODO list of missing javadoc, etc:
-# out/target/common/docs/libfilterfw-docs-todo.html
-#
-# Rerun:
-# rm -rf out/target/common/docs/libfilterfw-timestamp && m libfilterfw-docs
-#
-
-LOCAL_PATH := $(FILTERFW_PATH)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:=$(call libfilterfw_to_document,$(LOCAL_PATH))
-
-# rerun doc generation without recompiling the java
-LOCAL_JAVA_LIBRARIES:=
-LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
-
-LOCAL_MODULE := libfilterfw
-
-LOCAL_DROIDDOC_OPTIONS:= \
- -offlinemode \
- -title "libfilterfw" \
- -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
- -todo ../$(LOCAL_MODULE)-docs-todo.html \
- -hdf android.whichdoc offline
-
-LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
-
-include $(BUILD_DROIDDOC)
diff --git a/mca/Docs.mk b/mca/Docs.mk
deleted file mode 100644
index d9294b5..0000000
--- a/mca/Docs.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-# -*- mode: makefile -*-
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# List of mobile filter framework directories to include in documentation/API/SDK.
-# Shared between mobile filter framework and frameworks/base.
-
-define libfilterfw-all-java-files-under
-$(patsubst ./%,%, \
- $(shell cd $(1) ; \
- find $(2) -name "*.java" -and -not -name ".*") \
- )
-endef
-
-# List of mobile filter framework source files to include in the public API/SDK.
-#
-#
-# $(1): directory for search (to support use from frameworks/base)
-define libfilterfw_to_document
- $(call libfilterfw-all-java-files-under,$(1), \
- filterfw/java \
- effect/java \
- filterpacks/imageproc/java \
- filterpacks/numeric/java \
- filterpacks/performance/java \
- filterpacks/text/java \
- filterpacks/ui/java \
- filterpacks/videosrc/java \
- filterpacks/videoproc/java \
- filterpacks/videosink/java )
-endef
diff --git a/mca/effect/java/android/media/effect/Effect.java b/mca/effect/java/android/media/effect/Effect.java
deleted file mode 100644
index b2b4427..0000000
--- a/mca/effect/java/android/media/effect/Effect.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect;
-
-
-/**
- * <p>Effects are high-performance transformations that can be applied to image frames. These are
- * passed in the form of OpenGL ES 2.0 texture names. Typical frames could be images loaded from
- * disk, or frames from the camera or other video streams.</p>
- *
- * <p>To create an Effect you must first create an EffectContext. You can obtain an instance of the
- * context's EffectFactory by calling
- * {@link android.media.effect.EffectContext#getFactory() getFactory()}. The EffectFactory allows
- * you to instantiate specific Effects.</p>
- *
- * <p>The application is responsible for creating an EGL context, and making it current before
- * applying an effect. An effect is bound to a single EffectContext, which in turn is bound to a
- * single EGL context. If your EGL context is destroyed, the EffectContext becomes invalid and any
- * effects bound to this context can no longer be used.</p>
- *
- */
-public abstract class Effect {
-
- /**
- * Get the effect name.
- *
- * Returns the unique name of the effect, which matches the name used for instantiating this
- * effect by the EffectFactory.
- *
- * @return The name of the effect.
- */
- public abstract String getName();
-
- /**
- * Apply an effect to GL textures.
- *
- * <p>Apply the Effect on the specified input GL texture, and write the result into the
- * output GL texture. The texture names passed must be valid in the current GL context.</p>
- *
- * <p>The input texture must be a valid texture name with the given width and height and must be
- * bound to a GL_TEXTURE_2D texture image (usually done by calling the glTexImage2D() function).
- * Multiple mipmap levels may be provided.</p>
- *
- * <p>If the output texture has not been bound to a texture image, it will be automatically
- * bound by the effect as a GL_TEXTURE_2D. It will contain one mipmap level (0), which will have
- * the same size as the input. No other mipmap levels are defined. If the output texture was
- * bound already, and its size does not match the input texture size, the result may be clipped
- * or only partially fill the texture.</p>
- *
- * <p>Note, that regardless of whether a texture image was originally provided or not, both the
- * input and output textures are owned by the caller. That is, the caller is responsible for
- * calling glDeleteTextures() to deallocate the input and output textures.</p>
- *
- * @param inputTexId The GL texture name of a valid and bound input texture.
- * @param width The width of the input texture in pixels.
- * @param height The height of the input texture in pixels.
- * @param outputTexId The GL texture name of the output texture.
- */
- public abstract void apply(int inputTexId, int width, int height, int outputTexId);
-
- /**
- * Set a filter parameter.
- *
- * Consult the effect documentation for a list of supported parameter keys for each effect.
- *
- * @param parameterKey The name of the parameter to adjust.
- * @param value The new value to set the parameter to.
- * @throws InvalidArgumentException if parameterName is not a recognized name, or the value is
- * not a valid value for this parameter.
- */
- public abstract void setParameter(String parameterKey, Object value);
-
- /**
- * Set an effect listener.
- *
- * Some effects may report state changes back to the host, if a listener is set. Consult the
- * individual effect documentation for more details.
- *
- * @param listener The listener to receive update callbacks on.
- */
- public void setUpdateListener(EffectUpdateListener listener) {
- }
-
- /**
- * Release an effect.
- *
- * <p>Releases the effect and any resources associated with it. You may call this if you need to
- * make sure acquired resources are no longer held by the effect. Releasing an effect makes it
- * invalid for reuse.</p>
- *
- * <p>Note that this method must be called with the EffectContext and EGL context current, as
- * the effect may release internal GL resources.</p>
- */
- public abstract void release();
-}
-
diff --git a/mca/effect/java/android/media/effect/EffectContext.java b/mca/effect/java/android/media/effect/EffectContext.java
deleted file mode 100644
index ef03229..0000000
--- a/mca/effect/java/android/media/effect/EffectContext.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect;
-
-import android.filterfw.core.CachedFrameManager;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.FilterFactory;
-import android.filterfw.core.GLEnvironment;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.FrameManager;
-import android.opengl.GLES20;
-
-/**
- * <p>An EffectContext keeps all necessary state information to run Effects within a Open GL ES 2.0
- * context.</p>
- *
- * <p>Every EffectContext is bound to one GL context. The application is responsible for creating
- * this EGL context, and making it current before applying any effect. If your EGL context is
- * destroyed, the EffectContext becomes invalid and any effects bound to this context can no longer
- * be used. If you switch to another EGL context, you must create a new EffectContext. Each Effect
- * is bound to a single EffectContext, and can only be executed in that context.</p>
- */
-public class EffectContext {
-
- private final int GL_STATE_FBO = 0;
- private final int GL_STATE_PROGRAM = 1;
- private final int GL_STATE_ARRAYBUFFER = 2;
- private final int GL_STATE_COUNT = 3;
-
- FilterContext mFilterContext;
-
- private EffectFactory mFactory;
-
- private int[] mOldState = new int[GL_STATE_COUNT];
-
- /**
- * Creates a context within the current GL context.
- *
- * <p>Binds the EffectContext to the current OpenGL context. All subsequent calls to the
- * EffectContext must be made in the GL context that was active during creation.
- * When you have finished using a context, you must call {@link #release()}. to dispose of all
- * resources associated with this context.</p>
- */
- public static EffectContext createWithCurrentGlContext() {
- EffectContext result = new EffectContext();
- result.initInCurrentGlContext();
- return result;
- }
-
- /**
- * Returns the EffectFactory for this context.
- *
- * <p>The EffectFactory returned from this method allows instantiating new effects within this
- * context.</p>
- *
- * @return The EffectFactory instance for this context.
- */
- public EffectFactory getFactory() {
- return mFactory;
- }
-
- /**
- * Releases the context.
- *
- * <p>Releases all the resources and effects associated with the EffectContext. This renders the
- * context and all the effects bound to this context invalid. You must no longer use the context
- * or any of its bound effects after calling release().</p>
- *
- * <p>Note that this method must be called with the proper EGL context made current, as the
- * EffectContext and its effects may release internal GL resources.</p>
- */
- public void release() {
- mFilterContext.tearDown();
- mFilterContext = null;
- }
-
- private EffectContext() {
- mFilterContext = new FilterContext();
- mFilterContext.setFrameManager(new CachedFrameManager());
- mFactory = new EffectFactory(this);
- }
-
- private void initInCurrentGlContext() {
- if (!GLEnvironment.isAnyContextActive()) {
- throw new RuntimeException("Attempting to initialize EffectContext with no active "
- + "GL context!");
- }
- GLEnvironment glEnvironment = new GLEnvironment();
- glEnvironment.initWithCurrentContext();
- mFilterContext.initGLEnvironment(glEnvironment);
- }
-
- final void assertValidGLState() {
- GLEnvironment glEnv = mFilterContext.getGLEnvironment();
- if (glEnv == null || !glEnv.isContextActive()) {
- if (GLEnvironment.isAnyContextActive()) {
- throw new RuntimeException("Applying effect in wrong GL context!");
- } else {
- throw new RuntimeException("Attempting to apply effect without valid GL context!");
- }
- }
- }
-
- final void saveGLState() {
- GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, mOldState, GL_STATE_FBO);
- GLES20.glGetIntegerv(GLES20.GL_CURRENT_PROGRAM, mOldState, GL_STATE_PROGRAM);
- GLES20.glGetIntegerv(GLES20.GL_ARRAY_BUFFER_BINDING, mOldState, GL_STATE_ARRAYBUFFER);
- }
-
- final void restoreGLState() {
- GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mOldState[GL_STATE_FBO]);
- GLES20.glUseProgram(mOldState[GL_STATE_PROGRAM]);
- GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mOldState[GL_STATE_ARRAYBUFFER]);
- }
-}
-
diff --git a/mca/effect/java/android/media/effect/EffectFactory.java b/mca/effect/java/android/media/effect/EffectFactory.java
deleted file mode 100644
index 4330279..0000000
--- a/mca/effect/java/android/media/effect/EffectFactory.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect;
-
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-
-/**
- * <p>The EffectFactory class defines the list of available Effects, and provides functionality to
- * inspect and instantiate them. Some effects may not be available on all platforms, so before
- * creating a certain effect, the application should confirm that the effect is supported on this
- * platform by calling {@link #isEffectSupported(String)}.</p>
- */
-public class EffectFactory {
-
- private EffectContext mEffectContext;
-
- private final static String[] EFFECT_PACKAGES = {
- "android.media.effect.effects.", // Default effect package
- "" // Allows specifying full class path
- };
-
- /** List of Effects */
- /**
- * <p>Copies the input texture to the output.</p>
- * <p>Available parameters: None</p>
- * @hide
- */
- public final static String EFFECT_IDENTITY = "IdentityEffect";
-
- /**
- * <p>Adjusts the brightness of the image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>brightness</code></td>
- * <td>The brightness multiplier.</td>
- * <td>Positive float. 1.0 means no change;
- larger values will increase brightness.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_BRIGHTNESS =
- "android.media.effect.effects.BrightnessEffect";
-
- /**
- * <p>Adjusts the contrast of the image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>contrast</code></td>
- * <td>The contrast multiplier.</td>
- * <td>Float. 1.0 means no change;
- larger values will increase contrast.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_CONTRAST =
- "android.media.effect.effects.ContrastEffect";
-
- /**
- * <p>Applies a fisheye lens distortion to the image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>scale</code></td>
- * <td>The scale of the distortion.</td>
- * <td>Float, between 0 and 1. Zero means no distortion.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_FISHEYE =
- "android.media.effect.effects.FisheyeEffect";
-
- /**
- * <p>Replaces the background of the input frames with frames from a
- * selected video. Requires an initial learning period with only the
- * background visible before the effect becomes active. The effect will wait
- * until it does not see any motion in the scene before learning the
- * background and starting the effect.</p>
- *
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>source</code></td>
- * <td>A URI for the background video to use. This parameter must be
- * supplied before calling apply() for the first time.</td>
- * <td>String, such as from
- * {@link android.net.Uri#toString Uri.toString()}</td>
- * </tr>
- * </table>
- *
- * <p>If the update listener is set for this effect using
- * {@link Effect#setUpdateListener}, it will be called when the effect has
- * finished learning the background, with a null value for the info
- * parameter.</p>
- */
- public final static String EFFECT_BACKDROPPER =
- "android.media.effect.effects.BackDropperEffect";
-
- /**
- * <p>Attempts to auto-fix the image based on histogram equalization.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>scale</code></td>
- * <td>The scale of the adjustment.</td>
- * <td>Float, between 0 and 1. Zero means no adjustment, while 1 indicates the maximum
- * amount of adjustment.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_AUTOFIX =
- "android.media.effect.effects.AutoFixEffect";
-
- /**
- * <p>Adjusts the range of minimal and maximal color pixel intensities.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>black</code></td>
- * <td>The value of the minimal pixel.</td>
- * <td>Float, between 0 and 1.</td>
- * </tr>
- * <tr><td><code>white</code></td>
- * <td>The value of the maximal pixel.</td>
- * <td>Float, between 0 and 1.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_BLACKWHITE =
- "android.media.effect.effects.BlackWhiteEffect";
-
- /**
- * <p>Crops an upright rectangular area from the image. If the crop region falls outside of
- * the image bounds, the results are undefined.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>xorigin</code></td>
- * <td>The origin's x-value.</td>
- * <td>Integer, between 0 and width of the image.</td>
- * </tr>
- * <tr><td><code>yorigin</code></td>
- * <td>The origin's y-value.</td>
- * <td>Integer, between 0 and height of the image.</td>
- * </tr>
- * <tr><td><code>width</code></td>
- * <td>The width of the cropped image.</td>
- * <td>Integer, between 1 and the width of the image minus xorigin.</td>
- * </tr>
- * <tr><td><code>height</code></td>
- * <td>The height of the cropped image.</td>
- * <td>Integer, between 1 and the height of the image minus yorigin.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_CROP =
- "android.media.effect.effects.CropEffect";
-
- /**
- * <p>Applies a cross process effect on image, in which the red and green channels are
- * enhanced while the blue channel is restricted.</p>
- * <p>Available parameters: None</p>
- */
- public final static String EFFECT_CROSSPROCESS =
- "android.media.effect.effects.CrossProcessEffect";
-
- /**
- * <p>Applies black and white documentary style effect on image..</p>
- * <p>Available parameters: None</p>
- */
- public final static String EFFECT_DOCUMENTARY =
- "android.media.effect.effects.DocumentaryEffect";
-
-
- /**
- * <p>Overlays a bitmap (with premultiplied alpha channel) onto the input image. The bitmap
- * is stretched to fit the input image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>bitmap</code></td>
- * <td>The overlay bitmap.</td>
- * <td>A non-null Bitmap instance.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_BITMAPOVERLAY =
- "android.media.effect.effects.BitmapOverlayEffect";
-
- /**
- * <p>Representation of photo using only two color tones.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>first_color</code></td>
- * <td>The first color tone.</td>
- * <td>Integer, representing an ARGB color with 8 bits per channel. May be created using
- * {@link android.graphics.Color Color} class.</td>
- * </tr>
- * <tr><td><code>second_color</code></td>
- * <td>The second color tone.</td>
- * <td>Integer, representing an ARGB color with 8 bits per channel. May be created using
- * {@link android.graphics.Color Color} class.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_DUOTONE =
- "android.media.effect.effects.DuotoneEffect";
-
- /**
- * <p>Applies back-light filling to the image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>strength</code></td>
- * <td>The strength of the backlight.</td>
- * <td>Float, between 0 and 1. Zero means no change.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_FILLLIGHT =
- "android.media.effect.effects.FillLightEffect";
-
- /**
- * <p>Flips image vertically and/or horizontally.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>vertical</code></td>
- * <td>Whether to flip image vertically.</td>
- * <td>Boolean</td>
- * </tr>
- * <tr><td><code>horizontal</code></td>
- * <td>Whether to flip image horizontally.</td>
- * <td>Boolean</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_FLIP =
- "android.media.effect.effects.FlipEffect";
-
- /**
- * <p>Applies film grain effect to image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>strength</code></td>
- * <td>The strength of the grain effect.</td>
- * <td>Float, between 0 and 1. Zero means no change.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_GRAIN =
- "android.media.effect.effects.GrainEffect";
-
- /**
- * <p>Converts image to grayscale.</p>
- * <p>Available parameters: None</p>
- */
- public final static String EFFECT_GRAYSCALE =
- "android.media.effect.effects.GrayscaleEffect";
-
- /**
- * <p>Applies lomo-camera style effect to image.</p>
- * <p>Available parameters: None</p>
- */
- public final static String EFFECT_LOMOISH =
- "android.media.effect.effects.LomoishEffect";
-
- /**
- * <p>Inverts the image colors.</p>
- * <p>Available parameters: None</p>
- */
- public final static String EFFECT_NEGATIVE =
- "android.media.effect.effects.NegativeEffect";
-
- /**
- * <p>Applies posterization effect to image.</p>
- * <p>Available parameters: None</p>
- */
- public final static String EFFECT_POSTERIZE =
- "android.media.effect.effects.PosterizeEffect";
-
- /**
- * <p>Removes red eyes on specified region.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>centers</code></td>
- * <td>Multiple center points (x, y) of the red eye regions.</td>
- * <td>An array of floats, where (f[2*i], f[2*i+1]) specifies the center of the i'th eye.
- * Coordinate values are expected to be normalized between 0 and 1.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_REDEYE =
- "android.media.effect.effects.RedEyeEffect";
-
- /**
- * <p>Rotates the image. The output frame size must be able to fit the rotated version of
- * the input image. Note that the rotation snaps to a the closest multiple of 90 degrees.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>angle</code></td>
- * <td>The angle of rotation in degrees.</td>
- * <td>Integer value. This will be rounded to the nearest multiple of 90.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_ROTATE =
- "android.media.effect.effects.RotateEffect";
-
- /**
- * <p>Adjusts color saturation of image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>scale</code></td>
- * <td>The scale of color saturation.</td>
- * <td>Float, between -1 and 1. 0 means no change, while -1 indicates full desaturation,
- * i.e. grayscale.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_SATURATE =
- "android.media.effect.effects.SaturateEffect";
-
- /**
- * <p>Converts image to sepia tone.</p>
- * <p>Available parameters: None</p>
- */
- public final static String EFFECT_SEPIA =
- "android.media.effect.effects.SepiaEffect";
-
- /**
- * <p>Sharpens the image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>scale</code></td>
- * <td>The degree of sharpening.</td>
- * <td>Float, between 0 and 1. 0 means no change.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_SHARPEN =
- "android.media.effect.effects.SharpenEffect";
-
- /**
- * <p>Rotates the image according to the specified angle, and crops the image so that no
- * non-image portions are visible.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>angle</code></td>
- * <td>The angle of rotation.</td>
- * <td>Float, between -45 and +45.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_STRAIGHTEN =
- "android.media.effect.effects.StraightenEffect";
-
- /**
- * <p>Adjusts color temperature of the image.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>scale</code></td>
- * <td>The value of color temperature.</td>
- * <td>Float, between 0 and 1, with 0 indicating cool, and 1 indicating warm. A value of
- * of 0.5 indicates no change.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_TEMPERATURE =
- "android.media.effect.effects.ColorTemperatureEffect";
-
- /**
- * <p>Tints the photo with specified color.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>tint</code></td>
- * <td>The color of the tint.</td>
- * <td>Integer, representing an ARGB color with 8 bits per channel. May be created using
- * {@link android.graphics.Color Color} class.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_TINT =
- "android.media.effect.effects.TintEffect";
-
- /**
- * <p>Adds a vignette effect to image, i.e. fades away the outer image edges.</p>
- * <p>Available parameters:</p>
- * <table>
- * <tr><td>Parameter name</td><td>Meaning</td><td>Valid values</td></tr>
- * <tr><td><code>scale</code></td>
- * <td>The scale of vignetting.</td>
- * <td>Float, between 0 and 1. 0 means no change.</td>
- * </tr>
- * </table>
- */
- public final static String EFFECT_VIGNETTE =
- "android.media.effect.effects.VignetteEffect";
-
- EffectFactory(EffectContext effectContext) {
- mEffectContext = effectContext;
- }
-
- /**
- * Instantiate a new effect with the given effect name.
- *
- * <p>The effect's parameters will be set to their default values.</p>
- *
- * <p>Note that the EGL context associated with the current EffectContext need not be made
- * current when creating an effect. This allows the host application to instantiate effects
- * before any EGL context has become current.</p>
- *
- * @param effectName The name of the effect to create.
- * @return A new Effect instance.
- * @throws IllegalArgumentException if the effect with the specified name is not supported or
- * not known.
- */
- public Effect createEffect(String effectName) {
- Class effectClass = getEffectClassByName(effectName);
- if (effectClass == null) {
- throw new IllegalArgumentException("Cannot instantiate unknown effect '" +
- effectName + "'!");
- }
- return instantiateEffect(effectClass, effectName);
- }
-
- /**
- * Check if an effect is supported on this platform.
- *
- * <p>Some effects may only be available on certain platforms. Use this method before
- * instantiating an effect to make sure it is supported.</p>
- *
- * @param effectName The name of the effect.
- * @return true, if the effect is supported on this platform.
- * @throws IllegalArgumentException if the effect name is not known.
- */
- public static boolean isEffectSupported(String effectName) {
- return getEffectClassByName(effectName) != null;
- }
-
- private static Class getEffectClassByName(String className) {
- Class effectClass = null;
-
- // Get context's classloader; otherwise cannot load non-framework effects
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-
- // Look for the class in the imported packages
- for (String packageName : EFFECT_PACKAGES) {
- try {
- effectClass = contextClassLoader.loadClass(packageName + className);
- } catch (ClassNotFoundException e) {
- continue;
- }
- // Exit loop if class was found.
- if (effectClass != null) {
- break;
- }
- }
- return effectClass;
- }
-
- private Effect instantiateEffect(Class effectClass, String name) {
- // Make sure this is an Effect subclass
- try {
- effectClass.asSubclass(Effect.class);
- } catch (ClassCastException e) {
- throw new IllegalArgumentException("Attempting to allocate effect '" + effectClass
- + "' which is not a subclass of Effect!", e);
- }
-
- // Look for the correct constructor
- Constructor effectConstructor = null;
- try {
- effectConstructor = effectClass.getConstructor(EffectContext.class, String.class);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("The effect class '" + effectClass + "' does not have "
- + "the required constructor.", e);
- }
-
- // Construct the effect
- Effect effect = null;
- try {
- effect = (Effect)effectConstructor.newInstance(mEffectContext, name);
- } catch (Throwable t) {
- throw new RuntimeException("There was an error constructing the effect '" + effectClass
- + "'!", t);
- }
-
- return effect;
- }
-}
diff --git a/mca/effect/java/android/media/effect/EffectUpdateListener.java b/mca/effect/java/android/media/effect/EffectUpdateListener.java
deleted file mode 100644
index 155fe49..0000000
--- a/mca/effect/java/android/media/effect/EffectUpdateListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect;
-
-/**
- * Some effects may issue callbacks to inform the host of changes to the effect state. This is the
- * listener interface for receiving those callbacks.
- */
-public interface EffectUpdateListener {
-
- /**
- * Called when the effect state is updated.
- *
- * @param effect The effect that has been updated.
- * @param info A value that gives more information about the update. See the effect's
- * documentation for more details on what this object is.
- */
- public void onEffectUpdated(Effect effect, Object info);
-
-}
-
diff --git a/mca/effect/java/android/media/effect/FilterEffect.java b/mca/effect/java/android/media/effect/FilterEffect.java
deleted file mode 100644
index d7c319e..0000000
--- a/mca/effect/java/android/media/effect/FilterEffect.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect;
-
-import android.filterfw.core.CachedFrameManager;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.FilterFactory;
-import android.filterfw.core.GLEnvironment;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.format.ImageFormat;
-
-/**
- * The FilterEffect class is the base class for all Effects based on Filters from the Mobile
- * Filter Framework (MFF).
- * @hide
- */
-public abstract class FilterEffect extends Effect {
-
- protected EffectContext mEffectContext;
- private String mName;
-
- /**
- * Protected constructor as FilterEffects should be created by Factory.
- */
- protected FilterEffect(EffectContext context, String name) {
- mEffectContext = context;
- mName = name;
- }
-
- /**
- * Get the effect name.
- *
- * Returns the unique name of the effect, which matches the name used for instantiating this
- * effect by the EffectFactory.
- *
- * @return The name of the effect.
- */
- @Override
- public String getName() {
- return mName;
- }
-
- // Helper Methods for subclasses ///////////////////////////////////////////////////////////////
- /**
- * Call this before manipulating the GL context. Will assert that the GL environment is in a
- * valid state, and save it.
- */
- protected void beginGLEffect() {
- mEffectContext.assertValidGLState();
- mEffectContext.saveGLState();
- }
-
- /**
- * Call this after manipulating the GL context. Restores the previous GL state.
- */
- protected void endGLEffect() {
- mEffectContext.restoreGLState();
- }
-
- /**
- * Returns the active filter context for this effect.
- */
- protected FilterContext getFilterContext() {
- return mEffectContext.mFilterContext;
- }
-
- /**
- * Converts a texture into a Frame.
- */
- protected Frame frameFromTexture(int texId, int width, int height) {
- FrameManager manager = getFilterContext().getFrameManager();
- FrameFormat format = ImageFormat.create(width, height,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- Frame frame = manager.newBoundFrame(format,
- GLFrame.EXISTING_TEXTURE_BINDING,
- texId);
- frame.setTimestamp(Frame.TIMESTAMP_UNKNOWN);
- return frame;
- }
-
-}
-
diff --git a/mca/effect/java/android/media/effect/FilterGraphEffect.java b/mca/effect/java/android/media/effect/FilterGraphEffect.java
deleted file mode 100644
index b18bea8..0000000
--- a/mca/effect/java/android/media/effect/FilterGraphEffect.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media.effect;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterGraph;
-import android.filterfw.core.GraphRunner;
-import android.filterfw.core.SimpleScheduler;
-import android.filterfw.core.SyncRunner;
-import android.media.effect.Effect;
-import android.media.effect.FilterEffect;
-import android.media.effect.EffectContext;
-import android.filterfw.io.GraphIOException;
-import android.filterfw.io.GraphReader;
-import android.filterfw.io.TextGraphReader;
-
-import android.util.Log;
-
-/**
- * Effect subclass for effects based on a single Filter. Subclasses need only invoke the
- * constructor with the correct arguments to obtain an Effect implementation.
- *
- * @hide
- */
-public class FilterGraphEffect extends FilterEffect {
-
- private static final String TAG = "FilterGraphEffect";
-
- protected String mInputName;
- protected String mOutputName;
- protected GraphRunner mRunner;
- protected FilterGraph mGraph;
- protected Class mSchedulerClass;
-
- /**
- * Constructs a new FilterGraphEffect.
- *
- * @param name The name of this effect (used to create it in the EffectFactory).
- * @param graphString The graph string to create the graph.
- * @param inputName The name of the input GLTextureSource filter.
- * @param outputName The name of the output GLTextureSource filter.
- */
- public FilterGraphEffect(EffectContext context,
- String name,
- String graphString,
- String inputName,
- String outputName,
- Class scheduler) {
- super(context, name);
-
- mInputName = inputName;
- mOutputName = outputName;
- mSchedulerClass = scheduler;
- createGraph(graphString);
-
- }
-
- private void createGraph(String graphString) {
- GraphReader reader = new TextGraphReader();
- try {
- mGraph = reader.readGraphString(graphString);
- } catch (GraphIOException e) {
- throw new RuntimeException("Could not setup effect", e);
- }
-
- if (mGraph == null) {
- throw new RuntimeException("Could not setup effect");
- }
- mRunner = new SyncRunner(getFilterContext(), mGraph, mSchedulerClass);
- }
-
- @Override
- public void apply(int inputTexId, int width, int height, int outputTexId) {
- beginGLEffect();
- Filter src = mGraph.getFilter(mInputName);
- if (src != null) {
- src.setInputValue("texId", inputTexId);
- src.setInputValue("width", width);
- src.setInputValue("height", height);
- } else {
- throw new RuntimeException("Internal error applying effect");
- }
- Filter dest = mGraph.getFilter(mOutputName);
- if (dest != null) {
- dest.setInputValue("texId", outputTexId);
- } else {
- throw new RuntimeException("Internal error applying effect");
- }
- try {
- mRunner.run();
- } catch (RuntimeException e) {
- throw new RuntimeException("Internal error applying effect: ", e);
- }
- endGLEffect();
- }
-
- @Override
- public void setParameter(String parameterKey, Object value) {
- }
-
- @Override
- public void release() {
- mGraph.tearDown(getFilterContext());
- mGraph = null;
- }
-}
diff --git a/mca/effect/java/android/media/effect/SingleFilterEffect.java b/mca/effect/java/android/media/effect/SingleFilterEffect.java
deleted file mode 100644
index 6f85861..0000000
--- a/mca/effect/java/android/media/effect/SingleFilterEffect.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterFactory;
-import android.filterfw.core.FilterFunction;
-import android.filterfw.core.Frame;
-import android.media.effect.Effect;
-import android.media.effect.EffectContext;
-
-import android.util.Log;
-
-/**
- * Effect subclass for effects based on a single Filter. Subclasses need only invoke the
- * constructor with the correct arguments to obtain an Effect implementation.
- *
- * @hide
- */
-public class SingleFilterEffect extends FilterEffect {
-
- protected FilterFunction mFunction;
- protected String mInputName;
- protected String mOutputName;
-
- /**
- * Constructs a new FilterFunctionEffect.
- *
- * @param name The name of this effect (used to create it in the EffectFactory).
- * @param filterClass The class of the filter to wrap.
- * @param inputName The name of the input image port.
- * @param outputName The name of the output image port.
- * @param finalParameters Key-value pairs of final input port assignments.
- */
- public SingleFilterEffect(EffectContext context,
- String name,
- Class filterClass,
- String inputName,
- String outputName,
- Object... finalParameters) {
- super(context, name);
-
- mInputName = inputName;
- mOutputName = outputName;
-
- String filterName = filterClass.getSimpleName();
- FilterFactory factory = FilterFactory.sharedFactory();
- Filter filter = factory.createFilterByClass(filterClass, filterName);
- filter.initWithAssignmentList(finalParameters);
-
- mFunction = new FilterFunction(getFilterContext(), filter);
- }
-
- @Override
- public void apply(int inputTexId, int width, int height, int outputTexId) {
- beginGLEffect();
-
- Frame inputFrame = frameFromTexture(inputTexId, width, height);
- Frame outputFrame = frameFromTexture(outputTexId, width, height);
-
- Frame resultFrame = mFunction.executeWithArgList(mInputName, inputFrame);
-
- outputFrame.setDataFromFrame(resultFrame);
-
- inputFrame.release();
- outputFrame.release();
- resultFrame.release();
-
- endGLEffect();
- }
-
- @Override
- public void setParameter(String parameterKey, Object value) {
- mFunction.setInputValue(parameterKey, value);
- }
-
- @Override
- public void release() {
- mFunction.tearDown();
- mFunction = null;
- }
-}
-
diff --git a/mca/effect/java/android/media/effect/SizeChangeEffect.java b/mca/effect/java/android/media/effect/SizeChangeEffect.java
deleted file mode 100644
index 4d27bae..0000000
--- a/mca/effect/java/android/media/effect/SizeChangeEffect.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media.effect;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterFactory;
-import android.filterfw.core.FilterFunction;
-import android.filterfw.core.Frame;
-import android.media.effect.Effect;
-import android.media.effect.EffectContext;
-
-import android.util.Log;
-
-/**
- * Effect subclass for effects based on a single Filter with output size differnet
- * from input. Subclasses need only invoke the constructor with the correct arguments
- * to obtain an Effect implementation.
- *
- * @hide
- */
-public class SizeChangeEffect extends SingleFilterEffect {
-
- public SizeChangeEffect(EffectContext context,
- String name,
- Class filterClass,
- String inputName,
- String outputName,
- Object... finalParameters) {
- super(context, name, filterClass, inputName, outputName, finalParameters);
- }
-
- @Override
- public void apply(int inputTexId, int width, int height, int outputTexId) {
- beginGLEffect();
-
- Frame inputFrame = frameFromTexture(inputTexId, width, height);
- Frame resultFrame = mFunction.executeWithArgList(mInputName, inputFrame);
-
- int outputWidth = resultFrame.getFormat().getWidth();
- int outputHeight = resultFrame.getFormat().getHeight();
-
- Frame outputFrame = frameFromTexture(outputTexId, outputWidth, outputHeight);
- outputFrame.setDataFromFrame(resultFrame);
-
- inputFrame.release();
- outputFrame.release();
- resultFrame.release();
-
- endGLEffect();
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/AutoFixEffect.java b/mca/effect/java/android/media/effect/effects/AutoFixEffect.java
deleted file mode 100644
index 44a141b..0000000
--- a/mca/effect/java/android/media/effect/effects/AutoFixEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.AutoFixFilter;
-
-/**
- * @hide
- */
-public class AutoFixEffect extends SingleFilterEffect {
- public AutoFixEffect(EffectContext context, String name) {
- super(context, name, AutoFixFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/BackDropperEffect.java b/mca/effect/java/android/media/effect/effects/BackDropperEffect.java
deleted file mode 100644
index d5c7aaa..0000000
--- a/mca/effect/java/android/media/effect/effects/BackDropperEffect.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media.effect.effects;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.OneShotScheduler;
-import android.media.effect.EffectContext;
-import android.media.effect.FilterGraphEffect;
-import android.media.effect.EffectUpdateListener;
-
-import android.filterpacks.videoproc.BackDropperFilter;
-import android.filterpacks.videoproc.BackDropperFilter.LearningDoneListener;
-
-/**
- * Background replacement Effect.
- *
- * Replaces the background of the input video stream with a selected video
- * Learns the background when it first starts up;
- * needs unobstructed view of background when this happens.
- *
- * Effect parameters:
- * source: A URI for the background video
- * Listener: Called when learning period is complete
- *
- * @hide
- */
-public class BackDropperEffect extends FilterGraphEffect {
- private static final String mGraphDefinition =
- "@import android.filterpacks.base;\n" +
- "@import android.filterpacks.videoproc;\n" +
- "@import android.filterpacks.videosrc;\n" +
- "\n" +
- "@filter GLTextureSource foreground {\n" +
- " texId = 0;\n" + // Will be set by base class
- " width = 0;\n" +
- " height = 0;\n" +
- " repeatFrame = true;\n" +
- "}\n" +
- "\n" +
- "@filter MediaSource background {\n" +
- " sourceUrl = \"no_file_specified\";\n" +
- " waitForNewFrame = false;\n" +
- " sourceIsUrl = true;\n" +
- "}\n" +
- "\n" +
- "@filter BackDropperFilter replacer {\n" +
- " autowbToggle = 1;\n" +
- "}\n" +
- "\n" +
- "@filter GLTextureTarget output {\n" +
- " texId = 0;\n" +
- "}\n" +
- "\n" +
- "@connect foreground[frame] => replacer[video];\n" +
- "@connect background[video] => replacer[background];\n" +
- "@connect replacer[video] => output[frame];\n";
-
- private EffectUpdateListener mEffectListener = null;
-
- private LearningDoneListener mLearningListener = new LearningDoneListener() {
- public void onLearningDone(BackDropperFilter filter) {
- if (mEffectListener != null) {
- mEffectListener.onEffectUpdated(BackDropperEffect.this, null);
- }
- }
- };
-
- public BackDropperEffect(EffectContext context, String name) {
- super(context, name, mGraphDefinition, "foreground", "output", OneShotScheduler.class);
-
- Filter replacer = mGraph.getFilter("replacer");
- replacer.setInputValue("learningDoneListener", mLearningListener);
- }
-
- @Override
- public void setParameter(String parameterKey, Object value) {
- if (parameterKey.equals("source")) {
- Filter background = mGraph.getFilter("background");
- background.setInputValue("sourceUrl", value);
- }
- }
-
- @Override
- public void setUpdateListener(EffectUpdateListener listener) {
- mEffectListener = listener;
- }
-
-}
\ No newline at end of file
diff --git a/mca/effect/java/android/media/effect/effects/BitmapOverlayEffect.java b/mca/effect/java/android/media/effect/effects/BitmapOverlayEffect.java
deleted file mode 100644
index 43f461c..0000000
--- a/mca/effect/java/android/media/effect/effects/BitmapOverlayEffect.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.BitmapOverlayFilter;
-
-/**
- * @hide
- */
-public class BitmapOverlayEffect extends SingleFilterEffect {
- public BitmapOverlayEffect(EffectContext context, String name) {
- super(context, name, BitmapOverlayFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/BlackWhiteEffect.java b/mca/effect/java/android/media/effect/effects/BlackWhiteEffect.java
deleted file mode 100644
index 771afff..0000000
--- a/mca/effect/java/android/media/effect/effects/BlackWhiteEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.BlackWhiteFilter;
-
-/**
- * @hide
- */
-public class BlackWhiteEffect extends SingleFilterEffect {
- public BlackWhiteEffect(EffectContext context, String name) {
- super(context, name, BlackWhiteFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/BrightnessEffect.java b/mca/effect/java/android/media/effect/effects/BrightnessEffect.java
deleted file mode 100644
index 774e72f..0000000
--- a/mca/effect/java/android/media/effect/effects/BrightnessEffect.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.BrightnessFilter;
-
-/**
- * @hide
- */
-public class BrightnessEffect extends SingleFilterEffect {
- public BrightnessEffect(EffectContext context, String name) {
- super(context, name, BrightnessFilter.class, "image", "image");
- }
-}
-
diff --git a/mca/effect/java/android/media/effect/effects/ColorTemperatureEffect.java b/mca/effect/java/android/media/effect/effects/ColorTemperatureEffect.java
deleted file mode 100644
index 62d98ce..0000000
--- a/mca/effect/java/android/media/effect/effects/ColorTemperatureEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.ColorTemperatureFilter;
-
-/**
- * @hide
- */
-public class ColorTemperatureEffect extends SingleFilterEffect {
- public ColorTemperatureEffect(EffectContext context, String name) {
- super(context, name, ColorTemperatureFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/ContrastEffect.java b/mca/effect/java/android/media/effect/effects/ContrastEffect.java
deleted file mode 100644
index d5bfc21..0000000
--- a/mca/effect/java/android/media/effect/effects/ContrastEffect.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.ContrastFilter;
-
-/**
- * @hide
- */
-public class ContrastEffect extends SingleFilterEffect {
- public ContrastEffect(EffectContext context, String name) {
- super(context, name, ContrastFilter.class, "image", "image");
- }
-}
-
diff --git a/mca/effect/java/android/media/effect/effects/CropEffect.java b/mca/effect/java/android/media/effect/effects/CropEffect.java
deleted file mode 100644
index 3e8d78a..0000000
--- a/mca/effect/java/android/media/effect/effects/CropEffect.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SizeChangeEffect;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.CropRectFilter;
-
-/**
- * @hide
- */
-//public class CropEffect extends SingleFilterEffect {
-public class CropEffect extends SizeChangeEffect {
- public CropEffect(EffectContext context, String name) {
- super(context, name, CropRectFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/CrossProcessEffect.java b/mca/effect/java/android/media/effect/effects/CrossProcessEffect.java
deleted file mode 100644
index d7a7df5..0000000
--- a/mca/effect/java/android/media/effect/effects/CrossProcessEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.CrossProcessFilter;
-
-/**
- * @hide
- */
-public class CrossProcessEffect extends SingleFilterEffect {
- public CrossProcessEffect(EffectContext context, String name) {
- super(context, name, CrossProcessFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/DocumentaryEffect.java b/mca/effect/java/android/media/effect/effects/DocumentaryEffect.java
deleted file mode 100644
index 1a5ea35..0000000
--- a/mca/effect/java/android/media/effect/effects/DocumentaryEffect.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.DocumentaryFilter;
-
-/**
- * @hide
- */
-public class DocumentaryEffect extends SingleFilterEffect {
- public DocumentaryEffect(EffectContext context, String name) {
- super(context, name, DocumentaryFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/DuotoneEffect.java b/mca/effect/java/android/media/effect/effects/DuotoneEffect.java
deleted file mode 100644
index 1391b1f..0000000
--- a/mca/effect/java/android/media/effect/effects/DuotoneEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.DuotoneFilter;
-
-/**
- * @hide
- */
-public class DuotoneEffect extends SingleFilterEffect {
- public DuotoneEffect(EffectContext context, String name) {
- super(context, name, DuotoneFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/FillLightEffect.java b/mca/effect/java/android/media/effect/effects/FillLightEffect.java
deleted file mode 100644
index 5260de3..0000000
--- a/mca/effect/java/android/media/effect/effects/FillLightEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.FillLightFilter;
-
-/**
- * @hide
- */
-public class FillLightEffect extends SingleFilterEffect {
- public FillLightEffect(EffectContext context, String name) {
- super(context, name, FillLightFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/FisheyeEffect.java b/mca/effect/java/android/media/effect/effects/FisheyeEffect.java
deleted file mode 100644
index 6abfe42..0000000
--- a/mca/effect/java/android/media/effect/effects/FisheyeEffect.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.FisheyeFilter;
-
-/**
- * @hide
- */
-public class FisheyeEffect extends SingleFilterEffect {
- public FisheyeEffect(EffectContext context, String name) {
- super(context, name, FisheyeFilter.class, "image", "image");
- }
-}
-
diff --git a/mca/effect/java/android/media/effect/effects/FlipEffect.java b/mca/effect/java/android/media/effect/effects/FlipEffect.java
deleted file mode 100644
index 0f5c421..0000000
--- a/mca/effect/java/android/media/effect/effects/FlipEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.FlipFilter;
-
-/**
- * @hide
- */
-public class FlipEffect extends SingleFilterEffect {
- public FlipEffect(EffectContext context, String name) {
- super(context, name, FlipFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/GrainEffect.java b/mca/effect/java/android/media/effect/effects/GrainEffect.java
deleted file mode 100644
index 2fda7e9..0000000
--- a/mca/effect/java/android/media/effect/effects/GrainEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.GrainFilter;
-
-/**
- * @hide
- */
-public class GrainEffect extends SingleFilterEffect {
- public GrainEffect(EffectContext context, String name) {
- super(context, name, GrainFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/GrayscaleEffect.java b/mca/effect/java/android/media/effect/effects/GrayscaleEffect.java
deleted file mode 100644
index 26ca081..0000000
--- a/mca/effect/java/android/media/effect/effects/GrayscaleEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.ToGrayFilter;
-
-/**
- * @hide
- */
-public class GrayscaleEffect extends SingleFilterEffect {
- public GrayscaleEffect(EffectContext context, String name) {
- super(context, name, ToGrayFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/IdentityEffect.java b/mca/effect/java/android/media/effect/effects/IdentityEffect.java
deleted file mode 100644
index d07779e..0000000
--- a/mca/effect/java/android/media/effect/effects/IdentityEffect.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.filterfw.core.Frame;
-import android.media.effect.EffectContext;
-import android.media.effect.FilterEffect;
-
-/**
- * @hide
- */
-public class IdentityEffect extends FilterEffect {
-
- public IdentityEffect(EffectContext context, String name) {
- super(context, name);
- }
-
- @Override
- public void apply(int inputTexId, int width, int height, int outputTexId) {
- beginGLEffect();
-
- Frame inputFrame = frameFromTexture(inputTexId, width, height);
- Frame outputFrame = frameFromTexture(outputTexId, width, height);
-
- outputFrame.setDataFromFrame(inputFrame);
-
- inputFrame.release();
- outputFrame.release();
-
- endGLEffect();
- }
-
- @Override
- public void setParameter(String parameterKey, Object value) {
- throw new IllegalArgumentException("Unknown parameter " + parameterKey
- + " for IdentityEffect!");
- }
-
- @Override
- public void release() {
- }
-}
-
diff --git a/mca/effect/java/android/media/effect/effects/LomoishEffect.java b/mca/effect/java/android/media/effect/effects/LomoishEffect.java
deleted file mode 100644
index 776e53c..0000000
--- a/mca/effect/java/android/media/effect/effects/LomoishEffect.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.LomoishFilter;
-
-/**
- * @hide
- */
-public class LomoishEffect extends SingleFilterEffect {
- public LomoishEffect(EffectContext context, String name) {
- super(context, name, LomoishFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/NegativeEffect.java b/mca/effect/java/android/media/effect/effects/NegativeEffect.java
deleted file mode 100644
index 29fc94a..0000000
--- a/mca/effect/java/android/media/effect/effects/NegativeEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.NegativeFilter;
-
-/**
- * @hide
- */
-public class NegativeEffect extends SingleFilterEffect {
- public NegativeEffect(EffectContext context, String name) {
- super(context, name, NegativeFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/PosterizeEffect.java b/mca/effect/java/android/media/effect/effects/PosterizeEffect.java
deleted file mode 100644
index 20a8a37..0000000
--- a/mca/effect/java/android/media/effect/effects/PosterizeEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.PosterizeFilter;
-
-/**
- * @hide
- */
-public class PosterizeEffect extends SingleFilterEffect {
- public PosterizeEffect(EffectContext context, String name) {
- super(context, name, PosterizeFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/RedEyeEffect.java b/mca/effect/java/android/media/effect/effects/RedEyeEffect.java
deleted file mode 100644
index 8ed9909..0000000
--- a/mca/effect/java/android/media/effect/effects/RedEyeEffect.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.RedEyeFilter;
-
-/**
- * @hide
- */
-public class RedEyeEffect extends SingleFilterEffect {
- public RedEyeEffect(EffectContext context, String name) {
- super(context, name, RedEyeFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/RotateEffect.java b/mca/effect/java/android/media/effect/effects/RotateEffect.java
deleted file mode 100644
index 2340015..0000000
--- a/mca/effect/java/android/media/effect/effects/RotateEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SizeChangeEffect;
-import android.filterpacks.imageproc.RotateFilter;
-
-/**
- * @hide
- */
-public class RotateEffect extends SizeChangeEffect {
- public RotateEffect(EffectContext context, String name) {
- super(context, name, RotateFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/SaturateEffect.java b/mca/effect/java/android/media/effect/effects/SaturateEffect.java
deleted file mode 100644
index fe9250a..0000000
--- a/mca/effect/java/android/media/effect/effects/SaturateEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.SaturateFilter;
-
-/**
- * @hide
- */
-public class SaturateEffect extends SingleFilterEffect {
- public SaturateEffect(EffectContext context, String name) {
- super(context, name, SaturateFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/SepiaEffect.java b/mca/effect/java/android/media/effect/effects/SepiaEffect.java
deleted file mode 100644
index de85b2d..0000000
--- a/mca/effect/java/android/media/effect/effects/SepiaEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.SepiaFilter;
-
-/**
- * @hide
- */
-public class SepiaEffect extends SingleFilterEffect {
- public SepiaEffect(EffectContext context, String name) {
- super(context, name, SepiaFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/SharpenEffect.java b/mca/effect/java/android/media/effect/effects/SharpenEffect.java
deleted file mode 100644
index 46776eb..0000000
--- a/mca/effect/java/android/media/effect/effects/SharpenEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.SharpenFilter;
-
-/**
- * @hide
- */
-public class SharpenEffect extends SingleFilterEffect {
- public SharpenEffect(EffectContext context, String name) {
- super(context, name, SharpenFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/StraightenEffect.java b/mca/effect/java/android/media/effect/effects/StraightenEffect.java
deleted file mode 100644
index 49253a0..0000000
--- a/mca/effect/java/android/media/effect/effects/StraightenEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.StraightenFilter;
-
-/**
- * @hide
- */
-public class StraightenEffect extends SingleFilterEffect {
- public StraightenEffect(EffectContext context, String name) {
- super(context, name, StraightenFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/TintEffect.java b/mca/effect/java/android/media/effect/effects/TintEffect.java
deleted file mode 100644
index 6de9ea8..0000000
--- a/mca/effect/java/android/media/effect/effects/TintEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.TintFilter;
-
-/**
- * @hide
- */
-public class TintEffect extends SingleFilterEffect {
- public TintEffect(EffectContext context, String name) {
- super(context, name, TintFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/effects/VignetteEffect.java b/mca/effect/java/android/media/effect/effects/VignetteEffect.java
deleted file mode 100644
index b143d77..0000000
--- a/mca/effect/java/android/media/effect/effects/VignetteEffect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect.effects;
-
-import android.media.effect.EffectContext;
-import android.media.effect.SingleFilterEffect;
-import android.filterpacks.imageproc.VignetteFilter;
-
-/**
- * @hide
- */
-public class VignetteEffect extends SingleFilterEffect {
- public VignetteEffect(EffectContext context, String name) {
- super(context, name, VignetteFilter.class, "image", "image");
- }
-}
diff --git a/mca/effect/java/android/media/effect/package-info.java b/mca/effect/java/android/media/effect/package-info.java
deleted file mode 100644
index b2c14ff..0000000
--- a/mca/effect/java/android/media/effect/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.effect;
-
-/**
- * <h1>Effect Framework</h1>
- *
- * This package includes a collection of high-performance visual effects that make use of the
- * mobile filter framework subsystem.
- *
- * TODO: More Documentation
- *
- */
diff --git a/mca/effect/java/android/media/effect/package.html b/mca/effect/java/android/media/effect/package.html
deleted file mode 100644
index 8a210fd..0000000
--- a/mca/effect/java/android/media/effect/package.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<HTML>
-<BODY>
-<p>Provides classes that allow you to apply a variety of visual effects to images and
-videos. For example, you can easily fix red-eye, convert an image to grayscale,
-adjust brightness, adjust saturation, rotate an image, apply a fisheye effect, and much more. The
-system performs all effects processing on the GPU to obtain maximum performance.</p>
-
-<p>For maximum performance, effects are applied directly to OpenGL textures, so your application
-must have a valid OpenGL context before it can use the effects APIs. The textures to which you apply
-effects may be from bitmaps, videos or even the camera. However, there are certain restrictions that
-textures must meet:</p>
-<ol>
-<li>They must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture image</li>
-<li>They must contain at least one mipmap level</li>
-</ol>
-
-<p>An {@link android.media.effect.Effect} object defines a single media effect that you can apply to
-an image frame. The basic workflow to create an {@link android.media.effect.Effect} is:</p>
-
-<ol>
-<li>Call {@link android.media.effect.EffectContext#createWithCurrentGlContext
-EffectContext.createWithCurrentGlContext()} from your OpenGL ES 2.0 context.</li>
-<li>Use the returned {@link android.media.effect.EffectContext} to call {@link
-android.media.effect.EffectContext#getFactory EffectContext.getFactory()}, which returns an instance
-of {@link android.media.effect.EffectFactory}.</li>
-<li>Call {@link android.media.effect.EffectFactory#createEffect createEffect()}, passing it an
-effect name from @link android.media.effect.EffectFactory}, such as {@link
-android.media.effect.EffectFactory#EFFECT_FISHEYE} or {@link
-android.media.effect.EffectFactory#EFFECT_VIGNETTE}.</li>
-</ol>
-
-<p>You can adjust an effect’s parameters by calling {@link android.media.effect.Effect#setParameter
-setParameter()} and passing a parameter name and parameter value. Each type of effect accepts
-different parameters, which are documented with the effect name. For example, {@link
-android.media.effect.EffectFactory#EFFECT_FISHEYE} has one parameter for the {@code scale} of the
-distortion.</p>
-
-<p>To apply an effect on a texture, call {@link android.media.effect.Effect#apply apply()} on the
-{@link
-android.media.effect.Effect} and pass in the input texture, its width and height, and the output
-texture. The input texture must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture
-image (usually done by calling the {@link android.opengl.GLES20#glTexImage2D glTexImage2D()}
-function). You may provide multiple mipmap levels. If the output texture has not been bound to a
-texture image, it will be automatically bound by the effect as a {@link
-android.opengl.GLES20#GL_TEXTURE_2D} and with one mipmap level (0), which will have the same
-size as the input.</p>
-
-<p class="note"><strong>Note:</strong> All effects listed in {@link
-android.media.effect.EffectFactory} are guaranteed to be supported. However, some additional effects
-available from external libraries are not supported by all devices, so you must first check if the
-desired effect from the external library is supported by calling {@link
-android.media.effect.EffectFactory#isEffectSupported isEffectSupported()}.</p>
-</BODY>
-</HTML>
diff --git a/mca/filterfw/Android.mk b/mca/filterfw/Android.mk
deleted file mode 100644
index 1d69799..0000000
--- a/mca/filterfw/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#####################
-# Build native sublibraries
-
-include $(all-subdir-makefiles)
-
-#####################
-# Build main libfilterfw
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libfilterfw
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_WHOLE_STATIC_LIBRARIES := libfilterfw_jni \
- libfilterfw_native
-
-LOCAL_SHARED_LIBRARIES := libstlport \
- libGLESv2 \
- libEGL \
- libgui \
- libdl \
- libcutils \
- libutils \
- libandroid \
- libjnigraphics \
- libmedia
-
-# Don't prelink this library. For more efficient code, you may want
-# to add this library to the prelink map and set this to true. However,
-# it's difficult to do this for applications that are not supplied as
-# part of a system image.
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_SHARED_LIBRARY)
-
-
diff --git a/mca/filterfw/java/android/filterfw/FilterFunctionEnvironment.java b/mca/filterfw/java/android/filterfw/FilterFunctionEnvironment.java
deleted file mode 100644
index 3f36d98..0000000
--- a/mca/filterfw/java/android/filterfw/FilterFunctionEnvironment.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterFactory;
-import android.filterfw.core.FilterFunction;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameManager;
-
-/**
- * A FilterFunctionEnvironment provides a simple functional front-end to manually executing
- * filters. Use this environment if a graph-based approach is not convenient for your case.
- * Typically, a FilterFunctionEnvironment is used as follows:
- * 1. Instantiate a new FilterFunctionEnvironment instance.
- * 2. Perform any configuration, such as setting a GL environment.
- * 3. Wrap Filters into FilterFunctions by calling createFunction().
- * 4. Execute FilterFunctions individually and use the results for further processing.
- * Additionally, there is a convenience method to execute a number of filters in sequence.
- * @hide
- */
-public class FilterFunctionEnvironment extends MffEnvironment {
-
- /**
- * Create a new FilterFunctionEnvironment with the default components.
- */
- public FilterFunctionEnvironment() {
- super(null);
- }
-
- /**
- * Create a new FilterFunctionEnvironment with a custom FrameManager. Pass null to auto-create
- * a FrameManager.
- *
- * @param frameManager The FrameManager to use, or null to auto-create one.
- */
- public FilterFunctionEnvironment(FrameManager frameManager) {
- super(frameManager);
- }
-
- /**
- * Create a new FilterFunction from a specific filter class. The function is initialized with
- * the given key-value list of parameters. Note, that this function uses the default shared
- * FilterFactory to create the filter instance.
- *
- * @param filterClass The class of the filter to wrap. This must be a Filter subclass.
- * @param parameters An argument list of alternating key-value filter parameters.
- * @return A new FilterFunction instance.
- */
- public FilterFunction createFunction(Class filterClass, Object... parameters) {
- String filterName = "FilterFunction(" + filterClass.getSimpleName() + ")";
- Filter filter = FilterFactory.sharedFactory().createFilterByClass(filterClass, filterName);
- filter.initWithAssignmentList(parameters);
- return new FilterFunction(getContext(), filter);
- }
-
- /**
- * Convenience method to execute a sequence of filter functions. Note that every function in
- * the list MUST have one input and one output port, except the first filter (which must not
- * have any input ports) and the last filter (which may not have any output ports).
- *
- * @param functions A list of filter functions. The first filter must be a source filter.
- * @return The result of the last filter executed, or null if the last filter did not
- produce any output.
- *
- public Frame executeSequence(FilterFunction[] functions) {
- Frame oldFrame = null;
- Frame newFrame = null;
- for (FilterFunction filterFunction : functions) {
- if (oldFrame == null) {
- newFrame = filterFunction.executeWithArgList();
- } else {
- newFrame = filterFunction.executeWithArgList(oldFrame);
- oldFrame.release();
- }
- oldFrame = newFrame;
- }
- if (oldFrame != null) {
- oldFrame.release();
- }
- return newFrame;
- }*/
-
-}
diff --git a/mca/filterfw/java/android/filterfw/GraphEnvironment.java b/mca/filterfw/java/android/filterfw/GraphEnvironment.java
deleted file mode 100644
index 5f6d45c..0000000
--- a/mca/filterfw/java/android/filterfw/GraphEnvironment.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw;
-
-import android.content.Context;
-import android.filterfw.core.AsyncRunner;
-import android.filterfw.core.FilterGraph;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GraphRunner;
-import android.filterfw.core.RoundRobinScheduler;
-import android.filterfw.core.SyncRunner;
-import android.filterfw.io.GraphIOException;
-import android.filterfw.io.GraphReader;
-import android.filterfw.io.TextGraphReader;
-
-import java.util.ArrayList;
-
-/**
- * A GraphEnvironment provides a simple front-end to filter graph setup and execution using the
- * mobile filter framework. Typically, you use a GraphEnvironment in the following fashion:
- * 1. Instantiate a new GraphEnvironment instance.
- * 2. Perform any configuration, such as adding graph references and setting a GL environment.
- * 3. Load a graph file using loadGraph() or add a graph using addGraph().
- * 4. Obtain a GraphRunner instance using getRunner().
- * 5. Execute the obtained runner.
- * Note that it is possible to add multiple graphs and runners to a single GraphEnvironment.
- *
- * @hide
- */
-public class GraphEnvironment extends MffEnvironment {
-
- public static final int MODE_ASYNCHRONOUS = 1;
- public static final int MODE_SYNCHRONOUS = 2;
-
- private GraphReader mGraphReader;
- private ArrayList<GraphHandle> mGraphs = new ArrayList<GraphHandle>();
-
- private class GraphHandle {
- private FilterGraph mGraph;
- private AsyncRunner mAsyncRunner;
- private SyncRunner mSyncRunner;
-
- public GraphHandle(FilterGraph graph) {
- mGraph = graph;
- }
-
- public FilterGraph getGraph() {
- return mGraph;
- }
-
- public AsyncRunner getAsyncRunner(FilterContext environment) {
- if (mAsyncRunner == null) {
- mAsyncRunner = new AsyncRunner(environment, RoundRobinScheduler.class);
- mAsyncRunner.setGraph(mGraph);
- }
- return mAsyncRunner;
- }
-
- public GraphRunner getSyncRunner(FilterContext environment) {
- if (mSyncRunner == null) {
- mSyncRunner = new SyncRunner(environment, mGraph, RoundRobinScheduler.class);
- }
- return mSyncRunner;
- }
- }
-
- /**
- * Create a new GraphEnvironment with default components.
- */
- public GraphEnvironment() {
- super(null);
- }
-
- /**
- * Create a new GraphEnvironment with a custom FrameManager and GraphReader. Specifying null
- * for either of these, will auto-create a default instance.
- *
- * @param frameManager The FrameManager to use, or null to auto-create one.
- * @param reader The GraphReader to use for graph loading, or null to auto-create one.
- * Note, that the reader will not be created until it is required. Pass
- * null if you will not load any graph files.
- */
- public GraphEnvironment(FrameManager frameManager, GraphReader reader) {
- super(frameManager);
- mGraphReader = reader;
- }
-
- /**
- * Returns the used graph reader. This will create one, if a reader has not been set already.
- */
- public GraphReader getGraphReader() {
- if (mGraphReader == null) {
- mGraphReader = new TextGraphReader();
- }
- return mGraphReader;
- }
-
- /**
- * Add graph references to resolve during graph reading. The references added here are shared
- * among all graphs.
- *
- * @param references An alternating argument list of keys (Strings) and values.
- */
- public void addReferences(Object... references) {
- getGraphReader().addReferencesByKeysAndValues(references);
- }
-
- /**
- * Loads a graph file from the specified resource and adds it to this environment.
- *
- * @param context The context in which to read the resource.
- * @param resourceId The ID of the graph resource to load.
- * @return A unique ID for the graph.
- */
- public int loadGraph(Context context, int resourceId) {
- // Read the file into a graph
- FilterGraph graph = null;
- try {
- graph = getGraphReader().readGraphResource(context, resourceId);
- } catch (GraphIOException e) {
- throw new RuntimeException("Could not read graph: " + e.getMessage());
- }
-
- // Add graph to our list of graphs
- return addGraph(graph);
- }
-
- /**
- * Add a graph to the environment. Consider using loadGraph() if you are loading a graph from
- * a graph file.
- *
- * @param graph The graph to add to the environment.
- * @return A unique ID for the added graph.
- */
- public int addGraph(FilterGraph graph) {
- GraphHandle graphHandle = new GraphHandle(graph);
- mGraphs.add(graphHandle);
- return mGraphs.size() - 1;
- }
-
- /**
- * Access a specific graph of this environment given a graph ID (previously returned from
- * loadGraph() or addGraph()). Throws an InvalidArgumentException if no graph with the
- * specified ID could be found.
- *
- * @param graphId The ID of the graph to get.
- * @return The graph with the specified ID.
- */
- public FilterGraph getGraph(int graphId) {
- if (graphId < 0 || graphId >= mGraphs.size()) {
- throw new IllegalArgumentException(
- "Invalid graph ID " + graphId + " specified in runGraph()!");
- }
- return mGraphs.get(graphId).getGraph();
- }
-
- /**
- * Get a GraphRunner instance for the graph with the specified ID. The GraphRunner instance can
- * be used to execute the graph. Throws an InvalidArgumentException if no graph with the
- * specified ID could be found.
- *
- * @param graphId The ID of the graph to get.
- * @param executionMode The mode of graph execution. Currently this can be either
- MODE_SYNCHRONOUS or MODE_ASYNCHRONOUS.
- * @return A GraphRunner instance for this graph.
- */
- public GraphRunner getRunner(int graphId, int executionMode) {
- switch (executionMode) {
- case MODE_ASYNCHRONOUS:
- return mGraphs.get(graphId).getAsyncRunner(getContext());
-
- case MODE_SYNCHRONOUS:
- return mGraphs.get(graphId).getSyncRunner(getContext());
-
- default:
- throw new RuntimeException(
- "Invalid execution mode " + executionMode + " specified in getRunner()!");
- }
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/MffEnvironment.java b/mca/filterfw/java/android/filterfw/MffEnvironment.java
deleted file mode 100644
index 1ab416a..0000000
--- a/mca/filterfw/java/android/filterfw/MffEnvironment.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw;
-
-import android.filterfw.core.CachedFrameManager;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GLEnvironment;
-
-/**
- * Base class for mobile filter framework (MFF) frontend environments. These convenience classes
- * allow using the filter framework without the requirement of performing manual setup of its
- * required components.
- *
- * @hide
- */
-public class MffEnvironment {
-
- private FilterContext mContext;
-
- /**
- * Protected constructor to initialize the environment's essential components. These are the
- * frame-manager and the filter-context. Passing in null for the frame-manager causes this
- * to be auto-created.
- *
- * @param frameManager The FrameManager to use or null to auto-create one.
- */
- protected MffEnvironment(FrameManager frameManager) {
- // Get or create the frame manager
- if (frameManager == null) {
- frameManager = new CachedFrameManager();
- }
-
- // Setup the environment
- mContext = new FilterContext();
- mContext.setFrameManager(frameManager);
-
- }
-
- /**
- * Returns the environment's filter-context.
- */
- public FilterContext getContext() {
- return mContext;
- }
-
- /**
- * Set the environment's GL environment to the specified environment. This does not activate
- * the environment.
- */
- public void setGLEnvironment(GLEnvironment glEnvironment) {
- mContext.initGLEnvironment(glEnvironment);
- }
-
- /**
- * Create and activate a new GL environment for use in this filter context.
- */
- public void createGLEnvironment() {
- GLEnvironment glEnvironment = new GLEnvironment();
- glEnvironment.initWithNewContext();
- setGLEnvironment(glEnvironment);
- }
-
- /**
- * Activate the GL environment for use in the current thread. A GL environment must have been
- * previously set or created using setGLEnvironment() or createGLEnvironment()! Call this after
- * having switched to a new thread for GL filter execution.
- */
- public void activateGLEnvironment() {
- GLEnvironment glEnv = mContext.getGLEnvironment();
- if (glEnv != null) {
- mContext.getGLEnvironment().activate();
- } else {
- throw new NullPointerException("No GLEnvironment in place to activate!");
- }
- }
-
- /**
- * Deactivate the GL environment from use in the current thread. A GL environment must have been
- * previously set or created using setGLEnvironment() or createGLEnvironment()! Call this before
- * running GL filters in another thread.
- */
- public void deactivateGLEnvironment() {
- GLEnvironment glEnv = mContext.getGLEnvironment();
- if (glEnv != null) {
- mContext.getGLEnvironment().deactivate();
- } else {
- throw new NullPointerException("No GLEnvironment in place to deactivate!");
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/CallbackFilter.java b/mca/filterfw/java/android/filterfw/basefilters/CallbackFilter.java
deleted file mode 100644
index 4185343..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/CallbackFilter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.os.Handler;
-import android.os.Looper;
-
-import java.lang.Runnable;
-
-/**
- * @hide
- */
-public class CallbackFilter extends Filter {
-
- @GenerateFieldPort(name = "listener", hasDefault = true)
- private FilterContext.OnFrameReceivedListener mListener;
-
- @GenerateFieldPort(name = "userData", hasDefault = true)
- private Object mUserData;
-
- @GenerateFinalPort(name = "callUiThread", hasDefault = true)
- private boolean mCallbacksOnUiThread = true;
-
- private Handler mUiThreadHandler;
-
- private class CallbackRunnable implements Runnable {
- private Filter mFilter;
- private Frame mFrame;
- private Object mUserData;
- private FilterContext.OnFrameReceivedListener mListener;
-
- public CallbackRunnable(FilterContext.OnFrameReceivedListener listener, Filter filter, Frame frame, Object userData) {
- mListener = listener;
- mFilter = filter;
- mFrame = frame;
- mUserData = userData;
- }
-
- public void run() {
- mListener.onFrameReceived(mFilter, mFrame, mUserData);
- mFrame.release();
- }
- }
-
- public CallbackFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addInputPort("frame");
- }
-
- public void prepare(FilterContext context) {
- if (mCallbacksOnUiThread) {
- mUiThreadHandler = new Handler(Looper.getMainLooper());
- }
- }
-
- public void process(FilterContext context) {
- // Get frame and forward to listener
- final Frame input = pullInput("frame");
- if (mListener != null) {
- if (mCallbacksOnUiThread) {
- input.retain();
- CallbackRunnable uiRunnable = new CallbackRunnable(mListener, this, input, mUserData);
- if (!mUiThreadHandler.post(uiRunnable)) {
- throw new RuntimeException("Unable to send callback to UI thread!");
- }
- } else {
- mListener.onFrameReceived(this, input, mUserData);
- }
- } else {
- throw new RuntimeException("CallbackFilter received frame, but no listener set!");
- }
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/FrameBranch.java b/mca/filterfw/java/android/filterfw/basefilters/FrameBranch.java
deleted file mode 100644
index 6b8cbc7..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/FrameBranch.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.KeyValueMap;
-
-/**
- * @hide
- */
-public class FrameBranch extends Filter {
-
- @GenerateFinalPort(name = "outputs", hasDefault = true)
- private int mNumberOfOutputs = 2;
-
- public FrameBranch(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addInputPort("in");
- for (int i = 0; i < mNumberOfOutputs; ++i) {
- addOutputBasedOnInput("out" + i, "in");
- }
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("in");
-
- // Push output
- for (int i = 0; i < mNumberOfOutputs; ++i) {
- pushOutput("out" + i, input);
- }
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/FrameFetch.java b/mca/filterfw/java/android/filterfw/basefilters/FrameFetch.java
deleted file mode 100644
index 518b837..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/FrameFetch.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class FrameFetch extends Filter {
-
- @GenerateFinalPort(name = "format", hasDefault = true)
- private FrameFormat mFormat;
-
- @GenerateFieldPort(name = "key")
- private String mKey;
-
- @GenerateFieldPort(name = "repeatFrame", hasDefault = true)
- private boolean mRepeatFrame = false;
-
- public FrameFetch(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addOutputPort("frame", mFormat == null ? FrameFormat.unspecified() : mFormat);
- }
-
- public void process(FilterContext context) {
- Frame output = context.fetchFrame(mKey);
- if (output != null) {
- pushOutput("frame", output);
- if (!mRepeatFrame) {
- closeOutputPort("frame");
- }
- } else {
- delayNextProcess(250);
- }
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/FrameSource.java b/mca/filterfw/java/android/filterfw/basefilters/FrameSource.java
deleted file mode 100644
index 1218d1a..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/FrameSource.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-
-/**
- * @hide
- */
-public class FrameSource extends Filter {
-
- @GenerateFinalPort(name = "format")
- private FrameFormat mFormat;
-
- @GenerateFieldPort(name = "frame", hasDefault = true)
- private Frame mFrame = null;
-
- @GenerateFieldPort(name = "repeatFrame", hasDefault = true)
- private boolean mRepeatFrame = false;
-
- public FrameSource(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addOutputPort("frame", mFormat);
- }
-
- @Override
- public void process(FilterContext context) {
- if (mFrame != null) {
- // Push output
- pushOutput("frame", mFrame);
- }
-
- if (!mRepeatFrame) {
- // Close output port as we are done here
- closeOutputPort("frame");
- }
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/FrameStore.java b/mca/filterfw/java/android/filterfw/basefilters/FrameStore.java
deleted file mode 100644
index 3aadaac..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/FrameStore.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-
-/**
- * @hide
- */
-public class FrameStore extends Filter {
-
- @GenerateFieldPort(name = "key")
- private String mKey;
-
- public FrameStore(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addInputPort("frame");
- }
-
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("frame");
-
- // Store frame
- context.storeFrame(mKey, input);
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/GLTextureSource.java b/mca/filterfw/java/android/filterfw/basefilters/GLTextureSource.java
deleted file mode 100644
index 1776820..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/GLTextureSource.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Set;
-
-/**
- * @hide
- */
-public class GLTextureSource extends Filter {
-
- @GenerateFieldPort(name = "texId")
- private int mTexId;
-
- @GenerateFieldPort(name = "width")
- private int mWidth;
-
- @GenerateFieldPort(name = "height")
- private int mHeight;
-
- @GenerateFieldPort(name = "repeatFrame", hasDefault = true)
- private boolean mRepeatFrame = false;
-
- /* This timestamp will be used for all output frames from this source. They
- * represent nanoseconds, and should be positive and monotonically
- * increasing. Set to Frame.TIMESTAMP_UNKNOWN if timestamps are not
- * meaningful for these textures.
- */
- @GenerateFieldPort(name = "timestamp", hasDefault = true)
- private long mTimestamp = Frame.TIMESTAMP_UNKNOWN;
-
- private Frame mFrame;
-
- public GLTextureSource(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addOutputPort("frame", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- // Release frame, so that it is recreated during the next process call
- if (mFrame != null) {
- mFrame.release();
- mFrame = null;
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Generate frame if not generated already
- if (mFrame == null) {
- FrameFormat outputFormat = ImageFormat.create(mWidth, mHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- mFrame = context.getFrameManager().newBoundFrame(outputFormat,
- GLFrame.EXISTING_TEXTURE_BINDING,
- mTexId);
- mFrame.setTimestamp(mTimestamp);
- }
-
- // Push output
- pushOutput("frame", mFrame);
-
- if (!mRepeatFrame) {
- // Close output port as we are done here
- closeOutputPort("frame");
- }
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mFrame != null) {
- mFrame.release();
- }
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/GLTextureTarget.java b/mca/filterfw/java/android/filterfw/basefilters/GLTextureTarget.java
deleted file mode 100644
index b2285cd..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/GLTextureTarget.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Set;
-
-/**
- * @hide
- */
-public class GLTextureTarget extends Filter {
-
- @GenerateFieldPort(name = "texId")
- private int mTexId;
-
- public GLTextureTarget(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("frame", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("frame");
-
- FrameFormat format = ImageFormat.create(input.getFormat().getWidth(),
- input.getFormat().getHeight(),
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
-
- Frame frame = context.getFrameManager().newBoundFrame(format, GLFrame.EXISTING_TEXTURE_BINDING, mTexId);
-
- // Copy to our texture frame
- frame.setDataFromFrame(input);
- frame.release();
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/InputStreamSource.java b/mca/filterfw/java/android/filterfw/basefilters/InputStreamSource.java
deleted file mode 100644
index 6c22ee7..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/InputStreamSource.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.format.PrimitiveFormat;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * @hide
- */
-public class InputStreamSource extends Filter {
-
- @GenerateFinalPort(name = "target")
- private String mTarget;
-
- @GenerateFieldPort(name = "stream")
- private InputStream mInputStream;
-
- @GenerateFinalPort(name = "format", hasDefault = true)
- private MutableFrameFormat mOutputFormat = null;
-
- public InputStreamSource(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- int target = FrameFormat.readTargetString(mTarget);
- if (mOutputFormat == null) {
- mOutputFormat = PrimitiveFormat.createByteFormat(target);
- }
- addOutputPort("data", mOutputFormat);
- }
-
- @Override
- public void process(FilterContext context) {
- int fileSize = 0;
- ByteBuffer byteBuffer = null;
-
- // Read the file
- try {
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int bytesRead;
- while ((bytesRead = mInputStream.read(buffer)) > 0) {
- byteStream.write(buffer, 0, bytesRead);
- fileSize += bytesRead;
- }
- byteBuffer = ByteBuffer.wrap(byteStream.toByteArray());
- } catch (IOException exception) {
- throw new RuntimeException(
- "InputStreamSource: Could not read stream: " + exception.getMessage() + "!");
- }
-
- // Put it into a frame
- mOutputFormat.setDimensions(fileSize);
- Frame output = context.getFrameManager().newFrame(mOutputFormat);
- output.setData(byteBuffer);
-
- // Push output
- pushOutput("data", output);
-
- // Release pushed frame
- output.release();
-
- // Close output port as we are done here
- closeOutputPort("data");
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/NullFilter.java b/mca/filterfw/java/android/filterfw/basefilters/NullFilter.java
deleted file mode 100644
index f3e08e4..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/NullFilter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-
-/**
- * @hide
- */
-public class NullFilter extends Filter {
-
- public NullFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addInputPort("frame");
- }
-
- @Override
- public void process(FilterContext context) {
- pullInput("frame");
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/ObjectSource.java b/mca/filterfw/java/android/filterfw/basefilters/ObjectSource.java
deleted file mode 100644
index d511e44..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/ObjectSource.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import java.util.Set;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.format.ObjectFormat;
-
-/**
- * @hide
- */
-public class ObjectSource extends Filter {
-
- @GenerateFieldPort(name = "object")
- private Object mObject;
-
- @GenerateFinalPort(name = "format", hasDefault = true)
- private FrameFormat mOutputFormat = FrameFormat.unspecified();
-
- @GenerateFieldPort(name = "repeatFrame", hasDefault = true)
- boolean mRepeatFrame = false;
-
- private Frame mFrame;
-
- public ObjectSource(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addOutputPort("frame", mOutputFormat);
- }
-
- @Override
- public void process(FilterContext context) {
- // If no frame has been created, create one now.
- if (mFrame == null) {
- if (mObject == null) {
- throw new NullPointerException("ObjectSource producing frame with no object set!");
- }
- FrameFormat outputFormat = ObjectFormat.fromObject(mObject, FrameFormat.TARGET_SIMPLE);
- mFrame = context.getFrameManager().newFrame(outputFormat);
- mFrame.setObjectValue(mObject);
- mFrame.setTimestamp(Frame.TIMESTAMP_UNKNOWN);
- }
-
- // Push output
- pushOutput("frame", mFrame);
-
- // Wait for free output
- if (!mRepeatFrame) {
- closeOutputPort("frame");
- }
- }
-
- @Override
- public void tearDown(FilterContext context) {
- mFrame.release();
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- // Release our internal frame, so that it is regenerated on the next call to process().
- if (name.equals("object")) {
- if (mFrame != null) {
- mFrame.release();
- mFrame = null;
- }
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/OutputStreamTarget.java b/mca/filterfw/java/android/filterfw/basefilters/OutputStreamTarget.java
deleted file mode 100644
index 3d3d0f1..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/OutputStreamTarget.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-
-import java.io.OutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * @hide
- */
-public class OutputStreamTarget extends Filter {
-
- @GenerateFieldPort(name = "stream")
- private OutputStream mOutputStream;
-
- public OutputStreamTarget(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addInputPort("data");
- }
-
- @Override
- public void process(FilterContext context) {
- Frame input = pullInput("data");
- ByteBuffer data;
-
- if (input.getFormat().getObjectClass() == String.class) {
- String stringVal = (String)input.getObjectValue();
- data = ByteBuffer.wrap(stringVal.getBytes());
- } else {
- data = input.getData();
- }
- try {
- mOutputStream.write(data.array(), 0, data.limit());
- mOutputStream.flush();
- } catch (IOException exception) {
- throw new RuntimeException(
- "OutputStreamTarget: Could not write to stream: " + exception.getMessage() + "!");
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/basefilters/RetargetFilter.java b/mca/filterfw/java/android/filterfw/basefilters/RetargetFilter.java
deleted file mode 100644
index 254167a..0000000
--- a/mca/filterfw/java/android/filterfw/basefilters/RetargetFilter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.base;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-
-/**
- * @hide
- */
-public class RetargetFilter extends Filter {
-
- @GenerateFinalPort(name = "target", hasDefault = false)
- private String mTargetString;
-
- private MutableFrameFormat mOutputFormat;
- private int mTarget = -1;
-
- public RetargetFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- // Setup target
- mTarget = FrameFormat.readTargetString(mTargetString);
-
- // Add ports
- addInputPort("frame");
- addOutputBasedOnInput("frame", "frame");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- MutableFrameFormat retargeted = inputFormat.mutableCopy();
- retargeted.setTarget(mTarget);
- return retargeted;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("frame");
-
- // Create output frame
- Frame output = context.getFrameManager().duplicateFrameToTarget(input, mTarget);
-
- // Push output
- pushOutput("frame", output);
-
- // Release pushed frame
- output.release();
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/AsyncRunner.java b/mca/filterfw/java/android/filterfw/core/AsyncRunner.java
deleted file mode 100644
index 70cbad4..0000000
--- a/mca/filterfw/java/android/filterfw/core/AsyncRunner.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.os.AsyncTask;
-import android.os.Handler;
-
-import android.util.Log;
-
-import java.lang.InterruptedException;
-import java.lang.Runnable;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @hide
- */
-public class AsyncRunner extends GraphRunner{
-
- private Class mSchedulerClass;
- private SyncRunner mRunner;
- private AsyncRunnerTask mRunTask;
-
- private OnRunnerDoneListener mDoneListener;
- private boolean isProcessing;
-
- private Exception mException;
-
- private class RunnerResult {
- public int status = RESULT_UNKNOWN;
- public Exception exception;
- }
-
- private class AsyncRunnerTask extends AsyncTask<SyncRunner, Void, RunnerResult> {
-
- private static final String TAG = "AsyncRunnerTask";
-
- @Override
- protected RunnerResult doInBackground(SyncRunner... runner) {
- RunnerResult result = new RunnerResult();
- try {
- if (runner.length > 1) {
- throw new RuntimeException("More than one runner received!");
- }
-
- runner[0].assertReadyToStep();
-
- // Preparation
- if (mLogVerbose) Log.v(TAG, "Starting background graph processing.");
- activateGlContext();
-
- if (mLogVerbose) Log.v(TAG, "Preparing filter graph for processing.");
- runner[0].beginProcessing();
-
- if (mLogVerbose) Log.v(TAG, "Running graph.");
-
- // Run loop
- result.status = RESULT_RUNNING;
- while (!isCancelled() && result.status == RESULT_RUNNING) {
- if (!runner[0].performStep()) {
- result.status = runner[0].determinePostRunState();
- if (result.status == GraphRunner.RESULT_SLEEPING) {
- runner[0].waitUntilWake();
- result.status = RESULT_RUNNING;
- }
- }
- }
-
- // Cleanup
- if (isCancelled()) {
- result.status = RESULT_STOPPED;
- }
- } catch (Exception exception) {
- result.exception = exception;
- result.status = RESULT_ERROR;
- }
-
- // Deactivate context.
- try {
- deactivateGlContext();
- } catch (Exception exception) {
- result.exception = exception;
- result.status = RESULT_ERROR;
- }
-
- if (mLogVerbose) Log.v(TAG, "Done with background graph processing.");
- return result;
- }
-
- @Override
- protected void onCancelled(RunnerResult result) {
- onPostExecute(result);
- }
-
- @Override
- protected void onPostExecute(RunnerResult result) {
- if (mLogVerbose) Log.v(TAG, "Starting post-execute.");
- setRunning(false);
- if (result == null) {
- // Cancelled before got to doInBackground
- result = new RunnerResult();
- result.status = RESULT_STOPPED;
- }
- setException(result.exception);
- if (result.status == RESULT_STOPPED || result.status == RESULT_ERROR) {
- if (mLogVerbose) Log.v(TAG, "Closing filters.");
- try {
- mRunner.close();
- } catch (Exception exception) {
- result.status = RESULT_ERROR;
- setException(exception);
- }
- }
- if (mDoneListener != null) {
- if (mLogVerbose) Log.v(TAG, "Calling graph done callback.");
- mDoneListener.onRunnerDone(result.status);
- }
- if (mLogVerbose) Log.v(TAG, "Completed post-execute.");
- }
- }
-
- private boolean mLogVerbose;
- private static final String TAG = "AsyncRunner";
-
- /** Create a new asynchronous graph runner with the given filter
- * context, and the given scheduler class.
- *
- * Must be created on the UI thread.
- */
- public AsyncRunner(FilterContext context, Class schedulerClass) {
- super(context);
-
- mSchedulerClass = schedulerClass;
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- /** Create a new asynchronous graph runner with the given filter
- * context. Uses a default scheduler.
- *
- * Must be created on the UI thread.
- */
- public AsyncRunner(FilterContext context) {
- super(context);
-
- mSchedulerClass = SimpleScheduler.class;
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- /** Set a callback to be called in the UI thread once the AsyncRunner
- * completes running a graph, whether the completion is due to a stop() call
- * or the filters running out of data to process.
- */
- @Override
- public void setDoneCallback(OnRunnerDoneListener listener) {
- mDoneListener = listener;
- }
-
- /** Sets the graph to be run. Will call prepare() on graph. Cannot be called
- * when a graph is already running.
- */
- synchronized public void setGraph(FilterGraph graph) {
- if (isRunning()) {
- throw new RuntimeException("Graph is already running!");
- }
- mRunner = new SyncRunner(mFilterContext, graph, mSchedulerClass);
- }
-
- @Override
- public FilterGraph getGraph() {
- return mRunner != null ? mRunner.getGraph() : null;
- }
-
- /** Execute the graph in a background thread. */
- @Override
- synchronized public void run() {
- if (mLogVerbose) Log.v(TAG, "Running graph.");
- setException(null);
-
- if (isRunning()) {
- throw new RuntimeException("Graph is already running!");
- }
- if (mRunner == null) {
- throw new RuntimeException("Cannot run before a graph is set!");
- }
- mRunTask = this.new AsyncRunnerTask();
-
- setRunning(true);
- mRunTask.execute(mRunner);
- }
-
- /** Stop graph execution. This is an asynchronous call; register a callback
- * with setDoneCallback to be notified of when the background processing has
- * been completed. Calling stop will close the filter graph. */
- @Override
- synchronized public void stop() {
- if (mRunTask != null && !mRunTask.isCancelled() ) {
- if (mLogVerbose) Log.v(TAG, "Stopping graph.");
- mRunTask.cancel(false);
- }
- }
-
- @Override
- synchronized public void close() {
- if (isRunning()) {
- throw new RuntimeException("Cannot close graph while it is running!");
- }
- if (mLogVerbose) Log.v(TAG, "Closing filters.");
- mRunner.close();
- }
-
- /** Check if background processing is happening */
- @Override
- synchronized public boolean isRunning() {
- return isProcessing;
- }
-
- @Override
- synchronized public Exception getError() {
- return mException;
- }
-
- synchronized private void setRunning(boolean running) {
- isProcessing = running;
- }
-
- synchronized private void setException(Exception exception) {
- mException = exception;
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/CachedFrameManager.java b/mca/filterfw/java/android/filterfw/core/CachedFrameManager.java
deleted file mode 100644
index a2cf2a0..0000000
--- a/mca/filterfw/java/android/filterfw/core/CachedFrameManager.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.SimpleFrameManager;
-
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * @hide
- */
-public class CachedFrameManager extends SimpleFrameManager {
-
- private SortedMap<Integer, Frame> mAvailableFrames;
- private int mStorageCapacity = 24 * 1024 * 1024; // Cap default storage to 24MB
- private int mStorageSize = 0;
- private int mTimeStamp = 0;
-
- public CachedFrameManager() {
- super();
- mAvailableFrames = new TreeMap<Integer, Frame>();
- }
-
- @Override
- public Frame newFrame(FrameFormat format) {
- Frame result = findAvailableFrame(format, Frame.NO_BINDING, 0);
- if (result == null) {
- result = super.newFrame(format);
- }
- result.setTimestamp(Frame.TIMESTAMP_NOT_SET);
- return result;
- }
-
- @Override
- public Frame newBoundFrame(FrameFormat format, int bindingType, long bindingId) {
- Frame result = findAvailableFrame(format, bindingType, bindingId);
- if (result == null) {
- result = super.newBoundFrame(format, bindingType, bindingId);
- }
- result.setTimestamp(Frame.TIMESTAMP_NOT_SET);
- return result;
- }
-
- @Override
- public Frame retainFrame(Frame frame) {
- return super.retainFrame(frame);
- }
-
- @Override
- public Frame releaseFrame(Frame frame) {
- if (frame.isReusable()) {
- int refCount = frame.decRefCount();
- if (refCount == 0 && frame.hasNativeAllocation()) {
- if (!storeFrame(frame)) {
- frame.releaseNativeAllocation();
- }
- return null;
- } else if (refCount < 0) {
- throw new RuntimeException("Frame reference count dropped below 0!");
- }
- } else {
- super.releaseFrame(frame);
- }
- return frame;
- }
-
- public void clearCache() {
- for (Frame frame : mAvailableFrames.values()) {
- frame.releaseNativeAllocation();
- }
- mAvailableFrames.clear();
- }
-
- @Override
- public void tearDown() {
- clearCache();
- }
-
- private boolean storeFrame(Frame frame) {
- synchronized(mAvailableFrames) {
- // Make sure this frame alone does not exceed capacity
- int frameSize = frame.getFormat().getSize();
- if (frameSize > mStorageCapacity) {
- return false;
- }
-
- // Drop frames if adding this frame would exceed capacity
- int newStorageSize = mStorageSize + frameSize;
- while (newStorageSize > mStorageCapacity) {
- dropOldestFrame();
- newStorageSize = mStorageSize + frameSize;
- }
-
- // Store new frame
- frame.onFrameStore();
- mStorageSize = newStorageSize;
- mAvailableFrames.put(mTimeStamp, frame);
- ++mTimeStamp;
- return true;
- }
- }
-
- private void dropOldestFrame() {
- int oldest = mAvailableFrames.firstKey();
- Frame frame = mAvailableFrames.get(oldest);
- mStorageSize -= frame.getFormat().getSize();
- frame.releaseNativeAllocation();
- mAvailableFrames.remove(oldest);
- }
-
- private Frame findAvailableFrame(FrameFormat format, int bindingType, long bindingId) {
- // Look for a frame that is compatible with the requested format
- synchronized(mAvailableFrames) {
- for (Map.Entry<Integer, Frame> entry : mAvailableFrames.entrySet()) {
- Frame frame = entry.getValue();
- // Check that format is compatible
- if (frame.getFormat().isReplaceableBy(format)) {
- // Check that binding is compatible (if frame is bound)
- if ((bindingType == frame.getBindingType())
- && (bindingType == Frame.NO_BINDING || bindingId == frame.getBindingId())) {
- // We found one! Take it out of the set of available frames and attach the
- // requested format to it.
- super.retainFrame(frame);
- mAvailableFrames.remove(entry.getKey());
- frame.onFrameFetch();
- frame.reset(format);
- mStorageSize -= format.getSize();
- return frame;
- }
- }
- }
- }
- return null;
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FieldPort.java b/mca/filterfw/java/android/filterfw/core/FieldPort.java
deleted file mode 100644
index b0350cc..0000000
--- a/mca/filterfw/java/android/filterfw/core/FieldPort.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.lang.reflect.Field;
-
-/**
- * @hide
- */
-public class FieldPort extends InputPort {
-
- protected Field mField;
- protected boolean mHasFrame;
- protected boolean mValueWaiting = false;
- protected Object mValue;
-
- public FieldPort(Filter filter, String name, Field field, boolean hasDefault) {
- super(filter, name);
- mField = field;
- mHasFrame = hasDefault;
- }
-
- @Override
- public void clear() {
- }
-
- @Override
- public void pushFrame(Frame frame) {
- setFieldFrame(frame, false);
- }
-
- @Override
- public void setFrame(Frame frame) {
- setFieldFrame(frame, true);
- }
-
- @Override
- public Object getTarget() {
- try {
- return mField.get(mFilter);
- } catch (IllegalAccessException e) {
- return null;
- }
- }
-
- @Override
- public synchronized void transfer(FilterContext context) {
- if (mValueWaiting) {
- try {
- mField.set(mFilter, mValue);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(
- "Access to field '" + mField.getName() + "' was denied!");
- }
- mValueWaiting = false;
- if (context != null) {
- mFilter.notifyFieldPortValueUpdated(mName, context);
- }
- }
- }
-
- @Override
- public synchronized Frame pullFrame() {
- throw new RuntimeException("Cannot pull frame on " + this + "!");
- }
-
- @Override
- public synchronized boolean hasFrame() {
- return mHasFrame;
- }
-
- @Override
- public synchronized boolean acceptsFrame() {
- return !mValueWaiting;
- }
-
- @Override
- public String toString() {
- return "field " + super.toString();
- }
-
- protected synchronized void setFieldFrame(Frame frame, boolean isAssignment) {
- assertPortIsOpen();
- checkFrameType(frame, isAssignment);
-
- // Store the object value
- Object value = frame.getObjectValue();
- if ((value == null && mValue != null) || !value.equals(mValue)) {
- mValue = value;
- mValueWaiting = true;
- }
-
- // Since a frame was set, mark this port as having a frame to pull
- mHasFrame = true;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/Filter.java b/mca/filterfw/java/android/filterfw/core/Filter.java
deleted file mode 100644
index 73b009d..0000000
--- a/mca/filterfw/java/android/filterfw/core/Filter.java
+++ /dev/null
@@ -1,709 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.FilterPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.io.TextGraphReader;
-import android.filterfw.io.GraphIOException;
-import android.filterfw.format.ObjectFormat;
-import android.util.Log;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.Thread;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map.Entry;
-import java.util.LinkedList;
-import java.util.Set;
-
-/**
- * @hide
- */
-public abstract class Filter {
-
- static final int STATUS_PREINIT = 0;
- static final int STATUS_UNPREPARED = 1;
- static final int STATUS_PREPARED = 2;
- static final int STATUS_PROCESSING = 3;
- static final int STATUS_SLEEPING = 4;
- static final int STATUS_FINISHED = 5;
- static final int STATUS_ERROR = 6;
- static final int STATUS_RELEASED = 7;
-
- private String mName;
-
- private int mInputCount = -1;
- private int mOutputCount = -1;
-
- private HashMap<String, InputPort> mInputPorts;
- private HashMap<String, OutputPort> mOutputPorts;
-
- private HashSet<Frame> mFramesToRelease;
- private HashMap<String, Frame> mFramesToSet;
-
- private int mStatus = 0;
- private boolean mIsOpen = false;
- private int mSleepDelay;
-
- private long mCurrentTimestamp;
-
- private boolean mLogVerbose;
- private static final String TAG = "Filter";
-
- public Filter(String name) {
- mName = name;
- mFramesToRelease = new HashSet<Frame>();
- mFramesToSet = new HashMap<String, Frame>();
- mStatus = STATUS_PREINIT;
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- /** Tests to see if a given filter is installed on the system. Requires
- * full filter package name, including filterpack.
- */
- public static final boolean isAvailable(String filterName) {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- Class filterClass;
- // First see if a class of that name exists
- try {
- filterClass = contextClassLoader.loadClass(filterName);
- } catch (ClassNotFoundException e) {
- return false;
- }
- // Then make sure it's a subclass of Filter.
- try {
- filterClass.asSubclass(Filter.class);
- } catch (ClassCastException e) {
- return false;
- }
- return true;
- }
-
- public final void initWithValueMap(KeyValueMap valueMap) {
- // Initialization
- initFinalPorts(valueMap);
-
- // Setup remaining ports
- initRemainingPorts(valueMap);
-
- // This indicates that final ports can no longer be set
- mStatus = STATUS_UNPREPARED;
- }
-
- public final void initWithAssignmentString(String assignments) {
- try {
- KeyValueMap valueMap = new TextGraphReader().readKeyValueAssignments(assignments);
- initWithValueMap(valueMap);
- } catch (GraphIOException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
-
- public final void initWithAssignmentList(Object... keyValues) {
- KeyValueMap valueMap = new KeyValueMap();
- valueMap.setKeyValues(keyValues);
- initWithValueMap(valueMap);
- }
-
- public final void init() throws ProtocolException {
- KeyValueMap valueMap = new KeyValueMap();
- initWithValueMap(valueMap);
- }
-
- public String getFilterClassName() {
- return getClass().getSimpleName();
- }
-
- public final String getName() {
- return mName;
- }
-
- public boolean isOpen() {
- return mIsOpen;
- }
-
- public void setInputFrame(String inputName, Frame frame) {
- FilterPort port = getInputPort(inputName);
- if (!port.isOpen()) {
- port.open();
- }
- port.setFrame(frame);
- }
-
- public final void setInputValue(String inputName, Object value) {
- setInputFrame(inputName, wrapInputValue(inputName, value));
- }
-
- protected void prepare(FilterContext context) {
- }
-
- protected void parametersUpdated(Set<String> updated) {
- }
-
- protected void delayNextProcess(int millisecs) {
- mSleepDelay = millisecs;
- mStatus = STATUS_SLEEPING;
- }
-
- public abstract void setupPorts();
-
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return null;
- }
-
- public final FrameFormat getInputFormat(String portName) {
- InputPort inputPort = getInputPort(portName);
- return inputPort.getSourceFormat();
- }
-
- public void open(FilterContext context) {
- }
-
- public abstract void process(FilterContext context);
-
- public final int getSleepDelay() {
- return 250;
- }
-
- public void close(FilterContext context) {
- }
-
- public void tearDown(FilterContext context) {
- }
-
- public final int getNumberOfConnectedInputs() {
- int c = 0;
- for (InputPort inputPort : mInputPorts.values()) {
- if (inputPort.isConnected()) {
- ++c;
- }
- }
- return c;
- }
-
- public final int getNumberOfConnectedOutputs() {
- int c = 0;
- for (OutputPort outputPort : mOutputPorts.values()) {
- if (outputPort.isConnected()) {
- ++c;
- }
- }
- return c;
- }
-
- public final int getNumberOfInputs() {
- return mOutputPorts == null ? 0 : mInputPorts.size();
- }
-
- public final int getNumberOfOutputs() {
- return mInputPorts == null ? 0 : mOutputPorts.size();
- }
-
- public final InputPort getInputPort(String portName) {
- if (mInputPorts == null) {
- throw new NullPointerException("Attempting to access input port '" + portName
- + "' of " + this + " before Filter has been initialized!");
- }
- InputPort result = mInputPorts.get(portName);
- if (result == null) {
- throw new IllegalArgumentException("Unknown input port '" + portName + "' on filter "
- + this + "!");
- }
- return result;
- }
-
- public final OutputPort getOutputPort(String portName) {
- if (mInputPorts == null) {
- throw new NullPointerException("Attempting to access output port '" + portName
- + "' of " + this + " before Filter has been initialized!");
- }
- OutputPort result = mOutputPorts.get(portName);
- if (result == null) {
- throw new IllegalArgumentException("Unknown output port '" + portName + "' on filter "
- + this + "!");
- }
- return result;
- }
-
- protected final void pushOutput(String name, Frame frame) {
- if (frame.getTimestamp() == Frame.TIMESTAMP_NOT_SET) {
- if (mLogVerbose) Log.v(TAG, "Default-setting output Frame timestamp on port " + name + " to " + mCurrentTimestamp);
- frame.setTimestamp(mCurrentTimestamp);
- }
- getOutputPort(name).pushFrame(frame);
- }
-
- protected final Frame pullInput(String name) {
- Frame result = getInputPort(name).pullFrame();
- if (mCurrentTimestamp == Frame.TIMESTAMP_UNKNOWN) {
- mCurrentTimestamp = result.getTimestamp();
- if (mLogVerbose) Log.v(TAG, "Default-setting current timestamp from input port " + name + " to " + mCurrentTimestamp);
- }
- // As result is retained, we add it to the release pool here
- mFramesToRelease.add(result);
-
- return result;
- }
-
- public void fieldPortValueUpdated(String name, FilterContext context) {
- }
-
- /**
- * Transfers any frame from an input port to its destination. This is useful to force a
- * transfer from a FieldPort or ProgramPort to its connected target (field or program variable).
- */
- protected void transferInputPortFrame(String name, FilterContext context) {
- getInputPort(name).transfer(context);
- }
-
- /**
- * Assigns all program variables to the ports they are connected to. Call this after
- * constructing a Program instance with attached ProgramPorts.
- */
- protected void initProgramInputs(Program program, FilterContext context) {
- if (program != null) {
- for (InputPort inputPort : mInputPorts.values()) {
- if (inputPort.getTarget() == program) {
- inputPort.transfer(context);
- }
- }
- }
- }
-
- /**
- * Adds an input port to the filter. You should call this from within setupPorts, if your
- * filter has input ports. No type-checking is performed on the input. If you would like to
- * check against a type mask, use
- * {@link #addMaskedInputPort(String, FrameFormat) addMaskedInputPort} instead.
- *
- * @param name the name of the input port
- */
- protected void addInputPort(String name) {
- addMaskedInputPort(name, null);
- }
-
- /**
- * Adds an input port to the filter. You should call this from within setupPorts, if your
- * filter has input ports. When type-checking is performed, the input format is
- * checked against the provided format mask. An exception is thrown in case of a conflict.
- *
- * @param name the name of the input port
- * @param formatMask a format mask, which filters the allowable input types
- */
- protected void addMaskedInputPort(String name, FrameFormat formatMask) {
- InputPort port = new StreamPort(this, name);
- if (mLogVerbose) Log.v(TAG, "Filter " + this + " adding " + port);
- mInputPorts.put(name, port);
- port.setPortFormat(formatMask);
- }
-
- /**
- * Adds an output port to the filter with a fixed output format. You should call this from
- * within setupPorts, if your filter has output ports. You cannot use this method, if your
- * output format depends on the input format (e.g. in a pass-through filter). In this case, use
- * {@link #addOutputBasedOnInput(String, String) addOutputBasedOnInput} instead.
- *
- * @param name the name of the output port
- * @param format the fixed output format of this port
- */
- protected void addOutputPort(String name, FrameFormat format) {
- OutputPort port = new OutputPort(this, name);
- if (mLogVerbose) Log.v(TAG, "Filter " + this + " adding " + port);
- port.setPortFormat(format);
- mOutputPorts.put(name, port);
- }
-
- /**
- * Adds an output port to the filter. You should call this from within setupPorts, if your
- * filter has output ports. Using this method indicates that the output format for this
- * particular port, depends on the format of an input port. You MUST also override
- * {@link #getOutputFormat(String, FrameFormat) getOutputFormat} to specify what format your
- * filter will output for a given input. If the output format of your filter port does not
- * depend on the input, use {@link #addOutputPort(String, FrameFormat) addOutputPort} instead.
- *
- * @param outputName the name of the output port
- * @param inputName the name of the input port, that this output depends on
- */
- protected void addOutputBasedOnInput(String outputName, String inputName) {
- OutputPort port = new OutputPort(this, outputName);
- if (mLogVerbose) Log.v(TAG, "Filter " + this + " adding " + port);
- port.setBasePort(getInputPort(inputName));
- mOutputPorts.put(outputName, port);
- }
-
- protected void addFieldPort(String name,
- Field field,
- boolean hasDefault,
- boolean isFinal) {
- // Make sure field is accessible
- field.setAccessible(true);
-
- // Create port for this input
- InputPort fieldPort = isFinal
- ? new FinalPort(this, name, field, hasDefault)
- : new FieldPort(this, name, field, hasDefault);
-
- // Create format for this input
- if (mLogVerbose) Log.v(TAG, "Filter " + this + " adding " + fieldPort);
- MutableFrameFormat format = ObjectFormat.fromClass(field.getType(),
- FrameFormat.TARGET_SIMPLE);
- fieldPort.setPortFormat(format);
-
- // Add port
- mInputPorts.put(name, fieldPort);
- }
-
- protected void addProgramPort(String name,
- String varName,
- Field field,
- Class varType,
- boolean hasDefault) {
- // Make sure field is accessible
- field.setAccessible(true);
-
- // Create port for this input
- InputPort programPort = new ProgramPort(this, name, varName, field, hasDefault);
-
- // Create format for this input
- if (mLogVerbose) Log.v(TAG, "Filter " + this + " adding " + programPort);
- MutableFrameFormat format = ObjectFormat.fromClass(varType,
- FrameFormat.TARGET_SIMPLE);
- programPort.setPortFormat(format);
-
- // Add port
- mInputPorts.put(name, programPort);
- }
-
- protected void closeOutputPort(String name) {
- getOutputPort(name).close();
- }
-
- /**
- * Specifies whether the filter should not be scheduled until a frame is available on that
- * input port. Note, that setting this to false, does not block a new frame from coming in
- * (though there is no necessity to pull that frame for processing).
- * @param portName the name of the input port.
- * @param waits true, if the filter should wait for a frame on this port.
- */
- protected void setWaitsOnInputPort(String portName, boolean waits) {
- getInputPort(portName).setBlocking(waits);
- }
-
- /**
- * Specifies whether the filter should not be scheduled until the output port is free, i.e.
- * there is no frame waiting on that output.
- * @param portName the name of the output port.
- * @param waits true, if the filter should wait for the port to become free.
- */
- protected void setWaitsOnOutputPort(String portName, boolean waits) {
- getOutputPort(portName).setBlocking(waits);
- }
-
- public String toString() {
- return "'" + getName() + "' (" + getFilterClassName() + ")";
- }
-
- // Core internal methods ///////////////////////////////////////////////////////////////////////
- final Collection<InputPort> getInputPorts() {
- return mInputPorts.values();
- }
-
- final Collection<OutputPort> getOutputPorts() {
- return mOutputPorts.values();
- }
-
- final synchronized int getStatus() {
- return mStatus;
- }
-
- final synchronized void unsetStatus(int flag) {
- mStatus &= ~flag;
- }
-
- final synchronized void performOpen(FilterContext context) {
- if (!mIsOpen) {
- if (mStatus == STATUS_UNPREPARED) {
- if (mLogVerbose) Log.v(TAG, "Preparing " + this);
- prepare(context);
- mStatus = STATUS_PREPARED;
- }
- if (mStatus == STATUS_PREPARED) {
- if (mLogVerbose) Log.v(TAG, "Opening " + this);
- open(context);
- mStatus = STATUS_PROCESSING;
- }
- if (mStatus != STATUS_PROCESSING) {
- throw new RuntimeException("Filter " + this + " was brought into invalid state during "
- + "opening (state: " + mStatus + ")!");
- }
- mIsOpen = true;
- }
- }
-
- final synchronized void performProcess(FilterContext context) {
- if (mStatus == STATUS_RELEASED) {
- throw new RuntimeException("Filter " + this + " is already torn down!");
- }
- transferInputFrames(context);
- if (mStatus < STATUS_PROCESSING) {
- performOpen(context);
- }
- if (mLogVerbose) Log.v(TAG, "Processing " + this);
- mCurrentTimestamp = Frame.TIMESTAMP_UNKNOWN;
- process(context);
- releasePulledFrames(context);
- if (filterMustClose()) {
- performClose(context);
- }
- }
-
- final synchronized void performClose(FilterContext context) {
- if (mIsOpen) {
- if (mLogVerbose) Log.v(TAG, "Closing " + this);
- mIsOpen = false;
- mStatus = STATUS_PREPARED;
- close(context);
- closePorts();
- }
- }
-
- final synchronized void performTearDown(FilterContext context) {
- performClose(context);
- if (mStatus != STATUS_RELEASED) {
- tearDown(context);
- mStatus = STATUS_RELEASED;
- }
- }
-
- synchronized final boolean canProcess() {
- if (mLogVerbose) Log.v(TAG, "Checking if can process: " + this + " (" + mStatus + ").");
- if (mStatus <= STATUS_PROCESSING) {
- return inputConditionsMet() && outputConditionsMet();
- } else {
- return false;
- }
- }
-
- final void openOutputs() {
- if (mLogVerbose) Log.v(TAG, "Opening all output ports on " + this + "!");
- for (OutputPort outputPort : mOutputPorts.values()) {
- if (!outputPort.isOpen()) {
- outputPort.open();
- }
- }
- }
-
- final void clearInputs() {
- for (InputPort inputPort : mInputPorts.values()) {
- inputPort.clear();
- }
- }
-
- final void clearOutputs() {
- for (OutputPort outputPort : mOutputPorts.values()) {
- outputPort.clear();
- }
- }
-
- final void notifyFieldPortValueUpdated(String name, FilterContext context) {
- if (mStatus == STATUS_PROCESSING || mStatus == STATUS_PREPARED) {
- fieldPortValueUpdated(name, context);
- }
- }
-
- final synchronized void pushInputFrame(String inputName, Frame frame) {
- FilterPort port = getInputPort(inputName);
- if (!port.isOpen()) {
- port.open();
- }
- port.pushFrame(frame);
- }
-
- final synchronized void pushInputValue(String inputName, Object value) {
- pushInputFrame(inputName, wrapInputValue(inputName, value));
- }
-
- // Filter internal methods /////////////////////////////////////////////////////////////////////
- private final void initFinalPorts(KeyValueMap values) {
- mInputPorts = new HashMap<String, InputPort>();
- mOutputPorts = new HashMap<String, OutputPort>();
- addAndSetFinalPorts(values);
- }
-
- private final void initRemainingPorts(KeyValueMap values) {
- addAnnotatedPorts();
- setupPorts(); // TODO: rename to addFilterPorts() ?
- setInitialInputValues(values);
- }
-
- private final void addAndSetFinalPorts(KeyValueMap values) {
- Class filterClass = getClass();
- Annotation annotation;
- for (Field field : filterClass.getDeclaredFields()) {
- if ((annotation = field.getAnnotation(GenerateFinalPort.class)) != null) {
- GenerateFinalPort generator = (GenerateFinalPort)annotation;
- String name = generator.name().isEmpty() ? field.getName() : generator.name();
- boolean hasDefault = generator.hasDefault();
- addFieldPort(name, field, hasDefault, true);
- if (values.containsKey(name)) {
- setImmediateInputValue(name, values.get(name));
- values.remove(name);
- } else if (!generator.hasDefault()) {
- throw new RuntimeException("No value specified for final input port '"
- + name + "' of filter " + this + "!");
- }
- }
- }
- }
-
- private final void addAnnotatedPorts() {
- Class filterClass = getClass();
- Annotation annotation;
- for (Field field : filterClass.getDeclaredFields()) {
- if ((annotation = field.getAnnotation(GenerateFieldPort.class)) != null) {
- GenerateFieldPort generator = (GenerateFieldPort)annotation;
- addFieldGenerator(generator, field);
- } else if ((annotation = field.getAnnotation(GenerateProgramPort.class)) != null) {
- GenerateProgramPort generator = (GenerateProgramPort)annotation;
- addProgramGenerator(generator, field);
- } else if ((annotation = field.getAnnotation(GenerateProgramPorts.class)) != null) {
- GenerateProgramPorts generators = (GenerateProgramPorts)annotation;
- for (GenerateProgramPort generator : generators.value()) {
- addProgramGenerator(generator, field);
- }
- }
- }
- }
-
- private final void addFieldGenerator(GenerateFieldPort generator, Field field) {
- String name = generator.name().isEmpty() ? field.getName() : generator.name();
- boolean hasDefault = generator.hasDefault();
- addFieldPort(name, field, hasDefault, false);
- }
-
- private final void addProgramGenerator(GenerateProgramPort generator, Field field) {
- String name = generator.name();
- String varName = generator.variableName().isEmpty() ? name
- : generator.variableName();
- Class varType = generator.type();
- boolean hasDefault = generator.hasDefault();
- addProgramPort(name, varName, field, varType, hasDefault);
- }
-
- private final void setInitialInputValues(KeyValueMap values) {
- for (Entry<String, Object> entry : values.entrySet()) {
- setInputValue(entry.getKey(), entry.getValue());
- }
- }
-
- private final void setImmediateInputValue(String name, Object value) {
- if (mLogVerbose) Log.v(TAG, "Setting immediate value " + value + " for port " + name + "!");
- FilterPort port = getInputPort(name);
- port.open();
- port.setFrame(SimpleFrame.wrapObject(value, null));
- }
-
- private final void transferInputFrames(FilterContext context) {
- for (InputPort inputPort : mInputPorts.values()) {
- inputPort.transfer(context);
- }
- }
-
- private final Frame wrapInputValue(String inputName, Object value) {
- MutableFrameFormat inputFormat = ObjectFormat.fromObject(value, FrameFormat.TARGET_SIMPLE);
- if (value == null) {
- // If the value is null, the format cannot guess the class, so we adjust it to the
- // class of the input port here
- FrameFormat portFormat = getInputPort(inputName).getPortFormat();
- Class portClass = (portFormat == null) ? null : portFormat.getObjectClass();
- inputFormat.setObjectClass(portClass);
- }
-
- // Serialize if serializable, and type is not an immutable primitive.
- boolean shouldSerialize = !(value instanceof Number)
- && !(value instanceof Boolean)
- && !(value instanceof String)
- && value instanceof Serializable;
-
- // Create frame wrapper
- Frame frame = shouldSerialize
- ? new SerializedFrame(inputFormat, null)
- : new SimpleFrame(inputFormat, null);
- frame.setObjectValue(value);
- return frame;
- }
-
- private final void releasePulledFrames(FilterContext context) {
- for (Frame frame : mFramesToRelease) {
- context.getFrameManager().releaseFrame(frame);
- }
- mFramesToRelease.clear();
- }
-
- private final boolean inputConditionsMet() {
- for (FilterPort port : mInputPorts.values()) {
- if (!port.isReady()) {
- if (mLogVerbose) Log.v(TAG, "Input condition not met: " + port + "!");
- return false;
- }
- }
- return true;
- }
-
- private final boolean outputConditionsMet() {
- for (FilterPort port : mOutputPorts.values()) {
- if (!port.isReady()) {
- if (mLogVerbose) Log.v(TAG, "Output condition not met: " + port + "!");
- return false;
- }
- }
- return true;
- }
-
- private final void closePorts() {
- if (mLogVerbose) Log.v(TAG, "Closing all ports on " + this + "!");
- for (InputPort inputPort : mInputPorts.values()) {
- inputPort.close();
- }
- for (OutputPort outputPort : mOutputPorts.values()) {
- outputPort.close();
- }
- }
-
- private final boolean filterMustClose() {
- for (InputPort inputPort : mInputPorts.values()) {
- if (inputPort.filterMustClose()) {
- if (mLogVerbose) Log.v(TAG, "Filter " + this + " must close due to port " + inputPort);
- return true;
- }
- }
- for (OutputPort outputPort : mOutputPorts.values()) {
- if (outputPort.filterMustClose()) {
- if (mLogVerbose) Log.v(TAG, "Filter " + this + " must close due to port " + outputPort);
- return true;
- }
- }
- return false;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FilterContext.java b/mca/filterfw/java/android/filterfw/core/FilterContext.java
deleted file mode 100644
index 3c79d1b..0000000
--- a/mca/filterfw/java/android/filterfw/core/FilterContext.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GLEnvironment;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @hide
- */
-public class FilterContext {
-
- private FrameManager mFrameManager;
- private GLEnvironment mGLEnvironment;
- private HashMap<String, Frame> mStoredFrames = new HashMap<String, Frame>();
- private Set<FilterGraph> mGraphs = new HashSet<FilterGraph>();
-
- public FrameManager getFrameManager() {
- return mFrameManager;
- }
-
- public void setFrameManager(FrameManager manager) {
- if (manager == null) {
- throw new NullPointerException("Attempting to set null FrameManager!");
- } else if (manager.getContext() != null) {
- throw new IllegalArgumentException("Attempting to set FrameManager which is already "
- + "bound to another FilterContext!");
- } else {
- mFrameManager = manager;
- mFrameManager.setContext(this);
- }
- }
-
- public GLEnvironment getGLEnvironment() {
- return mGLEnvironment;
- }
-
- public void initGLEnvironment(GLEnvironment environment) {
- if (mGLEnvironment == null) {
- mGLEnvironment = environment;
- } else {
- throw new RuntimeException("Attempting to re-initialize GL Environment for " +
- "FilterContext!");
- }
- }
-
- public interface OnFrameReceivedListener {
- public void onFrameReceived(Filter filter, Frame frame, Object userData);
- }
-
- public synchronized void storeFrame(String key, Frame frame) {
- Frame storedFrame = fetchFrame(key);
- if (storedFrame != null) {
- storedFrame.release();
- }
- frame.onFrameStore();
- mStoredFrames.put(key, frame.retain());
- }
-
- public synchronized Frame fetchFrame(String key) {
- Frame frame = mStoredFrames.get(key);
- if (frame != null) {
- frame.onFrameFetch();
- }
- return frame;
- }
-
- public synchronized void removeFrame(String key) {
- Frame frame = mStoredFrames.get(key);
- if (frame != null) {
- mStoredFrames.remove(key);
- frame.release();
- }
- }
-
- public synchronized void tearDown() {
- // Release stored frames
- for (Frame frame : mStoredFrames.values()) {
- frame.release();
- }
- mStoredFrames.clear();
-
- // Release graphs
- for (FilterGraph graph : mGraphs) {
- graph.tearDown(this);
- }
- mGraphs.clear();
-
- // Release frame manager
- if (mFrameManager != null) {
- mFrameManager.tearDown();
- mFrameManager = null;
- }
-
- // Release GL context
- if (mGLEnvironment != null) {
- mGLEnvironment.tearDown();
- mGLEnvironment = null;
- }
- }
-
- final void addGraph(FilterGraph graph) {
- mGraphs.add(graph);
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FilterFactory.java b/mca/filterfw/java/android/filterfw/core/FilterFactory.java
deleted file mode 100644
index 779df99..0000000
--- a/mca/filterfw/java/android/filterfw/core/FilterFactory.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Filter;
-import android.util.Log;
-
-import dalvik.system.PathClassLoader;
-
-import java.lang.reflect.Constructor;
-import java.lang.ClassLoader;
-import java.lang.Thread;
-import java.util.HashSet;
-
-/**
- * @hide
- */
-public class FilterFactory {
-
- private static FilterFactory mSharedFactory;
- private HashSet<String> mPackages = new HashSet<String>();
-
- private static ClassLoader mCurrentClassLoader;
- private static HashSet<String> mLibraries;
- private static Object mClassLoaderGuard;
-
- static {
- mCurrentClassLoader = Thread.currentThread().getContextClassLoader();
- mLibraries = new HashSet<String>();
- mClassLoaderGuard = new Object();
- }
-
- private static final String TAG = "FilterFactory";
- private static boolean mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
-
- public static FilterFactory sharedFactory() {
- if (mSharedFactory == null) {
- mSharedFactory = new FilterFactory();
- }
- return mSharedFactory;
- }
-
- /**
- * Adds a new Java library to the list to be scanned for filters.
- * libraryPath must be an absolute path of the jar file. This needs to be
- * static because only one classloader per process can open a shared native
- * library, which a filter may well have.
- */
- public static void addFilterLibrary(String libraryPath) {
- if (mLogVerbose) Log.v(TAG, "Adding filter library " + libraryPath);
- synchronized(mClassLoaderGuard) {
- if (mLibraries.contains(libraryPath)) {
- if (mLogVerbose) Log.v(TAG, "Library already added");
- return;
- }
- mLibraries.add(libraryPath);
- // Chain another path loader to the current chain
- mCurrentClassLoader = new PathClassLoader(libraryPath, mCurrentClassLoader);
- }
- }
-
- public void addPackage(String packageName) {
- if (mLogVerbose) Log.v(TAG, "Adding package " + packageName);
- /* TODO: This should use a getPackage call in the caller's context, but no such method exists.
- Package pkg = Package.getPackage(packageName);
- if (pkg == null) {
- throw new IllegalArgumentException("Unknown filter package '" + packageName + "'!");
- }
- */
- mPackages.add(packageName);
- }
-
- public Filter createFilterByClassName(String className, String filterName) {
- if (mLogVerbose) Log.v(TAG, "Looking up class " + className);
- Class filterClass = null;
-
- // Look for the class in the imported packages
- for (String packageName : mPackages) {
- try {
- if (mLogVerbose) Log.v(TAG, "Trying "+packageName + "." + className);
- synchronized(mClassLoaderGuard) {
- filterClass = mCurrentClassLoader.loadClass(packageName + "." + className);
- }
- } catch (ClassNotFoundException e) {
- continue;
- }
- // Exit loop if class was found.
- if (filterClass != null) {
- break;
- }
- }
- if (filterClass == null) {
- throw new IllegalArgumentException("Unknown filter class '" + className + "'!");
- }
- return createFilterByClass(filterClass, filterName);
- }
-
- public Filter createFilterByClass(Class filterClass, String filterName) {
- // Make sure this is a Filter subclass
- try {
- filterClass.asSubclass(Filter.class);
- } catch (ClassCastException e) {
- throw new IllegalArgumentException("Attempting to allocate class '" + filterClass
- + "' which is not a subclass of Filter!");
- }
-
- // Look for the correct constructor
- Constructor filterConstructor = null;
- try {
- filterConstructor = filterClass.getConstructor(String.class);
- } catch (NoSuchMethodException e) {
- throw new IllegalArgumentException("The filter class '" + filterClass
- + "' does not have a constructor of the form <init>(String name)!");
- }
-
- // Construct the filter
- Filter filter = null;
- try {
- filter = (Filter)filterConstructor.newInstance(filterName);
- } catch (Throwable t) {
- // Condition checked below
- }
-
- if (filter == null) {
- throw new IllegalArgumentException("Could not construct the filter '"
- + filterName + "'!");
- }
- return filter;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FilterFunction.java b/mca/filterfw/java/android/filterfw/core/FilterFunction.java
deleted file mode 100644
index ce81a18..0000000
--- a/mca/filterfw/java/android/filterfw/core/FilterFunction.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.util.Map.Entry;
-
-/**
- * @hide
- */
-public class FilterFunction {
-
- private Filter mFilter;
- private FilterContext mFilterContext;
- private boolean mFilterIsSetup = false;
- private FrameHolderPort[] mResultHolders;
-
- private class FrameHolderPort extends StreamPort {
- public FrameHolderPort() {
- super(null, "holder");
- }
- }
-
- public FilterFunction(FilterContext context, Filter filter) {
- mFilterContext = context;
- mFilter = filter;
- }
-
- public Frame execute(KeyValueMap inputMap) {
- int filterOutCount = mFilter.getNumberOfOutputs();
-
- // Sanity checks
- if (filterOutCount > 1) {
- throw new RuntimeException("Calling execute on filter " + mFilter + " with multiple "
- + "outputs! Use executeMulti() instead!");
- }
-
- // Setup filter
- if (!mFilterIsSetup) {
- connectFilterOutputs();
- mFilterIsSetup = true;
- }
-
- // Make sure GL environment is active
- boolean didActivateGLEnv = false;
- GLEnvironment glEnv = mFilterContext.getGLEnvironment();
- if (glEnv != null && !glEnv.isActive()) {
- glEnv.activate();
- didActivateGLEnv = true;
- }
-
- // Setup the inputs
- for (Entry<String, Object> entry : inputMap.entrySet()) {
- if (entry.getValue() instanceof Frame) {
- mFilter.pushInputFrame(entry.getKey(), (Frame)entry.getValue());
- } else {
- mFilter.pushInputValue(entry.getKey(), entry.getValue());
- }
- }
-
- // Process the filter
- if (mFilter.getStatus() != Filter.STATUS_PROCESSING) {
- mFilter.openOutputs();
- }
-
- mFilter.performProcess(mFilterContext);
-
- // Create result handle
- Frame result = null;
- if (filterOutCount == 1 && mResultHolders[0].hasFrame()) {
- result = mResultHolders[0].pullFrame();
- }
-
- // Deactivate GL environment if activated
- if (didActivateGLEnv) {
- glEnv.deactivate();
- }
-
- return result;
- }
-
- public Frame executeWithArgList(Object... inputs) {
- return execute(KeyValueMap.fromKeyValues(inputs));
- }
-
- public void close() {
- mFilter.performClose(mFilterContext);
- }
-
- public FilterContext getContext() {
- return mFilterContext;
- }
-
- public Filter getFilter() {
- return mFilter;
- }
-
- public void setInputFrame(String input, Frame frame) {
- mFilter.setInputFrame(input, frame);
- }
-
- public void setInputValue(String input, Object value) {
- mFilter.setInputValue(input, value);
- }
-
- public void tearDown() {
- mFilter.performTearDown(mFilterContext);
- mFilter = null;
- }
-
- @Override
- public String toString() {
- return mFilter.getName();
- }
-
- private void connectFilterOutputs() {
- int i = 0;
- mResultHolders = new FrameHolderPort[mFilter.getNumberOfOutputs()];
- for (OutputPort outputPort : mFilter.getOutputPorts()) {
- mResultHolders[i] = new FrameHolderPort();
- outputPort.connectTo(mResultHolders[i]);
- ++i;
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FilterGraph.java b/mca/filterfw/java/android/filterfw/core/FilterGraph.java
deleted file mode 100644
index 12f7892..0000000
--- a/mca/filterfw/java/android/filterfw/core/FilterGraph.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.Stack;
-
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.KeyValueMap;
-import android.filterpacks.base.FrameBranch;
-import android.filterpacks.base.NullFilter;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class FilterGraph {
-
- private HashSet<Filter> mFilters = new HashSet<Filter>();
- private HashMap<String, Filter> mNameMap = new HashMap<String, Filter>();
- private HashMap<OutputPort, LinkedList<InputPort>> mPreconnections = new
- HashMap<OutputPort, LinkedList<InputPort>>();
-
- public static final int AUTOBRANCH_OFF = 0;
- public static final int AUTOBRANCH_SYNCED = 1;
- public static final int AUTOBRANCH_UNSYNCED = 2;
-
- public static final int TYPECHECK_OFF = 0;
- public static final int TYPECHECK_DYNAMIC = 1;
- public static final int TYPECHECK_STRICT = 2;
-
- private boolean mIsReady = false;
- private int mAutoBranchMode = AUTOBRANCH_OFF;
- private int mTypeCheckMode = TYPECHECK_STRICT;
- private boolean mDiscardUnconnectedOutputs = false;
-
- private boolean mLogVerbose;
- private String TAG = "FilterGraph";
-
- public FilterGraph() {
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- public boolean addFilter(Filter filter) {
- if (!containsFilter(filter)) {
- mFilters.add(filter);
- mNameMap.put(filter.getName(), filter);
- return true;
- }
- return false;
- }
-
- public boolean containsFilter(Filter filter) {
- return mFilters.contains(filter);
- }
-
- public Filter getFilter(String name) {
- return mNameMap.get(name);
- }
-
- public void connect(Filter source,
- String outputName,
- Filter target,
- String inputName) {
- if (source == null || target == null) {
- throw new IllegalArgumentException("Passing null Filter in connect()!");
- } else if (!containsFilter(source) || !containsFilter(target)) {
- throw new RuntimeException("Attempting to connect filter not in graph!");
- }
-
- OutputPort outPort = source.getOutputPort(outputName);
- InputPort inPort = target.getInputPort(inputName);
- if (outPort == null) {
- throw new RuntimeException("Unknown output port '" + outputName + "' on Filter " +
- source + "!");
- } else if (inPort == null) {
- throw new RuntimeException("Unknown input port '" + inputName + "' on Filter " +
- target + "!");
- }
-
- preconnect(outPort, inPort);
- }
-
- public void connect(String sourceName,
- String outputName,
- String targetName,
- String inputName) {
- Filter source = getFilter(sourceName);
- Filter target = getFilter(targetName);
- if (source == null) {
- throw new RuntimeException(
- "Attempting to connect unknown source filter '" + sourceName + "'!");
- } else if (target == null) {
- throw new RuntimeException(
- "Attempting to connect unknown target filter '" + targetName + "'!");
- }
- connect(source, outputName, target, inputName);
- }
-
- public Set<Filter> getFilters() {
- return mFilters;
- }
-
- public void beginProcessing() {
- if (mLogVerbose) Log.v(TAG, "Opening all filter connections...");
- for (Filter filter : mFilters) {
- filter.openOutputs();
- }
- mIsReady = true;
- }
-
- public void flushFrames() {
- for (Filter filter : mFilters) {
- filter.clearOutputs();
- }
- }
-
- public void closeFilters(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Closing all filters...");
- for (Filter filter : mFilters) {
- filter.performClose(context);
- }
- mIsReady = false;
- }
-
- public boolean isReady() {
- return mIsReady;
- }
-
- public void setAutoBranchMode(int autoBranchMode) {
- mAutoBranchMode = autoBranchMode;
- }
-
- public void setDiscardUnconnectedOutputs(boolean discard) {
- mDiscardUnconnectedOutputs = discard;
- }
-
- public void setTypeCheckMode(int typeCheckMode) {
- mTypeCheckMode = typeCheckMode;
- }
-
- public void tearDown(FilterContext context) {
- if (!mFilters.isEmpty()) {
- flushFrames();
- for (Filter filter : mFilters) {
- filter.performTearDown(context);
- }
- mFilters.clear();
- mNameMap.clear();
- mIsReady = false;
- }
- }
-
- private boolean readyForProcessing(Filter filter, Set<Filter> processed) {
- // Check if this has been already processed
- if (processed.contains(filter)) {
- return false;
- }
-
- // Check if all dependencies have been processed
- for (InputPort port : filter.getInputPorts()) {
- Filter dependency = port.getSourceFilter();
- if (dependency != null && !processed.contains(dependency)) {
- return false;
- }
- }
- return true;
- }
-
- private void runTypeCheck() {
- Stack<Filter> filterStack = new Stack<Filter>();
- Set<Filter> processedFilters = new HashSet<Filter>();
- filterStack.addAll(getSourceFilters());
-
- while (!filterStack.empty()) {
- // Get current filter and mark as processed
- Filter filter = filterStack.pop();
- processedFilters.add(filter);
-
- // Anchor output formats
- updateOutputs(filter);
-
- // Perform type check
- if (mLogVerbose) Log.v(TAG, "Running type check on " + filter + "...");
- runTypeCheckOn(filter);
-
- // Push connected filters onto stack
- for (OutputPort port : filter.getOutputPorts()) {
- Filter target = port.getTargetFilter();
- if (target != null && readyForProcessing(target, processedFilters)) {
- filterStack.push(target);
- }
- }
- }
-
- // Make sure all ports were setup
- if (processedFilters.size() != getFilters().size()) {
- throw new RuntimeException("Could not schedule all filters! Is your graph malformed?");
- }
- }
-
- private void updateOutputs(Filter filter) {
- for (OutputPort outputPort : filter.getOutputPorts()) {
- InputPort inputPort = outputPort.getBasePort();
- if (inputPort != null) {
- FrameFormat inputFormat = inputPort.getSourceFormat();
- FrameFormat outputFormat = filter.getOutputFormat(outputPort.getName(),
- inputFormat);
- if (outputFormat == null) {
- throw new RuntimeException("Filter did not return an output format for "
- + outputPort + "!");
- }
- outputPort.setPortFormat(outputFormat);
- }
- }
- }
-
- private void runTypeCheckOn(Filter filter) {
- for (InputPort inputPort : filter.getInputPorts()) {
- if (mLogVerbose) Log.v(TAG, "Type checking port " + inputPort);
- FrameFormat sourceFormat = inputPort.getSourceFormat();
- FrameFormat targetFormat = inputPort.getPortFormat();
- if (sourceFormat != null && targetFormat != null) {
- if (mLogVerbose) Log.v(TAG, "Checking " + sourceFormat + " against " + targetFormat + ".");
-
- boolean compatible = true;
- switch (mTypeCheckMode) {
- case TYPECHECK_OFF:
- inputPort.setChecksType(false);
- break;
- case TYPECHECK_DYNAMIC:
- compatible = sourceFormat.mayBeCompatibleWith(targetFormat);
- inputPort.setChecksType(true);
- break;
- case TYPECHECK_STRICT:
- compatible = sourceFormat.isCompatibleWith(targetFormat);
- inputPort.setChecksType(false);
- break;
- }
-
- if (!compatible) {
- throw new RuntimeException("Type mismatch: Filter " + filter + " expects a "
- + "format of type " + targetFormat + " but got a format of type "
- + sourceFormat + "!");
- }
- }
- }
- }
-
- private void checkConnections() {
- // TODO
- }
-
- private void discardUnconnectedOutputs() {
- // Connect unconnected ports to Null filters
- LinkedList<Filter> addedFilters = new LinkedList<Filter>();
- for (Filter filter : mFilters) {
- int id = 0;
- for (OutputPort port : filter.getOutputPorts()) {
- if (!port.isConnected()) {
- if (mLogVerbose) Log.v(TAG, "Autoconnecting unconnected " + port + " to Null filter.");
- NullFilter nullFilter = new NullFilter(filter.getName() + "ToNull" + id);
- nullFilter.init();
- addedFilters.add(nullFilter);
- port.connectTo(nullFilter.getInputPort("frame"));
- ++id;
- }
- }
- }
- // Add all added filters to this graph
- for (Filter filter : addedFilters) {
- addFilter(filter);
- }
- }
-
- private void removeFilter(Filter filter) {
- mFilters.remove(filter);
- mNameMap.remove(filter.getName());
- }
-
- private void preconnect(OutputPort outPort, InputPort inPort) {
- LinkedList<InputPort> targets;
- targets = mPreconnections.get(outPort);
- if (targets == null) {
- targets = new LinkedList<InputPort>();
- mPreconnections.put(outPort, targets);
- }
- targets.add(inPort);
- }
-
- private void connectPorts() {
- int branchId = 1;
- for (Entry<OutputPort, LinkedList<InputPort>> connection : mPreconnections.entrySet()) {
- OutputPort outputPort = connection.getKey();
- LinkedList<InputPort> inputPorts = connection.getValue();
- if (inputPorts.size() == 1) {
- outputPort.connectTo(inputPorts.get(0));
- } else if (mAutoBranchMode == AUTOBRANCH_OFF) {
- throw new RuntimeException("Attempting to connect " + outputPort + " to multiple "
- + "filter ports! Enable auto-branching to allow this.");
- } else {
- if (mLogVerbose) Log.v(TAG, "Creating branch for " + outputPort + "!");
- FrameBranch branch = null;
- if (mAutoBranchMode == AUTOBRANCH_SYNCED) {
- branch = new FrameBranch("branch" + branchId++);
- } else {
- throw new RuntimeException("TODO: Unsynced branches not implemented yet!");
- }
- KeyValueMap branchParams = new KeyValueMap();
- branch.initWithAssignmentList("outputs", inputPorts.size());
- addFilter(branch);
- outputPort.connectTo(branch.getInputPort("in"));
- Iterator<InputPort> inputPortIter = inputPorts.iterator();
- for (OutputPort branchOutPort : ((Filter)branch).getOutputPorts()) {
- branchOutPort.connectTo(inputPortIter.next());
- }
- }
- }
- mPreconnections.clear();
- }
-
- private HashSet<Filter> getSourceFilters() {
- HashSet<Filter> sourceFilters = new HashSet<Filter>();
- for (Filter filter : getFilters()) {
- if (filter.getNumberOfConnectedInputs() == 0) {
- if (mLogVerbose) Log.v(TAG, "Found source filter: " + filter);
- sourceFilters.add(filter);
- }
- }
- return sourceFilters;
- }
-
- // Core internal methods /////////////////////////////////////////////////////////////////////////
- void setupFilters() {
- if (mDiscardUnconnectedOutputs) {
- discardUnconnectedOutputs();
- }
- connectPorts();
- checkConnections();
- runTypeCheck();
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FilterPort.java b/mca/filterfw/java/android/filterfw/core/FilterPort.java
deleted file mode 100644
index 9734b89..0000000
--- a/mca/filterfw/java/android/filterfw/core/FilterPort.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FrameFormat;
-import android.util.Log;
-
-/**
- * @hide
- */
-public abstract class FilterPort {
-
- protected Filter mFilter;
- protected String mName;
- protected FrameFormat mPortFormat;
- protected boolean mIsBlocking = true;
- protected boolean mIsOpen = false;
- protected boolean mChecksType = false;
- private boolean mLogVerbose;
- private static final String TAG = "FilterPort";
-
- public FilterPort(Filter filter, String name) {
- mName = name;
- mFilter = filter;
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- public boolean isAttached() {
- return mFilter != null;
- }
-
- public FrameFormat getPortFormat() {
- return mPortFormat;
- }
-
- public void setPortFormat(FrameFormat format) {
- mPortFormat = format;
- }
-
- public Filter getFilter() {
- return mFilter;
- }
-
- public String getName() {
- return mName;
- }
-
- public void setBlocking(boolean blocking) {
- mIsBlocking = blocking;
- }
-
- public void setChecksType(boolean checksType) {
- mChecksType = checksType;
- }
-
- public void open() {
- if (!mIsOpen) {
- if (mLogVerbose) Log.v(TAG, "Opening " + this);
- }
- mIsOpen = true;
- }
-
- public void close() {
- if (mIsOpen) {
- if (mLogVerbose) Log.v(TAG, "Closing " + this);
- }
- mIsOpen = false;
- }
-
- public boolean isOpen() {
- return mIsOpen;
- }
-
- public boolean isBlocking() {
- return mIsBlocking;
- }
-
- public abstract boolean filterMustClose();
-
- public abstract boolean isReady();
-
- public abstract void pushFrame(Frame frame);
-
- public abstract void setFrame(Frame frame);
-
- public abstract Frame pullFrame();
-
- public abstract boolean hasFrame();
-
- public abstract void clear();
-
- public String toString() {
- return "port '" + mName + "' of " + mFilter;
- }
-
- protected void assertPortIsOpen() {
- if (!isOpen()) {
- throw new RuntimeException("Illegal operation on closed " + this + "!");
- }
- }
-
- protected void checkFrameType(Frame frame, boolean forceCheck) {
- if ((mChecksType || forceCheck)
- && mPortFormat != null
- && !frame.getFormat().isCompatibleWith(mPortFormat)) {
- throw new RuntimeException("Frame passed to " + this + " is of incorrect type! "
- + "Expected " + mPortFormat + " but got " + frame.getFormat());
- }
- }
-
- protected void checkFrameManager(Frame frame, FilterContext context) {
- if (frame.getFrameManager() != null
- && frame.getFrameManager() != context.getFrameManager()) {
- throw new RuntimeException("Frame " + frame + " is managed by foreign FrameManager! ");
- }
- }
-}
-
diff --git a/mca/filterfw/java/android/filterfw/core/FilterSurfaceView.java b/mca/filterfw/java/android/filterfw/core/FilterSurfaceView.java
deleted file mode 100644
index 49306b2..0000000
--- a/mca/filterfw/java/android/filterfw/core/FilterSurfaceView.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-/**
- * @hide
- */
-public class FilterSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
-
- private static int STATE_ALLOCATED = 0;
- private static int STATE_CREATED = 1;
- private static int STATE_INITIALIZED = 2;
-
- private int mState = STATE_ALLOCATED;
- private SurfaceHolder.Callback mListener;
- private GLEnvironment mGLEnv;
- private int mFormat;
- private int mWidth;
- private int mHeight;
- private int mSurfaceId = -1;
-
- public FilterSurfaceView(Context context) {
- super(context);
- getHolder().addCallback(this);
- }
-
- public FilterSurfaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
- getHolder().addCallback(this);
- }
-
- public synchronized void bindToListener(SurfaceHolder.Callback listener, GLEnvironment glEnv) {
- // Make sure we are not bound already
- if (listener == null) {
- throw new NullPointerException("Attempting to bind null filter to SurfaceView!");
- } else if (mListener != null && mListener != listener) {
- throw new RuntimeException(
- "Attempting to bind filter " + listener + " to SurfaceView with another open "
- + "filter " + mListener + " attached already!");
- }
-
- // Set listener
- mListener = listener;
-
- // Set GLEnv
- if (mGLEnv != null && mGLEnv != glEnv) {
- mGLEnv.unregisterSurfaceId(mSurfaceId);
- }
- mGLEnv = glEnv;
-
- // Check if surface has been created already
- if (mState >= STATE_CREATED) {
- // Register with env (double registration will be ignored by GLEnv, so we can simply
- // try to do it here).
- registerSurface();
-
- // Forward surface created to listener
- mListener.surfaceCreated(getHolder());
-
- // Forward surface changed to listener
- if (mState == STATE_INITIALIZED) {
- mListener.surfaceChanged(getHolder(), mFormat, mWidth, mHeight);
- }
- }
- }
-
- public synchronized void unbind() {
- mListener = null;
- }
-
- public synchronized int getSurfaceId() {
- return mSurfaceId;
- }
-
- public synchronized GLEnvironment getGLEnv() {
- return mGLEnv;
- }
-
- @Override
- public synchronized void surfaceCreated(SurfaceHolder holder) {
- mState = STATE_CREATED;
-
- // Register with GLEnvironment if we have it already
- if (mGLEnv != null) {
- registerSurface();
- }
-
- // Forward callback to listener
- if (mListener != null) {
- mListener.surfaceCreated(holder);
- }
- }
-
- @Override
- public synchronized void surfaceChanged(SurfaceHolder holder,
- int format,
- int width,
- int height) {
- // Remember these values
- mFormat = format;
- mWidth = width;
- mHeight = height;
- mState = STATE_INITIALIZED;
-
- // Forward to renderer
- if (mListener != null) {
- mListener.surfaceChanged(holder, format, width, height);
- }
- }
-
- @Override
- public synchronized void surfaceDestroyed(SurfaceHolder holder) {
- mState = STATE_ALLOCATED;
-
- // Forward to renderer
- if (mListener != null) {
- mListener.surfaceDestroyed(holder);
- }
-
- // Get rid of internal objects associated with this surface
- unregisterSurface();
- }
-
- private void registerSurface() {
- mSurfaceId = mGLEnv.registerSurface(getHolder().getSurface());
- if (mSurfaceId < 0) {
- throw new RuntimeException("Could not register Surface: " + getHolder().getSurface() +
- " in FilterSurfaceView!");
- }
- }
- private void unregisterSurface() {
- if (mGLEnv != null && mSurfaceId > 0) {
- mGLEnv.unregisterSurfaceId(mSurfaceId);
- }
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FinalPort.java b/mca/filterfw/java/android/filterfw/core/FinalPort.java
deleted file mode 100644
index ad65169..0000000
--- a/mca/filterfw/java/android/filterfw/core/FinalPort.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.lang.reflect.Field;
-
-/**
- * @hide
- */
-public class FinalPort extends FieldPort {
-
- public FinalPort(Filter filter, String name, Field field, boolean hasDefault) {
- super(filter, name, field, hasDefault);
- }
-
- @Override
- protected synchronized void setFieldFrame(Frame frame, boolean isAssignment) {
- assertPortIsOpen();
- checkFrameType(frame, isAssignment);
- if (mFilter.getStatus() != Filter.STATUS_PREINIT) {
- throw new RuntimeException("Attempting to modify " + this + "!");
- } else {
- super.setFieldFrame(frame, isAssignment);
- super.transfer(null);
- }
- }
-
- @Override
- public String toString() {
- return "final " + super.toString();
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/Frame.java b/mca/filterfw/java/android/filterfw/core/Frame.java
deleted file mode 100644
index ef8c542..0000000
--- a/mca/filterfw/java/android/filterfw/core/Frame.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.graphics.Bitmap;
-import android.util.Log;
-
-import java.nio.ByteBuffer;
-
-/**
- * @hide
- */
-public abstract class Frame {
-
- public final static int NO_BINDING = 0;
-
- public final static long TIMESTAMP_NOT_SET = -2;
- public final static long TIMESTAMP_UNKNOWN = -1;
-
- private FrameFormat mFormat;
- private FrameManager mFrameManager;
- private boolean mReadOnly = false;
- private boolean mReusable = false;
- private int mRefCount = 1;
- private int mBindingType = NO_BINDING;
- private long mBindingId = 0;
- private long mTimestamp = TIMESTAMP_NOT_SET;
-
- Frame(FrameFormat format, FrameManager frameManager) {
- mFormat = format.mutableCopy();
- mFrameManager = frameManager;
- }
-
- Frame(FrameFormat format, FrameManager frameManager, int bindingType, long bindingId) {
- mFormat = format.mutableCopy();
- mFrameManager = frameManager;
- mBindingType = bindingType;
- mBindingId = bindingId;
- }
-
- public FrameFormat getFormat() {
- return mFormat;
- }
-
- public int getCapacity() {
- return getFormat().getSize();
- }
-
- public boolean isReadOnly() {
- return mReadOnly;
- }
-
- public int getBindingType() {
- return mBindingType;
- }
-
- public long getBindingId() {
- return mBindingId;
- }
-
- public void setObjectValue(Object object) {
- assertFrameMutable();
-
- // Attempt to set the value using a specific setter (which may be more optimized), and
- // fall back to the setGenericObjectValue(...) in case of no match.
- if (object instanceof int[]) {
- setInts((int[])object);
- } else if (object instanceof float[]) {
- setFloats((float[])object);
- } else if (object instanceof ByteBuffer) {
- setData((ByteBuffer)object);
- } else if (object instanceof Bitmap) {
- setBitmap((Bitmap)object);
- } else {
- setGenericObjectValue(object);
- }
- }
-
- public abstract Object getObjectValue();
-
- public abstract void setInts(int[] ints);
-
- public abstract int[] getInts();
-
- public abstract void setFloats(float[] floats);
-
- public abstract float[] getFloats();
-
- public abstract void setData(ByteBuffer buffer, int offset, int length);
-
- public void setData(ByteBuffer buffer) {
- setData(buffer, 0, buffer.limit());
- }
-
- public void setData(byte[] bytes, int offset, int length) {
- setData(ByteBuffer.wrap(bytes, offset, length));
- }
-
- public abstract ByteBuffer getData();
-
- public abstract void setBitmap(Bitmap bitmap);
-
- public abstract Bitmap getBitmap();
-
- public void setTimestamp(long timestamp) {
- mTimestamp = timestamp;
- }
-
- public long getTimestamp() {
- return mTimestamp;
- }
-
- public void setDataFromFrame(Frame frame) {
- setData(frame.getData());
- }
-
- protected boolean requestResize(int[] newDimensions) {
- return false;
- }
-
- public int getRefCount() {
- return mRefCount;
- }
-
- public Frame release() {
- if (mFrameManager != null) {
- return mFrameManager.releaseFrame(this);
- } else {
- return this;
- }
- }
-
- public Frame retain() {
- if (mFrameManager != null) {
- return mFrameManager.retainFrame(this);
- } else {
- return this;
- }
- }
-
- public FrameManager getFrameManager() {
- return mFrameManager;
- }
-
- protected void assertFrameMutable() {
- if (isReadOnly()) {
- throw new RuntimeException("Attempting to modify read-only frame!");
- }
- }
-
- protected void setReusable(boolean reusable) {
- mReusable = reusable;
- }
-
- protected void setFormat(FrameFormat format) {
- mFormat = format.mutableCopy();
- }
-
- protected void setGenericObjectValue(Object value) {
- throw new RuntimeException(
- "Cannot set object value of unsupported type: " + value.getClass());
- }
-
- protected static Bitmap convertBitmapToRGBA(Bitmap bitmap) {
- if (bitmap.getConfig() == Bitmap.Config.ARGB_8888) {
- return bitmap;
- } else {
- Bitmap result = bitmap.copy(Bitmap.Config.ARGB_8888, false);
- if (result == null) {
- throw new RuntimeException("Error converting bitmap to RGBA!");
- } else if (result.getRowBytes() != result.getWidth() * 4) {
- throw new RuntimeException("Unsupported row byte count in bitmap!");
- }
- return result;
- }
- }
-
- protected void reset(FrameFormat newFormat) {
- mFormat = newFormat.mutableCopy();
- mReadOnly = false;
- mRefCount = 1;
- }
-
- /**
- * Called just before a frame is stored, such as when storing to a cache or context.
- */
- protected void onFrameStore() {
- }
-
- /**
- * Called when a frame is fetched from an internal store such as a cache.
- */
- protected void onFrameFetch() {
- }
-
- // Core internal methods ///////////////////////////////////////////////////////////////////////
- protected abstract boolean hasNativeAllocation();
-
- protected abstract void releaseNativeAllocation();
-
- final int incRefCount() {
- ++mRefCount;
- return mRefCount;
- }
-
- final int decRefCount() {
- --mRefCount;
- return mRefCount;
- }
-
- final boolean isReusable() {
- return mReusable;
- }
-
- final void markReadOnly() {
- mReadOnly = true;
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FrameFormat.java b/mca/filterfw/java/android/filterfw/core/FrameFormat.java
deleted file mode 100644
index 8f619be..0000000
--- a/mca/filterfw/java/android/filterfw/core/FrameFormat.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-
-import java.util.Arrays;
-import java.util.Map.Entry;
-
-/**
- * @hide
- */
-public class FrameFormat {
-
- public static final int TYPE_UNSPECIFIED = 0;
- public static final int TYPE_BIT = 1;
- public static final int TYPE_BYTE = 2;
- public static final int TYPE_INT16 = 3;
- public static final int TYPE_INT32 = 4;
- public static final int TYPE_FLOAT = 5;
- public static final int TYPE_DOUBLE = 6;
- public static final int TYPE_POINTER = 7;
- public static final int TYPE_OBJECT = 8;
-
- public static final int TARGET_UNSPECIFIED = 0;
- public static final int TARGET_SIMPLE = 1;
- public static final int TARGET_NATIVE = 2;
- public static final int TARGET_GPU = 3;
- public static final int TARGET_VERTEXBUFFER = 4;
- public static final int TARGET_RS = 5;
-
- public static final int SIZE_UNSPECIFIED = 0;
-
- // TODO: When convenience formats are used, consider changing this to 0 and have the convenience
- // intializers use a proper BPS.
- public static final int BYTES_PER_SAMPLE_UNSPECIFIED = 1;
-
- protected static final int SIZE_UNKNOWN = -1;
-
- protected int mBaseType = TYPE_UNSPECIFIED;
- protected int mBytesPerSample = 1;
- protected int mSize = SIZE_UNKNOWN;
- protected int mTarget = TARGET_UNSPECIFIED;
- protected int[] mDimensions;
- protected KeyValueMap mMetaData;
- protected Class mObjectClass;
-
- protected FrameFormat() {
- }
-
- public FrameFormat(int baseType, int target) {
- mBaseType = baseType;
- mTarget = target;
- initDefaults();
- }
-
- public static FrameFormat unspecified() {
- return new FrameFormat(TYPE_UNSPECIFIED, TARGET_UNSPECIFIED);
- }
-
- public int getBaseType() {
- return mBaseType;
- }
-
- public boolean isBinaryDataType() {
- return mBaseType >= TYPE_BIT && mBaseType <= TYPE_DOUBLE;
- }
-
- public int getBytesPerSample() {
- return mBytesPerSample;
- }
-
- public int getValuesPerSample() {
- return mBytesPerSample / bytesPerSampleOf(mBaseType);
- }
-
- public int getTarget() {
- return mTarget;
- }
-
- public int[] getDimensions() {
- return mDimensions;
- }
-
- public int getDimension(int i) {
- return mDimensions[i];
- }
-
- public int getDimensionCount() {
- return mDimensions == null ? 0 : mDimensions.length;
- }
-
- public boolean hasMetaKey(String key) {
- return mMetaData != null ? mMetaData.containsKey(key) : false;
- }
-
- public boolean hasMetaKey(String key, Class expectedClass) {
- if (mMetaData != null && mMetaData.containsKey(key)) {
- if (!expectedClass.isAssignableFrom(mMetaData.get(key).getClass())) {
- throw new RuntimeException(
- "FrameFormat meta-key '" + key + "' is of type " +
- mMetaData.get(key).getClass() + " but expected to be of type " +
- expectedClass + "!");
- }
- return true;
- }
- return false;
- }
-
- public Object getMetaValue(String key) {
- return mMetaData != null ? mMetaData.get(key) : null;
- }
-
- public int getNumberOfDimensions() {
- return mDimensions != null ? mDimensions.length : 0;
- }
-
- public int getLength() {
- return (mDimensions != null && mDimensions.length >= 1) ? mDimensions[0] : -1;
- }
-
- public int getWidth() {
- return getLength();
- }
-
- public int getHeight() {
- return (mDimensions != null && mDimensions.length >= 2) ? mDimensions[1] : -1;
- }
-
- public int getDepth() {
- return (mDimensions != null && mDimensions.length >= 3) ? mDimensions[2] : -1;
- }
-
- public int getSize() {
- if (mSize == SIZE_UNKNOWN) mSize = calcSize(mDimensions);
- return mSize;
- }
-
- public Class getObjectClass() {
- return mObjectClass;
- }
-
- public MutableFrameFormat mutableCopy() {
- MutableFrameFormat result = new MutableFrameFormat();
- result.setBaseType(getBaseType());
- result.setTarget(getTarget());
- result.setBytesPerSample(getBytesPerSample());
- result.setDimensions(getDimensions());
- result.setObjectClass(getObjectClass());
- result.mMetaData = mMetaData == null ? null : (KeyValueMap)mMetaData.clone();
- return result;
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
-
- if (!(object instanceof FrameFormat)) {
- return false;
- }
-
- FrameFormat format = (FrameFormat)object;
- return format.mBaseType == mBaseType &&
- format.mTarget == mTarget &&
- format.mBytesPerSample == mBytesPerSample &&
- Arrays.equals(format.mDimensions, mDimensions) &&
- format.mMetaData.equals(mMetaData);
- }
-
- @Override
- public int hashCode() {
- return 4211 ^ mBaseType ^ mBytesPerSample ^ getSize();
- }
-
- public boolean isCompatibleWith(FrameFormat specification) {
- // Check base type
- if (specification.getBaseType() != TYPE_UNSPECIFIED
- && getBaseType() != specification.getBaseType()) {
- return false;
- }
-
- // Check target
- if (specification.getTarget() != TARGET_UNSPECIFIED
- && getTarget() != specification.getTarget()) {
- return false;
- }
-
- // Check bytes per sample
- if (specification.getBytesPerSample() != BYTES_PER_SAMPLE_UNSPECIFIED
- && getBytesPerSample() != specification.getBytesPerSample()) {
- return false;
- }
-
- // Check number of dimensions
- if (specification.getDimensionCount() > 0
- && getDimensionCount() != specification.getDimensionCount()) {
- return false;
- }
-
- // Check dimensions
- for (int i = 0; i < specification.getDimensionCount(); ++i) {
- int specDim = specification.getDimension(i);
- if (specDim != SIZE_UNSPECIFIED && getDimension(i) != specDim) {
- return false;
- }
- }
-
- // Check class
- if (specification.getObjectClass() != null) {
- if (getObjectClass() == null
- || !specification.getObjectClass().isAssignableFrom(getObjectClass())) {
- return false;
- }
- }
-
- // Check meta-data
- if (specification.mMetaData != null) {
- for (String specKey : specification.mMetaData.keySet()) {
- if (mMetaData == null
- || !mMetaData.containsKey(specKey)
- || !mMetaData.get(specKey).equals(specification.mMetaData.get(specKey))) {
- return false;
- }
- }
- }
-
- // Passed all the tests
- return true;
- }
-
- public boolean mayBeCompatibleWith(FrameFormat specification) {
- // Check base type
- if (specification.getBaseType() != TYPE_UNSPECIFIED
- && getBaseType() != TYPE_UNSPECIFIED
- && getBaseType() != specification.getBaseType()) {
- return false;
- }
-
- // Check target
- if (specification.getTarget() != TARGET_UNSPECIFIED
- && getTarget() != TARGET_UNSPECIFIED
- && getTarget() != specification.getTarget()) {
- return false;
- }
-
- // Check bytes per sample
- if (specification.getBytesPerSample() != BYTES_PER_SAMPLE_UNSPECIFIED
- && getBytesPerSample() != BYTES_PER_SAMPLE_UNSPECIFIED
- && getBytesPerSample() != specification.getBytesPerSample()) {
- return false;
- }
-
- // Check number of dimensions
- if (specification.getDimensionCount() > 0
- && getDimensionCount() > 0
- && getDimensionCount() != specification.getDimensionCount()) {
- return false;
- }
-
- // Check dimensions
- for (int i = 0; i < specification.getDimensionCount(); ++i) {
- int specDim = specification.getDimension(i);
- if (specDim != SIZE_UNSPECIFIED
- && getDimension(i) != SIZE_UNSPECIFIED
- && getDimension(i) != specDim) {
- return false;
- }
- }
-
- // Check class
- if (specification.getObjectClass() != null && getObjectClass() != null) {
- if (!specification.getObjectClass().isAssignableFrom(getObjectClass())) {
- return false;
- }
- }
-
- // Check meta-data
- if (specification.mMetaData != null && mMetaData != null) {
- for (String specKey : specification.mMetaData.keySet()) {
- if (mMetaData.containsKey(specKey)
- && !mMetaData.get(specKey).equals(specification.mMetaData.get(specKey))) {
- return false;
- }
- }
- }
-
- // Passed all the tests
- return true;
- }
-
- public static int bytesPerSampleOf(int baseType) {
- // Defaults based on base-type
- switch (baseType) {
- case TYPE_BIT:
- case TYPE_BYTE:
- return 1;
- case TYPE_INT16:
- return 2;
- case TYPE_INT32:
- case TYPE_FLOAT:
- case TYPE_POINTER:
- return 4;
- case TYPE_DOUBLE:
- return 8;
- default:
- return 1;
- }
- }
-
- public static String dimensionsToString(int[] dimensions) {
- StringBuffer buffer = new StringBuffer();
- if (dimensions != null) {
- int n = dimensions.length;
- for (int i = 0; i < n; ++i) {
- if (dimensions[i] == SIZE_UNSPECIFIED) {
- buffer.append("[]");
- } else {
- buffer.append("[" + String.valueOf(dimensions[i]) + "]");
- }
- }
- }
- return buffer.toString();
- }
-
- public static String baseTypeToString(int baseType) {
- switch (baseType) {
- case TYPE_UNSPECIFIED: return "unspecified";
- case TYPE_BIT: return "bit";
- case TYPE_BYTE: return "byte";
- case TYPE_INT16: return "int";
- case TYPE_INT32: return "int";
- case TYPE_FLOAT: return "float";
- case TYPE_DOUBLE: return "double";
- case TYPE_POINTER: return "pointer";
- case TYPE_OBJECT: return "object";
- default: return "unknown";
- }
- }
-
- public static String targetToString(int target) {
- switch (target) {
- case TARGET_UNSPECIFIED: return "unspecified";
- case TARGET_SIMPLE: return "simple";
- case TARGET_NATIVE: return "native";
- case TARGET_GPU: return "gpu";
- case TARGET_VERTEXBUFFER: return "vbo";
- case TARGET_RS: return "renderscript";
- default: return "unknown";
- }
- }
-
- public static String metaDataToString(KeyValueMap metaData) {
- if (metaData == null) {
- return "";
- } else {
- StringBuffer buffer = new StringBuffer();
- buffer.append("{ ");
- for (Entry<String, Object> entry : metaData.entrySet()) {
- buffer.append(entry.getKey() + ": " + entry.getValue() + " ");
- }
- buffer.append("}");
- return buffer.toString();
- }
- }
-
- public static int readTargetString(String targetString) {
- if (targetString.equalsIgnoreCase("CPU") || targetString.equalsIgnoreCase("NATIVE")) {
- return FrameFormat.TARGET_NATIVE;
- } else if (targetString.equalsIgnoreCase("GPU")) {
- return FrameFormat.TARGET_GPU;
- } else if (targetString.equalsIgnoreCase("SIMPLE")) {
- return FrameFormat.TARGET_SIMPLE;
- } else if (targetString.equalsIgnoreCase("VERTEXBUFFER")) {
- return FrameFormat.TARGET_VERTEXBUFFER;
- } else if (targetString.equalsIgnoreCase("UNSPECIFIED")) {
- return FrameFormat.TARGET_UNSPECIFIED;
- } else {
- throw new RuntimeException("Unknown target type '" + targetString + "'!");
- }
- }
-
- // TODO: FromString
-
- public String toString() {
- int valuesPerSample = getValuesPerSample();
- String sampleCountString = valuesPerSample == 1 ? "" : String.valueOf(valuesPerSample);
- String targetString = mTarget == TARGET_UNSPECIFIED ? "" : (targetToString(mTarget) + " ");
- String classString = mObjectClass == null
- ? ""
- : (" class(" + mObjectClass.getSimpleName() + ") ");
-
- return targetString
- + baseTypeToString(mBaseType)
- + sampleCountString
- + dimensionsToString(mDimensions)
- + classString
- + metaDataToString(mMetaData);
- }
-
- private void initDefaults() {
- mBytesPerSample = bytesPerSampleOf(mBaseType);
- }
-
- // Core internal methods ///////////////////////////////////////////////////////////////////////
- int calcSize(int[] dimensions) {
- if (dimensions != null && dimensions.length > 0) {
- int size = getBytesPerSample();
- for (int dim : dimensions) {
- size *= dim;
- }
- return size;
- }
- return 0;
- }
-
- boolean isReplaceableBy(FrameFormat format) {
- return mTarget == format.mTarget
- && getSize() == format.getSize()
- && Arrays.equals(format.mDimensions, mDimensions);
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/FrameManager.java b/mca/filterfw/java/android/filterfw/core/FrameManager.java
deleted file mode 100644
index 8d6c483..0000000
--- a/mca/filterfw/java/android/filterfw/core/FrameManager.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.MutableFrameFormat;
-
-/**
- * @hide
- */
-public abstract class FrameManager {
-
- private FilterContext mContext;
-
- public abstract Frame newFrame(FrameFormat format);
-
- public abstract Frame newBoundFrame(FrameFormat format, int bindingType, long bindingId);
-
- public Frame duplicateFrame(Frame frame) {
- Frame result = newFrame(frame.getFormat());
- result.setDataFromFrame(frame);
- return result;
- }
-
- public Frame duplicateFrameToTarget(Frame frame, int newTarget) {
- MutableFrameFormat newFormat = frame.getFormat().mutableCopy();
- newFormat.setTarget(newTarget);
- Frame result = newFrame(newFormat);
- result.setDataFromFrame(frame);
- return result;
- }
-
- public abstract Frame retainFrame(Frame frame);
-
- public abstract Frame releaseFrame(Frame frame);
-
- public FilterContext getContext() {
- return mContext;
- }
-
- public GLEnvironment getGLEnvironment() {
- return mContext != null ? mContext.getGLEnvironment() : null;
- }
-
- public void tearDown() {
- }
-
- void setContext(FilterContext context) {
- mContext = context;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/GLEnvironment.java b/mca/filterfw/java/android/filterfw/core/GLEnvironment.java
deleted file mode 100644
index f887d6b..0000000
--- a/mca/filterfw/java/android/filterfw/core/GLEnvironment.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.NativeAllocatorTag;
-import android.graphics.SurfaceTexture;
-import android.os.Looper;
-import android.util.Log;
-import android.view.Surface;
-import android.media.MediaRecorder;
-
-/**
- * @hide
- */
-public class GLEnvironment {
-
- private int glEnvId;
-
- public GLEnvironment() {
- nativeAllocate();
- }
-
- private GLEnvironment(NativeAllocatorTag tag) {
- }
-
- public synchronized void tearDown() {
- if (glEnvId != -1) {
- nativeDeallocate();
- glEnvId = -1;
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- tearDown();
- }
-
- public void initWithNewContext() {
- if (!nativeInitWithNewContext()) {
- throw new RuntimeException("Could not initialize GLEnvironment with new context!");
- }
- }
-
- public void initWithCurrentContext() {
- if (!nativeInitWithCurrentContext()) {
- throw new RuntimeException("Could not initialize GLEnvironment with current context!");
- }
- }
-
- public boolean isActive() {
- return nativeIsActive();
- }
-
- public boolean isContextActive() {
- return nativeIsContextActive();
- }
-
- public static boolean isAnyContextActive() {
- return nativeIsAnyContextActive();
- }
-
- public void activate() {
- if (Looper.myLooper() != null && Looper.myLooper().equals(Looper.getMainLooper())) {
- Log.e("FilterFramework", "Activating GL context in UI thread!");
- }
- if (!nativeActivate()) {
- throw new RuntimeException("Could not activate GLEnvironment!");
- }
- }
-
- public void deactivate() {
- if (!nativeDeactivate()) {
- throw new RuntimeException("Could not deactivate GLEnvironment!");
- }
- }
-
- public void swapBuffers() {
- if (!nativeSwapBuffers()) {
- throw new RuntimeException("Error swapping EGL buffers!");
- }
- }
-
- public int registerSurface(Surface surface) {
- int result = nativeAddSurface(surface);
- if (result < 0) {
- throw new RuntimeException("Error registering surface " + surface + "!");
- }
- return result;
- }
-
- public int registerSurfaceTexture(SurfaceTexture surfaceTexture, int width, int height) {
- int result = nativeAddSurfaceTexture(surfaceTexture, width, height);
- if (result < 0) {
- throw new RuntimeException("Error registering surfaceTexture " + surfaceTexture + "!");
- }
- return result;
- }
-
- public int registerSurfaceFromMediaRecorder(MediaRecorder mediaRecorder) {
- int result = nativeAddSurfaceFromMediaRecorder(mediaRecorder);
- if (result < 0) {
- throw new RuntimeException("Error registering surface from "
- + "MediaRecorder" + mediaRecorder + "!");
- }
- return result;
- }
-
- public void activateSurfaceWithId(int surfaceId) {
- if (!nativeActivateSurfaceId(surfaceId)) {
- throw new RuntimeException("Could not activate surface " + surfaceId + "!");
- }
- }
-
- public void unregisterSurfaceId(int surfaceId) {
- if (!nativeRemoveSurfaceId(surfaceId)) {
- throw new RuntimeException("Could not unregister surface " + surfaceId + "!");
- }
- }
-
- public void setSurfaceTimestamp(long timestamp) {
- if (!nativeSetSurfaceTimestamp(timestamp)) {
- throw new RuntimeException("Could not set timestamp for current surface!");
- }
- }
-
- static {
- System.loadLibrary("filterfw");
- }
-
- private native boolean nativeInitWithNewContext();
-
- private native boolean nativeInitWithCurrentContext();
-
- private native boolean nativeIsActive();
-
- private native boolean nativeIsContextActive();
-
- private static native boolean nativeIsAnyContextActive();
-
- private native boolean nativeActivate();
-
- private native boolean nativeDeactivate();
-
- private native boolean nativeSwapBuffers();
-
- private native boolean nativeAllocate();
-
- private native boolean nativeDeallocate();
-
- private native int nativeAddSurface(Surface surface);
-
- private native int nativeAddSurfaceTexture(SurfaceTexture surface, int width, int height);
-
- private native int nativeAddSurfaceFromMediaRecorder(MediaRecorder mediaRecorder);
-
- private native boolean nativeDisconnectSurfaceMediaSource(MediaRecorder mediaRecorder);
-
- private native boolean nativeActivateSurfaceId(int surfaceId);
-
- private native boolean nativeRemoveSurfaceId(int surfaceId);
-
- private native boolean nativeSetSurfaceTimestamp(long timestamp);
-}
diff --git a/mca/filterfw/java/android/filterfw/core/GLFrame.java b/mca/filterfw/java/android/filterfw/core/GLFrame.java
deleted file mode 100644
index 1558cc6..0000000
--- a/mca/filterfw/java/android/filterfw/core/GLFrame.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.StopWatchMap;
-import android.graphics.Bitmap;
-import android.opengl.GLES20;
-import android.graphics.Rect;
-
-import java.nio.ByteBuffer;
-
-class GLFrameTimer {
-
- private static StopWatchMap mTimer = null;
-
- public static StopWatchMap get() {
- if (mTimer == null) {
- mTimer = new StopWatchMap();
- }
- return mTimer;
- }
-
-}
-
-/**
- * @hide
- */
-public class GLFrame extends Frame {
-
- // GL-related binding types
- public final static int EXISTING_TEXTURE_BINDING = 100;
- public final static int EXISTING_FBO_BINDING = 101;
- public final static int NEW_TEXTURE_BINDING = 102; // TODO: REMOVE THIS
- public final static int NEW_FBO_BINDING = 103; // TODO: REMOVE THIS
- public final static int EXTERNAL_TEXTURE = 104;
-
- private int glFrameId = -1;
-
- /**
- * Flag whether we own the texture or not. If we do not, we must be careful when caching or
- * storing the frame, as the user may delete, and regenerate it.
- */
- private boolean mOwnsTexture = true;
-
- /**
- * Keep a reference to the GL environment, so that it does not get deallocated while there
- * are still frames living in it.
- */
- private GLEnvironment mGLEnvironment;
-
- GLFrame(FrameFormat format, FrameManager frameManager) {
- super(format, frameManager);
- }
-
- GLFrame(FrameFormat format, FrameManager frameManager, int bindingType, long bindingId) {
- super(format, frameManager, bindingType, bindingId);
- }
-
- void init(GLEnvironment glEnv) {
- FrameFormat format = getFormat();
- mGLEnvironment = glEnv;
-
- // Check that we have a valid format
- if (format.getBytesPerSample() != 4) {
- throw new IllegalArgumentException("GL frames must have 4 bytes per sample!");
- } else if (format.getDimensionCount() != 2) {
- throw new IllegalArgumentException("GL frames must be 2-dimensional!");
- } else if (getFormat().getSize() < 0) {
- throw new IllegalArgumentException("Initializing GL frame with zero size!");
- }
-
- // Create correct frame
- int bindingType = getBindingType();
- boolean reusable = true;
- if (bindingType == Frame.NO_BINDING) {
- initNew(false);
- } else if (bindingType == EXTERNAL_TEXTURE) {
- initNew(true);
- reusable = false;
- } else if (bindingType == EXISTING_TEXTURE_BINDING) {
- initWithTexture((int)getBindingId());
- } else if (bindingType == EXISTING_FBO_BINDING) {
- initWithFbo((int)getBindingId());
- } else if (bindingType == NEW_TEXTURE_BINDING) {
- initWithTexture((int)getBindingId());
- } else if (bindingType == NEW_FBO_BINDING) {
- initWithFbo((int)getBindingId());
- } else {
- throw new RuntimeException("Attempting to create GL frame with unknown binding type "
- + bindingType + "!");
- }
- setReusable(reusable);
- }
-
- private void initNew(boolean isExternal) {
- if (isExternal) {
- if (!nativeAllocateExternal(mGLEnvironment)) {
- throw new RuntimeException("Could not allocate external GL frame!");
- }
- } else {
- if (!nativeAllocate(mGLEnvironment, getFormat().getWidth(), getFormat().getHeight())) {
- throw new RuntimeException("Could not allocate GL frame!");
- }
- }
- }
-
- private void initWithTexture(int texId) {
- int width = getFormat().getWidth();
- int height = getFormat().getHeight();
- if (!nativeAllocateWithTexture(mGLEnvironment, texId, width, height)) {
- throw new RuntimeException("Could not allocate texture backed GL frame!");
- }
- mOwnsTexture = false;
- markReadOnly();
- }
-
- private void initWithFbo(int fboId) {
- int width = getFormat().getWidth();
- int height = getFormat().getHeight();
- if (!nativeAllocateWithFbo(mGLEnvironment, fboId, width, height)) {
- throw new RuntimeException("Could not allocate FBO backed GL frame!");
- }
- }
-
- void flushGPU(String message) {
- StopWatchMap timer = GLFrameTimer.get();
- if (timer.LOG_MFF_RUNNING_TIMES) {
- timer.start("glFinish " + message);
- GLES20.glFinish();
- timer.stop("glFinish " + message);
- }
- }
-
- @Override
- protected synchronized boolean hasNativeAllocation() {
- return glFrameId != -1;
- }
-
- @Override
- protected synchronized void releaseNativeAllocation() {
- nativeDeallocate();
- glFrameId = -1;
- }
-
- public GLEnvironment getGLEnvironment() {
- return mGLEnvironment;
- }
-
- @Override
- public Object getObjectValue() {
- assertGLEnvValid();
- return ByteBuffer.wrap(getNativeData());
- }
-
- @Override
- public void setInts(int[] ints) {
- assertFrameMutable();
- assertGLEnvValid();
- if (!setNativeInts(ints)) {
- throw new RuntimeException("Could not set int values for GL frame!");
- }
- }
-
- @Override
- public int[] getInts() {
- assertGLEnvValid();
- flushGPU("getInts");
- return getNativeInts();
- }
-
- @Override
- public void setFloats(float[] floats) {
- assertFrameMutable();
- assertGLEnvValid();
- if (!setNativeFloats(floats)) {
- throw new RuntimeException("Could not set int values for GL frame!");
- }
- }
-
- @Override
- public float[] getFloats() {
- assertGLEnvValid();
- flushGPU("getFloats");
- return getNativeFloats();
- }
-
- @Override
- public void setData(ByteBuffer buffer, int offset, int length) {
- assertFrameMutable();
- assertGLEnvValid();
- byte[] bytes = buffer.array();
- if (getFormat().getSize() != bytes.length) {
- throw new RuntimeException("Data size in setData does not match GL frame size!");
- } else if (!setNativeData(bytes, offset, length)) {
- throw new RuntimeException("Could not set GL frame data!");
- }
- }
-
- @Override
- public ByteBuffer getData() {
- assertGLEnvValid();
- flushGPU("getData");
- return ByteBuffer.wrap(getNativeData());
- }
-
- @Override
- public void setBitmap(Bitmap bitmap) {
- assertFrameMutable();
- assertGLEnvValid();
- if (getFormat().getWidth() != bitmap.getWidth() ||
- getFormat().getHeight() != bitmap.getHeight()) {
- throw new RuntimeException("Bitmap dimensions do not match GL frame dimensions!");
- } else {
- Bitmap rgbaBitmap = convertBitmapToRGBA(bitmap);
- if (!setNativeBitmap(rgbaBitmap, rgbaBitmap.getByteCount())) {
- throw new RuntimeException("Could not set GL frame bitmap data!");
- }
- }
- }
-
- @Override
- public Bitmap getBitmap() {
- assertGLEnvValid();
- flushGPU("getBitmap");
- Bitmap result = Bitmap.createBitmap(getFormat().getWidth(),
- getFormat().getHeight(),
- Bitmap.Config.ARGB_8888);
- if (!getNativeBitmap(result)) {
- throw new RuntimeException("Could not get bitmap data from GL frame!");
- }
- return result;
- }
-
- @Override
- public void setDataFromFrame(Frame frame) {
- assertGLEnvValid();
-
- // Make sure frame fits
- if (getFormat().getSize() < frame.getFormat().getSize()) {
- throw new RuntimeException(
- "Attempting to assign frame of size " + frame.getFormat().getSize() + " to " +
- "smaller GL frame of size " + getFormat().getSize() + "!");
- }
-
- // Invoke optimized implementations if possible
- if (frame instanceof NativeFrame) {
- nativeCopyFromNative((NativeFrame)frame);
- } else if (frame instanceof GLFrame) {
- nativeCopyFromGL((GLFrame)frame);
- } else if (frame instanceof SimpleFrame) {
- setObjectValue(frame.getObjectValue());
- } else {
- super.setDataFromFrame(frame);
- }
- }
-
- public void setViewport(int x, int y, int width, int height) {
- assertFrameMutable();
- setNativeViewport(x, y, width, height);
- }
-
- public void setViewport(Rect rect) {
- assertFrameMutable();
- setNativeViewport(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
- }
-
- public void generateMipMap() {
- assertFrameMutable();
- assertGLEnvValid();
- if (!generateNativeMipMap()) {
- throw new RuntimeException("Could not generate mip-map for GL frame!");
- }
- }
-
- public void setTextureParameter(int param, int value) {
- assertFrameMutable();
- assertGLEnvValid();
- if (!setNativeTextureParam(param, value)) {
- throw new RuntimeException("Could not set texture value " + param + " = " + value + " " +
- "for GLFrame!");
- }
- }
-
- public int getTextureId() {
- return getNativeTextureId();
- }
-
- public int getFboId() {
- return getNativeFboId();
- }
-
- public void focus() {
- if (!nativeFocus()) {
- throw new RuntimeException("Could not focus on GLFrame for drawing!");
- }
- }
-
- @Override
- public String toString() {
- return "GLFrame id: " + glFrameId + " (" + getFormat() + ") with texture ID "
- + getTextureId() + ", FBO ID " + getFboId();
- }
-
- @Override
- protected void reset(FrameFormat newFormat) {
- if (!nativeResetParams()) {
- throw new RuntimeException("Could not reset GLFrame texture parameters!");
- }
- super.reset(newFormat);
- }
-
- @Override
- protected void onFrameStore() {
- if (!mOwnsTexture) {
- // Detach texture from FBO in case user manipulates it.
- nativeDetachTexFromFbo();
- }
- }
-
- @Override
- protected void onFrameFetch() {
- if (!mOwnsTexture) {
- // Reattach texture to FBO when using frame again. This may reallocate the texture
- // in case it has become invalid.
- nativeReattachTexToFbo();
- }
- }
-
- private void assertGLEnvValid() {
- if (!mGLEnvironment.isContextActive()) {
- if (GLEnvironment.isAnyContextActive()) {
- throw new RuntimeException("Attempting to access " + this + " with foreign GL " +
- "context active!");
- } else {
- throw new RuntimeException("Attempting to access " + this + " with no GL context " +
- " active!");
- }
- }
- }
-
- static {
- System.loadLibrary("filterfw");
- }
-
- private native boolean nativeAllocate(GLEnvironment env, int width, int height);
-
- private native boolean nativeAllocateWithTexture(GLEnvironment env,
- int textureId,
- int width,
- int height);
-
- private native boolean nativeAllocateWithFbo(GLEnvironment env,
- int fboId,
- int width,
- int height);
-
- private native boolean nativeAllocateExternal(GLEnvironment env);
-
- private native boolean nativeDeallocate();
-
- private native boolean setNativeData(byte[] data, int offset, int length);
-
- private native byte[] getNativeData();
-
- private native boolean setNativeInts(int[] ints);
-
- private native boolean setNativeFloats(float[] floats);
-
- private native int[] getNativeInts();
-
- private native float[] getNativeFloats();
-
- private native boolean setNativeBitmap(Bitmap bitmap, int size);
-
- private native boolean getNativeBitmap(Bitmap bitmap);
-
- private native boolean setNativeViewport(int x, int y, int width, int height);
-
- private native int getNativeTextureId();
-
- private native int getNativeFboId();
-
- private native boolean generateNativeMipMap();
-
- private native boolean setNativeTextureParam(int param, int value);
-
- private native boolean nativeResetParams();
-
- private native boolean nativeCopyFromNative(NativeFrame frame);
-
- private native boolean nativeCopyFromGL(GLFrame frame);
-
- private native boolean nativeFocus();
-
- private native boolean nativeReattachTexToFbo();
-
- private native boolean nativeDetachTexFromFbo();
-}
diff --git a/mca/filterfw/java/android/filterfw/core/GenerateFieldPort.java b/mca/filterfw/java/android/filterfw/core/GenerateFieldPort.java
deleted file mode 100644
index 3e37d4f..0000000
--- a/mca/filterfw/java/android/filterfw/core/GenerateFieldPort.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.lang.annotation.*;
-
-/**
- * @hide
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface GenerateFieldPort {
- String name() default "";
- boolean hasDefault() default false;
-}
diff --git a/mca/filterfw/java/android/filterfw/core/GenerateFinalPort.java b/mca/filterfw/java/android/filterfw/core/GenerateFinalPort.java
deleted file mode 100644
index 0dec8cc..0000000
--- a/mca/filterfw/java/android/filterfw/core/GenerateFinalPort.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.lang.annotation.*;
-
-/**
- * @hide
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface GenerateFinalPort {
- String name() default "";
- boolean hasDefault() default false;
-}
diff --git a/mca/filterfw/java/android/filterfw/core/GenerateProgramPort.java b/mca/filterfw/java/android/filterfw/core/GenerateProgramPort.java
deleted file mode 100644
index fb40416..0000000
--- a/mca/filterfw/java/android/filterfw/core/GenerateProgramPort.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.lang.annotation.*;
-
-/**
- * @hide
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface GenerateProgramPort {
- String name();
- Class type();
- String variableName() default "";
- boolean hasDefault() default false;
-}
diff --git a/mca/filterfw/java/android/filterfw/core/GenerateProgramPorts.java b/mca/filterfw/java/android/filterfw/core/GenerateProgramPorts.java
deleted file mode 100644
index 354126d..0000000
--- a/mca/filterfw/java/android/filterfw/core/GenerateProgramPorts.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.lang.annotation.*;
-
-/**
- * @hide
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface GenerateProgramPorts {
- GenerateProgramPort[] value();
-}
diff --git a/mca/filterfw/java/android/filterfw/core/GraphRunner.java b/mca/filterfw/java/android/filterfw/core/GraphRunner.java
deleted file mode 100644
index b496c54..0000000
--- a/mca/filterfw/java/android/filterfw/core/GraphRunner.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-/**
- * @hide
- */
-public abstract class GraphRunner {
-
- protected FilterContext mFilterContext = null;
-
- /** Interface for listeners waiting for the runner to complete. */
- public interface OnRunnerDoneListener {
- /** Callback method to be called when the runner completes a
- * {@link #run()} call.
- *
- * @param result will be RESULT_FINISHED if the graph finished running
- * on its own, RESULT_STOPPED if the runner was stopped by a call
- * to stop(), RESULT_BLOCKED if no filters could run due to lack
- * of inputs or outputs or due to scheduling policies, and
- * RESULT_SLEEPING if a filter node requested sleep.
- */
- public void onRunnerDone(int result);
- }
-
- public static final int RESULT_UNKNOWN = 0;
- public static final int RESULT_RUNNING = 1;
- public static final int RESULT_FINISHED = 2;
- public static final int RESULT_SLEEPING = 3;
- public static final int RESULT_BLOCKED = 4;
- public static final int RESULT_STOPPED = 5;
- public static final int RESULT_ERROR = 6;
-
- public GraphRunner(FilterContext context) {
- mFilterContext = context;
- }
-
- public abstract FilterGraph getGraph();
-
- public FilterContext getContext() {
- return mFilterContext;
- }
-
- /**
- * Helper function for subclasses to activate the GL environment before running.
- * @return true, if the GL environment was activated. Returns false, if the GL environment
- * was already active.
- */
- protected boolean activateGlContext() {
- GLEnvironment glEnv = mFilterContext.getGLEnvironment();
- if (glEnv != null && !glEnv.isActive()) {
- glEnv.activate();
- return true;
- }
- return false;
- }
-
- /**
- * Helper function for subclasses to deactivate the GL environment after running.
- */
- protected void deactivateGlContext() {
- GLEnvironment glEnv = mFilterContext.getGLEnvironment();
- if (glEnv != null) {
- glEnv.deactivate();
- }
- }
-
- /** Starts running the graph. Will open the filters in the graph if they are not already open. */
- public abstract void run();
-
- public abstract void setDoneCallback(OnRunnerDoneListener listener);
- public abstract boolean isRunning();
-
- /** Stops graph execution. As part of stopping, also closes the graph nodes. */
- public abstract void stop();
-
- /** Closes the filters in a graph. Can only be called if the graph is not running. */
- public abstract void close();
-
- /**
- * Returns the last exception that happened during an asynchronous run. Returns null if
- * there is nothing to report.
- */
- public abstract Exception getError();
-}
diff --git a/mca/filterfw/java/android/filterfw/core/InputPort.java b/mca/filterfw/java/android/filterfw/core/InputPort.java
deleted file mode 100644
index de5cccc..0000000
--- a/mca/filterfw/java/android/filterfw/core/InputPort.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-/**
- * @hide
- */
-public abstract class InputPort extends FilterPort {
-
- protected OutputPort mSourcePort;
-
- public InputPort(Filter filter, String name) {
- super(filter, name);
- }
-
- public void setSourcePort(OutputPort source) {
- if (mSourcePort != null) {
- throw new RuntimeException(this + " already connected to " + mSourcePort + "!");
- }
- mSourcePort = source;
- }
-
- public boolean isConnected() {
- return mSourcePort != null;
- }
-
- public void open() {
- super.open();
- if (mSourcePort != null && !mSourcePort.isOpen()) {
- mSourcePort.open();
- }
- }
-
- public void close() {
- if (mSourcePort != null && mSourcePort.isOpen()) {
- mSourcePort.close();
- }
- super.close();
- }
-
- public OutputPort getSourcePort() {
- return mSourcePort;
- }
-
- public Filter getSourceFilter() {
- return mSourcePort == null ? null : mSourcePort.getFilter();
- }
-
- public FrameFormat getSourceFormat() {
- return mSourcePort != null ? mSourcePort.getPortFormat() : getPortFormat();
- }
-
- public Object getTarget() {
- return null;
- }
-
- public boolean filterMustClose() {
- return !isOpen() && isBlocking() && !hasFrame();
- }
-
- public boolean isReady() {
- return hasFrame() || !isBlocking();
- }
-
- public boolean acceptsFrame() {
- return !hasFrame();
- }
-
- public abstract void transfer(FilterContext context);
-}
diff --git a/mca/filterfw/java/android/filterfw/core/KeyValueMap.java b/mca/filterfw/java/android/filterfw/core/KeyValueMap.java
deleted file mode 100644
index 8cf9a13..0000000
--- a/mca/filterfw/java/android/filterfw/core/KeyValueMap.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @hide
- */
-public class KeyValueMap extends HashMap<String, Object> {
-
- public void setKeyValues(Object... keyValues) {
- if (keyValues.length % 2 != 0) {
- throw new RuntimeException("Key-Value arguments passed into setKeyValues must be "
- + "an alternating list of keys and values!");
- }
- for (int i = 0; i < keyValues.length; i += 2) {
- if (!(keyValues[i] instanceof String)) {
- throw new RuntimeException("Key-value argument " + i + " must be a key of type "
- + "String, but found an object of type " + keyValues[i].getClass() + "!");
- }
- String key = (String)keyValues[i];
- Object value = keyValues[i+1];
- put(key, value);
- }
- }
-
- public static KeyValueMap fromKeyValues(Object... keyValues) {
- KeyValueMap result = new KeyValueMap();
- result.setKeyValues(keyValues);
- return result;
- }
-
- public String getString(String key) {
- Object result = get(key);
- return result != null ? (String)result : null;
- }
-
- public int getInt(String key) {
- Object result = get(key);
- return result != null ? (Integer)result : null;
- }
-
- public float getFloat(String key) {
- Object result = get(key);
- return result != null ? (Float)result : null;
- }
-
- @Override
- public String toString() {
- StringWriter writer = new StringWriter();
- for (Map.Entry<String, Object> entry : entrySet()) {
- String valueString;
- Object value = entry.getValue();
- if (value instanceof String) {
- valueString = "\"" + value + "\"";
- } else {
- valueString = value.toString();
- }
- writer.write(entry.getKey() + " = " + valueString + ";\n");
- }
- return writer.toString();
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/MutableFrameFormat.java b/mca/filterfw/java/android/filterfw/core/MutableFrameFormat.java
deleted file mode 100644
index 8c78975..0000000
--- a/mca/filterfw/java/android/filterfw/core/MutableFrameFormat.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-
-import java.util.Arrays;
-
-/**
- * @hide
- */
-public class MutableFrameFormat extends FrameFormat {
-
- public MutableFrameFormat() {
- super();
- }
-
- public MutableFrameFormat(int baseType, int target) {
- super(baseType, target);
- }
-
- public void setBaseType(int baseType) {
- mBaseType = baseType;
- mBytesPerSample = bytesPerSampleOf(baseType);
- }
-
- public void setTarget(int target) {
- mTarget = target;
- }
-
- public void setBytesPerSample(int bytesPerSample) {
- mBytesPerSample = bytesPerSample;
- mSize = SIZE_UNKNOWN;
- }
-
- public void setDimensions(int[] dimensions) {
- mDimensions = (dimensions == null) ? null : Arrays.copyOf(dimensions, dimensions.length);
- mSize = SIZE_UNKNOWN;
- }
-
- public void setDimensions(int size) {
- int[] dimensions = new int[1];
- dimensions[0] = size;
- mDimensions = dimensions;
- mSize = SIZE_UNKNOWN;
- }
-
- public void setDimensions(int width, int height) {
- int[] dimensions = new int[2];
- dimensions[0] = width;
- dimensions[1] = height;
- mDimensions = dimensions;
- mSize = SIZE_UNKNOWN;
- }
-
- public void setDimensions(int width, int height, int depth) {
- int[] dimensions = new int[3];
- dimensions[0] = width;
- dimensions[1] = height;
- dimensions[2] = depth;
- mDimensions = dimensions;
- mSize = SIZE_UNKNOWN;
- }
-
- public void setDimensionCount(int count) {
- mDimensions = new int[count];
- }
-
- public void setObjectClass(Class objectClass) {
- mObjectClass = objectClass;
- }
-
- public void setMetaValue(String key, Object value) {
- if (mMetaData == null) {
- mMetaData = new KeyValueMap();
- }
- mMetaData.put(key, value);
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/NativeAllocatorTag.java b/mca/filterfw/java/android/filterfw/core/NativeAllocatorTag.java
deleted file mode 100644
index 4d43d7c..0000000
--- a/mca/filterfw/java/android/filterfw/core/NativeAllocatorTag.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-/**
- * This class is simply a place-holder type used to identify calls coming
- * from the native layer. This way method signatures can be selected
- * that are to be accessed from the native layer only.
- *
- * @hide
- **/
-public class NativeAllocatorTag {
-}
diff --git a/mca/filterfw/java/android/filterfw/core/NativeBuffer.java b/mca/filterfw/java/android/filterfw/core/NativeBuffer.java
deleted file mode 100644
index 80da5ea..0000000
--- a/mca/filterfw/java/android/filterfw/core/NativeBuffer.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-
-/**
- * @hide
- */
-public class NativeBuffer {
-
- // These are set by the native layer
- private long mDataPointer = 0;
- private int mSize = 0;
-
- private Frame mAttachedFrame;
-
- private boolean mOwnsData = false;
- private int mRefCount = 1;
-
- public NativeBuffer() {
- }
-
- public NativeBuffer(int count) {
- allocate(count * getElementSize());
- mOwnsData = true;
- }
-
- public NativeBuffer mutableCopy() {
- NativeBuffer result = null;
- try {
- Class myClass = getClass();
- result = (NativeBuffer)myClass.newInstance();
- } catch (Exception e) {
- throw new RuntimeException("Unable to allocate a copy of " + getClass() + "! Make " +
- "sure the class has a default constructor!");
- }
- if (mSize > 0 && !nativeCopyTo(result)) {
- throw new RuntimeException("Failed to copy NativeBuffer to mutable instance!");
- }
- return result;
- }
-
- public int size() {
- return mSize;
- }
-
- public int count() {
- return (mDataPointer != 0) ? mSize / getElementSize() : 0;
- }
-
- public int getElementSize() {
- return 1;
- }
-
- public NativeBuffer retain() {
- if (mAttachedFrame != null) {
- mAttachedFrame.retain();
- } else if (mOwnsData) {
- ++mRefCount;
- }
- return this;
- }
-
- public NativeBuffer release() {
- // Decrement refcount
- boolean doDealloc = false;
- if (mAttachedFrame != null) {
- doDealloc = (mAttachedFrame.release() == null);
- } else if (mOwnsData) {
- --mRefCount;
- doDealloc = (mRefCount == 0);
- }
-
- // Deallocate if necessary
- if (doDealloc) {
- deallocate(mOwnsData);
- return null;
- } else {
- return this;
- }
- }
-
- public boolean isReadOnly() {
- return (mAttachedFrame != null) ? mAttachedFrame.isReadOnly() : false;
- }
-
- static {
- System.loadLibrary("filterfw");
- }
-
- void attachToFrame(Frame frame) {
- // We do not auto-retain. We expect the user to call retain() if they want to hold on to
- // the frame.
- mAttachedFrame = frame;
- }
-
- protected void assertReadable() {
- if (mDataPointer == 0 || mSize == 0
- || (mAttachedFrame != null && !mAttachedFrame.hasNativeAllocation())) {
- throw new NullPointerException("Attempting to read from null data frame!");
- }
- }
-
- protected void assertWritable() {
- if (isReadOnly()) {
- throw new RuntimeException("Attempting to modify read-only native (structured) data!");
- }
- }
-
- private native boolean allocate(int size);
- private native boolean deallocate(boolean ownsData);
- private native boolean nativeCopyTo(NativeBuffer buffer);
-}
diff --git a/mca/filterfw/java/android/filterfw/core/NativeFrame.java b/mca/filterfw/java/android/filterfw/core/NativeFrame.java
deleted file mode 100644
index bfd09ba..0000000
--- a/mca/filterfw/java/android/filterfw/core/NativeFrame.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.NativeBuffer;
-import android.graphics.Bitmap;
-
-import android.util.Log;
-
-import java.nio.ByteBuffer;
-
-/**
- * @hide
- */
-public class NativeFrame extends Frame {
-
- private int nativeFrameId = -1;
-
- NativeFrame(FrameFormat format, FrameManager frameManager) {
- super(format, frameManager);
- int capacity = format.getSize();
- nativeAllocate(capacity);
- setReusable(capacity != 0);
- }
-
- @Override
- protected synchronized void releaseNativeAllocation() {
- nativeDeallocate();
- nativeFrameId = -1;
- }
-
- @Override
- protected synchronized boolean hasNativeAllocation() {
- return nativeFrameId != -1;
- }
-
- @Override
- public int getCapacity() {
- return getNativeCapacity();
- }
-
- /**
- * Returns the native frame's Object value.
- *
- * If the frame's base-type is not TYPE_OBJECT, this returns a data buffer containing the native
- * data (this is equivalent to calling getData().
- * If the frame is based on an object type, this type is expected to be a subclass of
- * NativeBuffer. The NativeBuffer returned is only valid for as long as the frame is alive. If
- * you need to hold on to the returned value, you must retain it.
- */
- @Override
- public Object getObjectValue() {
- // If this is not a structured frame, return our data
- if (getFormat().getBaseType() != FrameFormat.TYPE_OBJECT) {
- return getData();
- }
-
- // Get the structure class
- Class structClass = getFormat().getObjectClass();
- if (structClass == null) {
- throw new RuntimeException("Attempting to get object data from frame that does " +
- "not specify a structure object class!");
- }
-
- // Make sure it is a NativeBuffer subclass
- if (!NativeBuffer.class.isAssignableFrom(structClass)) {
- throw new RuntimeException("NativeFrame object class must be a subclass of " +
- "NativeBuffer!");
- }
-
- // Instantiate a new empty instance of this class
- NativeBuffer structData = null;
- try {
- structData = (NativeBuffer)structClass.newInstance();
- } catch (Exception e) {
- throw new RuntimeException("Could not instantiate new structure instance of type '" +
- structClass + "'!");
- }
-
- // Wrap it around our data
- if (!getNativeBuffer(structData)) {
- throw new RuntimeException("Could not get the native structured data for frame!");
- }
-
- // Attach this frame to it
- structData.attachToFrame(this);
-
- return structData;
- }
-
- @Override
- public void setInts(int[] ints) {
- assertFrameMutable();
- if (ints.length * nativeIntSize() > getFormat().getSize()) {
- throw new RuntimeException(
- "NativeFrame cannot hold " + ints.length + " integers. (Can only hold " +
- (getFormat().getSize() / nativeIntSize()) + " integers).");
- } else if (!setNativeInts(ints)) {
- throw new RuntimeException("Could not set int values for native frame!");
- }
- }
-
- @Override
- public int[] getInts() {
- return getNativeInts(getFormat().getSize());
- }
-
- @Override
- public void setFloats(float[] floats) {
- assertFrameMutable();
- if (floats.length * nativeFloatSize() > getFormat().getSize()) {
- throw new RuntimeException(
- "NativeFrame cannot hold " + floats.length + " floats. (Can only hold " +
- (getFormat().getSize() / nativeFloatSize()) + " floats).");
- } else if (!setNativeFloats(floats)) {
- throw new RuntimeException("Could not set int values for native frame!");
- }
- }
-
- @Override
- public float[] getFloats() {
- return getNativeFloats(getFormat().getSize());
- }
-
- // TODO: This function may be a bit confusing: Is the offset the target or source offset? Maybe
- // we should allow specifying both? (May be difficult for other frame types).
- @Override
- public void setData(ByteBuffer buffer, int offset, int length) {
- assertFrameMutable();
- byte[] bytes = buffer.array();
- if ((length + offset) > buffer.limit()) {
- throw new RuntimeException("Offset and length exceed buffer size in native setData: " +
- (length + offset) + " bytes given, but only " + buffer.limit() +
- " bytes available!");
- } else if (getFormat().getSize() != length) {
- throw new RuntimeException("Data size in setData does not match native frame size: " +
- "Frame size is " + getFormat().getSize() + " bytes, but " +
- length + " bytes given!");
- } else if (!setNativeData(bytes, offset, length)) {
- throw new RuntimeException("Could not set native frame data!");
- }
- }
-
- @Override
- public ByteBuffer getData() {
- byte[] data = getNativeData(getFormat().getSize());
- return data == null ? null : ByteBuffer.wrap(data);
- }
-
- @Override
- public void setBitmap(Bitmap bitmap) {
- assertFrameMutable();
- if (getFormat().getNumberOfDimensions() != 2) {
- throw new RuntimeException("Attempting to set Bitmap for non 2-dimensional native frame!");
- } else if (getFormat().getWidth() != bitmap.getWidth() ||
- getFormat().getHeight() != bitmap.getHeight()) {
- throw new RuntimeException("Bitmap dimensions do not match native frame dimensions!");
- } else {
- Bitmap rgbaBitmap = convertBitmapToRGBA(bitmap);
- int byteCount = rgbaBitmap.getByteCount();
- int bps = getFormat().getBytesPerSample();
- if (!setNativeBitmap(rgbaBitmap, byteCount, bps)) {
- throw new RuntimeException("Could not set native frame bitmap data!");
- }
- }
- }
-
- @Override
- public Bitmap getBitmap() {
- if (getFormat().getNumberOfDimensions() != 2) {
- throw new RuntimeException("Attempting to get Bitmap for non 2-dimensional native frame!");
- }
- Bitmap result = Bitmap.createBitmap(getFormat().getWidth(),
- getFormat().getHeight(),
- Bitmap.Config.ARGB_8888);
- int byteCount = result.getByteCount();
- int bps = getFormat().getBytesPerSample();
- if (!getNativeBitmap(result, byteCount, bps)) {
- throw new RuntimeException("Could not get bitmap data from native frame!");
- }
- return result;
- }
-
- @Override
- public void setDataFromFrame(Frame frame) {
- // Make sure frame fits
- if (getFormat().getSize() < frame.getFormat().getSize()) {
- throw new RuntimeException(
- "Attempting to assign frame of size " + frame.getFormat().getSize() + " to " +
- "smaller native frame of size " + getFormat().getSize() + "!");
- }
-
- // Invoke optimized implementations if possible
- if (frame instanceof NativeFrame) {
- nativeCopyFromNative((NativeFrame)frame);
- } else if (frame instanceof GLFrame) {
- nativeCopyFromGL((GLFrame)frame);
- } else if (frame instanceof SimpleFrame) {
- setObjectValue(frame.getObjectValue());
- } else {
- super.setDataFromFrame(frame);
- }
- }
-
- @Override
- public String toString() {
- return "NativeFrame id: " + nativeFrameId + " (" + getFormat() + ") of size "
- + getCapacity();
- }
-
- static {
- System.loadLibrary("filterfw");
- }
-
- private native boolean nativeAllocate(int capacity);
-
- private native boolean nativeDeallocate();
-
- private native int getNativeCapacity();
-
- private static native int nativeIntSize();
-
- private static native int nativeFloatSize();
-
- private native boolean setNativeData(byte[] data, int offset, int length);
-
- private native byte[] getNativeData(int byteCount);
-
- private native boolean getNativeBuffer(NativeBuffer buffer);
-
- private native boolean setNativeInts(int[] ints);
-
- private native boolean setNativeFloats(float[] floats);
-
- private native int[] getNativeInts(int byteCount);
-
- private native float[] getNativeFloats(int byteCount);
-
- private native boolean setNativeBitmap(Bitmap bitmap, int size, int bytesPerSample);
-
- private native boolean getNativeBitmap(Bitmap bitmap, int size, int bytesPerSample);
-
- private native boolean nativeCopyFromNative(NativeFrame frame);
-
- private native boolean nativeCopyFromGL(GLFrame frame);
-}
diff --git a/mca/filterfw/java/android/filterfw/core/NativeProgram.java b/mca/filterfw/java/android/filterfw/core/NativeProgram.java
deleted file mode 100644
index 791ab3c..0000000
--- a/mca/filterfw/java/android/filterfw/core/NativeProgram.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.Program;
-
-/**
- * @hide
- */
-public class NativeProgram extends Program {
-
- private int nativeProgramId;
- private boolean mHasInitFunction = false;
- private boolean mHasTeardownFunction = false;
- private boolean mHasSetValueFunction = false;
- private boolean mHasGetValueFunction = false;
- private boolean mHasResetFunction = false;
- private boolean mTornDown = false;
-
- public NativeProgram(String nativeLibName, String nativeFunctionPrefix) {
- // Allocate the native instance
- allocate();
-
- // Open the native library
- String fullLibName = "lib" + nativeLibName + ".so";
- if (!openNativeLibrary(fullLibName)) {
- throw new RuntimeException("Could not find native library named '" + fullLibName + "' " +
- "required for native program!");
- }
-
- // Bind the native functions
- String processFuncName = nativeFunctionPrefix + "_process";
- if (!bindProcessFunction(processFuncName)) {
- throw new RuntimeException("Could not find native program function name " +
- processFuncName + " in library " + fullLibName + "! " +
- "This function is required!");
- }
-
- String initFuncName = nativeFunctionPrefix + "_init";
- mHasInitFunction = bindInitFunction(initFuncName);
-
- String teardownFuncName = nativeFunctionPrefix + "_teardown";
- mHasTeardownFunction = bindTeardownFunction(teardownFuncName);
-
- String setValueFuncName = nativeFunctionPrefix + "_setvalue";
- mHasSetValueFunction = bindSetValueFunction(setValueFuncName);
-
- String getValueFuncName = nativeFunctionPrefix + "_getvalue";
- mHasGetValueFunction = bindGetValueFunction(getValueFuncName);
-
- String resetFuncName = nativeFunctionPrefix + "_reset";
- mHasResetFunction = bindResetFunction(resetFuncName);
-
- // Initialize the native code
- if (mHasInitFunction && !callNativeInit()) {
- throw new RuntimeException("Could not initialize NativeProgram!");
- }
- }
-
- public void tearDown() {
- if (mTornDown) return;
- if (mHasTeardownFunction && !callNativeTeardown()) {
- throw new RuntimeException("Could not tear down NativeProgram!");
- }
- deallocate();
- mTornDown = true;
- }
-
- @Override
- public void reset() {
- if (mHasResetFunction && !callNativeReset()) {
- throw new RuntimeException("Could not reset NativeProgram!");
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- tearDown();
- }
-
- @Override
- public void process(Frame[] inputs, Frame output) {
- if (mTornDown) {
- throw new RuntimeException("NativeProgram already torn down!");
- }
- NativeFrame[] nativeInputs = new NativeFrame[inputs.length];
- for (int i = 0; i < inputs.length; ++i) {
- if (inputs[i] == null || inputs[i] instanceof NativeFrame) {
- nativeInputs[i] = (NativeFrame)inputs[i];
- } else {
- throw new RuntimeException("NativeProgram got non-native frame as input "+ i +"!");
- }
- }
-
- // Get the native output frame
- NativeFrame nativeOutput = null;
- if (output == null || output instanceof NativeFrame) {
- nativeOutput = (NativeFrame)output;
- } else {
- throw new RuntimeException("NativeProgram got non-native output frame!");
- }
-
- // Process!
- if (!callNativeProcess(nativeInputs, nativeOutput)) {
- throw new RuntimeException("Calling native process() caused error!");
- }
- }
-
- @Override
- public void setHostValue(String variableName, Object value) {
- if (mTornDown) {
- throw new RuntimeException("NativeProgram already torn down!");
- }
- if (!mHasSetValueFunction) {
- throw new RuntimeException("Attempting to set native variable, but native code does not " +
- "define native setvalue function!");
- }
- if (!callNativeSetValue(variableName, value.toString())) {
- throw new RuntimeException("Error setting native value for variable '" + variableName + "'!");
- }
- }
-
- @Override
- public Object getHostValue(String variableName) {
- if (mTornDown) {
- throw new RuntimeException("NativeProgram already torn down!");
- }
- if (!mHasGetValueFunction) {
- throw new RuntimeException("Attempting to get native variable, but native code does not " +
- "define native getvalue function!");
- }
- return callNativeGetValue(variableName);
- }
-
- static {
- System.loadLibrary("filterfw");
- }
-
- private native boolean allocate();
-
- private native boolean deallocate();
-
- private native boolean nativeInit();
-
- private native boolean openNativeLibrary(String libName);
-
- private native boolean bindInitFunction(String funcName);
- private native boolean bindSetValueFunction(String funcName);
- private native boolean bindGetValueFunction(String funcName);
- private native boolean bindProcessFunction(String funcName);
- private native boolean bindResetFunction(String funcName);
- private native boolean bindTeardownFunction(String funcName);
-
- private native boolean callNativeInit();
- private native boolean callNativeSetValue(String key, String value);
- private native String callNativeGetValue(String key);
- private native boolean callNativeProcess(NativeFrame[] inputs, NativeFrame output);
- private native boolean callNativeReset();
- private native boolean callNativeTeardown();
-}
diff --git a/mca/filterfw/java/android/filterfw/core/OneShotScheduler.java b/mca/filterfw/java/android/filterfw/core/OneShotScheduler.java
deleted file mode 100644
index dbc8d16..0000000
--- a/mca/filterfw/java/android/filterfw/core/OneShotScheduler.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.Scheduler;
-import android.filterfw.core.RoundRobinScheduler;
-import android.util.Log;
-
-import java.util.HashMap;
-
-/**
- * This OneShotScheduler only schedules source filters at most once. All other
- * filters will be scheduled, and possibly repeatedly, until there is no filter
- * that can be scheduled.
- *
- * @hide
- */
-public class OneShotScheduler extends RoundRobinScheduler {
- private HashMap <String, Integer> scheduled;
-
- private final boolean mLogVerbose;
- private static final String TAG = "OneShotScheduler";
-
- public OneShotScheduler(FilterGraph graph) {
- super(graph);
- scheduled = new HashMap<String, Integer>();
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void reset() {
- super.reset();
- scheduled.clear();
- }
-
- @Override
- public Filter scheduleNextNode() {
- Filter first = null;
- // return the first filter that is not scheduled before.
- while (true) {
- Filter filter = super.scheduleNextNode();
- if (filter == null) {
- if (mLogVerbose) Log.v(TAG, "No filters available to run.");
- return null;
- }
- if (!scheduled.containsKey(filter.getName())) {
- if (filter.getNumberOfConnectedInputs() == 0)
- scheduled.put(filter.getName(),1);
- if (mLogVerbose) Log.v(TAG, "Scheduling filter \"" + filter.getName() + "\" of type " + filter.getFilterClassName());
- return filter;
- }
- // if loop back, nothing available
- if (first == filter) {
- break;
- }
- // save the first scheduled one
- if (first == null) first = filter;
- }
- if (mLogVerbose) Log.v(TAG, "One pass through graph completed.");
- return null;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/OutputPort.java b/mca/filterfw/java/android/filterfw/core/OutputPort.java
deleted file mode 100644
index 872dbdd..0000000
--- a/mca/filterfw/java/android/filterfw/core/OutputPort.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-/**
- * @hide
- */
-public class OutputPort extends FilterPort {
-
- protected InputPort mTargetPort;
- protected InputPort mBasePort;
-
- public OutputPort(Filter filter, String name) {
- super(filter, name);
- }
-
- public void connectTo(InputPort target) {
- if (mTargetPort != null) {
- throw new RuntimeException(this + " already connected to " + mTargetPort + "!");
- }
- mTargetPort = target;
- mTargetPort.setSourcePort(this);
- }
-
- public boolean isConnected() {
- return mTargetPort != null;
- }
-
- public void open() {
- super.open();
- if (mTargetPort != null && !mTargetPort.isOpen()) {
- mTargetPort.open();
- }
- }
-
- public void close() {
- super.close();
- if (mTargetPort != null && mTargetPort.isOpen()) {
- mTargetPort.close();
- }
- }
-
- public InputPort getTargetPort() {
- return mTargetPort;
- }
-
- public Filter getTargetFilter() {
- return mTargetPort == null ? null : mTargetPort.getFilter();
- }
-
- public void setBasePort(InputPort basePort) {
- mBasePort = basePort;
- }
-
- public InputPort getBasePort() {
- return mBasePort;
- }
-
- public boolean filterMustClose() {
- return !isOpen() && isBlocking();
- }
-
- public boolean isReady() {
- return (isOpen() && mTargetPort.acceptsFrame()) || !isBlocking();
- }
-
- @Override
- public void clear() {
- if (mTargetPort != null) {
- mTargetPort.clear();
- }
- }
-
- @Override
- public void pushFrame(Frame frame) {
- if (mTargetPort == null) {
- throw new RuntimeException(
- "Attempting to push frame on unconnected port: " + this + "!");
- }
- mTargetPort.pushFrame(frame);
- }
-
- @Override
- public void setFrame(Frame frame) {
- assertPortIsOpen();
- if (mTargetPort == null) {
- throw new RuntimeException(
- "Attempting to set frame on unconnected port: " + this + "!");
- }
- mTargetPort.setFrame(frame);
- }
-
- @Override
- public Frame pullFrame() {
- throw new RuntimeException("Cannot pull frame on " + this + "!");
- }
-
- @Override
- public boolean hasFrame() {
- return mTargetPort == null ? false : mTargetPort.hasFrame();
- }
-
- @Override
- public String toString() {
- return "output " + super.toString();
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/Program.java b/mca/filterfw/java/android/filterfw/core/Program.java
deleted file mode 100644
index 1930648..0000000
--- a/mca/filterfw/java/android/filterfw/core/Program.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-
-/**
- * @hide
- */
-public abstract class Program {
-
- public abstract void process(Frame[] inputs, Frame output);
-
- public void process(Frame input, Frame output) {
- Frame[] inputs = new Frame[1];
- inputs[0] = input;
- process(inputs, output);
- }
-
- public abstract void setHostValue(String variableName, Object value);
-
- public abstract Object getHostValue(String variableName);
-
- public void reset() {
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/ProgramPort.java b/mca/filterfw/java/android/filterfw/core/ProgramPort.java
deleted file mode 100644
index 3cab26d..0000000
--- a/mca/filterfw/java/android/filterfw/core/ProgramPort.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.lang.reflect.Field;
-
-/**
- * @hide
- */
-public class ProgramPort extends FieldPort {
-
- protected String mVarName;
-
- public ProgramPort(Filter filter,
- String name,
- String varName,
- Field field,
- boolean hasDefault) {
- super(filter, name, field, hasDefault);
- mVarName = varName;
- }
-
- @Override
- public String toString() {
- return "Program " + super.toString();
- }
-
- @Override
- public synchronized void transfer(FilterContext context) {
- if (mValueWaiting) {
- try {
- Object fieldValue = mField.get(mFilter);
- if (fieldValue != null) {
- Program program = (Program)fieldValue;
- program.setHostValue(mVarName, mValue);
- mValueWaiting = false;
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException(
- "Access to program field '" + mField.getName() + "' was denied!");
- } catch (ClassCastException e) {
- throw new RuntimeException("Non Program field '" + mField.getName()
- + "' annotated with ProgramParameter!");
- }
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/ProgramVariable.java b/mca/filterfw/java/android/filterfw/core/ProgramVariable.java
deleted file mode 100644
index 5592d37..0000000
--- a/mca/filterfw/java/android/filterfw/core/ProgramVariable.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-/**
- * @hide
- */
-public class ProgramVariable {
-
- private Program mProgram;
- private String mVarName;
-
- public ProgramVariable(Program program, String varName) {
- mProgram = program;
- mVarName = varName;
- }
-
- public Program getProgram() {
- return mProgram;
- }
-
- public String getVariableName() {
- return mVarName;
- }
-
- public void setValue(Object value) {
- if (mProgram == null) {
- throw new RuntimeException("Attempting to set program variable '" + mVarName
- + "' but the program is null!");
- }
- mProgram.setHostValue(mVarName, value);
- }
-
- public Object getValue() {
- if (mProgram == null) {
- throw new RuntimeException("Attempting to get program variable '" + mVarName
- + "' but the program is null!");
- }
- return mProgram.getHostValue(mVarName);
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/ProtocolException.java b/mca/filterfw/java/android/filterfw/core/ProtocolException.java
deleted file mode 100644
index 2c7a29a..0000000
--- a/mca/filterfw/java/android/filterfw/core/ProtocolException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-/**
- * @hide
- */
-public class ProtocolException extends RuntimeException {
-
- public ProtocolException() {
- super();
- }
-
- public ProtocolException(String message) {
- super(message);
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/RandomScheduler.java b/mca/filterfw/java/android/filterfw/core/RandomScheduler.java
deleted file mode 100644
index 087f5db..0000000
--- a/mca/filterfw/java/android/filterfw/core/RandomScheduler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.util.Random;
-import java.util.Vector;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.Scheduler;
-
-/**
- * @hide
- */
-public class RandomScheduler extends Scheduler {
-
- private Random mRand = new Random();
-
- public RandomScheduler(FilterGraph graph) {
- super(graph);
- }
-
- @Override
- public void reset() {
- }
-
- @Override
- public Filter scheduleNextNode() {
- Vector<Filter> candidates = new Vector<Filter>();
- for (Filter filter : getGraph().getFilters()) {
- if (filter.canProcess())
- candidates.add(filter);
- }
- if (candidates.size() > 0) {
- int r = mRand.nextInt(candidates.size());
- return candidates.elementAt(r);
- }
- return null;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/RoundRobinScheduler.java b/mca/filterfw/java/android/filterfw/core/RoundRobinScheduler.java
deleted file mode 100644
index 12cbf19..0000000
--- a/mca/filterfw/java/android/filterfw/core/RoundRobinScheduler.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import java.util.Set;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.Scheduler;
-
-/**
- * @hide
- */
-public class RoundRobinScheduler extends Scheduler {
-
- private int mLastPos = -1;
-
- public RoundRobinScheduler(FilterGraph graph) {
- super(graph);
- }
-
- @Override
- public void reset() {
- mLastPos = -1;
- }
-
- @Override
- public Filter scheduleNextNode() {
- Set<Filter> all_filters = getGraph().getFilters();
- if (mLastPos >= all_filters.size()) mLastPos = -1;
- int pos = 0;
- Filter first = null;
- int firstNdx = -1;
- for (Filter filter : all_filters) {
- if (filter.canProcess()) {
- if (pos <= mLastPos) {
- if (first == null) {
- // store the first available filter
- first = filter;
- firstNdx = pos;
- }
- } else {
- // return the next available filter since last
- mLastPos = pos;
- return filter;
- }
- }
- pos ++;
- }
- // going around from the beginning
- if (first != null ) {
- mLastPos = firstNdx;
- return first;
- }
- // if there is nothing to be scheduled, still keep the previous
- // position.
- return null;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/Scheduler.java b/mca/filterfw/java/android/filterfw/core/Scheduler.java
deleted file mode 100644
index 6f0864a..0000000
--- a/mca/filterfw/java/android/filterfw/core/Scheduler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterGraph;
-
-/**
- * @hide
- */
-public abstract class Scheduler {
- // All methods are core internal methods as Scheduler internals are only used by the GraphRunner.
-
- private FilterGraph mGraph;
-
- Scheduler(FilterGraph graph) {
- mGraph = graph;
- }
-
- FilterGraph getGraph() {
- return mGraph;
- }
-
- abstract void reset();
-
- abstract Filter scheduleNextNode();
-
- boolean finished() {
- // TODO: Check that the state of all nodes is FINISHED.
- return true;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/SerializedFrame.java b/mca/filterfw/java/android/filterfw/core/SerializedFrame.java
deleted file mode 100644
index f493fd2..0000000
--- a/mca/filterfw/java/android/filterfw/core/SerializedFrame.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.NativeBuffer;
-import android.filterfw.format.ObjectFormat;
-import android.graphics.Bitmap;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OptionalDataException;
-import java.io.OutputStream;
-import java.io.StreamCorruptedException;
-import java.lang.reflect.Constructor;
-import java.nio.ByteBuffer;
-
-/**
- * A frame that serializes any assigned values. Such a frame is used when passing data objects
- * between threads.
- *
- * @hide
- */
-public class SerializedFrame extends Frame {
-
- /**
- * The initial capacity of the serialized data stream.
- */
- private final static int INITIAL_CAPACITY = 64;
-
- /**
- * The internal data streams.
- */
- private DirectByteOutputStream mByteOutputStream;
- private ObjectOutputStream mObjectOut;
-
- /**
- * An unsynchronized output stream that writes data to an accessible byte array. Callers are
- * responsible for synchronization. This is more efficient than a ByteArrayOutputStream, as
- * there are no array copies or synchronization involved to read back written data.
- */
- private class DirectByteOutputStream extends OutputStream {
- private byte[] mBuffer = null;
- private int mOffset = 0;
- private int mDataOffset = 0;
-
- public DirectByteOutputStream(int size) {
- mBuffer = new byte[size];
- }
-
- private final void ensureFit(int bytesToWrite) {
- if (mOffset + bytesToWrite > mBuffer.length) {
- byte[] oldBuffer = mBuffer;
- mBuffer = new byte[Math.max(mOffset + bytesToWrite, mBuffer.length * 2)];
- System.arraycopy(oldBuffer, 0, mBuffer, 0, mOffset);
- oldBuffer = null;
- }
- }
-
- public final void markHeaderEnd() {
- mDataOffset = mOffset;
- }
-
- public final int getSize() {
- return mOffset;
- }
-
- public byte[] getByteArray() {
- return mBuffer;
- }
-
- @Override
- public final void write(byte b[]) {
- write(b, 0, b.length);
- }
-
- @Override
- public final void write(byte b[], int off, int len) {
- ensureFit(len);
- System.arraycopy(b, off, mBuffer, mOffset, len);
- mOffset += len;
- }
-
- @Override
- public final void write(int b) {
- ensureFit(1);
- mBuffer[mOffset++] = (byte)b;
- }
-
- public final void reset() {
- mOffset = mDataOffset;
- }
-
- public final DirectByteInputStream getInputStream() {
- return new DirectByteInputStream(mBuffer, mOffset);
- }
- }
-
- /**
- * An unsynchronized input stream that reads data directly from a provided byte array. Callers
- * are responsible for synchronization and ensuring that the byte buffer is valid.
- */
- private class DirectByteInputStream extends InputStream {
-
- private byte[] mBuffer;
- private int mPos = 0;
- private int mSize;
-
- public DirectByteInputStream(byte[] buffer, int size) {
- mBuffer = buffer;
- mSize = size;
- }
-
- @Override
- public final int available() {
- return mSize - mPos;
- }
-
- @Override
- public final int read() {
- return (mPos < mSize) ? (mBuffer[mPos++] & 0xFF) : -1;
- }
-
- @Override
- public final int read(byte[] b, int off, int len) {
- if (mPos >= mSize) {
- return -1;
- }
- if ((mPos + len) > mSize) {
- len = mSize - mPos;
- }
- System.arraycopy(mBuffer, mPos, b, off, len);
- mPos += len;
- return len;
- }
-
- @Override
- public final long skip(long n) {
- if ((mPos + n) > mSize) {
- n = mSize - mPos;
- }
- if (n < 0) {
- return 0;
- }
- mPos += n;
- return n;
- }
- }
-
- SerializedFrame(FrameFormat format, FrameManager frameManager) {
- super(format, frameManager);
- setReusable(false);
-
- // Setup streams
- try {
- mByteOutputStream = new DirectByteOutputStream(INITIAL_CAPACITY);
- mObjectOut = new ObjectOutputStream(mByteOutputStream);
- mByteOutputStream.markHeaderEnd();
- } catch (IOException e) {
- throw new RuntimeException("Could not create serialization streams for "
- + "SerializedFrame!", e);
- }
- }
-
- static SerializedFrame wrapObject(Object object, FrameManager frameManager) {
- FrameFormat format = ObjectFormat.fromObject(object, FrameFormat.TARGET_SIMPLE);
- SerializedFrame result = new SerializedFrame(format, frameManager);
- result.setObjectValue(object);
- return result;
- }
-
- @Override
- protected boolean hasNativeAllocation() {
- return false;
- }
-
- @Override
- protected void releaseNativeAllocation() {
- }
-
- @Override
- public Object getObjectValue() {
- return deserializeObjectValue();
- }
-
- @Override
- public void setInts(int[] ints) {
- assertFrameMutable();
- setGenericObjectValue(ints);
- }
-
- @Override
- public int[] getInts() {
- Object result = deserializeObjectValue();
- return (result instanceof int[]) ? (int[])result : null;
- }
-
- @Override
- public void setFloats(float[] floats) {
- assertFrameMutable();
- setGenericObjectValue(floats);
- }
-
- @Override
- public float[] getFloats() {
- Object result = deserializeObjectValue();
- return (result instanceof float[]) ? (float[])result : null;
- }
-
- @Override
- public void setData(ByteBuffer buffer, int offset, int length) {
- assertFrameMutable();
- setGenericObjectValue(ByteBuffer.wrap(buffer.array(), offset, length));
- }
-
- @Override
- public ByteBuffer getData() {
- Object result = deserializeObjectValue();
- return (result instanceof ByteBuffer) ? (ByteBuffer)result : null;
- }
-
- @Override
- public void setBitmap(Bitmap bitmap) {
- assertFrameMutable();
- setGenericObjectValue(bitmap);
- }
-
- @Override
- public Bitmap getBitmap() {
- Object result = deserializeObjectValue();
- return (result instanceof Bitmap) ? (Bitmap)result : null;
- }
-
- @Override
- protected void setGenericObjectValue(Object object) {
- serializeObjectValue(object);
- }
-
- private final void serializeObjectValue(Object object) {
- try {
- mByteOutputStream.reset();
- mObjectOut.writeObject(object);
- mObjectOut.flush();
- mObjectOut.close();
- } catch (IOException e) {
- throw new RuntimeException("Could not serialize object " + object + " in "
- + this + "!", e);
- }
- }
-
- private final Object deserializeObjectValue() {
- try {
- InputStream inputStream = mByteOutputStream.getInputStream();
- ObjectInputStream objectStream = new ObjectInputStream(inputStream);
- return objectStream.readObject();
- } catch (IOException e) {
- throw new RuntimeException("Could not deserialize object in " + this + "!", e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Unable to deserialize object of unknown class in "
- + this + "!", e);
- }
- }
-
- @Override
- public String toString() {
- return "SerializedFrame (" + getFormat() + ")";
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/ShaderProgram.java b/mca/filterfw/java/android/filterfw/core/ShaderProgram.java
deleted file mode 100644
index a971cb6..0000000
--- a/mca/filterfw/java/android/filterfw/core/ShaderProgram.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.NativeAllocatorTag;
-import android.filterfw.core.Program;
-import android.filterfw.core.StopWatchMap;
-import android.filterfw.core.VertexFrame;
-import android.filterfw.geometry.Quad;
-import android.opengl.GLES20;
-
-/**
- * @hide
- */
-public class ShaderProgram extends Program {
-
- private int shaderProgramId;
-
- private int mMaxTileSize = 0;
-
- // Keep a reference to the GL environment, so that it does not get deallocated while there
- // are still programs living in it.
- private GLEnvironment mGLEnvironment;
-
- private StopWatchMap mTimer = null;
-
- private void setTimer() {
- mTimer = new StopWatchMap();
- }
-
- // Used from native layer for creating empty wrapper only!
- private ShaderProgram() {
- }
-
- private ShaderProgram(NativeAllocatorTag tag) {
- }
-
- public ShaderProgram(FilterContext context, String fragmentShader) {
- mGLEnvironment = getGLEnvironment(context);
- allocate(mGLEnvironment, null, fragmentShader);
- if (!compileAndLink()) {
- throw new RuntimeException("Could not compile and link shader!");
- }
- this.setTimer();
- }
-
- public ShaderProgram(FilterContext context, String vertexShader, String fragmentShader) {
- mGLEnvironment = getGLEnvironment(context);
- allocate(mGLEnvironment, vertexShader, fragmentShader);
- if (!compileAndLink()) {
- throw new RuntimeException("Could not compile and link shader!");
- }
- this.setTimer();
- }
-
- public static ShaderProgram createIdentity(FilterContext context) {
- ShaderProgram program = nativeCreateIdentity(getGLEnvironment(context));
- program.setTimer();
- return program;
- }
-
- @Override
- protected void finalize() throws Throwable {
- deallocate();
- }
-
- public GLEnvironment getGLEnvironment() {
- return mGLEnvironment;
- }
-
- @Override
- public void process(Frame[] inputs, Frame output) {
- if (mTimer.LOG_MFF_RUNNING_TIMES) {
- mTimer.start("glFinish");
- GLES20.glFinish();
- mTimer.stop("glFinish");
- }
-
- // Get the GL input frames
- // TODO: We do the same in the NativeProgram... can we find a better way?!
- GLFrame[] glInputs = new GLFrame[inputs.length];
- for (int i = 0; i < inputs.length; ++i) {
- if (inputs[i] instanceof GLFrame) {
- glInputs[i] = (GLFrame)inputs[i];
- } else {
- throw new RuntimeException("ShaderProgram got non-GL frame as input " + i + "!");
- }
- }
-
- // Get the GL output frame
- GLFrame glOutput = null;
- if (output instanceof GLFrame) {
- glOutput = (GLFrame)output;
- } else {
- throw new RuntimeException("ShaderProgram got non-GL output frame!");
- }
-
- // Adjust tiles to meet maximum tile size requirement
- if (mMaxTileSize > 0) {
- int xTiles = (output.getFormat().getWidth() + mMaxTileSize - 1) / mMaxTileSize;
- int yTiles = (output.getFormat().getHeight() + mMaxTileSize - 1) / mMaxTileSize;
- setShaderTileCounts(xTiles, yTiles);
- }
-
- // Process!
- if (!shaderProcess(glInputs, glOutput)) {
- throw new RuntimeException("Error executing ShaderProgram!");
- }
-
- if (mTimer.LOG_MFF_RUNNING_TIMES) {
- GLES20.glFinish();
- }
- }
-
- @Override
- public void setHostValue(String variableName, Object value) {
- if (!setUniformValue(variableName, value)) {
- throw new RuntimeException("Error setting uniform value for variable '" +
- variableName + "'!");
- }
- }
-
- @Override
- public Object getHostValue(String variableName) {
- return getUniformValue(variableName);
- }
-
- public void setAttributeValues(String attributeName, float[] data, int componentCount) {
- if (!setShaderAttributeValues(attributeName, data, componentCount)) {
- throw new RuntimeException("Error setting attribute value for attribute '" +
- attributeName + "'!");
- }
- }
-
- public void setAttributeValues(String attributeName,
- VertexFrame vertexData,
- int type,
- int componentCount,
- int strideInBytes,
- int offsetInBytes,
- boolean normalize) {
- if (!setShaderAttributeVertexFrame(attributeName,
- vertexData,
- type,
- componentCount,
- strideInBytes,
- offsetInBytes,
- normalize)) {
- throw new RuntimeException("Error setting attribute value for attribute '" +
- attributeName + "'!");
- }
- }
-
- public void setSourceRegion(Quad region) {
- setSourceRegion(region.p0.x, region.p0.y,
- region.p1.x, region.p1.y,
- region.p2.x, region.p2.y,
- region.p3.x, region.p3.y);
- }
-
- public void setTargetRegion(Quad region) {
- setTargetRegion(region.p0.x, region.p0.y,
- region.p1.x, region.p1.y,
- region.p2.x, region.p2.y,
- region.p3.x, region.p3.y);
- }
-
- public void setSourceRect(float x, float y, float width, float height) {
- setSourceRegion(x, y, x + width, y, x, y + height, x + width, y + height);
- }
-
- public void setTargetRect(float x, float y, float width, float height) {
- setTargetRegion(x, y, x + width, y, x, y + height, x + width, y + height);
- }
-
- public void setClearsOutput(boolean clears) {
- if (!setShaderClearsOutput(clears)) {
- throw new RuntimeException("Could not set clears-output flag to " + clears + "!");
- }
- }
-
- public void setClearColor(float r, float g, float b) {
- if (!setShaderClearColor(r, g, b)) {
- throw new RuntimeException("Could not set clear color to " + r + "," + g + "," + b + "!");
- }
- }
-
- public void setBlendEnabled(boolean enable) {
- if (!setShaderBlendEnabled(enable)) {
- throw new RuntimeException("Could not set Blending " + enable + "!");
- }
- }
-
- public void setBlendFunc(int sfactor, int dfactor) {
- if (!setShaderBlendFunc(sfactor, dfactor)) {
- throw new RuntimeException("Could not set BlendFunc " + sfactor +","+ dfactor + "!");
- }
- }
-
- public void setDrawMode(int drawMode) {
- if (!setShaderDrawMode(drawMode)) {
- throw new RuntimeException("Could not set GL draw-mode to " + drawMode + "!");
- }
- }
-
- public void setVertexCount(int count) {
- if (!setShaderVertexCount(count)) {
- throw new RuntimeException("Could not set GL vertex count to " + count + "!");
- }
- }
-
- public void setMaximumTileSize(int size) {
- mMaxTileSize = size;
- }
-
- public void beginDrawing() {
- if (!beginShaderDrawing()) {
- throw new RuntimeException("Could not prepare shader-program for drawing!");
- }
- }
-
- private static GLEnvironment getGLEnvironment(FilterContext context) {
- GLEnvironment result = context != null ? context.getGLEnvironment() : null;
- if (result == null) {
- throw new NullPointerException("Attempting to create ShaderProgram with no GL "
- + "environment in place!");
- }
- return result;
- }
-
- static {
- System.loadLibrary("filterfw");
- }
-
- private native boolean allocate(GLEnvironment glEnv,
- String vertexShader,
- String fragmentShader);
-
- private native boolean deallocate();
-
- private native boolean compileAndLink();
-
- private native boolean shaderProcess(GLFrame[] inputs, GLFrame output);
-
- private native boolean setUniformValue(String name, Object value);
-
- private native Object getUniformValue(String name);
-
- public native boolean setSourceRegion(float x0, float y0, float x1, float y1,
- float x2, float y2, float x3, float y3);
-
- private native boolean setTargetRegion(float x0, float y0, float x1, float y1,
- float x2, float y2, float x3, float y3);
-
- private static native ShaderProgram nativeCreateIdentity(GLEnvironment glEnv);
-
- private native boolean setShaderClearsOutput(boolean clears);
-
- private native boolean setShaderBlendEnabled(boolean enable);
-
- private native boolean setShaderBlendFunc(int sfactor, int dfactor);
-
- private native boolean setShaderClearColor(float r, float g, float b);
-
- private native boolean setShaderDrawMode(int drawMode);
-
- private native boolean setShaderTileCounts(int xCount, int yCount);
-
- private native boolean setShaderVertexCount(int vertexCount);
-
- private native boolean beginShaderDrawing();
-
- private native boolean setShaderAttributeValues(String attributeName,
- float[] data,
- int componentCount);
-
- private native boolean setShaderAttributeVertexFrame(String attributeName,
- VertexFrame vertexData,
- int type,
- int componentCount,
- int strideInBytes,
- int offsetInBytes,
- boolean normalize);
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/SimpleFrame.java b/mca/filterfw/java/android/filterfw/core/SimpleFrame.java
deleted file mode 100644
index 534a30d..0000000
--- a/mca/filterfw/java/android/filterfw/core/SimpleFrame.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.NativeBuffer;
-import android.filterfw.format.ObjectFormat;
-import android.graphics.Bitmap;
-
-import java.lang.reflect.Constructor;
-import java.nio.ByteBuffer;
-
-/**
- * @hide
- */
-public class SimpleFrame extends Frame {
-
- private Object mObject;
-
- SimpleFrame(FrameFormat format, FrameManager frameManager) {
- super(format, frameManager);
- initWithFormat(format);
- setReusable(false);
- }
-
- static SimpleFrame wrapObject(Object object, FrameManager frameManager) {
- FrameFormat format = ObjectFormat.fromObject(object, FrameFormat.TARGET_SIMPLE);
- SimpleFrame result = new SimpleFrame(format, frameManager);
- result.setObjectValue(object);
- return result;
- }
-
- private void initWithFormat(FrameFormat format) {
- final int count = format.getLength();
- final int baseType = format.getBaseType();
- switch (baseType) {
- case FrameFormat.TYPE_BYTE:
- mObject = new byte[count];
- break;
- case FrameFormat.TYPE_INT16:
- mObject = new short[count];
- break;
- case FrameFormat.TYPE_INT32:
- mObject = new int[count];
- break;
- case FrameFormat.TYPE_FLOAT:
- mObject = new float[count];
- break;
- case FrameFormat.TYPE_DOUBLE:
- mObject = new double[count];
- break;
- default:
- mObject = null;
- break;
- }
- }
-
- @Override
- protected boolean hasNativeAllocation() {
- return false;
- }
-
- @Override
- protected void releaseNativeAllocation() {
- }
-
- @Override
- public Object getObjectValue() {
- return mObject;
- }
-
- @Override
- public void setInts(int[] ints) {
- assertFrameMutable();
- setGenericObjectValue(ints);
- }
-
- @Override
- public int[] getInts() {
- return (mObject instanceof int[]) ? (int[])mObject : null;
- }
-
- @Override
- public void setFloats(float[] floats) {
- assertFrameMutable();
- setGenericObjectValue(floats);
- }
-
- @Override
- public float[] getFloats() {
- return (mObject instanceof float[]) ? (float[])mObject : null;
- }
-
- @Override
- public void setData(ByteBuffer buffer, int offset, int length) {
- assertFrameMutable();
- setGenericObjectValue(ByteBuffer.wrap(buffer.array(), offset, length));
- }
-
- @Override
- public ByteBuffer getData() {
- return (mObject instanceof ByteBuffer) ? (ByteBuffer)mObject : null;
- }
-
- @Override
- public void setBitmap(Bitmap bitmap) {
- assertFrameMutable();
- setGenericObjectValue(bitmap);
- }
-
- @Override
- public Bitmap getBitmap() {
- return (mObject instanceof Bitmap) ? (Bitmap)mObject : null;
- }
-
- private void setFormatObjectClass(Class objectClass) {
- MutableFrameFormat format = getFormat().mutableCopy();
- format.setObjectClass(objectClass);
- setFormat(format);
- }
-
- @Override
- protected void setGenericObjectValue(Object object) {
- // Update the FrameFormat class
- // TODO: Take this out! FrameFormats should not be modified and convenience formats used
- // instead!
- FrameFormat format = getFormat();
- if (format.getObjectClass() == null) {
- setFormatObjectClass(object.getClass());
- } else if (!format.getObjectClass().isAssignableFrom(object.getClass())) {
- throw new RuntimeException(
- "Attempting to set object value of type '" + object.getClass() + "' on " +
- "SimpleFrame of type '" + format.getObjectClass() + "'!");
- }
-
- // Set the object value
- mObject = object;
- }
-
- @Override
- public String toString() {
- return "SimpleFrame (" + getFormat() + ")";
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/SimpleFrameManager.java b/mca/filterfw/java/android/filterfw/core/SimpleFrameManager.java
deleted file mode 100644
index e2b9047..0000000
--- a/mca/filterfw/java/android/filterfw/core/SimpleFrameManager.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.SimpleFrame;
-import android.filterfw.core.VertexFrame;
-
-/**
- * @hide
- */
-public class SimpleFrameManager extends FrameManager {
-
- public SimpleFrameManager() {
- }
-
- @Override
- public Frame newFrame(FrameFormat format) {
- return createNewFrame(format);
- }
-
- @Override
- public Frame newBoundFrame(FrameFormat format, int bindingType, long bindingId) {
- Frame result = null;
- switch(format.getTarget()) {
- case FrameFormat.TARGET_GPU: {
- GLFrame glFrame = new GLFrame(format, this, bindingType, bindingId);
- glFrame.init(getGLEnvironment());
- result = glFrame;
- break;
- }
-
- default:
- throw new RuntimeException("Attached frames are not supported for target type: "
- + FrameFormat.targetToString(format.getTarget()) + "!");
- }
- return result;
- }
-
- private Frame createNewFrame(FrameFormat format) {
- Frame result = null;
- switch(format.getTarget()) {
- case FrameFormat.TARGET_SIMPLE:
- result = new SimpleFrame(format, this);
- break;
-
- case FrameFormat.TARGET_NATIVE:
- result = new NativeFrame(format, this);
- break;
-
- case FrameFormat.TARGET_GPU: {
- GLFrame glFrame = new GLFrame(format, this);
- glFrame.init(getGLEnvironment());
- result = glFrame;
- break;
- }
-
- case FrameFormat.TARGET_VERTEXBUFFER: {
- result = new VertexFrame(format, this);
- break;
- }
-
- default:
- throw new RuntimeException("Unsupported frame target type: " +
- FrameFormat.targetToString(format.getTarget()) + "!");
- }
- return result;
- }
-
- @Override
- public Frame retainFrame(Frame frame) {
- frame.incRefCount();
- return frame;
- }
-
- @Override
- public Frame releaseFrame(Frame frame) {
- int refCount = frame.decRefCount();
- if (refCount == 0 && frame.hasNativeAllocation()) {
- frame.releaseNativeAllocation();
- return null;
- } else if (refCount < 0) {
- throw new RuntimeException("Frame reference count dropped below 0!");
- }
- return frame;
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/SimpleScheduler.java b/mca/filterfw/java/android/filterfw/core/SimpleScheduler.java
deleted file mode 100644
index bb4e5ba..0000000
--- a/mca/filterfw/java/android/filterfw/core/SimpleScheduler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.Scheduler;
-
-/**
- * @hide
- */
-public class SimpleScheduler extends Scheduler {
-
- public SimpleScheduler(FilterGraph graph) {
- super(graph);
- }
-
- @Override
- public void reset() {
- }
-
- @Override
- public Filter scheduleNextNode() {
- for (Filter filter : getGraph().getFilters()) {
- if (filter.canProcess())
- return filter;
- }
- return null;
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/StopWatchMap.java b/mca/filterfw/java/android/filterfw/core/StopWatchMap.java
deleted file mode 100644
index 444a1fc..0000000
--- a/mca/filterfw/java/android/filterfw/core/StopWatchMap.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterfw.core;
-
-import android.os.SystemClock;
-import android.util.Log;
-import java.util.HashMap;
-
-/**
- * @hide
- */
-class StopWatch {
-
- private int STOP_WATCH_LOGGING_PERIOD = 200;
- private String TAG = "MFF";
-
- private String mName;
- private long mStartTime;
- private long mTotalTime;
- private int mNumCalls;
-
- public StopWatch(String name) {
- mName = name;
- mStartTime = -1;
- mTotalTime = 0;
- mNumCalls = 0;
- }
-
- public void start() {
- if (mStartTime != -1) {
- throw new RuntimeException(
- "Calling start with StopWatch already running");
- }
- mStartTime = SystemClock.elapsedRealtime();
- }
-
- public void stop() {
- if (mStartTime == -1) {
- throw new RuntimeException(
- "Calling stop with StopWatch already stopped");
- }
- long stopTime = SystemClock.elapsedRealtime();
- mTotalTime += stopTime - mStartTime;
- ++mNumCalls;
- mStartTime = -1;
- if (mNumCalls % STOP_WATCH_LOGGING_PERIOD == 0) {
- Log.i(TAG, "AVG ms/call " + mName + ": " +
- String.format("%.1f", mTotalTime * 1.0f / mNumCalls));
- mTotalTime = 0;
- mNumCalls = 0;
- }
- }
-
-}
-
-public class StopWatchMap {
-
- public boolean LOG_MFF_RUNNING_TIMES = false;
-
- private HashMap<String, StopWatch> mStopWatches = null;
-
- public StopWatchMap() {
- mStopWatches = new HashMap<String, StopWatch>();
- }
-
- public void start(String stopWatchName) {
- if (!LOG_MFF_RUNNING_TIMES) {
- return;
- }
- if (!mStopWatches.containsKey(stopWatchName)) {
- mStopWatches.put(stopWatchName, new StopWatch(stopWatchName));
- }
- mStopWatches.get(stopWatchName).start();
- }
-
- public void stop(String stopWatchName) {
- if (!LOG_MFF_RUNNING_TIMES) {
- return;
- }
- if (!mStopWatches.containsKey(stopWatchName)) {
- throw new RuntimeException(
- "Calling stop with unknown stopWatchName: " + stopWatchName);
- }
- mStopWatches.get(stopWatchName).stop();
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/core/StreamPort.java b/mca/filterfw/java/android/filterfw/core/StreamPort.java
deleted file mode 100644
index 8520a0b..0000000
--- a/mca/filterfw/java/android/filterfw/core/StreamPort.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-/**
- * @hide
- */
-public class StreamPort extends InputPort {
-
- private Frame mFrame;
- private boolean mPersistent;
-
- public StreamPort(Filter filter, String name) {
- super(filter, name);
- }
-
- @Override
- public void clear() {
- if (mFrame != null) {
- mFrame.release();
- mFrame = null;
- }
- }
-
- @Override
- public void setFrame(Frame frame) {
- assignFrame(frame, true);
- }
-
- @Override
- public void pushFrame(Frame frame) {
- assignFrame(frame, false);
- }
-
- protected synchronized void assignFrame(Frame frame, boolean persistent) {
- assertPortIsOpen();
- checkFrameType(frame, persistent);
-
- if (persistent) {
- if (mFrame != null) {
- mFrame.release();
- }
- } else if (mFrame != null) {
- throw new RuntimeException(
- "Attempting to push more than one frame on port: " + this + "!");
- }
- mFrame = frame.retain();
- mFrame.markReadOnly();
- mPersistent = persistent;
- }
-
- @Override
- public synchronized Frame pullFrame() {
- // Make sure we have a frame
- if (mFrame == null) {
- throw new RuntimeException("No frame available to pull on port: " + this + "!");
- }
-
- // Return a retained result
- Frame result = mFrame;
- if (mPersistent) {
- mFrame.retain();
- } else {
- mFrame = null;
- }
- return result;
- }
-
- @Override
- public synchronized boolean hasFrame() {
- return mFrame != null;
- }
-
- @Override
- public String toString() {
- return "input " + super.toString();
- }
-
- @Override
- public synchronized void transfer(FilterContext context) {
- if (mFrame != null) {
- checkFrameManager(mFrame, context);
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/SyncRunner.java b/mca/filterfw/java/android/filterfw/core/SyncRunner.java
deleted file mode 100644
index abbd359..0000000
--- a/mca/filterfw/java/android/filterfw/core/SyncRunner.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.os.ConditionVariable;
-import android.util.Log;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @hide
- */
-public class SyncRunner extends GraphRunner {
-
- private Scheduler mScheduler = null;
-
- private OnRunnerDoneListener mDoneListener = null;
- private ScheduledThreadPoolExecutor mWakeExecutor = new ScheduledThreadPoolExecutor(1);
- private ConditionVariable mWakeCondition = new ConditionVariable();
-
- private StopWatchMap mTimer = null;
-
- private final boolean mLogVerbose;
- private final static String TAG = "SyncRunner";
-
- // TODO: Provide factory based constructor?
- public SyncRunner(FilterContext context, FilterGraph graph, Class schedulerClass) {
- super(context);
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
-
- if (mLogVerbose) Log.v(TAG, "Initializing SyncRunner");
-
- // Create the scheduler
- if (Scheduler.class.isAssignableFrom(schedulerClass)) {
- try {
- Constructor schedulerConstructor = schedulerClass.getConstructor(FilterGraph.class);
- mScheduler = (Scheduler)schedulerConstructor.newInstance(graph);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("Scheduler does not have constructor <init>(FilterGraph)!", e);
- } catch (InstantiationException e) {
- throw new RuntimeException("Could not instantiate the Scheduler instance!", e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Cannot access Scheduler constructor!", e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException("Scheduler constructor threw an exception", e);
- } catch (Exception e) {
- throw new RuntimeException("Could not instantiate Scheduler", e);
- }
- } else {
- throw new IllegalArgumentException("Class provided is not a Scheduler subclass!");
- }
-
- // Associate this runner and the graph with the context
- mFilterContext = context;
- mFilterContext.addGraph(graph);
-
- mTimer = new StopWatchMap();
-
- if (mLogVerbose) Log.v(TAG, "Setting up filters");
-
- // Setup graph filters
- graph.setupFilters();
- }
-
- @Override
- public FilterGraph getGraph() {
- return mScheduler != null ? mScheduler.getGraph() : null;
- }
-
- public int step() {
- assertReadyToStep();
- if (!getGraph().isReady() ) {
- throw new RuntimeException("Trying to process graph that is not open!");
- }
- return performStep() ? RESULT_RUNNING : determinePostRunState();
- }
-
- public void beginProcessing() {
- mScheduler.reset();
- getGraph().beginProcessing();
- }
-
- public void close() {
- // Close filters
- if (mLogVerbose) Log.v(TAG, "Closing graph.");
- getGraph().closeFilters(mFilterContext);
- mScheduler.reset();
- }
-
- @Override
- public void run() {
- if (mLogVerbose) Log.v(TAG, "Beginning run.");
-
- assertReadyToStep();
-
- // Preparation
- beginProcessing();
- boolean glActivated = activateGlContext();
-
- // Run
- boolean keepRunning = true;
- while (keepRunning) {
- keepRunning = performStep();
- }
-
- // Cleanup
- if (glActivated) {
- deactivateGlContext();
- }
-
- // Call completion callback if set
- if (mDoneListener != null) {
- if (mLogVerbose) Log.v(TAG, "Calling completion listener.");
- mDoneListener.onRunnerDone(determinePostRunState());
- }
- if (mLogVerbose) Log.v(TAG, "Run complete");
- }
-
- @Override
- public boolean isRunning() {
- return false;
- }
-
- @Override
- public void setDoneCallback(OnRunnerDoneListener listener) {
- mDoneListener = listener;
- }
-
- @Override
- public void stop() {
- throw new RuntimeException("SyncRunner does not support stopping a graph!");
- }
-
- @Override
- synchronized public Exception getError() {
- return null;
- }
-
- protected void waitUntilWake() {
- mWakeCondition.block();
- }
-
- protected void processFilterNode(Filter filter) {
- if (mLogVerbose) Log.v(TAG, "Processing filter node");
- filter.performProcess(mFilterContext);
- if (filter.getStatus() == Filter.STATUS_ERROR) {
- throw new RuntimeException("There was an error executing " + filter + "!");
- } else if (filter.getStatus() == Filter.STATUS_SLEEPING) {
- if (mLogVerbose) Log.v(TAG, "Scheduling filter wakeup");
- scheduleFilterWake(filter, filter.getSleepDelay());
- }
- }
-
- protected void scheduleFilterWake(Filter filter, int delay) {
- // Close the wake condition
- mWakeCondition.close();
-
- // Schedule the wake-up
- final Filter filterToSchedule = filter;
- final ConditionVariable conditionToWake = mWakeCondition;
-
- mWakeExecutor.schedule(new Runnable() {
- @Override
- public void run() {
- filterToSchedule.unsetStatus(Filter.STATUS_SLEEPING);
- conditionToWake.open();
- }
- }, delay, TimeUnit.MILLISECONDS);
- }
-
- protected int determinePostRunState() {
- boolean isBlocked = false;
- for (Filter filter : mScheduler.getGraph().getFilters()) {
- if (filter.isOpen()) {
- if (filter.getStatus() == Filter.STATUS_SLEEPING) {
- // If ANY node is sleeping, we return our state as sleeping
- return RESULT_SLEEPING;
- } else {
- // If a node is still open, it is blocked (by input or output)
- return RESULT_BLOCKED;
- }
- }
- }
- return RESULT_FINISHED;
- }
-
- // Core internal methods ///////////////////////////////////////////////////////////////////////
- boolean performStep() {
- if (mLogVerbose) Log.v(TAG, "Performing one step.");
- Filter filter = mScheduler.scheduleNextNode();
- if (filter != null) {
- mTimer.start(filter.getName());
- processFilterNode(filter);
- mTimer.stop(filter.getName());
- return true;
- } else {
- return false;
- }
- }
-
- void assertReadyToStep() {
- if (mScheduler == null) {
- throw new RuntimeException("Attempting to run schedule with no scheduler in place!");
- } else if (getGraph() == null) {
- throw new RuntimeException("Calling step on scheduler with no graph in place!");
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/core/VertexFrame.java b/mca/filterfw/java/android/filterfw/core/VertexFrame.java
deleted file mode 100644
index 6982ce3..0000000
--- a/mca/filterfw/java/android/filterfw/core/VertexFrame.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.graphics.Bitmap;
-
-import java.nio.ByteBuffer;
-
-/**
- * @hide
- */
-public class VertexFrame extends Frame {
-
- private int vertexFrameId = -1;
-
- VertexFrame(FrameFormat format, FrameManager frameManager) {
- super(format, frameManager);
- if (getFormat().getSize() <= 0) {
- throw new IllegalArgumentException("Initializing vertex frame with zero size!");
- } else {
- if (!nativeAllocate(getFormat().getSize())) {
- throw new RuntimeException("Could not allocate vertex frame!");
- }
- }
- }
-
- @Override
- protected synchronized boolean hasNativeAllocation() {
- return vertexFrameId != -1;
- }
-
- @Override
- protected synchronized void releaseNativeAllocation() {
- nativeDeallocate();
- vertexFrameId = -1;
- }
-
- @Override
- public Object getObjectValue() {
- throw new RuntimeException("Vertex frames do not support reading data!");
- }
-
- @Override
- public void setInts(int[] ints) {
- assertFrameMutable();
- if (!setNativeInts(ints)) {
- throw new RuntimeException("Could not set int values for vertex frame!");
- }
- }
-
- @Override
- public int[] getInts() {
- throw new RuntimeException("Vertex frames do not support reading data!");
- }
-
- @Override
- public void setFloats(float[] floats) {
- assertFrameMutable();
- if (!setNativeFloats(floats)) {
- throw new RuntimeException("Could not set int values for vertex frame!");
- }
- }
-
- @Override
- public float[] getFloats() {
- throw new RuntimeException("Vertex frames do not support reading data!");
- }
-
- @Override
- public void setData(ByteBuffer buffer, int offset, int length) {
- assertFrameMutable();
- byte[] bytes = buffer.array();
- if (getFormat().getSize() != bytes.length) {
- throw new RuntimeException("Data size in setData does not match vertex frame size!");
- } else if (!setNativeData(bytes, offset, length)) {
- throw new RuntimeException("Could not set vertex frame data!");
- }
- }
-
- @Override
- public ByteBuffer getData() {
- throw new RuntimeException("Vertex frames do not support reading data!");
- }
-
- @Override
- public void setBitmap(Bitmap bitmap) {
- throw new RuntimeException("Unsupported: Cannot set vertex frame bitmap value!");
- }
-
- @Override
- public Bitmap getBitmap() {
- throw new RuntimeException("Vertex frames do not support reading data!");
- }
-
- @Override
- public void setDataFromFrame(Frame frame) {
- // TODO: Optimize
- super.setDataFromFrame(frame);
- }
-
- public int getVboId() {
- return getNativeVboId();
- }
-
- @Override
- public String toString() {
- return "VertexFrame (" + getFormat() + ") with VBO ID " + getVboId();
- }
-
- static {
- System.loadLibrary("filterfw");
- }
-
- private native boolean nativeAllocate(int size);
-
- private native boolean nativeDeallocate();
-
- private native boolean setNativeData(byte[] data, int offset, int length);
-
- private native boolean setNativeInts(int[] ints);
-
- private native boolean setNativeFloats(float[] floats);
-
- private native int getNativeVboId();
-}
diff --git a/mca/filterfw/java/android/filterfw/core/package-info.java b/mca/filterfw/java/android/filterfw/core/package-info.java
deleted file mode 100644
index 4afda1b..0000000
--- a/mca/filterfw/java/android/filterfw/core/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterfw.core;
diff --git a/mca/filterfw/java/android/filterfw/format/ImageFormat.java b/mca/filterfw/java/android/filterfw/format/ImageFormat.java
deleted file mode 100644
index d57f47c..0000000
--- a/mca/filterfw/java/android/filterfw/format/ImageFormat.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.format;
-
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.MutableFrameFormat;
-import android.graphics.Bitmap;
-
-/**
- * @hide
- */
-public class ImageFormat {
-
- public static final String COLORSPACE_KEY = "colorspace";
-
- public static final int COLORSPACE_GRAY = 1;
- public static final int COLORSPACE_RGB = 2;
- public static final int COLORSPACE_RGBA = 3;
- public static final int COLORSPACE_YUV = 4;
-
- public static MutableFrameFormat create(int width,
- int height,
- int colorspace,
- int bytesPerSample,
- int target) {
- MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_BYTE, target);
- result.setDimensions(width, height);
- result.setBytesPerSample(bytesPerSample);
- result.setMetaValue(COLORSPACE_KEY, colorspace);
- if (target == FrameFormat.TARGET_SIMPLE) {
- result.setObjectClass(Bitmap.class);
- }
- return result;
- }
-
- public static MutableFrameFormat create(int width,
- int height,
- int colorspace,
- int target) {
- return create(width,
- height,
- colorspace,
- bytesPerSampleForColorspace(colorspace),
- target);
- }
-
- public static MutableFrameFormat create(int colorspace, int target) {
- return create(FrameFormat.SIZE_UNSPECIFIED,
- FrameFormat.SIZE_UNSPECIFIED,
- colorspace,
- bytesPerSampleForColorspace(colorspace),
- target);
- }
-
- public static MutableFrameFormat create(int colorspace) {
- return create(FrameFormat.SIZE_UNSPECIFIED,
- FrameFormat.SIZE_UNSPECIFIED,
- colorspace,
- bytesPerSampleForColorspace(colorspace),
- FrameFormat.TARGET_UNSPECIFIED);
- }
-
- public static int bytesPerSampleForColorspace(int colorspace) {
- switch (colorspace) {
- case COLORSPACE_GRAY:
- return 1;
- case COLORSPACE_RGB:
- return 3;
- case COLORSPACE_RGBA:
- return 4;
- case COLORSPACE_YUV:
- return 3;
- default:
- throw new RuntimeException("Unknown colorspace id " + colorspace + "!");
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/format/ObjectFormat.java b/mca/filterfw/java/android/filterfw/format/ObjectFormat.java
deleted file mode 100644
index ae39628..0000000
--- a/mca/filterfw/java/android/filterfw/format/ObjectFormat.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.format;
-
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeBuffer;
-
-/**
- * @hide
- */
-public class ObjectFormat {
-
- public static MutableFrameFormat fromClass(Class clazz, int count, int target) {
- // Create frame format
- MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target);
- result.setObjectClass(getBoxedClass(clazz));
- if (count != FrameFormat.SIZE_UNSPECIFIED) {
- result.setDimensions(count);
- }
- result.setBytesPerSample(bytesPerSampleForClass(clazz, target));
- return result;
- }
-
- public static MutableFrameFormat fromClass(Class clazz, int target) {
- return fromClass(clazz, FrameFormat.SIZE_UNSPECIFIED, target);
- }
-
- public static MutableFrameFormat fromObject(Object object, int target) {
- return object == null
- ? new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target)
- : fromClass(object.getClass(), FrameFormat.SIZE_UNSPECIFIED, target);
- }
-
- public static MutableFrameFormat fromObject(Object object, int count, int target) {
- return object == null
- ? new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target)
- : fromClass(object.getClass(), count, target);
- }
-
- private static int bytesPerSampleForClass(Class clazz, int target) {
- // Native targets have objects manifested in a byte buffer. Thus it is important to
- // correctly determine the size of single element here.
- if (target == FrameFormat.TARGET_NATIVE) {
- if (!NativeBuffer.class.isAssignableFrom(clazz)) {
- throw new IllegalArgumentException("Native object-based formats must be of a " +
- "NativeBuffer subclass! (Received class: " + clazz + ").");
- }
- try {
- return ((NativeBuffer)clazz.newInstance()).getElementSize();
- } catch (Exception e) {
- throw new RuntimeException("Could not determine the size of an element in a "
- + "native object-based frame of type " + clazz + "! Perhaps it is missing a "
- + "default constructor?");
- }
- } else {
- return FrameFormat.BYTES_PER_SAMPLE_UNSPECIFIED;
- }
- }
-
- private static Class getBoxedClass(Class type) {
- // Check if type is primitive
- if (type.isPrimitive()) {
- // Yes -> box it
- if (type == boolean.class) {
- return java.lang.Boolean.class;
- } else if (type == byte.class) {
- return java.lang.Byte.class;
- } else if (type == char.class) {
- return java.lang.Character.class;
- } else if (type == short.class) {
- return java.lang.Short.class;
- } else if (type == int.class) {
- return java.lang.Integer.class;
- } else if (type == long.class) {
- return java.lang.Long.class;
- } else if (type == float.class) {
- return java.lang.Float.class;
- } else if (type == double.class) {
- return java.lang.Double.class;
- } else {
- throw new IllegalArgumentException(
- "Unknown primitive type: " + type.getSimpleName() + "!");
- }
- } else {
- // No -> return it
- return type;
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/format/PrimitiveFormat.java b/mca/filterfw/java/android/filterfw/format/PrimitiveFormat.java
deleted file mode 100644
index 40f07aa..0000000
--- a/mca/filterfw/java/android/filterfw/format/PrimitiveFormat.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.format;
-
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.MutableFrameFormat;
-
-/**
- * @hide
- */
-public class PrimitiveFormat {
-
- public static MutableFrameFormat createByteFormat(int count, int target) {
- return createFormat(FrameFormat.TYPE_BYTE, count, target);
- }
-
- public static MutableFrameFormat createInt16Format(int count, int target) {
- return createFormat(FrameFormat.TYPE_INT16, count, target);
- }
-
- public static MutableFrameFormat createInt32Format(int count, int target) {
- return createFormat(FrameFormat.TYPE_INT32, count, target);
- }
-
- public static MutableFrameFormat createFloatFormat(int count, int target) {
- return createFormat(FrameFormat.TYPE_FLOAT, count, target);
- }
-
- public static MutableFrameFormat createDoubleFormat(int count, int target) {
- return createFormat(FrameFormat.TYPE_DOUBLE, count, target);
- }
-
- public static MutableFrameFormat createByteFormat(int target) {
- return createFormat(FrameFormat.TYPE_BYTE, target);
- }
-
- public static MutableFrameFormat createInt16Format(int target) {
- return createFormat(FrameFormat.TYPE_INT16, target);
- }
-
- public static MutableFrameFormat createInt32Format(int target) {
- return createFormat(FrameFormat.TYPE_INT32, target);
- }
-
- public static MutableFrameFormat createFloatFormat(int target) {
- return createFormat(FrameFormat.TYPE_FLOAT, target);
- }
-
- public static MutableFrameFormat createDoubleFormat(int target) {
- return createFormat(FrameFormat.TYPE_DOUBLE, target);
- }
-
- private static MutableFrameFormat createFormat(int baseType, int count, int target) {
- MutableFrameFormat result = new MutableFrameFormat(baseType, target);
- result.setDimensions(count);
- return result;
- }
-
- private static MutableFrameFormat createFormat(int baseType, int target) {
- MutableFrameFormat result = new MutableFrameFormat(baseType, target);
- result.setDimensionCount(1);
- return result;
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/format/package-info.java b/mca/filterfw/java/android/filterfw/format/package-info.java
deleted file mode 100644
index dfd9a3f..0000000
--- a/mca/filterfw/java/android/filterfw/format/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterfw.format;
diff --git a/mca/filterfw/java/android/filterfw/geometry/Point.java b/mca/filterfw/java/android/filterfw/geometry/Point.java
deleted file mode 100644
index 8207c72..0000000
--- a/mca/filterfw/java/android/filterfw/geometry/Point.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.geometry;
-
-import java.lang.Math;
-
-/**
- * @hide
- */
-public class Point {
-
- public float x;
- public float y;
-
- public Point() {
- }
-
- public Point(float x, float y) {
- this.x = x;
- this.y = y;
- }
-
- public void set(float x, float y) {
- this.x = x;
- this.y = y;
- }
-
- public boolean IsInUnitRange() {
- return x >= 0.0f && x <= 1.0f &&
- y >= 0.0f && y <= 1.0f;
- }
-
- public Point plus(float x, float y) {
- return new Point(this.x + x, this.y + y);
- }
-
- public Point plus(Point point) {
- return this.plus(point.x, point.y);
- }
-
- public Point minus(float x, float y) {
- return new Point(this.x - x, this.y - y);
- }
-
- public Point minus(Point point) {
- return this.minus(point.x, point.y);
- }
-
- public Point times(float s) {
- return new Point(this.x * s, this.y * s);
- }
-
- public Point mult(float x, float y) {
- return new Point(this.x * x, this.y * y);
- }
-
- public float length() {
- return (float)Math.sqrt(x*x + y*y);
- }
-
- public float distanceTo(Point p) {
- return p.minus(this).length();
- }
-
- public Point scaledTo(float length) {
- return this.times(length / this.length());
- }
-
- public Point normalize() {
- return this.scaledTo(1.0f);
- }
-
- public Point rotated90(int count) {
- float nx = this.x;
- float ny = this.y;
- for (int i = 0; i < count; ++i) {
- float ox = nx;
- nx = ny;
- ny = -ox;
- }
- return new Point(nx, ny);
- }
-
- public Point rotated(float radians) {
- // TODO(renn): Optimize: Keep cache of cos/sin values
- return new Point((float)(Math.cos(radians) * x - Math.sin(radians) * y),
- (float)(Math.sin(radians) * x + Math.cos(radians) * y));
- }
-
- public Point rotatedAround(Point center, float radians) {
- return this.minus(center).rotated(radians).plus(center);
- }
-
- @Override
- public String toString() {
- return "(" + x + ", " + y + ")";
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/geometry/Quad.java b/mca/filterfw/java/android/filterfw/geometry/Quad.java
deleted file mode 100644
index ee092fd..0000000
--- a/mca/filterfw/java/android/filterfw/geometry/Quad.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.geometry;
-
-import android.filterfw.geometry.Point;
-
-import java.lang.Float;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @hide
- */
-public class Quad {
-
- public Point p0;
- public Point p1;
- public Point p2;
- public Point p3;
-
- public Quad() {
- }
-
- public Quad(Point p0, Point p1, Point p2, Point p3) {
- this.p0 = p0;
- this.p1 = p1;
- this.p2 = p2;
- this.p3 = p3;
- }
-
- public boolean IsInUnitRange() {
- return p0.IsInUnitRange() &&
- p1.IsInUnitRange() &&
- p2.IsInUnitRange() &&
- p3.IsInUnitRange();
- }
-
- public Quad translated(Point t) {
- return new Quad(p0.plus(t), p1.plus(t), p2.plus(t), p3.plus(t));
- }
-
- public Quad translated(float x, float y) {
- return new Quad(p0.plus(x, y), p1.plus(x, y), p2.plus(x, y), p3.plus(x, y));
- }
-
- public Quad scaled(float s) {
- return new Quad(p0.times(s), p1.times(s), p2.times(s), p3.times(s));
- }
-
- public Quad scaled(float x, float y) {
- return new Quad(p0.mult(x, y), p1.mult(x, y), p2.mult(x, y), p3.mult(x, y));
- }
-
- public Rectangle boundingBox() {
- List<Float> xs = Arrays.asList(p0.x, p1.x, p2.x, p3.x);
- List<Float> ys = Arrays.asList(p0.y, p1.y, p2.y, p3.y);
- float x0 = Collections.min(xs);
- float y0 = Collections.min(ys);
- float x1 = Collections.max(xs);
- float y1 = Collections.max(ys);
- return new Rectangle(x0, y0, x1 - x0, y1 - y0);
- }
-
- public float getBoundingWidth() {
- List<Float> xs = Arrays.asList(p0.x, p1.x, p2.x, p3.x);
- return Collections.max(xs) - Collections.min(xs);
- }
-
- public float getBoundingHeight() {
- List<Float> ys = Arrays.asList(p0.y, p1.y, p2.y, p3.y);
- return Collections.max(ys) - Collections.min(ys);
- }
-
- @Override
- public String toString() {
- return "{" + p0 + ", " + p1 + ", " + p2 + ", " + p3 + "}";
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/geometry/Rectangle.java b/mca/filterfw/java/android/filterfw/geometry/Rectangle.java
deleted file mode 100644
index e4bd622..0000000
--- a/mca/filterfw/java/android/filterfw/geometry/Rectangle.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.geometry;
-
-import android.filterfw.geometry.Point;
-import android.filterfw.geometry.Quad;
-
-/**
- * @hide
- */
-public class Rectangle extends Quad {
-
- public Rectangle() {
- }
-
- public Rectangle(float x, float y, float width, float height) {
- super(new Point(x, y),
- new Point(x + width, y),
- new Point(x, y + height),
- new Point(x + width, y + height));
- }
-
- public Rectangle(Point origin, Point size) {
- super(origin,
- origin.plus(size.x, 0.0f),
- origin.plus(0.0f, size.y),
- origin.plus(size.x, size.y));
- }
-
- public static Rectangle fromRotatedRect(Point center, Point size, float rotation) {
- Point p0 = new Point(center.x - size.x/2f, center.y - size.y/2f);
- Point p1 = new Point(center.x + size.x/2f, center.y - size.y/2f);
- Point p2 = new Point(center.x - size.x/2f, center.y + size.y/2f);
- Point p3 = new Point(center.x + size.x/2f, center.y + size.y/2f);
- return new Rectangle(p0.rotatedAround(center, rotation),
- p1.rotatedAround(center, rotation),
- p2.rotatedAround(center, rotation),
- p3.rotatedAround(center, rotation));
- }
-
- private Rectangle(Point p0, Point p1, Point p2, Point p3) {
- super(p0, p1, p2, p3);
- }
-
- public static Rectangle fromCenterVerticalAxis(Point center, Point vAxis, Point size) {
- Point dy = vAxis.scaledTo(size.y / 2.0f);
- Point dx = vAxis.rotated90(1).scaledTo(size.x / 2.0f);
- return new Rectangle(center.minus(dx).minus(dy),
- center.plus(dx).minus(dy),
- center.minus(dx).plus(dy),
- center.plus(dx).plus(dy));
- }
-
- public float getWidth() {
- return p1.minus(p0).length();
- }
-
- public float getHeight() {
- return p2.minus(p0).length();
- }
-
- public Point center() {
- return p0.plus(p1).plus(p2).plus(p3).times(0.25f);
- }
-
- @Override
- public Rectangle scaled(float s) {
- return new Rectangle(p0.times(s), p1.times(s), p2.times(s), p3.times(s));
- }
-
- @Override
- public Rectangle scaled(float x, float y) {
- return new Rectangle(p0.mult(x, y), p1.mult(x, y), p2.mult(x, y), p3.mult(x, y));
- }
-
- //public Rectangle rotated(float radians) {
- // TODO: Implement this.
- //}
-
-}
diff --git a/mca/filterfw/java/android/filterfw/geometry/package-info.java b/mca/filterfw/java/android/filterfw/geometry/package-info.java
deleted file mode 100644
index 5547622..0000000
--- a/mca/filterfw/java/android/filterfw/geometry/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterfw.geometry;
diff --git a/mca/filterfw/java/android/filterfw/io/GraphIOException.java b/mca/filterfw/java/android/filterfw/io/GraphIOException.java
deleted file mode 100644
index 940b393..0000000
--- a/mca/filterfw/java/android/filterfw/io/GraphIOException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.io;
-
-/**
- * @hide
- */
-public class GraphIOException extends Exception {
-
- public GraphIOException() {
- super();
- }
-
- public GraphIOException(String message) {
- super(message);
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/io/GraphReader.java b/mca/filterfw/java/android/filterfw/io/GraphReader.java
deleted file mode 100644
index deb06e2..0000000
--- a/mca/filterfw/java/android/filterfw/io/GraphReader.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.io;
-
-import android.content.Context;
-import android.filterfw.core.FilterGraph;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.io.GraphIOException;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.StringWriter;
-
-/**
- * @hide
- */
-public abstract class GraphReader {
-
- protected KeyValueMap mReferences = new KeyValueMap();
-
- public abstract FilterGraph readGraphString(String graphString) throws GraphIOException;
-
- public abstract KeyValueMap readKeyValueAssignments(String assignments) throws GraphIOException;
-
- public FilterGraph readGraphResource(Context context, int resourceId) throws GraphIOException {
- InputStream inputStream = context.getResources().openRawResource(resourceId);
- InputStreamReader reader = new InputStreamReader(inputStream);
- StringWriter writer = new StringWriter();
- char[] buffer = new char[1024];
- try {
- int bytesRead;
- while ((bytesRead = reader.read(buffer, 0, 1024)) > 0) {
- writer.write(buffer, 0, bytesRead);
- }
- } catch (IOException e) {
- throw new RuntimeException("Could not read specified resource file!");
- }
- return readGraphString(writer.toString());
- }
-
- public void addReference(String name, Object object) {
- mReferences.put(name, object);
- }
-
- public void addReferencesByMap(KeyValueMap refs) {
- mReferences.putAll(refs);
- }
-
- public void addReferencesByKeysAndValues(Object... references) {
- mReferences.setKeyValues(references);
- }
-
-}
diff --git a/mca/filterfw/java/android/filterfw/io/PatternScanner.java b/mca/filterfw/java/android/filterfw/io/PatternScanner.java
deleted file mode 100644
index 4f1df02..0000000
--- a/mca/filterfw/java/android/filterfw/io/PatternScanner.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.io;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @hide
- */
-public class PatternScanner {
-
- private String mInput;
- private Pattern mIgnorePattern;
- private int mOffset = 0;
- private int mLineNo = 0;
- private int mStartOfLine = 0;
-
- public PatternScanner(String input) {
- mInput = input;
- }
-
- public PatternScanner(String input, Pattern ignorePattern) {
- mInput = input;
- mIgnorePattern = ignorePattern;
- skip(mIgnorePattern);
- }
-
- public String tryEat(Pattern pattern) {
- // Skip ignore pattern
- if (mIgnorePattern != null) {
- skip(mIgnorePattern);
- }
-
- // Create the matcher
- Matcher matcher = pattern.matcher(mInput);
- matcher.region(mOffset, mInput.length());
-
- // Attempt to match
- String result = null;
- if (matcher.lookingAt()) {
- updateLineCount(mOffset, matcher.end());
- mOffset = matcher.end();
- result = mInput.substring(matcher.start(), matcher.end());
- }
-
- // Skip ignore pattern
- if (result != null && mIgnorePattern != null) {
- skip(mIgnorePattern);
- }
-
- return result;
- }
-
- public String eat(Pattern pattern, String tokenName) {
- String result = tryEat(pattern);
- if (result == null) {
- throw new RuntimeException(unexpectedTokenMessage(tokenName));
- }
- return result;
- }
-
- public boolean peek(Pattern pattern) {
- // Skip ignore pattern
- if (mIgnorePattern != null) {
- skip(mIgnorePattern);
- }
-
- // Create the matcher
- Matcher matcher = pattern.matcher(mInput);
- matcher.region(mOffset, mInput.length());
-
- // Attempt to match
- return matcher.lookingAt();
- }
-
- public void skip(Pattern pattern) {
- Matcher matcher = pattern.matcher(mInput);
- matcher.region(mOffset, mInput.length());
- if (matcher.lookingAt()) {
- updateLineCount(mOffset, matcher.end());
- mOffset = matcher.end();
- }
- }
-
- public boolean atEnd() {
- return mOffset >= mInput.length();
- }
-
- public int lineNo() {
- return mLineNo;
- }
-
- public String unexpectedTokenMessage(String tokenName) {
- String line = mInput.substring(mStartOfLine, mOffset);
- return "Unexpected token on line " + (mLineNo + 1) + " after '" + line + "' <- Expected " +
- tokenName + "!";
- }
-
- public void updateLineCount(int start, int end) {
- for (int i = start; i < end; ++i) {
- if (mInput.charAt(i) == '\n') {
- ++mLineNo;
- mStartOfLine = i + 1;
- }
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/io/TextGraphReader.java b/mca/filterfw/java/android/filterfw/io/TextGraphReader.java
deleted file mode 100644
index 366ef82..0000000
--- a/mca/filterfw/java/android/filterfw/io/TextGraphReader.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.io;
-
-import java.lang.Float;
-import java.lang.Integer;
-import java.lang.String;
-
-import java.util.ArrayList;
-import java.util.regex.Pattern;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterFactory;
-import android.filterfw.core.FilterGraph;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.ProtocolException;
-import android.filterfw.io.GraphReader;
-import android.filterfw.io.GraphIOException;
-import android.filterfw.io.PatternScanner;
-
-/**
- * @hide
- */
-public class TextGraphReader extends GraphReader {
-
- private ArrayList<Command> mCommands = new ArrayList<Command>();
- private Filter mCurrentFilter;
- private FilterGraph mCurrentGraph;
- private KeyValueMap mBoundReferences;
- private KeyValueMap mSettings;
- private FilterFactory mFactory;
-
- private interface Command {
- public void execute(TextGraphReader reader) throws GraphIOException;
- }
-
- private class ImportPackageCommand implements Command {
- private String mPackageName;
-
- public ImportPackageCommand(String packageName) {
- mPackageName = packageName;
- }
-
- @Override
- public void execute(TextGraphReader reader) throws GraphIOException {
- try {
- reader.mFactory.addPackage(mPackageName);
- } catch (IllegalArgumentException e) {
- throw new GraphIOException(e.getMessage());
- }
- }
- }
-
- private class AddLibraryCommand implements Command {
- private String mLibraryName;
-
- public AddLibraryCommand(String libraryName) {
- mLibraryName = libraryName;
- }
-
- @Override
- public void execute(TextGraphReader reader) {
- reader.mFactory.addFilterLibrary(mLibraryName);
- }
- }
-
- private class AllocateFilterCommand implements Command {
- private String mClassName;
- private String mFilterName;
-
- public AllocateFilterCommand(String className, String filterName) {
- mClassName = className;
- mFilterName = filterName;
- }
-
- public void execute(TextGraphReader reader) throws GraphIOException {
- // Create the filter
- Filter filter = null;
- try {
- filter = reader.mFactory.createFilterByClassName(mClassName, mFilterName);
- } catch (IllegalArgumentException e) {
- throw new GraphIOException(e.getMessage());
- }
-
- // Set it as the current filter
- reader.mCurrentFilter = filter;
- }
- }
-
- private class InitFilterCommand implements Command {
- private KeyValueMap mParams;
-
- public InitFilterCommand(KeyValueMap params) {
- mParams = params;
- }
-
- @Override
- public void execute(TextGraphReader reader) throws GraphIOException {
- Filter filter = reader.mCurrentFilter;
- try {
- filter.initWithValueMap(mParams);
- } catch (ProtocolException e) {
- throw new GraphIOException(e.getMessage());
- }
- reader.mCurrentGraph.addFilter(mCurrentFilter);
- }
- }
-
- private class ConnectCommand implements Command {
- private String mSourceFilter;
- private String mSourcePort;
- private String mTargetFilter;
- private String mTargetName;
-
- public ConnectCommand(String sourceFilter,
- String sourcePort,
- String targetFilter,
- String targetName) {
- mSourceFilter = sourceFilter;
- mSourcePort = sourcePort;
- mTargetFilter = targetFilter;
- mTargetName = targetName;
- }
-
- @Override
- public void execute(TextGraphReader reader) {
- reader.mCurrentGraph.connect(mSourceFilter, mSourcePort, mTargetFilter, mTargetName);
- }
- }
-
- @Override
- public FilterGraph readGraphString(String graphString) throws GraphIOException {
- FilterGraph result = new FilterGraph();
-
- reset();
- mCurrentGraph = result;
- parseString(graphString);
- applySettings();
- executeCommands();
- reset();
-
- return result;
- }
-
- private void reset() {
- mCurrentGraph = null;
- mCurrentFilter = null;
- mCommands.clear();
- mBoundReferences = new KeyValueMap();
- mSettings = new KeyValueMap();
- mFactory = new FilterFactory();
- }
-
- private void parseString(String graphString) throws GraphIOException {
- final Pattern commandPattern = Pattern.compile("@[a-zA-Z]+");
- final Pattern curlyClosePattern = Pattern.compile("\\}");
- final Pattern curlyOpenPattern = Pattern.compile("\\{");
- final Pattern ignorePattern = Pattern.compile("(\\s+|//[^\\n]*\\n)+");
- final Pattern packageNamePattern = Pattern.compile("[a-zA-Z\\.]+");
- final Pattern libraryNamePattern = Pattern.compile("[a-zA-Z\\./:]+");
- final Pattern portPattern = Pattern.compile("\\[[a-zA-Z0-9\\-_]+\\]");
- final Pattern rightArrowPattern = Pattern.compile("=>");
- final Pattern semicolonPattern = Pattern.compile(";");
- final Pattern wordPattern = Pattern.compile("[a-zA-Z0-9\\-_]+");
-
- final int STATE_COMMAND = 0;
- final int STATE_IMPORT_PKG = 1;
- final int STATE_ADD_LIBRARY = 2;
- final int STATE_FILTER_CLASS = 3;
- final int STATE_FILTER_NAME = 4;
- final int STATE_CURLY_OPEN = 5;
- final int STATE_PARAMETERS = 6;
- final int STATE_CURLY_CLOSE = 7;
- final int STATE_SOURCE_FILTERNAME = 8;
- final int STATE_SOURCE_PORT = 9;
- final int STATE_RIGHT_ARROW = 10;
- final int STATE_TARGET_FILTERNAME = 11;
- final int STATE_TARGET_PORT = 12;
- final int STATE_ASSIGNMENT = 13;
- final int STATE_EXTERNAL = 14;
- final int STATE_SETTING = 15;
- final int STATE_SEMICOLON = 16;
-
- int state = STATE_COMMAND;
- PatternScanner scanner = new PatternScanner(graphString, ignorePattern);
-
- String curClassName = null;
- String curSourceFilterName = null;
- String curSourcePortName = null;
- String curTargetFilterName = null;
- String curTargetPortName = null;
-
- // State machine main loop
- while (!scanner.atEnd()) {
- switch (state) {
- case STATE_COMMAND: {
- String curCommand = scanner.eat(commandPattern, "<command>");
- if (curCommand.equals("@import")) {
- state = STATE_IMPORT_PKG;
- } else if (curCommand.equals("@library")) {
- state = STATE_ADD_LIBRARY;
- } else if (curCommand.equals("@filter")) {
- state = STATE_FILTER_CLASS;
- } else if (curCommand.equals("@connect")) {
- state = STATE_SOURCE_FILTERNAME;
- } else if (curCommand.equals("@set")) {
- state = STATE_ASSIGNMENT;
- } else if (curCommand.equals("@external")) {
- state = STATE_EXTERNAL;
- } else if (curCommand.equals("@setting")) {
- state = STATE_SETTING;
- } else {
- throw new GraphIOException("Unknown command '" + curCommand + "'!");
- }
- break;
- }
-
- case STATE_IMPORT_PKG: {
- String packageName = scanner.eat(packageNamePattern, "<package-name>");
- mCommands.add(new ImportPackageCommand(packageName));
- state = STATE_SEMICOLON;
- break;
- }
-
- case STATE_ADD_LIBRARY: {
- String libraryName = scanner.eat(libraryNamePattern, "<library-name>");
- mCommands.add(new AddLibraryCommand(libraryName));
- state = STATE_SEMICOLON;
- break;
- }
-
- case STATE_FILTER_CLASS:
- curClassName = scanner.eat(wordPattern, "<class-name>");
- state = STATE_FILTER_NAME;
- break;
-
- case STATE_FILTER_NAME: {
- String curFilterName = scanner.eat(wordPattern, "<filter-name>");
- mCommands.add(new AllocateFilterCommand(curClassName, curFilterName));
- state = STATE_CURLY_OPEN;
- break;
- }
-
- case STATE_CURLY_OPEN:
- scanner.eat(curlyOpenPattern, "{");
- state = STATE_PARAMETERS;
- break;
-
- case STATE_PARAMETERS: {
- KeyValueMap params = readKeyValueAssignments(scanner, curlyClosePattern);
- mCommands.add(new InitFilterCommand(params));
- state = STATE_CURLY_CLOSE;
- break;
- }
-
- case STATE_CURLY_CLOSE:
- scanner.eat(curlyClosePattern, "}");
- state = STATE_COMMAND;
- break;
-
- case STATE_SOURCE_FILTERNAME:
- curSourceFilterName = scanner.eat(wordPattern, "<source-filter-name>");
- state = STATE_SOURCE_PORT;
- break;
-
- case STATE_SOURCE_PORT: {
- String portString = scanner.eat(portPattern, "[<source-port-name>]");
- curSourcePortName = portString.substring(1, portString.length() - 1);
- state = STATE_RIGHT_ARROW;
- break;
- }
-
- case STATE_RIGHT_ARROW:
- scanner.eat(rightArrowPattern, "=>");
- state = STATE_TARGET_FILTERNAME;
- break;
-
- case STATE_TARGET_FILTERNAME:
- curTargetFilterName = scanner.eat(wordPattern, "<target-filter-name>");
- state = STATE_TARGET_PORT;
- break;
-
- case STATE_TARGET_PORT: {
- String portString = scanner.eat(portPattern, "[<target-port-name>]");
- curTargetPortName = portString.substring(1, portString.length() - 1);
- mCommands.add(new ConnectCommand(curSourceFilterName,
- curSourcePortName,
- curTargetFilterName,
- curTargetPortName));
- state = STATE_SEMICOLON;
- break;
- }
-
- case STATE_ASSIGNMENT: {
- KeyValueMap assignment = readKeyValueAssignments(scanner, semicolonPattern);
- mBoundReferences.putAll(assignment);
- state = STATE_SEMICOLON;
- break;
- }
-
- case STATE_EXTERNAL: {
- String externalName = scanner.eat(wordPattern, "<external-identifier>");
- bindExternal(externalName);
- state = STATE_SEMICOLON;
- break;
- }
-
- case STATE_SETTING: {
- KeyValueMap setting = readKeyValueAssignments(scanner, semicolonPattern);
- mSettings.putAll(setting);
- state = STATE_SEMICOLON;
- break;
- }
-
- case STATE_SEMICOLON:
- scanner.eat(semicolonPattern, ";");
- state = STATE_COMMAND;
- break;
- }
- }
-
- // Make sure end of input was expected
- if (state != STATE_SEMICOLON && state != STATE_COMMAND) {
- throw new GraphIOException("Unexpected end of input!");
- }
- }
-
- @Override
- public KeyValueMap readKeyValueAssignments(String assignments) throws GraphIOException {
- final Pattern ignorePattern = Pattern.compile("\\s+");
- PatternScanner scanner = new PatternScanner(assignments, ignorePattern);
- return readKeyValueAssignments(scanner, null);
- }
-
- private KeyValueMap readKeyValueAssignments(PatternScanner scanner,
- Pattern endPattern) throws GraphIOException {
- // Our parser is a state-machine, and these are our states
- final int STATE_IDENTIFIER = 0;
- final int STATE_EQUALS = 1;
- final int STATE_VALUE = 2;
- final int STATE_POST_VALUE = 3;
-
- final Pattern equalsPattern = Pattern.compile("=");
- final Pattern semicolonPattern = Pattern.compile(";");
- final Pattern wordPattern = Pattern.compile("[a-zA-Z]+[a-zA-Z0-9]*");
- final Pattern stringPattern = Pattern.compile("'[^']*'|\\\"[^\\\"]*\\\"");
- final Pattern intPattern = Pattern.compile("[0-9]+");
- final Pattern floatPattern = Pattern.compile("[0-9]*\\.[0-9]+f?");
- final Pattern referencePattern = Pattern.compile("\\$[a-zA-Z]+[a-zA-Z0-9]");
- final Pattern booleanPattern = Pattern.compile("true|false");
-
- int state = STATE_IDENTIFIER;
- KeyValueMap newVals = new KeyValueMap();
- String curKey = null;
- String curValue = null;
-
- while (!scanner.atEnd() && !(endPattern != null && scanner.peek(endPattern))) {
- switch (state) {
- case STATE_IDENTIFIER:
- curKey = scanner.eat(wordPattern, "<identifier>");
- state = STATE_EQUALS;
- break;
-
- case STATE_EQUALS:
- scanner.eat(equalsPattern, "=");
- state = STATE_VALUE;
- break;
-
- case STATE_VALUE:
- if ((curValue = scanner.tryEat(stringPattern)) != null) {
- newVals.put(curKey, curValue.substring(1, curValue.length() - 1));
- } else if ((curValue = scanner.tryEat(referencePattern)) != null) {
- String refName = curValue.substring(1, curValue.length());
- Object referencedObject = mBoundReferences != null
- ? mBoundReferences.get(refName)
- : null;
- if (referencedObject == null) {
- throw new GraphIOException(
- "Unknown object reference to '" + refName + "'!");
- }
- newVals.put(curKey, referencedObject);
- } else if ((curValue = scanner.tryEat(booleanPattern)) != null) {
- newVals.put(curKey, Boolean.parseBoolean(curValue));
- } else if ((curValue = scanner.tryEat(floatPattern)) != null) {
- newVals.put(curKey, Float.parseFloat(curValue));
- } else if ((curValue = scanner.tryEat(intPattern)) != null) {
- newVals.put(curKey, Integer.parseInt(curValue));
- } else {
- throw new GraphIOException(scanner.unexpectedTokenMessage("<value>"));
- }
- state = STATE_POST_VALUE;
- break;
-
- case STATE_POST_VALUE:
- scanner.eat(semicolonPattern, ";");
- state = STATE_IDENTIFIER;
- break;
- }
- }
-
- // Make sure end is expected
- if (state != STATE_IDENTIFIER && state != STATE_POST_VALUE) {
- throw new GraphIOException(
- "Unexpected end of assignments on line " + scanner.lineNo() + "!");
- }
-
- return newVals;
- }
-
- private void bindExternal(String name) throws GraphIOException {
- if (mReferences.containsKey(name)) {
- Object value = mReferences.get(name);
- mBoundReferences.put(name, value);
- } else {
- throw new GraphIOException("Unknown external variable '" + name + "'! "
- + "You must add a reference to this external in the host program using "
- + "addReference(...)!");
- }
- }
-
- /**
- * Unused for now: Often you may want to declare references that are NOT in a certain graph,
- * e.g. when reading multiple graphs with the same reader. We could print a warning, but even
- * that may be too much.
- **/
- private void checkReferences() throws GraphIOException {
- for (String reference : mReferences.keySet()) {
- if (!mBoundReferences.containsKey(reference)) {
- throw new GraphIOException(
- "Host program specifies reference to '" + reference + "', which is not "
- + "declared @external in graph file!");
- }
- }
- }
-
- private void applySettings() throws GraphIOException {
- for (String setting : mSettings.keySet()) {
- Object value = mSettings.get(setting);
- if (setting.equals("autoBranch")) {
- expectSettingClass(setting, value, String.class);
- if (value.equals("synced")) {
- mCurrentGraph.setAutoBranchMode(FilterGraph.AUTOBRANCH_SYNCED);
- } else if (value.equals("unsynced")) {
- mCurrentGraph.setAutoBranchMode(FilterGraph.AUTOBRANCH_UNSYNCED);
- } else if (value.equals("off")) {
- mCurrentGraph.setAutoBranchMode(FilterGraph.AUTOBRANCH_OFF);
- } else {
- throw new GraphIOException("Unknown autobranch setting: " + value + "!");
- }
- } else if (setting.equals("discardUnconnectedOutputs")) {
- expectSettingClass(setting, value, Boolean.class);
- mCurrentGraph.setDiscardUnconnectedOutputs((Boolean)value);
- } else {
- throw new GraphIOException("Unknown @setting '" + setting + "'!");
- }
- }
- }
-
- private void expectSettingClass(String setting,
- Object value,
- Class expectedClass) throws GraphIOException {
- if (value.getClass() != expectedClass) {
- throw new GraphIOException("Setting '" + setting + "' must have a value of type "
- + expectedClass.getSimpleName() + ", but found a value of type "
- + value.getClass().getSimpleName() + "!");
- }
- }
-
- private void executeCommands() throws GraphIOException {
- for (Command command : mCommands) {
- command.execute(this);
- }
- }
-}
diff --git a/mca/filterfw/java/android/filterfw/io/package-info.java b/mca/filterfw/java/android/filterfw/io/package-info.java
deleted file mode 100644
index ea3e70f..0000000
--- a/mca/filterfw/java/android/filterfw/io/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterfw.io;
diff --git a/mca/filterfw/jni/Android.mk b/mca/filterfw/jni/Android.mk
deleted file mode 100644
index 5aa5af1..0000000
--- a/mca/filterfw/jni/Android.mk
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-#####################
-# Build module libfilterfw_jni
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE = libfilterfw_jni
-
-LOCAL_SRC_FILES = jni_init.cpp \
- jni_gl_environment.cpp \
- jni_gl_frame.cpp \
- jni_native_buffer.cpp \
- jni_native_frame.cpp \
- jni_native_program.cpp \
- jni_shader_program.cpp \
- jni_util.cpp \
- jni_vertex_frame.cpp
-
-# Need FilterFW lib
-include $(LOCAL_PATH)/../native/libfilterfw.mk
-
-# Also need the JNI headers.
-LOCAL_C_INCLUDES += \
- $(JNI_H_INCLUDE) \
- $(LOCAL_PATH)/..
-
-# Don't prelink this library. For more efficient code, you may want
-# to add this library to the prelink map and set this to true. However,
-# it's difficult to do this for applications that are not supplied as
-# part of a system image.
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/mca/filterfw/jni/jni_gl_environment.cpp b/mca/filterfw/jni/jni_gl_environment.cpp
deleted file mode 100644
index 4fa1718..0000000
--- a/mca/filterfw/jni/jni_gl_environment.cpp
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// #define LOG_NDEBUG 0
-
-#include <stdint.h>
-#include <android/native_window_jni.h>
-
-#include "jni/jni_gl_environment.h"
-#include "jni/jni_util.h"
-#include <media/mediarecorder.h>
-#include "native/core/gl_env.h"
-
-#include <gui/ISurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
-#include <utils/Errors.h>
-#include <system/window.h>
-
-
-using android::filterfw::GLEnv;
-using android::filterfw::WindowHandle;
-using android::MediaRecorder;
-using android::sp;
-using android::ISurfaceTexture;
-using android::SurfaceTextureClient;
-
-
-class NativeWindowHandle : public WindowHandle {
- public:
- NativeWindowHandle(ANativeWindow* window) : window_(window) {
- }
-
- virtual ~NativeWindowHandle() {
- }
-
- virtual void Destroy() {
- LOGI("Releasing ANativeWindow!");
- ANativeWindow_release(window_);
- }
-
- virtual const void* InternalHandle() const {
- return window_;
- }
-
- virtual void* InternalHandle() {
- return window_;
- }
-
- private:
- ANativeWindow* window_;
-};
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeAllocate(JNIEnv* env, jobject thiz) {
- return ToJBool(WrapObjectInJava(new GLEnv(), env, thiz, true));
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeDeallocate(JNIEnv* env, jobject thiz) {
- return ToJBool(DeleteNativeObject<GLEnv>(env, thiz));
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeInitWithNewContext(JNIEnv* env,
- jobject thiz) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->InitWithNewContext()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeInitWithCurrentContext(JNIEnv* env,
- jobject thiz) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->InitWithCurrentContext()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeIsActive(JNIEnv* env, jobject thiz) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->IsActive()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeIsContextActive(JNIEnv* env, jobject thiz) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->IsContextActive()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeIsAnyContextActive(JNIEnv* env,
- jclass clazz) {
- return ToJBool(GLEnv::IsAnyContextActive());
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeActivate(JNIEnv* env, jobject thiz) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->Activate()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeDeactivate(JNIEnv* env, jobject thiz) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->Deactivate()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeSwapBuffers(JNIEnv* env, jobject thiz) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->SwapBuffers()) : JNI_FALSE;
-}
-
-// Get the native mediarecorder object corresponding to the java object
-static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject jmediarecorder) {
- jclass clazz = env->FindClass("android/media/MediaRecorder");
- if (clazz == NULL) {
- return NULL;
- }
-
- jfieldID context = env->GetFieldID(clazz, "mNativeContext", "I");
- if (context == NULL) {
- return NULL;
- }
-
- MediaRecorder* const p = (MediaRecorder*)env->GetIntField(jmediarecorder, context);
- env->DeleteLocalRef(clazz);
- return sp<MediaRecorder>(p);
-}
-
-
-jint Java_android_filterfw_core_GLEnvironment_nativeAddSurface(JNIEnv* env,
- jobject thiz,
- jobject surface) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- if (!surface) {
- LOGE("GLEnvironment: Null Surface passed!");
- return -1;
- } else if (gl_env) {
- // Get the ANativeWindow
- ANativeWindow* window = ANativeWindow_fromSurface(env, surface);
- if (!window) {
- LOGE("GLEnvironment: Error creating window!");
- return -1;
- }
-
- NativeWindowHandle* winHandle = new NativeWindowHandle(window);
- int result = gl_env->FindSurfaceIdForWindow(winHandle);
- if (result == -1) {
- // Configure surface
- EGLConfig config;
- EGLint numConfigs = -1;
- EGLint configAttribs[] = {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_RECORDABLE_ANDROID, EGL_TRUE,
- EGL_NONE
- };
-
-
-
- eglChooseConfig(gl_env->display(), configAttribs, &config, 1, &numConfigs);
- if (numConfigs < 1) {
- LOGE("GLEnvironment: No suitable EGL configuration found for surface!");
- return -1;
- }
-
- // Create the EGL surface
- EGLSurface egl_surface = eglCreateWindowSurface(gl_env->display(),
- config,
- window,
- NULL);
-
- if (GLEnv::CheckEGLError("eglCreateWindowSurface")) {
- LOGE("GLEnvironment: Error creating window surface!");
- return -1;
- }
-
- // Add it to GL Env and assign ID
- result = gl_env->AddWindowSurface(egl_surface, winHandle);
- } else {
- delete winHandle;
- }
- return result;
- }
- return -1;
-}
-
-jint Java_android_filterfw_core_GLEnvironment_nativeAddSurfaceTexture(JNIEnv* env,
- jobject thiz,
- jobject surfaceTexture,
- jint width,
- jint height) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- if (!surfaceTexture) {
- LOGE("GLEnvironment: Null SurfaceTexture passed!");
- return -1;
- } else if (gl_env) {
- // Get the ANativeWindow
- ANativeWindow* window = ANativeWindow_fromSurfaceTexture(env, surfaceTexture);
- if (!window) {
- LOGE("GLEnvironment: Error creating window!");
- return -1;
- }
-
- // Don't care about format (will get overridden by SurfaceTexture
- // anyway), but do care about width and height
- // TODO: Probably, this should be just be
- // ANativeWindow_setBuffersDimensions. The pixel format is
- // set during the eglCreateWindowSurface
- ANativeWindow_setBuffersGeometry(window, width, height, 0);
-
- NativeWindowHandle* winHandle = new NativeWindowHandle(window);
- int result = gl_env->FindSurfaceIdForWindow(winHandle);
- if (result == -1) {
- // Configure surface
- EGLConfig config;
- EGLint numConfigs = -1;
- EGLint configAttribs[] = {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_RECORDABLE_ANDROID, EGL_TRUE,
- EGL_NONE
- };
-
-
-
- eglChooseConfig(gl_env->display(), configAttribs, &config, 1, &numConfigs);
- if (numConfigs < 1) {
- LOGE("GLEnvironment: No suitable EGL configuration found for surface texture!");
- return -1;
- }
-
- // Create the EGL surface
- EGLSurface egl_surface = eglCreateWindowSurface(gl_env->display(),
- config,
- window,
- NULL);
-
- if (GLEnv::CheckEGLError("eglCreateWindowSurface")) {
- LOGE("GLEnvironment: Error creating window surface!");
- return -1;
- }
-
- // Add it to GL Env and assign ID
- result = gl_env->AddWindowSurface(egl_surface, winHandle);
- } else {
- delete winHandle;
- }
- return result;
- }
- return -1;
-}
-
-// nativeAddSurfaceFromMediaRecorder gets an EGLSurface
-// using a MediaRecorder object.
-// When Mediarecorder is used for recording GL Frames, it
-// will have a reference to a Native Handle (a SurfaceTexureClient)
-// which talks to the StageFrightRecorder in mediaserver via
-// a binder interface.
-jint Java_android_filterfw_core_GLEnvironment_nativeAddSurfaceFromMediaRecorder(
- JNIEnv* env,
- jobject thiz,
- jobject jmediarecorder) {
- LOGV("GLEnv Jni: nativeAddSurfaceFromMediaRecorder");
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- if (!gl_env) {
- return -1;
- }
- // get a native mediarecorder object from the java object
- sp<MediaRecorder> mr = getMediaRecorder(env, jmediarecorder);
- if (mr == NULL) {
- LOGE("GLEnvironment: Error- MediaRecorder could not be initialized!");
- return -1;
- }
-
- // Ask the mediarecorder to return a handle to a surfacemediasource
- // This will talk to the StageFrightRecorder via MediaRecorderClient
- // over binder calls
- sp<ISurfaceTexture> surfaceMS = mr->querySurfaceMediaSourceFromMediaServer();
- if (surfaceMS == NULL) {
- LOGE("GLEnvironment: Error- MediaRecorder returned a null \
- <ISurfaceTexture> handle.");
- return -1;
- }
- sp<SurfaceTextureClient> surfaceTC = new SurfaceTextureClient(surfaceMS);
- // Get the ANativeWindow
- sp<ANativeWindow> window = surfaceTC;
-
-
- if (window == NULL) {
- LOGE("GLEnvironment: Error creating window!");
- return -1;
- }
- window->incStrong((void*)ANativeWindow_acquire);
-
- // In case of encoding, no need to set the dimensions
- // on the buffers. The dimensions for the final encoding are set by
- // the consumer side.
- // The pixel format is dictated by the GL, and set during the
- // eglCreateWindowSurface
-
- NativeWindowHandle* winHandle = new NativeWindowHandle(window.get());
- int result = gl_env->FindSurfaceIdForWindow(winHandle);
- // If we find a surface with that window handle, just return that id
- if (result != -1) {
- delete winHandle;
- return result;
- }
- // If we do not find a surface with that window handle, create
- // one and assign to it the handle
- // Configure surface
- EGLConfig config;
- EGLint numConfigs = -1;
- EGLint configAttribs[] = {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_RECORDABLE_ANDROID, EGL_TRUE,
- EGL_NONE
- };
-
-
- eglChooseConfig(gl_env->display(), configAttribs, &config, 1, &numConfigs);
- if (numConfigs < 1) {
- LOGE("GLEnvironment: No suitable EGL configuration found for surface texture!");
- delete winHandle;
- return -1;
- }
-
- // Create the EGL surface
- EGLSurface egl_surface = eglCreateWindowSurface(gl_env->display(),
- config,
- window.get(),
- NULL);
-
- if (GLEnv::CheckEGLError("eglCreateWindowSurface")) {
- LOGE("GLEnvironment: Error creating window surface!");
- delete winHandle;
- return -1;
- }
-
- // Add it to GL Env and assign ID
- result = gl_env->AddWindowSurface(egl_surface, winHandle);
- return result;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeActivateSurfaceId(JNIEnv* env,
- jobject thiz,
- jint surfaceId) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->SwitchToSurfaceId(surfaceId) && gl_env->Activate()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeRemoveSurfaceId(JNIEnv* env,
- jobject thiz,
- jint surfaceId) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- return gl_env ? ToJBool(gl_env->ReleaseSurfaceId(surfaceId)) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLEnvironment_nativeSetSurfaceTimestamp(JNIEnv* env,
- jobject thiz,
- jlong timestamp) {
- GLEnv* gl_env = ConvertFromJava<GLEnv>(env, thiz);
- int64_t timestamp_native = timestamp;
- return gl_env ? ToJBool(gl_env->SetSurfaceTimestamp(timestamp_native)) : JNI_FALSE;
-}
diff --git a/mca/filterfw/jni/jni_gl_environment.h b/mca/filterfw/jni/jni_gl_environment.h
deleted file mode 100644
index 5c9d298..0000000
--- a/mca/filterfw/jni/jni_gl_environment.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_JNI_GL_ENVIRONMENT_H
-#define ANDROID_FILTERFW_JNI_GL_ENVIRONMENT_H
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeAllocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeDeallocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeInitWithNewContext(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeInitWithCurrentContext(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeIsActive(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeIsContextActive(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeIsAnyContextActive(JNIEnv* env, jclass clazz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeActivate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeDeactivate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeSwapBuffers(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeAddSurface(JNIEnv* env,
- jobject thiz,
- jobject surface);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeAddSurfaceTexture(JNIEnv* env,
- jobject thiz,
- jobject surface,
- jint width,
- jint height);
-
-// The call to hook up the SurfaceMediaSource (in MediaServer) to the GL.
-// We get a sp<ISurfaceTexure> from the MediaServer and talks to MediaServer
-// over a binder interface. GL hooked up to the MediaServer by using the native
-// window created using the <ISurfaceTexture> handle
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeAddSurfaceFromMediaRecorder(
- JNIEnv* env,
- jobject thiz,
- jobject mediarecorder);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeActivateSurfaceId(JNIEnv* env,
- jobject thiz,
- jint surfaceId);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeRemoveSurfaceId(JNIEnv* env,
- jobject thiz,
- jint surfaceId);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLEnvironment_nativeSetSurfaceTimestamp(JNIEnv* env,
- jobject thiz,
- jlong timestamp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANDROID_FILTERFW_JNI_GL_ENVIRONMENT_H
diff --git a/mca/filterfw/jni/jni_gl_frame.cpp b/mca/filterfw/jni/jni_gl_frame.cpp
deleted file mode 100644
index 61340f9..0000000
--- a/mca/filterfw/jni/jni_gl_frame.cpp
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "android/bitmap.h"
-
-#include "jni/jni_gl_frame.h"
-#include "jni/jni_util.h"
-
-#include "native/core/gl_env.h"
-#include "native/core/gl_frame.h"
-#include "native/core/native_frame.h"
-
-using android::filterfw::GLEnv;
-using android::filterfw::GLFrame;
-using android::filterfw::NativeFrame;
-
-// Helper functions ////////////////////////////////////////////////////////////////////////////////
-void ConvertFloatsToRGBA(const float* floats, int length, uint8_t* result) {
- for (int i = 0; i < length; ++i) {
- result[i] = static_cast<uint8_t>(floats[i] * 255.0);
- }
-}
-
-void ConvertRGBAToFloats(const uint8_t* rgba, int length, float* result) {
- for (int i = 0; i < length; ++i) {
- result[i] = rgba[i] / 255.0;
- }
-}
-
-// GLFrame JNI implementation //////////////////////////////////////////////////////////////////////
-jboolean Java_android_filterfw_core_GLFrame_nativeAllocate(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jint width,
- jint height) {
- GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
- if (!gl_env_ptr) return JNI_FALSE;
- GLFrame* frame = new GLFrame(gl_env_ptr);
- if (frame->Init(width, height)) {
- return ToJBool(WrapObjectInJava(frame, env, thiz, true));
- } else {
- delete frame;
- return JNI_FALSE;
- }
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeAllocateWithTexture(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jint tex_id,
- jint width,
- jint height) {
- GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
- if (!gl_env_ptr) return JNI_FALSE;
- GLFrame* frame = new GLFrame(gl_env_ptr);
- if (frame->InitWithTexture(tex_id, width, height)) {
- return ToJBool(WrapObjectInJava(frame, env, thiz, true));
- } else {
- delete frame;
- return JNI_FALSE;
- }
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeAllocateWithFbo(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jint fbo_id,
- jint width,
- jint height) {
- GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
- if (!gl_env_ptr) return JNI_FALSE;
- GLFrame* frame = new GLFrame(gl_env_ptr);
- if (frame->InitWithFbo(fbo_id, width, height)) {
- return ToJBool(WrapObjectInJava(frame, env, thiz, true));
- } else {
- delete frame;
- return JNI_FALSE;
- }
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeAllocateExternal(JNIEnv* env,
- jobject thiz,
- jobject gl_env) {
- GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
- if (!gl_env_ptr) return JNI_FALSE;
- GLFrame* frame = new GLFrame(gl_env_ptr);
- if (frame->InitWithExternalTexture()) {
- return ToJBool(WrapObjectInJava(frame, env, thiz, true));
- } else {
- delete frame;
- return JNI_FALSE;
- }
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeDeallocate(JNIEnv* env, jobject thiz) {
- return ToJBool(DeleteNativeObject<GLFrame>(env, thiz));
-}
-
-jboolean Java_android_filterfw_core_GLFrame_setNativeData(JNIEnv* env,
- jobject thiz,
- jbyteArray data,
- jint offset,
- jint length) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && data) {
- jbyte* bytes = env->GetByteArrayElements(data, NULL);
- if (bytes) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(bytes + offset), length);
- env->ReleaseByteArrayElements(data, bytes, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jbyteArray Java_android_filterfw_core_GLFrame_getNativeData(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && frame->Size() > 0) {
- jbyteArray result = env->NewByteArray(frame->Size());
- jbyte* data = env->GetByteArrayElements(result, NULL);
- frame->CopyDataTo(reinterpret_cast<uint8_t*>(data), frame->Size());
- env->ReleaseByteArrayElements(result, data, 0);
- return result;
- }
- return NULL;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_setNativeInts(JNIEnv* env,
- jobject thiz,
- jintArray ints) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && ints) {
- jint* int_ptr = env->GetIntArrayElements(ints, NULL);
- const int length = env->GetArrayLength(ints);
- if (int_ptr) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(int_ptr),
- length * sizeof(jint));
- env->ReleaseIntArrayElements(ints, int_ptr, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jintArray Java_android_filterfw_core_GLFrame_getNativeInts(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && frame->Size() > 0 && (frame->Size() % sizeof(jint) == 0)) {
- jintArray result = env->NewIntArray(frame->Size() / sizeof(jint));
- jint* data = env->GetIntArrayElements(result, NULL);
- frame->CopyDataTo(reinterpret_cast<uint8_t*>(data), frame->Size());
- env->ReleaseIntArrayElements(result, data, 0);
- return result;
- }
- return NULL;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_setNativeFloats(JNIEnv* env,
- jobject thiz,
- jfloatArray floats) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && floats) {
- jfloat* float_ptr = env->GetFloatArrayElements(floats, NULL);
- const int length = env->GetArrayLength(floats);
- if (float_ptr) {
- // Convert floats to RGBA buffer
- uint8_t* rgba_buffer = new uint8_t[length];
- ConvertFloatsToRGBA(float_ptr, length, rgba_buffer);
- env->ReleaseFloatArrayElements(floats, float_ptr, JNI_ABORT);
-
- // Write RGBA buffer to frame
- const bool success = frame->WriteData(rgba_buffer, length);
-
- // Clean-up
- delete[] rgba_buffer;
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jfloatArray Java_android_filterfw_core_GLFrame_getNativeFloats(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && frame->Size() > 0) {
- // Create the result array
- jfloatArray result = env->NewFloatArray(frame->Size());
- jfloat* float_array = env->GetFloatArrayElements(result, NULL);
-
- // Read the frame pixels
- uint8_t* pixels = new uint8_t[frame->Size()];
- frame->CopyDataTo(pixels, frame->Size());
-
- // Convert them to floats
- ConvertRGBAToFloats(pixels, frame->Size(), float_array);
-
- // Clean-up
- delete[] pixels;
- env->ReleaseFloatArrayElements(result, float_array, 0);
- return result;
- }
- return NULL;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_setNativeBitmap(JNIEnv* env,
- jobject thiz,
- jobject bitmap,
- jint size) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && bitmap) {
- uint8_t* pixels;
- const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&pixels));
- if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
- const bool success = frame->WriteData(pixels, size);
- return ToJBool(success &&
- AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
- }
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_getNativeBitmap(JNIEnv* env,
- jobject thiz,
- jobject bitmap) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- if (frame && bitmap) {
- uint8_t* pixels;
- const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&pixels));
- if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
- frame->CopyDataTo(pixels, frame->Size());
- return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
- }
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_setNativeViewport(JNIEnv* env,
- jobject thiz,
- jint x,
- jint y,
- jint width,
- jint height) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return frame ? ToJBool(frame->SetViewport(x, y, width, height)) : JNI_FALSE;
-}
-
-jint Java_android_filterfw_core_GLFrame_getNativeTextureId(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return frame ? frame->GetTextureId() : -1;
-}
-
-jint Java_android_filterfw_core_GLFrame_getNativeFboId(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return frame ? frame->GetFboId() : -1;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_generateNativeMipMap(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return frame ? ToJBool(frame->GenerateMipMap()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_setNativeTextureParam(JNIEnv* env,
- jobject thiz,
- jint param,
- jint value) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return frame ? ToJBool(frame->SetTextureParameter(param, value)) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeResetParams(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return frame ? ToJBool(frame->ResetTexParameters()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeCopyFromNative(JNIEnv* env,
- jobject thiz,
- jobject frame) {
- GLFrame* this_frame = ConvertFromJava<GLFrame>(env, thiz);
- NativeFrame* other_frame = ConvertFromJava<NativeFrame>(env, frame);
- if (this_frame && other_frame) {
- return ToJBool(this_frame->WriteData(other_frame->Data(), other_frame->Size()));
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeCopyFromGL(JNIEnv* env,
- jobject thiz,
- jobject frame) {
- GLFrame* this_frame = ConvertFromJava<GLFrame>(env, thiz);
- GLFrame* other_frame = ConvertFromJava<GLFrame>(env, frame);
- if (this_frame && other_frame) {
- return ToJBool(this_frame->CopyPixelsFrom(other_frame));
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeFocus(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return ToJBool(frame && frame->FocusFrameBuffer());
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeReattachTexToFbo(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return ToJBool(frame && frame->ReattachTextureToFbo());
-}
-
-jboolean Java_android_filterfw_core_GLFrame_nativeDetachTexFromFbo(JNIEnv* env, jobject thiz) {
- GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
- return ToJBool(frame && frame->DetachTextureFromFbo());
-}
-
diff --git a/mca/filterfw/jni/jni_gl_frame.h b/mca/filterfw/jni/jni_gl_frame.h
deleted file mode 100644
index 8a25aea..0000000
--- a/mca/filterfw/jni/jni_gl_frame.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_JNI_GL_FRAME_H
-#define ANDROID_FILTERFW_JNI_GL_FRAME_H
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeAllocate(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jint width,
- jint height);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeAllocateWithTexture(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jint tex_id,
- jint width,
- jint height);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeAllocateWithFbo(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jint fbo_id,
- jint width,
- jint height);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeAllocateExternal(JNIEnv* env,
- jobject thiz,
- jobject gl_env);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeDeallocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_setNativeInts(JNIEnv* env, jobject thiz, jintArray ints);
-
-JNIEXPORT jintArray JNICALL
-Java_android_filterfw_core_GLFrame_getNativeInts(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_setNativeFloats(JNIEnv* env, jobject thiz, jfloatArray ints);
-
-JNIEXPORT jfloatArray JNICALL
-Java_android_filterfw_core_GLFrame_getNativeFloats(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_setNativeData(JNIEnv* env,
- jobject thiz,
- jbyteArray data,
- jint offset,
- jint length);
-
-JNIEXPORT jbyteArray JNICALL
-Java_android_filterfw_core_GLFrame_getNativeData(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_setNativeBitmap(JNIEnv* env,
- jobject thiz,
- jobject bitmap,
- jint size);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_getNativeBitmap(JNIEnv* env, jobject thiz, jobject bitmap);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_setNativeViewport(JNIEnv* env,
- jobject thiz,
- jint x,
- jint y,
- jint width,
- jint height);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_GLFrame_getNativeTextureId(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_GLFrame_getNativeFboId(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_generateNativeMipMap(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_setNativeTextureParam(JNIEnv* env,
- jobject thiz,
- jint param,
- jint value);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeResetParams(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeCopyFromNative(JNIEnv* env,
- jobject thiz,
- jobject frame);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeCopyFromGL(JNIEnv* env,
- jobject thiz,
- jobject frame);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeFocus(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeReattachTexToFbo(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_GLFrame_nativeDetachTexFromFbo(JNIEnv* env, jobject thiz);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ANDROID_FILTERFW_JNI_GL_FRAME_H */
diff --git a/mca/filterfw/jni/jni_init.cpp b/mca/filterfw/jni/jni_init.cpp
deleted file mode 100644
index 3b131f1..0000000
--- a/mca/filterfw/jni/jni_init.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "jni/jni_util.h"
-
-#include "native/core/native_frame.h"
-#include "native/core/native_program.h"
-#include "native/core/gl_env.h"
-#include "native/core/gl_frame.h"
-#include "native/core/shader_program.h"
-#include "native/core/vertex_frame.h"
-
-using namespace android::filterfw;
-
-JavaVM* g_current_java_vm_ = NULL;
-
-jint JNI_OnLoad(JavaVM* vm, void* reserved) {
- // Set the current vm pointer
- g_current_java_vm_ = vm;
-
- // Initialize object pools
- ObjectPool<NativeFrame>::Setup("android/filterfw/core/NativeFrame", "nativeFrameId");
- ObjectPool<NativeProgram>::Setup("android/filterfw/core/NativeProgram", "nativeProgramId");
- ObjectPool<GLFrame>::Setup("android/filterfw/core/GLFrame", "glFrameId");
- ObjectPool<ShaderProgram>::Setup("android/filterfw/core/ShaderProgram", "shaderProgramId");
- ObjectPool<GLEnv>::Setup("android/filterfw/core/GLEnvironment", "glEnvId");
- ObjectPool<VertexFrame>::Setup("android/filterfw/core/VertexFrame", "vertexFrameId");
-
- return JNI_VERSION_1_4;
-}
diff --git a/mca/filterfw/jni/jni_native_buffer.cpp b/mca/filterfw/jni/jni_native_buffer.cpp
deleted file mode 100644
index 097c145..0000000
--- a/mca/filterfw/jni/jni_native_buffer.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "jni/jni_native_buffer.h"
-#include "jni/jni_util.h"
-
-char* GetJBufferData(JNIEnv* env, jobject buffer, int* size) {
- jclass base_class = env->FindClass("android/filterfw/core/NativeBuffer");
-
- // Get fields
- jfieldID ptr_field = env->GetFieldID(base_class, "mDataPointer", "J");
- jfieldID size_field = env->GetFieldID(base_class, "mSize", "I");
-
- // Get their values
- char* data = reinterpret_cast<char*>(env->GetLongField(buffer, ptr_field));
- if (size) {
- *size = env->GetIntField(buffer, size_field);
- }
-
- // Clean-up
- env->DeleteLocalRef(base_class);
-
- return data;
-}
-
-bool AttachDataToJBuffer(JNIEnv* env, jobject buffer, char* data, int size) {
- jclass base_class = env->FindClass("android/filterfw/core/NativeBuffer");
-
- // Get fields
- jfieldID ptr_field = env->GetFieldID(base_class, "mDataPointer", "J");
- jfieldID size_field = env->GetFieldID(base_class, "mSize", "I");
-
- // Set their values
- env->SetLongField(buffer, ptr_field, reinterpret_cast<jlong>(data));
- env->SetIntField(buffer, size_field, size);
-
- return true;
-}
-
-jboolean Java_android_filterfw_core_NativeBuffer_allocate(JNIEnv* env, jobject thiz, jint size) {
- char* data = new char[size];
- return ToJBool(AttachDataToJBuffer(env, thiz, data, size));
-}
-
-jboolean Java_android_filterfw_core_NativeBuffer_deallocate(JNIEnv* env,
- jobject thiz,
- jboolean owns_data) {
- if (ToCppBool(owns_data)) {
- char* data = GetJBufferData(env, thiz, NULL);
- delete[] data;
- }
- return JNI_TRUE;
-}
-
-jboolean Java_android_filterfw_core_NativeBuffer_nativeCopyTo(JNIEnv* env,
- jobject thiz,
- jobject new_buffer) {
- // Get source buffer
- int size;
- char* source_data = GetJBufferData(env, thiz, &size);
-
- // Make copy
- char* target_data = new char[size];
- memcpy(target_data, source_data, size);
-
- // Attach it to new buffer
- AttachDataToJBuffer(env, new_buffer, target_data, size);
-
- return JNI_TRUE;
-}
-
diff --git a/mca/filterfw/jni/jni_native_buffer.h b/mca/filterfw/jni/jni_native_buffer.h
deleted file mode 100644
index 73c12be..0000000
--- a/mca/filterfw/jni/jni_native_buffer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTEFW_JNI_NATIVE_BUFFER_H
-#define ANDROID_FILTEFW_JNI_NATIVE_BUFFER_H
-
-#include <jni.h>
-
-// Internal Buffer Unwrapping functions ////////////////////////////////////////////////////////////
-/**
- * Given a Java NativeBuffer instance, get access to the underlying C pointer and its size. The
- * size argument may be NULL, in which case the object is not queried for its size.
- **/
-char* GetJBufferData(JNIEnv* env, jobject buffer, int* size);
-
-/**
- * Attach a given C data buffer and its size to a given allocated Java NativeBuffer instance. After
- * this call, the java instance will have the given C buffer as its backing. Note, that the Java
- * instance contains the flag on whether or not it owns the buffer or not, so make sure it is what
- * you expect.
- **/
-bool AttachDataToJBuffer(JNIEnv* env, jobject buffer, char* data, int size);
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// JNI Wrappers ////////////////////////////////////////////////////////////////////////////////////
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeBuffer_allocate(JNIEnv* env, jobject thiz, jint size);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeBuffer_deallocate(JNIEnv* env, jobject thiz, jboolean owns_data);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeBuffer_nativeCopyTo(JNIEnv* env, jobject thiz, jobject new_buffer);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANDROID_FILTEFW_JNI_NATIVE_BUFFER_H
diff --git a/mca/filterfw/jni/jni_native_frame.cpp b/mca/filterfw/jni/jni_native_frame.cpp
deleted file mode 100644
index ccc0880..0000000
--- a/mca/filterfw/jni/jni_native_frame.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "android/bitmap.h"
-
-#include "jni/jni_native_frame.h"
-#include "jni/jni_native_buffer.h"
-#include "jni/jni_util.h"
-
-#include "native/base/logging.h"
-#include "native/core/gl_frame.h"
-#include "native/core/native_frame.h"
-
-using android::filterfw::NativeFrame;
-using android::filterfw::GLFrame;
-
-typedef union {
- uint32_t value;
- uint8_t rgba[4];
-} Pixel;
-
-jboolean Java_android_filterfw_core_NativeFrame_nativeAllocate(JNIEnv* env,
- jobject thiz,
- jint size) {
- return ToJBool(WrapObjectInJava(new NativeFrame(size), env, thiz, true));
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_nativeDeallocate(JNIEnv* env, jobject thiz) {
- return ToJBool(DeleteNativeObject<NativeFrame>(env, thiz));
-}
-
-jint Java_android_filterfw_core_NativeFrame_nativeIntSize(JNIEnv*, jclass) {
- return sizeof(jint);
-}
-
-jint Java_android_filterfw_core_NativeFrame_nativeFloatSize(JNIEnv*, jclass) {
- return sizeof(jfloat);
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_setNativeData(JNIEnv* env,
- jobject thiz,
- jbyteArray data,
- jint offset,
- jint length) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame && data) {
- jbyte* bytes = env->GetByteArrayElements(data, NULL);
- if (bytes) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(bytes + offset),
- 0,
- length);
- env->ReleaseByteArrayElements(data, bytes, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jbyteArray Java_android_filterfw_core_NativeFrame_getNativeData(JNIEnv* env,
- jobject thiz,
- jint size) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame) {
- const uint8_t* data = frame->Data();
- if (!data || size > frame->Size())
- return NULL;
- jbyteArray result = env->NewByteArray(size);
- env->SetByteArrayRegion(result, 0, size, reinterpret_cast<const jbyte*>(data));
- return result;
- }
- return NULL;
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_getNativeBuffer(JNIEnv* env,
- jobject thiz,
- jobject buffer) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame) {
- char* data = reinterpret_cast<char*>(frame->MutableData());
- return ToJBool(AttachDataToJBuffer(env, buffer, data, frame->Size()));
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_setNativeInts(JNIEnv* env,
- jobject thiz,
- jintArray ints) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame && ints) {
- jint* int_ptr = env->GetIntArrayElements(ints, NULL);
- const int length = env->GetArrayLength(ints);
- if (int_ptr) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(int_ptr),
- 0,
- length * sizeof(jint));
- env->ReleaseIntArrayElements(ints, int_ptr, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jintArray Java_android_filterfw_core_NativeFrame_getNativeInts(JNIEnv* env,
- jobject thiz,
- jint size) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame) {
- const uint8_t* data = frame->Data();
- if (!data || size > frame->Size() || (size % sizeof(jint)) != 0)
- return NULL;
- const int count = size / sizeof(jint);
- jintArray result = env->NewIntArray(count);
- env->SetIntArrayRegion(result, 0, count, reinterpret_cast<const jint*>(data));
- return result;
- }
- return NULL;
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_setNativeFloats(JNIEnv* env,
- jobject thiz,
- jfloatArray floats) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame && floats) {
- jfloat* float_ptr = env->GetFloatArrayElements(floats, NULL);
- const int length = env->GetArrayLength(floats);
- if (float_ptr) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(float_ptr),
- 0,
- length * sizeof(jfloat));
- env->ReleaseFloatArrayElements(floats, float_ptr, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jfloatArray Java_android_filterfw_core_NativeFrame_getNativeFloats(JNIEnv* env,
- jobject thiz,
- jint size) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame) {
- const uint8_t* data = frame->Data();
- if (!data || size > frame->Size() || (size % sizeof(jfloat)) != 0)
- return NULL;
- const int count = size / sizeof(jfloat);
- jfloatArray result = env->NewFloatArray(count);
- env->SetFloatArrayRegion(result, 0, count, reinterpret_cast<const jfloat*>(data));
- return result;
- }
- return NULL;
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_setNativeBitmap(JNIEnv* env,
- jobject thiz,
- jobject bitmap,
- jint size,
- jint bytes_per_sample) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame && bitmap) {
- // Make sure frame size matches bitmap size
- if ((size / 4) != (frame->Size() / bytes_per_sample)) {
- LOGE("Size mismatch in native setBitmap()!");
- return JNI_FALSE;
- }
-
- Pixel* src_ptr;
- const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&src_ptr));
- if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
- // Create destination pointers
- uint8_t* dst_ptr = reinterpret_cast<uint8_t*>(frame->MutableData());
- const uint8_t* end_ptr = dst_ptr + frame->Size();
- switch (bytes_per_sample) {
- case 1: { // RGBA -> GRAY
- while (dst_ptr < end_ptr) {
- const Pixel pixel = *(src_ptr++);
- *(dst_ptr++) = (pixel.rgba[0] + pixel.rgba[1] + pixel.rgba[2]) / 3;
- }
- break;
- }
- case 3: { // RGBA -> RGB
- while (dst_ptr < end_ptr) {
- const Pixel pixel = *(src_ptr++);
- *(dst_ptr++) = pixel.rgba[0];
- *(dst_ptr++) = pixel.rgba[1];
- *(dst_ptr++) = pixel.rgba[2];
- }
- break;
- }
- case 4: { // RGBA -> RGBA
- memcpy(dst_ptr, src_ptr, frame->Size());
- break;
- }
- default:
- LOGE("Unsupported bytes-per-pixel %d in setBitmap!", bytes_per_sample);
- break;
- }
- return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
- }
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_getNativeBitmap(JNIEnv* env,
- jobject thiz,
- jobject bitmap,
- jint size,
- jint bytes_per_sample) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- if (frame && bitmap) {
- Pixel* dst_ptr;
- const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&dst_ptr));
- if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
- // Make sure frame size matches bitmap size
- if ((size / 4) != (frame->Size() / bytes_per_sample)) {
- LOGE("Size mismatch in native getBitmap()!");
- return JNI_FALSE;
- }
-
- const uint8_t* src_ptr = frame->Data();
- const uint8_t* end_ptr = src_ptr + frame->Size();
- switch (bytes_per_sample) {
- case 1: { // GRAY -> RGBA
- while (src_ptr < end_ptr) {
- const uint8_t value = *(src_ptr++);
- dst_ptr->rgba[0] = dst_ptr->rgba[1] = dst_ptr->rgba[2] = value;
- dst_ptr->rgba[3] = 255;
- ++dst_ptr;
- }
- break;
- }
- case 3: { // RGB -> RGBA
- while (src_ptr < end_ptr) {
- dst_ptr->rgba[0] = *(src_ptr++);
- dst_ptr->rgba[1] = *(src_ptr++);
- dst_ptr->rgba[2] = *(src_ptr++);
- dst_ptr->rgba[3] = 255;
- ++dst_ptr;
- }
- break;
- }
- case 4: { // RGBA -> RGBA
- memcpy(dst_ptr, src_ptr, frame->Size());
- break;
- }
- default:
- LOGE("Unsupported bytes-per-pixel %d in getBitmap!", bytes_per_sample);
- break;
- }
- return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
- }
- }
- return JNI_FALSE;
-}
-
-jint Java_android_filterfw_core_NativeFrame_getNativeCapacity(JNIEnv* env, jobject thiz) {
- NativeFrame* frame = ConvertFromJava<NativeFrame>(env, thiz);
- return frame ? frame->Capacity() : -1;
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_nativeCopyFromNative(JNIEnv* env,
- jobject thiz,
- jobject frame) {
- NativeFrame* this_frame = ConvertFromJava<NativeFrame>(env, thiz);
- NativeFrame* other_frame = ConvertFromJava<NativeFrame>(env, frame);
- if (this_frame && other_frame) {
- return ToJBool(this_frame->WriteData(other_frame->Data(), 0, other_frame->Size()));
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_NativeFrame_nativeCopyFromGL(JNIEnv* env,
- jobject thiz,
- jobject frame) {
- NativeFrame* this_frame = ConvertFromJava<NativeFrame>(env, thiz);
- GLFrame* other_frame = ConvertFromJava<GLFrame>(env, frame);
- if (this_frame && other_frame) {
- return ToJBool(other_frame->CopyDataTo(this_frame->MutableData(), this_frame->Size()));
- }
- return JNI_FALSE;
-}
diff --git a/mca/filterfw/jni/jni_native_frame.h b/mca/filterfw/jni/jni_native_frame.h
deleted file mode 100644
index ecd9f82..0000000
--- a/mca/filterfw/jni/jni_native_frame.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_JNI_NATIVE_FRAME_H
-#define ANDROID_FILTERFW_JNI_NATIVE_FRAME_H
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_nativeAllocate(JNIEnv* env, jobject thiz, jint size);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_nativeDeallocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_NativeFrame_nativeIntSize(JNIEnv* env, jclass clazz);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_NativeFrame_nativeFloatSize(JNIEnv* env, jclass clazz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_setNativeInts(JNIEnv* env, jobject thiz, jintArray ints);
-
-JNIEXPORT jintArray JNICALL
-Java_android_filterfw_core_NativeFrame_getNativeInts(JNIEnv* env, jobject thiz, jint size);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_setNativeFloats(JNIEnv* env, jobject thiz, jfloatArray ints);
-
-JNIEXPORT jfloatArray JNICALL
-Java_android_filterfw_core_NativeFrame_getNativeFloats(JNIEnv* env, jobject thiz, jint size);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_setNativeData(JNIEnv* env,
- jobject thiz,
- jbyteArray data,
- jint offset,
- jint length);
-
-JNIEXPORT jbyteArray JNICALL
-Java_android_filterfw_core_NativeFrame_getNativeData(JNIEnv* env, jobject thiz, jint size);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_getNativeBuffer(JNIEnv* env, jobject thiz, jobject buffer);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_setNativeBitmap(JNIEnv* env,
- jobject thiz,
- jobject bitmap,
- jint size,
- jint bytes_per_sample);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_getNativeBitmap(JNIEnv* env,
- jobject thiz,
- jobject bitmap,
- jint size,
- jint bytes_per_sample);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_NativeFrame_getNativeCapacity(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_nativeCopyFromNative(JNIEnv* env,
- jobject thiz,
- jobject frame);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeFrame_nativeCopyFromGL(JNIEnv* env,
- jobject thiz,
- jobject frame);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANDROID_FILTERFW_JNI_NATIVE_FRAME_H
diff --git a/mca/filterfw/jni/jni_native_program.cpp b/mca/filterfw/jni/jni_native_program.cpp
deleted file mode 100644
index c53e67d..0000000
--- a/mca/filterfw/jni/jni_native_program.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-#include <vector>
-
-#include "jni/jni_native_program.h"
-#include "jni/jni_util.h"
-
-#include "native/base/logging.h"
-#include "native/core/native_frame.h"
-#include "native/core/native_program.h"
-
-using android::filterfw::NativeFrame;
-using android::filterfw::NativeProgram;
-
-jboolean Java_android_filterfw_core_NativeProgram_allocate(JNIEnv* env, jobject thiz) {
- return ToJBool(WrapObjectInJava(new NativeProgram(), env, thiz, true));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_deallocate(JNIEnv* env, jobject thiz) {
- return ToJBool(DeleteNativeObject<NativeProgram>(env, thiz));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_nativeInit(JNIEnv* env, jobject thiz) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program && program->CallInit());
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_openNativeLibrary(JNIEnv* env,
- jobject thiz,
- jstring lib_name) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program && lib_name && program->OpenLibrary(ToCppString(env, lib_name)));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_bindInitFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program && func_name && program->BindInitFunction(ToCppString(env, func_name)));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_bindSetValueFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program &&
- func_name &&
- program->BindSetValueFunction(ToCppString(env, func_name)));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_bindGetValueFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program &&
- func_name &&
- program->BindGetValueFunction(ToCppString(env, func_name)));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_bindProcessFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program && func_name && program->BindProcessFunction(ToCppString(env, func_name)));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_bindResetFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program &&
- func_name &&
- program->BindResetFunction(ToCppString(env, func_name)));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_bindTeardownFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program &&
- func_name &&
- program->BindTeardownFunction(ToCppString(env, func_name)));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_callNativeInit(JNIEnv* env, jobject thiz) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program && program->CallInit());
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_callNativeSetValue(JNIEnv* env,
- jobject thiz,
- jstring key,
- jstring value) {
- if (!value) {
- LOGE("Native Program: Attempting to set null value for key %s!",
- ToCppString(env, key).c_str());
- }
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- const std::string c_value = ToCppString(env, value);
- const std::string c_key = ToCppString(env, key);
- return ToJBool(program && program->CallSetValue(c_key, c_value));
-}
-
-jstring Java_android_filterfw_core_NativeProgram_callNativeGetValue(JNIEnv* env,
- jobject thiz,
- jstring key) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- const std::string c_key = ToCppString(env, key);
- if (program) {
- return ToJString(env, program->CallGetValue(c_key));
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_callNativeProcess(JNIEnv* env,
- jobject thiz,
- jobjectArray inputs,
- jobject output) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
-
- // Sanity checks
- if (!program || !inputs) {
- return JNI_FALSE;
- }
-
- // Get the input buffers
- const int input_count = env->GetArrayLength(inputs);
- std::vector<const char*> input_buffers(input_count, NULL);
- std::vector<int> input_sizes(input_count, 0);
- for (int i = 0 ; i < input_count; ++i) {
- const char* input_data = NULL;
- int input_size = 0;
- jobject input = env->GetObjectArrayElement(inputs, i);
- if (input) {
- NativeFrame* native_frame = ConvertFromJava<NativeFrame>(env, input);
- if (!native_frame) {
- LOGE("NativeProgram: Could not grab NativeFrame input %d!", i);
- return JNI_FALSE;
- }
- input_data = reinterpret_cast<const char*>(native_frame->Data());
- input_size = native_frame->Size();
- }
- input_buffers[i] = input_data;
- input_sizes[i] = input_size;
- }
-
- // Get the output buffer
- char* output_data = NULL;
- int output_size = 0;
- if (output) {
- NativeFrame* output_frame = ConvertFromJava<NativeFrame>(env, output);
- if (!output_frame) {
- LOGE("NativeProgram: Could not grab NativeFrame output!");
- return JNI_FALSE;
- }
- output_data = reinterpret_cast<char*>(output_frame->MutableData());
- output_size = output_frame->Size();
- }
-
- // Process the frames!
- return ToJBool(program->CallProcess(input_buffers, input_sizes, output_data, output_size));
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_callNativeReset(JNIEnv* env, jobject thiz) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program && program->CallReset());
-}
-
-jboolean Java_android_filterfw_core_NativeProgram_callNativeTeardown(JNIEnv* env, jobject thiz) {
- NativeProgram* program = ConvertFromJava<NativeProgram>(env, thiz);
- return ToJBool(program && program->CallTeardown());
-}
diff --git a/mca/filterfw/jni/jni_native_program.h b/mca/filterfw/jni/jni_native_program.h
deleted file mode 100644
index fa97c39..0000000
--- a/mca/filterfw/jni/jni_native_program.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_JNI_NATIVE_PROGRAM_H
-#define ANDROID_FILTERFW_JNI_NATIVE_PROGRAM_H
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_allocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_deallocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_nativeInit(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_openNativeLibrary(JNIEnv* env,
- jobject thiz,
- jstring lib_name);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_bindInitFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_bindSetValueFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_bindGetValueFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_bindProcessFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_bindResetFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_bindTeardownFunction(JNIEnv* env,
- jobject thiz,
- jstring func_name);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_callNativeInit(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_callNativeSetValue(JNIEnv* env,
- jobject thiz,
- jstring key,
- jstring value);
-
-JNIEXPORT jstring JNICALL
-Java_android_filterfw_core_NativeProgram_callNativeGetValue(JNIEnv* env,
- jobject thiz,
- jstring key);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_callNativeProcess(JNIEnv* env,
- jobject thiz,
- jobjectArray inputs,
- jobject output);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_callNativeReset(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_NativeProgram_callNativeTeardown(JNIEnv* env, jobject thiz);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANDROID_FILTERFW_JNI_NATIVE_PROGRAM_H
diff --git a/mca/filterfw/jni/jni_shader_program.cpp b/mca/filterfw/jni/jni_shader_program.cpp
deleted file mode 100644
index f804874..0000000
--- a/mca/filterfw/jni/jni_shader_program.cpp
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-#include <vector>
-
-#include "jni/jni_shader_program.h"
-#include "jni/jni_util.h"
-
-#include "native/base/logging.h"
-#include "native/core/geometry.h"
-#include "native/core/gl_env.h"
-#include "native/core/gl_frame.h"
-#include "native/core/shader_program.h"
-#include "native/core/vertex_frame.h"
-
-using android::filterfw::GLEnv;
-using android::filterfw::GLFrame;
-using android::filterfw::Point;
-using android::filterfw::ProgramVar;
-using android::filterfw::Quad;
-using android::filterfw::ShaderProgram;
-using android::filterfw::VertexFrame;
-
-jboolean Java_android_filterfw_core_ShaderProgram_allocate(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jstring vertex_shader,
- jstring fragment_shader) {
- // Get the GLEnv pointer
- GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
-
- // Create the shader
- if (!fragment_shader || !gl_env_ptr)
- return false;
- else if (!vertex_shader)
- return ToJBool(WrapObjectInJava(new ShaderProgram(
- gl_env_ptr,
- ToCppString(env, fragment_shader)),
- env,
- thiz,
- true));
- else
- return ToJBool(WrapObjectInJava(new ShaderProgram(
- gl_env_ptr,
- ToCppString(env, vertex_shader),
- ToCppString(env, fragment_shader)),
- env,
- thiz,
- true));
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_deallocate(JNIEnv* env, jobject thiz) {
- return ToJBool(DeleteNativeObject<ShaderProgram>(env, thiz));
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_compileAndLink(JNIEnv* env, jobject thiz) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- return program ? ToJBool(program->CompileAndLink()) : JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setUniformValue(JNIEnv* env,
- jobject thiz,
- jstring key,
- jobject value) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- const Value c_value = ToCValue(env, value);
- const std::string c_key = ToCppString(env, key);
- if (c_value.value) {
- return ToJBool(program && program->SetUniformValue(c_key, c_value));
- } else {
- LOGE("ShaderProgram: Could not convert java object value passed for key '%s'!", c_key.c_str());
- return JNI_FALSE;
- }
-}
-
-jobject Java_android_filterfw_core_ShaderProgram_getUniformValue(JNIEnv* env,
- jobject thiz,
- jstring key) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- const std::string c_key = ToCppString(env, key);
- return program ? ToJObject(env, program->GetUniformValue(c_key)) : JNI_NULL;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_shaderProcess(JNIEnv* env,
- jobject thiz,
- jobjectArray inputs,
- jobject output) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- std::vector<const GLFrame*> input_frames;
- if (program && inputs && output) {
- // Get the input frames
- const int input_count = env->GetArrayLength(inputs);
- for (int i = 0; i < input_count; ++i) {
- jobject input = env->GetObjectArrayElement(inputs, i);
- const GLFrame* input_frame = ConvertFromJava<GLFrame>(env, input);
- if (!input || !input_frame) {
- LOGE("ShaderProgram: invalid input frame %d!", i);
- return JNI_FALSE;
- }
- input_frames.push_back(input_frame);
- }
-
- // Get the output frame
- GLFrame* output_frame = ConvertFromJava<GLFrame>(env, output);
- if (!output_frame) {
- LOGE("ShaderProgram: no output frame found!");
- return JNI_FALSE;
- }
-
- // Process the frames!
- if (!program->Process(input_frames, output_frame)) {
- LOGE("ShaderProgram: error processing shader!");
- return JNI_FALSE;
- }
-
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jobject Java_android_filterfw_core_ShaderProgram_nativeCreateIdentity(JNIEnv* env,
- jclass,
- jobject gl_env) {
- GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
- ShaderProgram* program = gl_env_ptr ? ShaderProgram::CreateIdentity(gl_env_ptr) : NULL;
- return program ? WrapNewObjectInJava(program, env, false) : NULL;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setSourceRegion(JNIEnv* env,
- jobject thiz,
- jfloat x0,
- jfloat y0,
- jfloat x1,
- jfloat y1,
- jfloat x2,
- jfloat y2,
- jfloat x3,
- jfloat y3) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetSourceRegion(Quad(Point(x0, y0), Point(x1, y1), Point(x2, y2), Point(x3, y3)));
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setTargetRegion(JNIEnv* env,
- jobject thiz,
- jfloat x0,
- jfloat y0,
- jfloat x1,
- jfloat y1,
- jfloat x2,
- jfloat y2,
- jfloat x3,
- jfloat y3) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetTargetRegion(Quad(Point(x0, y0), Point(x1, y1), Point(x2, y2), Point(x3, y3)));
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderClearsOutput(JNIEnv* env,
- jobject thiz,
- jboolean clears) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetClearsOutput(ToCppBool(clears));
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderBlendEnabled(JNIEnv* env,
- jobject thiz,
- jboolean enable) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetBlendEnabled(ToCppBool(enable));
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderBlendFunc(JNIEnv* env,
- jobject thiz,
- jint sfactor,
- jint dfactor) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetBlendFunc(sfactor, dfactor);
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderClearColor(JNIEnv* env,
- jobject thiz,
- jfloat r,
- jfloat g,
- jfloat b) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetClearColor(r, g, b, 1.0f);
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderDrawMode(JNIEnv* env,
- jobject thiz,
- jint draw_mode) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetDrawMode(draw_mode);
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderTileCounts(JNIEnv* env,
- jobject thiz,
- jint x_count,
- jint y_count) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetTileCounts(x_count, y_count);
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderVertexCount(JNIEnv* env,
- jobject thiz,
- jint vertex_count) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- program->SetVertexCount(vertex_count);
- return JNI_TRUE;
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_beginShaderDrawing(JNIEnv* env, jobject thiz) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- return ToJBool(program && program->BeginDraw());
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderAttributeValues(
- JNIEnv* env,
- jobject thiz,
- jstring attr_name,
- jfloatArray values,
- jint component_count) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- // Get the floats to set
- jfloat* float_ptr = env->GetFloatArrayElements(values, NULL);
- const int length = env->GetArrayLength(values);
-
- // Get the program variable to set
- const std::string attr_string = ToCppString(env, attr_name);
- ProgramVar program_var = program->GetAttribute(attr_string);
-
- // Set the variable
- if (float_ptr && ShaderProgram::IsVarValid(program_var)) {
- const bool success = program->SetAttributeValues(program_var,
- reinterpret_cast<float*>(float_ptr),
- length,
- component_count);
- env->ReleaseFloatArrayElements(values, float_ptr, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_ShaderProgram_setShaderAttributeVertexFrame(
- JNIEnv* env,
- jobject thiz,
- jstring attr_name,
- jobject vertex_frame,
- jint type,
- jint component_count,
- jint stride,
- jint offset,
- jboolean normalize) {
- ShaderProgram* program = ConvertFromJava<ShaderProgram>(env, thiz);
- if (program) {
- // Get the vertex frame
- VertexFrame* v_frame = ConvertFromJava<VertexFrame>(env, vertex_frame);
-
- // Get the program variable to set
- const std::string attr_string = ToCppString(env, attr_name);
- ProgramVar program_var = program->GetAttribute(attr_string);
-
- // Set the variable
- if (v_frame && ShaderProgram::IsVarValid(program_var)) {
- const bool success = program->SetAttributeValues(program_var,
- v_frame,
- type,
- component_count,
- stride,
- offset,
- ToCppBool(normalize));
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
diff --git a/mca/filterfw/jni/jni_shader_program.h b/mca/filterfw/jni/jni_shader_program.h
deleted file mode 100644
index 94a1dd4..0000000
--- a/mca/filterfw/jni/jni_shader_program.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_JNI_SHADER_PROGRAM_H
-#define ANDROID_FILTERFW_JNI_SHADER_PROGRAM_H
-
-#include <jni.h>
-
-#include "native/core/value.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_allocate(JNIEnv* env,
- jobject thiz,
- jobject gl_env,
- jstring vertex_shader,
- jstring fragment_shader);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_deallocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_compileAndLink(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setUniformValue(JNIEnv* env,
- jobject thiz,
- jstring key,
- jobject value);
-
-JNIEXPORT jobject JNICALL
-Java_android_filterfw_core_ShaderProgram_getUniformValue(JNIEnv* env,
- jobject thiz,
- jstring key);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_shaderProcess(JNIEnv* env,
- jobject thiz,
- jobjectArray inputs,
- jobject output);
-
-JNIEXPORT jobject JNICALL
-Java_android_filterfw_core_ShaderProgram_nativeCreateIdentity(JNIEnv* env,
- jclass clazz,
- jobject gl_env);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setSourceRegion(JNIEnv* env,
- jobject thiz,
- jfloat x0,
- jfloat y0,
- jfloat x1,
- jfloat y1,
- jfloat x2,
- jfloat y2,
- jfloat x3,
- jfloat y3);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setTargetRegion(JNIEnv* env,
- jobject thiz,
- jfloat x0,
- jfloat y0,
- jfloat x1,
- jfloat y1,
- jfloat x2,
- jfloat y2,
- jfloat x3,
- jfloat y3);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderClearsOutput(JNIEnv* env,
- jobject thiz,
- jboolean clears);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderClearColor(JNIEnv* env,
- jobject thiz,
- jfloat r,
- jfloat g,
- jfloat b);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderBlendEnabled(JNIEnv* env,
- jobject thiz,
- jboolean enable);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderBlendFunc(JNIEnv* env,
- jobject thiz,
- jint sfactor,
- jint dfactor);
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderDrawMode(JNIEnv* env,
- jobject thiz,
- jint draw_mode);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderTileCounts(JNIEnv* env,
- jobject thiz,
- jint x_count,
- jint y_count);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderVertexCount(JNIEnv* env,
- jobject thiz,
- jint vertex_count);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_beginShaderDrawing(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderAttributeValues(JNIEnv* env,
- jobject thiz,
- jstring attr_name,
- jfloatArray values,
- jint component_count);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_ShaderProgram_setShaderAttributeVertexFrame(JNIEnv* env,
- jobject thiz,
- jstring attr_name,
- jobject vertex_frame,
- jint type,
- jint component_count,
- jint stride,
- jint offset,
- jboolean normalize);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANDROID_FILTERFW_JNI_SHADER_PROGRAM_H
diff --git a/mca/filterfw/jni/jni_util.cpp b/mca/filterfw/jni/jni_util.cpp
deleted file mode 100644
index acb0e8a..0000000
--- a/mca/filterfw/jni/jni_util.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-
-#include "jni/jni_util.h"
-
-#include "base/logging.h"
-
-#if 0
-JavaObject::JavaObject()
- : object_(JNI_NULL),
- ref_count_(new int(0)) {
-}
-
-JavaObject::JavaObject(const JavaObject& java_obj)
- : object_(java_obj.object_),
- ref_count_(java_obj.ref_count_) {
- Retain();
-}
-
-JavaObject::JavaObject(jobject object, JNIEnv* env)
- : object_(NULL),
- ref_count_(new int(0)) {
- Retain();
- object_ = env->NewGlobalRef(object_);
-}
-
-JavaObject::~JavaObject() {
- Release();
-}
-
-JavaObject& JavaObject::operator=(const JavaObject& java_obj) {
- Release();
- object_ = java_obj.object_;
- ref_count_ = java_obj.ref_count_;
- Retain();
- return *this;
-}
-
-void JavaObject::Retain() {
- if (ref_count_)
- ++(*ref_count_);
- else
- LOGE("JavaObject: Reference count is NULL! JavaObject may be corrupted.");
-}
-
-void JavaObject::Release() {
- if (ref_count_) {
- if (*ref_count_ > 0)
- --(*ref_count_);
- if (*ref_count_ == 0) {
- JNIEnv* env = GetCurrentJNIEnv();
- if (!env)
- LOGE("JavaObject: Releasing outside of Java thread. Will just leak!");
- else if (object_)
- env->DeleteGlobalRef(object_);
- delete ref_count_;
- ref_count_ = NULL;
- }
- } else {
- LOGE("JavaObject: Reference count is NULL! JavaObject may be corrupted.");
- }
-}
-
-void JavaObject::Reset() {
- Release();
- object_ = NULL;
- ref_count_ = new int(0);
-}
-
-JavaVM* GetCurrentJavaVM() {
- return g_current_java_vm_;
-}
-
-JNIEnv* GetCurrentJNIEnv() {
- JavaVM* vm = GetCurrentJavaVM();
- JNIEnv* env = NULL;
- const jint result = vm->GetEnv(reinterpret_cast<void**>(&env),
- JNI_VERSION_1_4);
- return result == JNI_OK ? env : NULL;
-}
-#endif
-
-jstring ToJString(JNIEnv* env, const std::string& value) {
- return env->NewStringUTF(value.c_str());
-}
-
-std::string ToCppString(JNIEnv* env, jstring value) {
- jboolean isCopy;
- const char* c_value = env->GetStringUTFChars(value, &isCopy);
- std::string result(c_value);
- if (isCopy == JNI_TRUE)
- env->ReleaseStringUTFChars(value, c_value);
- return result;
-}
-
-jboolean ToJBool(bool value) {
- return value ? JNI_TRUE : JNI_FALSE;
-}
-
-bool ToCppBool(jboolean value) {
- return value == JNI_TRUE;
-}
-
-// TODO: We actually shouldn't use such a function as it requires a class name lookup at every
-// invocation. Instead, store the class objects and use those.
-bool IsJavaInstanceOf(JNIEnv* env, jobject object, const std::string& class_name) {
- jclass clazz = env->FindClass(class_name.c_str());
- return clazz ? env->IsInstanceOf(object, clazz) == JNI_TRUE : false;
-}
-
-template<typename T>
-jobject CreateJObject(JNIEnv* env, const std::string& class_name, const std::string& signature, T value) {
- jobject result = JNI_NULL;
-
- return result;
-}
-
-Value ToCValue(JNIEnv* env, jobject object) {
- Value result = MakeNullValue();
- if (object != NULL) {
- if (IsJavaInstanceOf(env, object, "java/lang/Boolean")) {
- jmethodID method = env->GetMethodID(env->GetObjectClass(object), "booleanValue", "()Z");
- result = MakeIntValue(env->CallBooleanMethod(object, method) == JNI_TRUE ? 1 : 0);
- } else if (IsJavaInstanceOf(env, object, "java/lang/Integer")) {
- jmethodID method = env->GetMethodID(env->GetObjectClass(object), "intValue", "()I");
- result = MakeIntValue(env->CallIntMethod(object, method));
- } else if (IsJavaInstanceOf(env, object, "java/lang/Float")) {
- jmethodID method = env->GetMethodID(env->GetObjectClass(object), "floatValue", "()F");
- result = MakeFloatValue(env->CallFloatMethod(object, method));
- } else if (IsJavaInstanceOf(env, object, "java/lang/String")) {
- result = MakeStringValue(ToCppString(env, static_cast<jstring>(object)).c_str());
- } else if (IsJavaInstanceOf(env, object, "[I")) {
- jint* elems = env->GetIntArrayElements(static_cast<jintArray>(object), NULL);
- const jint count = env->GetArrayLength(static_cast<jintArray>(object));
- result = MakeIntArrayValue(elems, count);
- env->ReleaseIntArrayElements(static_cast<jintArray>(object), elems, JNI_ABORT);
- } else if (IsJavaInstanceOf(env, object, "[F")) {
- jfloat* elems = env->GetFloatArrayElements(static_cast<jfloatArray>(object), NULL);
- const jint count = env->GetArrayLength(static_cast<jfloatArray>(object));
- result = MakeFloatArrayValue(elems, count);
- env->ReleaseFloatArrayElements(static_cast<jfloatArray>(object), elems, JNI_ABORT);
- }
- }
- return result;
-}
-
-jobject ToJObject(JNIEnv* env, const Value& value) {
- jobject result = JNI_NULL;
- if (ValueIsInt(value)) {
- jclass clazz = env->FindClass("java/lang/Integer");
- jmethodID constructorID = env->GetMethodID(clazz, "<init>", "(I)V");
- result = env->NewObject(clazz, constructorID, GetIntValue(value));
- } else if (ValueIsFloat(value)) {
- jclass clazz = env->FindClass("java/lang/Float");
- jmethodID constructorID = env->GetMethodID(clazz, "<init>", "(F)V");
- result = env->NewObject(clazz, constructorID, GetFloatValue(value));
- } else if (ValueIsString(value)) {
- result = ToJString(env, GetStringValue(value));
- } else if (ValueIsIntArray(value)) {
- result = env->NewIntArray(GetValueCount(value));
- env->SetIntArrayRegion(static_cast<jintArray>(result),
- 0,
- GetValueCount(value),
- reinterpret_cast<const jint*>(GetIntArrayValue(value)));
- } else if (ValueIsFloatArray(value)) {
- result = env->NewFloatArray(GetValueCount(value));
- env->SetFloatArrayRegion(static_cast<jfloatArray>(result),
- 0,
- GetValueCount(value),
- reinterpret_cast<const jfloat*>(GetFloatArrayValue(value)));
- }
- return result;
-}
diff --git a/mca/filterfw/jni/jni_util.h b/mca/filterfw/jni/jni_util.h
deleted file mode 100644
index 68ff653..0000000
--- a/mca/filterfw/jni/jni_util.h
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <jni.h>
-
-#include <hash_map>
-#include <string>
-
-#include "base/utilities.h"
-#include "core/value.h"
-
-#ifndef ANDROID_FILTERFW_JNI_JNI_UTIL_H
-#define ANDROID_FILTERFW_JNI_JNI_UTIL_H
-
-// We add this JNI_NULL macro to allow consistent code separation of Java and
-// C++ types.
-#define JNI_NULL NULL
-
-#if 0
-// Pointer to current JavaVM. Do not use this directly. Instead use the funciton
-// GetCurrentJavaVM().
-extern JavaVM* g_current_java_vm_;
-
-// Wrapper around a java object pointer, which includes the environment
-// pointer in which the object "lives". This is used for passing down Java
-// objects from the Java layer to C++.
-// While an instance of this class does not own the underlying java object, it
-// does hold a global reference to it, so that the Java garbage collector does
-// not destroy it. It uses reference counting to determine when it can destroy
-// the reference.
-// TODO: Add multi-thread support!
-class JavaObject {
- public:
- // Creates a NULL JavaObject.
- JavaObject();
-
- // Creates a wrapper around the given object in the given JNI environment.
- JavaObject(jobject object, JNIEnv* env);
-
- // Copy constructor.
- JavaObject(const JavaObject& java_obj);
-
- // Destructor.
- ~JavaObject();
-
- // Assignment operator.
- JavaObject& operator=(const JavaObject& java_obj);
-
- // Access to the object (non-const as JNI functions are non-const).
- jobject object() const {
- return object_;
- }
-
- // Resets this object to the NULL JavaObject.
- void Reset();
-
- private:
- // Retain the instance, i.e. increase reference count.
- void Retain();
-
- // Release the instance, i.e. decrease reference count.
- void Release();
-
- // The object pointer (not owned).
- jobject object_;
-
- // The reference count of this object
- int* ref_count_;
-};
-#endif
-
-// ObjectPool template class. This class keeps track of C++ instances that are
-// coupled to Java objects. This is done by using an "id" field in the Java
-// object, which is then mapped to the correct instance here. It should not be
-// necessary to use this class directly. Instead, the convenience functions
-// below can be used.
-template<class T>
-class ObjectPool {
- public:
- // Create a new ObjectPool for a specific object type. Pass the path to the
- // Java equivalent class of the C++ class, and the name of the java member
- // field that will store the object's ID.
- static void Setup(const std::string& jclass_name,
- const std::string& id_fld_name) {
- instance_ = new ObjectPool<T>(jclass_name, id_fld_name);
- }
-
- // Return the shared instance to this type's pool.
- static ObjectPool* Instance() {
- return instance_;
- }
-
- // Delete this type's pool.
- static void TearDown() {
- delete instance_;
- }
-
- // Register a new C++ object with the pool. This does not affect the Java
- // layer. Use WrapObject() instead to perform the necessary Java-side
- // assignments. Pass true to owns if the object pool owns the object.
- int RegisterObject(T* object, bool owns) {
- const int id = next_id_;
- objects_[id] = object;
- owns_[id] = owns;
- ++next_id_;
- return id;
- }
-
- // Return the object in the pool with the specified ID.
- T* ObjectWithID(int obj_id) const {
- typename CObjMap::const_iterator iter = objects_.find(obj_id);
- return iter == objects_.end() ? NULL : iter->second;
- }
-
- // Get the ID of a Java object. This ID can be used to look-up the C++
- // object.
- int GetObjectID(JNIEnv* env, jobject j_object) {
- jclass cls = env->GetObjectClass(j_object);
- jfieldID id_field = env->GetFieldID(cls, id_field_name_.c_str(), "I");
- const int result = env->GetIntField(j_object, id_field);
- env->DeleteLocalRef(cls);
- return result;
- }
-
- // Take a C++ object and wrap it with a given Java object. This will
- // essentially set the ID member of the Java object to the ID of the C++
- // object. Pass true to owns if the object pool owns the object.
- bool WrapObject(T* c_object, JNIEnv* env, jobject j_object, bool owns) {
- const int id = RegisterObject(c_object, owns);
- jclass cls = env->GetObjectClass(j_object);
- jfieldID id_field = env->GetFieldID(cls, id_field_name_.c_str(), "I");
- env->SetIntField(j_object, id_field, id);
- env->DeleteLocalRef(cls);
- return true;
- }
-
- // Remove the object with the given ID from this pool, and delete it. This
- // does not affect the Java layer.
- bool DeleteObjectWithID(int obj_id) {
- typename CObjMap::iterator iter = objects_.find(obj_id);
- const bool found = iter != objects_.end();
- if (found) {
- if (owns_[obj_id])
- delete iter->second;
- objects_.erase(iter);
- }
- return found;
- }
-
- // Instantiates a new java object for this class. The Java class must have
- // a default constructor for this to succeed.
- jobject CreateJavaObject(JNIEnv* env) {
- jclass cls = env->FindClass(jclass_name_.c_str());
- jmethodID constructor = env->GetMethodID(
- cls,
- "<init>",
- "(Landroid/filterfw/core/NativeAllocatorTag;)V");
- jobject result = env->NewObject(cls, constructor, JNI_NULL);
- env->DeleteLocalRef(cls);
- return result;
- }
-
- int GetObjectCount() const {
- return objects_.size();
- }
-
- const std::string& GetJavaClassName() const {
- return jclass_name_;
- }
-
- private:
- explicit ObjectPool(const std::string& jclass_name,
- const std::string& id_fld_name)
- : jclass_name_(jclass_name),
- id_field_name_(id_fld_name),
- next_id_(0) { }
-
- typedef std::hash_map<int, T*> CObjMap;
- typedef std::hash_map<int, bool> FlagMap;
- static ObjectPool* instance_;
- std::string jclass_name_;
- std::string id_field_name_;
- int next_id_;
- CObjMap objects_;
- FlagMap owns_;
-
- DISALLOW_COPY_AND_ASSIGN(ObjectPool);
-};
-
-template<typename T> ObjectPool<T>* ObjectPool<T>::instance_ = NULL;
-
-// Convenience Functions ///////////////////////////////////////////////////////
-
-// This function "links" the C++ instance and the Java instance, so that they
-// can be mapped to one another. This must be called for every C++ instance
-// which is wrapped by a Java front-end interface. Pass true to owns, if the
-// Java layer should own the object.
-template<typename T>
-bool WrapObjectInJava(T* c_object, JNIEnv* env, jobject j_object, bool owns) {
- ObjectPool<T>* pool = ObjectPool<T>::Instance();
- return pool ? pool->WrapObject(c_object, env, j_object, owns) : false;
-}
-
-// Creates a new Java instance, which wraps the passed C++ instance. Returns
-// the wrapped object or JNI_NULL if there was an error. Pass true to owns, if
-// the Java layer should own the object.
-template<typename T>
-jobject WrapNewObjectInJava(T* c_object, JNIEnv* env, bool owns) {
- ObjectPool<T>* pool = ObjectPool<T>::Instance();
- if (pool) {
- jobject result = pool->CreateJavaObject(env);
- if (WrapObjectInJava(c_object, env, result, owns))
- return result;
- }
- return JNI_NULL;
-}
-
-// Use ConvertFromJava to obtain a C++ instance given a Java object. This
-// instance must have been wrapped in Java using the WrapObjectInJava()
-// function.
-template<typename T>
-T* ConvertFromJava(JNIEnv* env, jobject j_object) {
- ObjectPool<T>* pool = ObjectPool<T>::Instance();
- return pool && j_object
- ? pool->ObjectWithID(pool->GetObjectID(env, j_object))
- : NULL;
-}
-
-// Delete the native object given a Java instance. This should be called from
-// the Java object's finalizer.
-template<typename T>
-bool DeleteNativeObject(JNIEnv* env, jobject j_object) {
- ObjectPool<T>* pool = ObjectPool<T>::Instance();
- return pool && j_object
- ? pool->DeleteObjectWithID(pool->GetObjectID(env, j_object))
- : false;
-}
-
-#if 0
-// Get the current JNI VM, or NULL if there is no current VM
-JavaVM* GetCurrentJavaVM();
-
-// Get the current JNI environment, or NULL if this is not a JNI thread
-JNIEnv* GetCurrentJNIEnv();
-#endif
-
-// Convert C++ boolean to Java boolean.
-jboolean ToJBool(bool value);
-
-// Convert Java boolean to C++ boolean.
-bool ToCppBool(jboolean value);
-
-// Convert Java String to C++ string.
-jstring ToJString(JNIEnv* env, const std::string& value);
-
-// Convert C++ string to Java String.
-std::string ToCppString(JNIEnv* env, jstring value);
-
-// Convert Java object to a (C) Value object.
-Value ToCValue(JNIEnv* env, jobject object);
-
-// Convert a (C) Value object to a Java object.
-jobject ToJObject(JNIEnv* env, const Value& value);
-
-// Returns true, iff the passed object is an instance of the class specified
-// by its fully qualified class name.
-bool IsJavaInstanceOf(JNIEnv* env, jobject object,
- const std::string& class_name);
-
-#endif // ANDROID_FILTERFW_JNI_JNI_UTIL_H
diff --git a/mca/filterfw/jni/jni_vertex_frame.cpp b/mca/filterfw/jni/jni_vertex_frame.cpp
deleted file mode 100644
index caae938..0000000
--- a/mca/filterfw/jni/jni_vertex_frame.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "jni/jni_vertex_frame.h"
-#include "jni/jni_util.h"
-
-#include "native/core/vertex_frame.h"
-
-using android::filterfw::VertexFrame;
-
-jboolean Java_android_filterfw_core_VertexFrame_nativeAllocate(JNIEnv* env,
- jobject thiz,
- jint size) {
- return ToJBool(WrapObjectInJava(new VertexFrame(size), env, thiz, true));
-}
-
-jboolean Java_android_filterfw_core_VertexFrame_nativeDeallocate(JNIEnv* env, jobject thiz) {
- return ToJBool(DeleteNativeObject<VertexFrame>(env, thiz));
-}
-
-jboolean Java_android_filterfw_core_VertexFrame_setNativeInts(JNIEnv* env,
- jobject thiz,
- jintArray ints) {
-
- VertexFrame* frame = ConvertFromJava<VertexFrame>(env, thiz);
- if (frame && ints) {
- jint* int_ptr = env->GetIntArrayElements(ints, NULL);
- const int length = env->GetArrayLength(ints);
- if (int_ptr) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(int_ptr),
- length * sizeof(jint));
- env->ReleaseIntArrayElements(ints, int_ptr, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_VertexFrame_setNativeFloats(JNIEnv* env,
- jobject thiz,
- jfloatArray floats) {
- VertexFrame* frame = ConvertFromJava<VertexFrame>(env, thiz);
- if (frame && floats) {
- jfloat* float_ptr = env->GetFloatArrayElements(floats, NULL);
- const int length = env->GetArrayLength(floats);
- if (float_ptr) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(float_ptr),
- length * sizeof(jfloat));
- env->ReleaseFloatArrayElements(floats, float_ptr, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jboolean Java_android_filterfw_core_VertexFrame_setNativeData(JNIEnv* env,
- jobject thiz,
- jbyteArray data,
- jint offset,
- jint length) {
- VertexFrame* frame = ConvertFromJava<VertexFrame>(env, thiz);
- if (frame && data) {
- jbyte* bytes = env->GetByteArrayElements(data, NULL);
- if (bytes) {
- const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(bytes + offset),
- length);
- env->ReleaseByteArrayElements(data, bytes, JNI_ABORT);
- return ToJBool(success);
- }
- }
- return JNI_FALSE;
-}
-
-jint Java_android_filterfw_core_VertexFrame_getNativeVboId(JNIEnv* env, jobject thiz) {
- VertexFrame* frame = ConvertFromJava<VertexFrame>(env, thiz);
- return frame ? frame->GetVboId() : -1;
-}
diff --git a/mca/filterfw/jni/jni_vertex_frame.h b/mca/filterfw/jni/jni_vertex_frame.h
deleted file mode 100644
index fcd7ea1..0000000
--- a/mca/filterfw/jni/jni_vertex_frame.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_JNI_VERTEX_FRAME_H
-#define ANDROID_FILTERFW_JNI_VERTEX_FRAME_H
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_VertexFrame_nativeAllocate(JNIEnv* env, jobject thiz, jint size);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_VertexFrame_nativeDeallocate(JNIEnv* env, jobject thiz);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_VertexFrame_setNativeInts(JNIEnv* env, jobject thiz, jintArray ints);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_VertexFrame_setNativeFloats(JNIEnv* env,
- jobject thiz,
- jfloatArray floats);
-
-JNIEXPORT jboolean JNICALL
-Java_android_filterfw_core_VertexFrame_setNativeData(JNIEnv* env,
- jobject thiz,
- jbyteArray data,
- jint offset,
- jint length);
-
-JNIEXPORT jint JNICALL
-Java_android_filterfw_core_VertexFrame_getNativeVboId(JNIEnv* env, jobject thiz);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // ANDROID_FILTERFW_JNI_VERTEX_FRAME_H
diff --git a/mca/filterfw/native/Android.mk b/mca/filterfw/native/Android.mk
deleted file mode 100644
index 46ee283..0000000
--- a/mca/filterfw/native/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-#####################
-# Build module libfilterfw_static
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := libfilterfw_native
-
-LOCAL_SRC_FILES += core/geometry.cpp \
- core/gl_env.cpp \
- core/gl_frame.cpp \
- core/native_frame.cpp \
- core/native_program.cpp \
- core/shader_program.cpp \
- core/vertex_frame.cpp \
- core/value.cpp
-
-# add local includes
-include $(LOCAL_PATH)/libfilterfw.mk
-
-# gcc should always be placed at the end.
-LOCAL_EXPORT_LDLIBS := -llog -lgcc
-
-# TODO: Build a shared library as well?
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/mca/filterfw/native/base/logging.h b/mca/filterfw/native/base/logging.h
deleted file mode 100644
index 1236d0b..0000000
--- a/mca/filterfw/native/base/logging.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_BASE_LOGGING_H
-#define ANDROID_FILTERFW_BASE_LOGGING_H
-
-#define LOG_EVERY_FRAME false
-
-#define LOG_FRAME(...) if (LOG_EVERY_FRAME) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
-
-#define LOG_TAG "MCA"
-#include <utils/Log.h>
-
-#endif // ANDROID_FILTERFW_BASE_LOGGING_H
diff --git a/mca/filterfw/native/base/utilities.h b/mca/filterfw/native/base/utilities.h
deleted file mode 100644
index 6bb3b7f..0000000
--- a/mca/filterfw/native/base/utilities.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_BASE_UTILITIES_H
-#define ANDROID_FILTERFW_BASE_UTILITIES_H
-
-#include <set>
-#include <utility>
-
-namespace android {
-namespace filterfw {
-
-// Convenience Macro to make copy constructor and assignment operator private
-// (thereby disallowing copying and assigning).
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- void operator=(const TypeName&)
-
-// A macro to disallow all the implicit constructors, namely the
-// default constructor, copy constructor and operator= functions.
-#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
- TypeName(); \
- DISALLOW_COPY_AND_ASSIGN(TypeName)
-
-// STLDeleteContainerPointers()
-// For a range within a container of pointers, calls delete
-// (non-array version) on these pointers.
-// NOTE: for these three functions, we could just implement a DeleteObject
-// functor and then call for_each() on the range and functor, but this
-// requires us to pull in all of algorithm.h, which seems expensive.
-// For hash_[multi]set, it is important that this deletes behind the iterator
-// because the hash_set may call the hash function on the iterator when it is
-// advanced, which could result in the hash function trying to deference a
-// stale pointer.
-template <class ForwardIterator>
-void STLDeleteContainerPointers(ForwardIterator begin,
- ForwardIterator end) {
- while (begin != end) {
- ForwardIterator temp = begin;
- ++begin;
- delete *temp;
- }
-}
-
-// Given an STL container consisting of (key, value) pairs, STLDeleteValues
-// deletes all the "value" components and clears the container. Does nothing
-// in the case it's given a NULL pointer.
-template <class T>
-void STLDeleteValues(T *v) {
- if (!v) return;
- for (typename T::iterator i = v->begin(); i != v->end(); ++i) {
- delete i->second;
- }
- v->clear();
-}
-
-// Perform a lookup in a map or hash_map.
-// If the key is present a const pointer to the associated value is returned,
-// otherwise a NULL pointer is returned.
-template <class Collection>
-const typename Collection::value_type::second_type*
-FindOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return &it->second;
-}
-
-// A simple class that gives checklist functionality: There are essemtially two
-// operations defined on a CheckList:
-// - Adding a new (unchecked) item.
-// - Checking off an item.
-// When checking off the last remaining item CheckItem() returns true.
-template<typename T>
-class CheckList {
- public:
- // Add a new unchecked item. Does nothing if item is already in checklist.
- void AddItem(const T& item);
-
- // Check off an item in the checklist. Returns true if all items have been
- // checked.
- bool CheckItem(const T& item);
-
- // Clear the checklist.
- void Clear() {
- items_.clear();
- }
-
- private:
- std::set<T> items_;
-};
-
-template<typename T>
-void CheckList<T>::AddItem(const T& item) {
- if (!ContainsKey(items_, item))
- items_.insert(item);
-}
-
-template<typename T>
-bool CheckList<T>::CheckItem(const T& item) {
- typename std::set<T>::iterator iter = items_.find(item);
- if (iter != items_.end())
- items_.erase(iter);
- return items_.empty();
-}
-
-// Perform a lookup in a map or hash_map whose values are pointers.
-// If the key is present a const pointer to the associated value is returned,
-// otherwise a NULL pointer is returned.
-// This function does not distinguish between a missing key and a key mapped
-// to a NULL value.
-template <class Collection>
-const typename Collection::value_type::second_type
-FindPtrOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return it->second;
-}
-
-// Test to see if a set, map, hash_set or hash_map contains a particular key.
-// Returns true if the key is in the collection.
-template <typename Collection, typename Key>
-bool ContainsKey(const Collection& collection, const Key& key) {
- return collection.find(key) != collection.end();
-}
-
-// Insert a new key and value into a map or hash_map.
-// If the key is not present in the map the key and value are
-// inserted, otherwise nothing happens. True indicates that an insert
-// took place, false indicates the key was already present.
-template <class Collection, class Key, class Value>
-bool InsertIfNotPresent(Collection * const collection,
- const Key& key, const Value& value) {
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, value));
- return ret.second;
-}
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_BASE_UTILITIES_H
diff --git a/mca/filterfw/native/core/geometry.cpp b/mca/filterfw/native/core/geometry.cpp
deleted file mode 100644
index efd1946..0000000
--- a/mca/filterfw/native/core/geometry.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "core/geometry.h"
-
-#include <cmath>
-
-#include "base/logging.h"
-
-namespace android {
-namespace filterfw {
-
-float Point::Length() const {
- return std::sqrt(x_ * x_ + y_ * y_);
-}
-
-bool Point::ScaleTo(float new_length) {
- float length = Length();
- if (length == 0.0f) {
- return false;
- }
- x_ *= new_length / length;
- y_ *= new_length / length;
- return true;
-}
-
-float Point::Distance(const Point& p0, const Point& p1) {
- Point diff = p1 - p0;
- return diff.Length();
-}
-
-Point Point::operator+(const Point& other) const {
- Point out;
- out.x_ = x_ + other.x_;
- out.y_ = y_ + other.y_;
- return out;
-}
-
-Point Point::operator-(const Point& other) const {
- Point out;
- out.x_ = x_ - other.x_;
- out.y_ = y_ - other.y_;
- return out;
-}
-
-Point Point::operator*(float factor) const {
- Point out;
- out.x_ = factor * x_;
- out.y_ = factor * y_;
- return out;
-}
-
-void Point::Rotate90Clockwise() {
- const float x = x_;
- x_ = y_;
- y_ = -x;
-}
-
-bool Rect::ExpandToAspectRatio(float ratio) {
- if (width <= 0.0f || height <= 0.0f || ratio <= 0.0f) {
- return false;
- }
-
- const float current_ratio = width / height;
- if (current_ratio < ratio) {
- const float dx = width * (ratio / current_ratio - 1.0f);
- x -= dx / 2.0f;
- width += dx;
- } else {
- const float dy = height * (current_ratio / ratio - 1.0f);
- y -= dy / 2.0f;
- height += dy;
- }
- return true;
-}
-
-bool Rect::ExpandToMinLength(float length) {
- if (width <= 0.0f || height <= 0.0f || length <= 0.0f) {
- return false;
- }
-
- const float current_length = width > height ? width : height;
- if (length > current_length) {
- const float dx = width * (length / current_length - 1.0f);
- x -= dx / 2.0f;
- width += dx;
- const float dy = height * (length / current_length - 1.0f);
- y -= dy / 2.0f;
- height += dy;
- }
- return true;
-}
-
-bool Rect::ScaleWithLengthLimit(float factor, float max_length) {
- if (width <= 0.0f || height <= 0.0f || factor <= 0.0f) {
- return false;
- }
-
- const float current_length = width > height ? width : height;
- if (current_length >= max_length) {
- return true;
- }
-
- float f = factor;
- if (current_length * f > max_length) {
- f *= max_length / (current_length * f);
- }
-
- const float dx = width * (f - 1.0f);
- x -= dx / 2.0f;
- width += dx;
- const float dy = height * (f - 1.0f);
- y -= dy / 2.0f;
- height += dy;
- return true;
-}
-
-const Point& Quad::point(int ix) const {
- LOG_ASSERT(ix < static_cast<int>(points_.size()), "Access out of bounds");
- return points_[ix];
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/geometry.h b/mca/filterfw/native/core/geometry.h
deleted file mode 100644
index 7f89eef..0000000
--- a/mca/filterfw/native/core/geometry.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_GEOMETRY_H
-#define ANDROID_FILTERFW_CORE_GEOMETRY_H
-
-#include <vector>
-
-namespace android {
-namespace filterfw {
-
-// This is an initial implementation of some geometrical structures. This is
-// likely to grow and become more sophisticated in the future.
-
-class Point {
- public:
- Point() : x_(0.0f), y_(0.0f) {}
- Point(float x, float y) : x_(x), y_(y) {}
-
- float x() const { return x_; }
- float y() const { return y_; }
-
- float Length() const;
- bool ScaleTo(float new_length);
- static float Distance(const Point& p0, const Point& p1);
-
- // Add more of these as needed:
- Point operator+(const Point& other) const;
- Point operator-(const Point& other) const;
- Point operator*(float factor) const;
-
- void Rotate90Clockwise();
-
- private:
- float x_, y_;
-};
-
-class Quad {
- public:
- Quad() : points_(4) {}
- virtual ~Quad() {}
-
- Quad(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
- : points_(4) {
- points_[0] = p0;
- points_[1] = p1;
- points_[2] = p2;
- points_[3] = p3;
- }
-
- const std::vector<Point>& points() const { return points_; }
- const Point& point(int ix) const;
-
- protected:
- std::vector<Point> points_;
-};
-
-struct Rect {
- float x, y, width, height;
-
- Rect() {
- x = y = 0.0f;
- width = height = 1.0f;
- }
-
- Rect(float x, float y, float width, float height) {
- this->x = x;
- this->y = y;
- this->width = width;
- this->height = height;
- }
-
- bool ExpandToAspectRatio(float ratio);
- bool ExpandToMinLength(float length);
- bool ScaleWithLengthLimit(float factor, float max_length);
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_GEOMETRY_H
diff --git a/mca/filterfw/native/core/gl_buffer_interface.h b/mca/filterfw/native/core/gl_buffer_interface.h
deleted file mode 100644
index 24b1db9..0000000
--- a/mca/filterfw/native/core/gl_buffer_interface.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_GL_BUFFER_INTERFACE_H
-#define ANDROID_FILTERFW_CORE_GL_BUFFER_INTERFACE_H
-
-#include <GLES2/gl2.h>
-
-namespace android {
-namespace filterfw {
-
-class GLTextureHandle {
- public:
- virtual ~GLTextureHandle() { }
-
- // Returns the held texture id.
- virtual GLuint GetTextureId() const = 0;
-
- // Binds the held texture. This may result in creating the texture if it
- // is not yet available.
- virtual bool FocusTexture() = 0;
-
- // Generates the mipmap chain of the held texture. Returns true, iff
- // generating was successful.
- virtual bool GenerateMipMap() = 0;
-
- // Set a texture parameter (see glTextureParameter documentation). Returns
- // true iff the parameter was set successfully.
- virtual bool SetTextureParameter(GLenum pname, GLint value) = 0;
-
- // Returns the texture target used.
- // Texture Target should be: GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES.
- virtual GLuint GetTextureTarget() const = 0;
-};
-
-class GLFrameBufferHandle {
- public:
- virtual ~GLFrameBufferHandle() { }
-
- // Returns the held FBO id.
- virtual GLuint GetFboId() const = 0;
-
- // Binds the held FBO. This may result in creating the FBO if it
- // is not yet available.
- virtual bool FocusFrameBuffer() = 0;
-};
-
-// Interface to instances that hold GL textures and frame-buffer-objects.
-// The GLFrame class implements this interface.
-class GLBufferHandle : public GLTextureHandle, public GLFrameBufferHandle {
- public:
- virtual ~GLBufferHandle() { }
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_GL_BUFFER_INTERFACE_H
diff --git a/mca/filterfw/native/core/gl_env.cpp b/mca/filterfw/native/core/gl_env.cpp
deleted file mode 100644
index b412ac5..0000000
--- a/mca/filterfw/native/core/gl_env.cpp
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// #define LOG_NDEBUG 0
-
-#include "base/logging.h"
-#include "base/utilities.h"
-#include "core/gl_env.h"
-#include "core/shader_program.h"
-#include "core/vertex_frame.h"
-#include "system/window.h"
-
-#include <map>
-#include <string>
-#include <EGL/eglext.h>
-
-namespace android {
-namespace filterfw {
-
-GLEnv::GLEnv()
- : display_(EGL_NO_DISPLAY),
- context_id_(0),
- surface_id_(0),
- max_surface_id_(0),
- created_context_(false),
- created_surface_(false),
- initialized_(false) {
-}
-
-GLEnv::~GLEnv() {
- // Destroy surfaces
- for (std::map<int, SurfaceWindowPair>::iterator it = surfaces_.begin();
- it != surfaces_.end();
- ++it) {
- if (it->first != 0 || created_surface_) {
- eglDestroySurface(display(), it->second.first);
- if (it->second.second) {
- it->second.second->Destroy();
- delete it->second.second;
- }
- }
- }
-
- // Destroy contexts
- for (std::map<int, EGLContext>::iterator it = contexts_.begin();
- it != contexts_.end();
- ++it) {
- if (it->first != 0 || created_context_)
- eglDestroyContext(display(), it->second);
- }
-
- // Destroy attached shaders and frames
- STLDeleteValues(&attached_shaders_);
- STLDeleteValues(&attached_vframes_);
-
- // Destroy display
- if (initialized_)
- eglTerminate(display());
-
- // Log error if this did not work
- if (CheckEGLError("TearDown!"))
- LOGE("GLEnv: Error tearing down GL Environment!");
-}
-
-bool GLEnv::IsInitialized() const {
- return (contexts_.size() > 0 &&
- surfaces_.size() > 0 &&
- display_ != EGL_NO_DISPLAY);
-}
-
-bool GLEnv::Deactivate() {
- eglMakeCurrent(display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- return !CheckEGLError("eglMakeCurrent");
-}
-
-bool GLEnv::Activate() {
- LOGV("Activate()");
- if (display() != eglGetCurrentDisplay() ||
- context() != eglGetCurrentContext() ||
- surface() != eglGetCurrentSurface(EGL_DRAW)) {
- // Make sure we are initialized
- if (context() == EGL_NO_CONTEXT || surface() == EGL_NO_SURFACE)
- return false;
-
- // Make our context current
- LOGV("eglMakeCurrent");
- eglMakeCurrent(display(), surface(), surface(), context());
-
- return !CheckEGLMakeCurrentError();
- }
- return true;
-}
-
-bool GLEnv::SwapBuffers() {
- const bool result = eglSwapBuffers(display(), surface()) == EGL_TRUE;
- return !CheckEGLError("eglSwapBuffers") && result;
-}
-
-bool GLEnv::InitWithCurrentContext() {
- if (IsInitialized())
- return true;
-
- display_ = eglGetCurrentDisplay();
- contexts_[0] = eglGetCurrentContext();
- surfaces_[0] = SurfaceWindowPair(eglGetCurrentSurface(EGL_DRAW), NULL);
-
- return (context() != EGL_NO_CONTEXT) &&
- (display() != EGL_NO_DISPLAY) &&
- (surface() != EGL_NO_SURFACE);
-}
-
-bool GLEnv::InitWithNewContext() {
- if (IsInitialized()) {
- LOGE("GLEnv: Attempting to reinitialize environment!");
- return false;
- }
-
- display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (CheckEGLError("eglGetDisplay")) return false;
-
- EGLint majorVersion;
- EGLint minorVersion;
- eglInitialize(display(), &majorVersion, &minorVersion);
- if (CheckEGLError("eglInitialize")) return false;
- initialized_ = true;
-
- // Configure context/surface
- EGLConfig config;
- EGLint numConfigs = -1;
-
- // TODO(renn): Do we need the window bit here?
- // TODO: Currently choosing the config that includes all
- // This is not needed if the encoding is not being used
- EGLint configAttribs[] = {
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_RECORDABLE_ANDROID, EGL_TRUE,
- EGL_NONE
- };
-
- eglChooseConfig(display(), configAttribs, &config, 1, &numConfigs);
- if (numConfigs < 1) {
- LOGE("GLEnv::Init: No suitable EGL configuration found!");
- return false;
- }
-
- // Create dummy surface using a SurfaceTexture
- sp<SurfaceTexture> st = new SurfaceTexture(0, false);
- window_ = new SurfaceTextureClient(st);
-
- surfaces_[0] = SurfaceWindowPair(eglCreateWindowSurface(display(), config, window_.get(), NULL), NULL);
- if (CheckEGLError("eglCreateWindowSurface")) return false;
-
- // Create context
- EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
- contexts_[0] = eglCreateContext(display(),
- config,
- EGL_NO_CONTEXT,
- context_attribs);
- if (CheckEGLError("eglCreateContext")) return false;
-
- created_context_ = created_surface_ = true;
-
- return true;
-}
-
-bool GLEnv::IsActive() const {
- LOGV("IsActive()");
- return context() == eglGetCurrentContext()
- && display() == eglGetCurrentDisplay()
- && surface() == eglGetCurrentSurface(EGL_DRAW);
-}
-
-bool GLEnv::IsContextActive() const {
- return context() == eglGetCurrentContext();
-}
-
-bool GLEnv::IsAnyContextActive() {
- return eglGetCurrentContext() != EGL_NO_CONTEXT;
-}
-
-int GLEnv::AddWindowSurface(const EGLSurface& surface, WindowHandle* window_handle) {
- const int id = ++max_surface_id_;
- surfaces_[id] = SurfaceWindowPair(surface, window_handle);
- return id;
-}
-
-int GLEnv::AddSurface(const EGLSurface& surface) {
- return AddWindowSurface(surface, NULL);
-}
-
-bool GLEnv::SwitchToSurfaceId(int surface_id) {
- LOGV("SwitchToSurfaceId");
- if (surface_id_ != surface_id) {
- const SurfaceWindowPair* surface = FindOrNull(surfaces_, surface_id);
- if (surface) {
- bool wasActive = IsActive();
- surface_id_ = surface_id;
- return wasActive ? Activate() : true;
- }
- return false;
- }
- return true;
-}
-
-bool GLEnv::ReleaseSurfaceId(int surface_id) {
- if (surface_id > 0) {
- const SurfaceWindowPair* surface_window_pair = FindOrNull(surfaces_, surface_id);
- if (surface_window_pair) {
- if (surface_id_ == surface_id)
- SwitchToSurfaceId(0);
- eglDestroySurface(display(), surface_window_pair->first);
- if (surface_window_pair->second) {
- surface_window_pair->second->Destroy();
- delete surface_window_pair->second;
- }
- surfaces_.erase(surface_id);
- return true;
- }
- }
- return false;
-}
-
-bool GLEnv::SetSurfaceTimestamp(int64_t timestamp) {
- if (surface_id_ > 0) {
- const SurfaceWindowPair* surface_window_pair = FindOrNull(surfaces_,
- surface_id_);
- if (surface_window_pair) {
- ANativeWindow *window = static_cast<ANativeWindow*>(
- surface_window_pair->second->InternalHandle());
- native_window_set_buffers_timestamp(window, timestamp);
- return true;
- }
- }
- return false;
-}
-
-int GLEnv::FindSurfaceIdForWindow(const WindowHandle* window_handle) {
- for (std::map<int, SurfaceWindowPair>::iterator it = surfaces_.begin();
- it != surfaces_.end();
- ++it) {
- const WindowHandle* my_handle = it->second.second;
- if (my_handle && my_handle->Equals(window_handle)) {
- return it->first;
- }
- }
- return -1;
-}
-
-
-int GLEnv::AddContext(const EGLContext& context) {
- const int id = contexts_.size();
- contexts_[id] = context;
- return id;
-}
-
-bool GLEnv::SwitchToContextId(int context_id) {
- const EGLContext* context = FindOrNull(contexts_, context_id);
- if (context) {
- if (context_id_ != context_id) {
- context_id_ = context_id;
- return Activate();
- }
- return true;
- }
- return false;
-}
-
-void GLEnv::ReleaseContextId(int context_id) {
- if (context_id > 0) {
- const EGLContext* context = FindOrNull(contexts_, context_id);
- if (context) {
- contexts_.erase(context_id);
- if (context_id_ == context_id && IsActive())
- SwitchToContextId(0);
- eglDestroyContext(display(), *context);
- }
- }
-}
-
-bool GLEnv::CheckGLError(const std::string& op) {
- bool err = false;
- for (GLint error = glGetError(); error; error = glGetError()) {
- LOGE("GL Error: Operation '%s' caused GL error (0x%x)\n",
- op.c_str(),
- error);
- err = true;
- }
- return err;
-}
-
-bool GLEnv::CheckEGLError(const std::string& op) {
- bool err = false;
- for (EGLint error = eglGetError();
- error != EGL_SUCCESS;
- error = eglGetError()) {
- LOGE("EGL Error: Operation '%s' caused EGL error (0x%x)\n",
- op.c_str(),
- error);
- err = true;
- }
- return err;
-}
-
-bool GLEnv::CheckEGLMakeCurrentError() {
- bool err = false;
- for (EGLint error = eglGetError();
- error != EGL_SUCCESS;
- error = eglGetError()) {
- switch (error) {
- case EGL_BAD_DISPLAY:
- LOGE("EGL Error: Attempting to activate context with bad display!");
- break;
- case EGL_BAD_SURFACE:
- LOGE("EGL Error: Attempting to activate context with bad surface!");
- break;
- case EGL_BAD_ACCESS:
- LOGE("EGL Error: Attempting to activate context, which is "
- "already active in another thread!");
- break;
- default:
- LOGE("EGL Error: Making EGL rendering context current caused "
- "error: 0x%x\n", error);
- }
- err = true;
- }
- return err;
-}
-
-GLuint GLEnv::GetCurrentProgram() {
- GLint result;
- glGetIntegerv(GL_CURRENT_PROGRAM, &result);
- LOG_ASSERT(result >= 0);
- return static_cast<GLuint>(result);
-}
-
-EGLDisplay GLEnv::GetCurrentDisplay() {
- return eglGetCurrentDisplay();
-}
-
-int GLEnv::NumberOfComponents(GLenum type) {
- switch (type) {
- case GL_BOOL:
- case GL_FLOAT:
- case GL_INT:
- return 1;
- case GL_BOOL_VEC2:
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- return 2;
- case GL_INT_VEC3:
- case GL_FLOAT_VEC3:
- case GL_BOOL_VEC3:
- return 3;
- case GL_BOOL_VEC4:
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_FLOAT_MAT2:
- return 4;
- case GL_FLOAT_MAT3:
- return 9;
- case GL_FLOAT_MAT4:
- return 16;
- default:
- return 0;
- }
-}
-
-void GLEnv::AttachShader(int key, ShaderProgram* shader) {
- ShaderProgram* existingShader = ShaderWithKey(key);
- if (existingShader)
- delete existingShader;
- attached_shaders_[key] = shader;
-}
-
-void GLEnv::AttachVertexFrame(int key, VertexFrame* frame) {
- VertexFrame* existingFrame = VertexFrameWithKey(key);
- if (existingFrame)
- delete existingFrame;
- attached_vframes_[key] = frame;
-}
-
-ShaderProgram* GLEnv::ShaderWithKey(int key) {
- return FindPtrOrNull(attached_shaders_, key);
-}
-
-VertexFrame* GLEnv::VertexFrameWithKey(int key) {
- return FindPtrOrNull(attached_vframes_, key);
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/gl_env.h b/mca/filterfw/native/core/gl_env.h
deleted file mode 100644
index 587c064..0000000
--- a/mca/filterfw/native/core/gl_env.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_GL_ENV_H
-#define ANDROID_FILTERFW_CORE_GL_ENV_H
-
-#include <string>
-#include <utility>
-#include <map>
-
-#include "base/logging.h"
-#include "base/utilities.h"
-
-#include <GLES2/gl2.h>
-#include <EGL/egl.h>
-
-#include <gui/ISurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
-
-namespace android {
-namespace filterfw {
-
-class ShaderProgram;
-class VertexFrame;
-
-class WindowHandle {
- public:
- virtual ~WindowHandle() {
- }
-
- virtual void Destroy() = 0;
-
- virtual bool Equals(const WindowHandle* window) const {
- return InternalHandle() == window->InternalHandle();
- }
-
- virtual const void* InternalHandle() const = 0;
-
- virtual void* InternalHandle() = 0;
-};
-
-// The GLEnv class provides functionality related to the EGL environment, which
-// includes the display, context, and surface. It is possible to either create
-// a new environment or base it off the currently active EGL environment. In
-// order to do the latter, an EGL environment must be setup already (though not
-// necessarily through this class), and have an active display, context, and
-// surface.
-class GLEnv {
- public:
- // Constructing and Activating /////////////////////////////////////////////
- // Constructs a new GLEnv object. This does not create a GL context.
- GLEnv();
-
- // Destructor. Tears down and deallocates any GL objects that were created
- // by this instance.
- ~GLEnv();
-
- // Inits a new GL environment, including a new surface and context. You
- // must call Activate() before performing any GL operations.
- bool InitWithNewContext();
-
- // Inits the GL environment from the current GL environment. Use this when
- // there is already a display, surface and context available (possibly
- // created by the host application). You do not need to call Activate() as
- // this context is active already.
- bool InitWithCurrentContext();
-
- // Activates the environment, and makes the associated GL context the
- // current context. Creates the environment, if it has not been created
- // already. Returns true if the activation was successful.
- bool Activate();
-
- // Deactivates the environment. Returns true if the deactivation was
- // successful. You may want to call this when moving a context to another
- // thread. In this case, deactivate the GLEnv in the old thread, and
- // reactivate it in the new thread.
- bool Deactivate();
-
- // When rendering to a visible surface, call this to swap between the
- // offscreen and onscreen buffers. Returns true if the buffer swap was
- // successful.
- bool SwapBuffers();
-
- // Working with Surfaces ///////////////////////////////////////////////////
-
- // Add a surface to the environment. This surface will now be managed (and
- // owned) by the GLEnv instance. Returns the id of the surface.
- int AddSurface(const EGLSurface& surface);
-
- // Add a window surface to the environment. The window is passed in as
- // an opaque window handle.
- // This surface will now be managed (and owned) by the GLEnv instance.
- // Returns the id of the surface.
- int AddWindowSurface(const EGLSurface& surface, WindowHandle* window_handle);
-
- // Switch to the surface with the specified id. This will make the surface
- // active, if it is not active already. Specify an ID of 0 if you would like
- // to switch to the default surface. Returns true if successful.
- bool SwitchToSurfaceId(int surface_id);
-
- // Release the surface with the specified id. This will deallocate the
- // surface. If this is the active surface, the environment will switch to
- // the default surface (0) first. You cannot release the default surface.
- bool ReleaseSurfaceId(int surface_id);
-
- // Set the timestamp for the current surface. Must be called
- // before swapBuffers to associate the timestamp with the frame
- // resulting from swapBuffers.
- bool SetSurfaceTimestamp(int64_t timestamp);
-
- // Looks for a surface with the associated window handle. Returns -1 if no
- // surface with such a window was found.
- int FindSurfaceIdForWindow(const WindowHandle* window_handle);
-
- // Obtain the environment's EGL surface.
- const EGLSurface& surface() const {
- return surfaces_.find(surface_id_)->second.first;
- }
-
- // Working with Contexts ///////////////////////////////////////////////////
-
- // Add a context to the environment. This context will now be managed (and
- // owned) by the GLEnv instance. Returns the id of the context.
- int AddContext(const EGLContext& context);
-
- // Switch to the context with the specified id. This will make the context
- // active, if it is not active already. Specify an ID of 0 if you would like
- // to switch to the default context. Returns true if successful.
- bool SwitchToContextId(int context_id);
-
- // Release the context with the specified id. This will deallocate the
- // context. If this is the active context, the environment will switch to
- // the default context (0) first. You cannot release the default context.
- void ReleaseContextId(int context_id);
-
- // Obtain the environment's EGL context.
- const EGLContext& context() const {
- return contexts_.find(context_id_)->second;
- }
-
- // Working with the Display ////////////////////////////////////////////////
-
- // Obtain the environment's EGL display.
- const EGLDisplay& display() const {
- return display_;
- }
-
- // Inspecting the environment //////////////////////////////////////////////
- // Returns true if the environment is active in the current thread.
- bool IsActive() const;
-
- // Returns true if the environment's context is active in the curent thread.
- bool IsContextActive() const;
-
- // Returns true if there is any EGL context active in the current thread.
- // This need not be a context created by a GLEnv instance.
- static bool IsAnyContextActive();
-
- // Attaching GL objects ////////////////////////////////////////////////////
-
- // Attach a shader to the environment. The environment takes ownership of
- // the shader.
- void AttachShader(int key, ShaderProgram* shader);
-
- // Attach a vertex frame to the environment. The environment takes ownership
- // of the frame.
- void AttachVertexFrame(int key, VertexFrame* frame);
-
- // Return the shader with the specified key, or NULL if there is no such
- // shader attached to this environment.
- ShaderProgram* ShaderWithKey(int key);
-
- // Return the vertex frame with the specified key, or NULL if there is no
- // such frame attached to this environment.
- VertexFrame* VertexFrameWithKey(int key);
-
- // Static methods //////////////////////////////////////////////////////////
- // These operate on the currently active environment!
-
- // Checks if the current environment is in a GL error state. If so, it will
- // output an error message referencing the given operation string. Returns
- // true if there was at least one error.
- static bool CheckGLError(const std::string& operation);
-
- // Checks if the current environment is in an EGL error state. If so, it
- // will output an error message referencing the given operation string.
- // Returns true if there was at least one error.
- static bool CheckEGLError(const std::string& operation);
-
- // Get the currently used (shader) program.
- static GLuint GetCurrentProgram();
-
- // Get the currently active display.
- static EGLDisplay GetCurrentDisplay();
-
- // Returns the number of components for a given GL type. For instance,
- // returns 4 for vec4, and 16 for mat4.
- static int NumberOfComponents(GLenum type);
-
- private:
- typedef std::pair<EGLSurface, WindowHandle*> SurfaceWindowPair;
-
- // Initializes a new GL environment.
- bool Init();
-
- // Returns true if one of the Inits has been called successfully on this
- // instance.
- bool IsInitialized() const;
-
- // Outputs error messages specific to the operation eglMakeCurrent().
- // Returns true if there was at least one error.
- static bool CheckEGLMakeCurrentError();
-
- // The EGL display, contexts, and surfaces.
- EGLDisplay display_;
- std::map<int, EGLContext> contexts_;
- std::map<int, SurfaceWindowPair> surfaces_;
-
- // The currently active context and surface ids.
- int context_id_;
- int surface_id_;
-
- // Dummy surface for context
- sp<ANativeWindow> window_;
-
- // The maximum surface id used.
- int max_surface_id_;
-
- // These bools keep track of which objects this GLEnv has created (and
- // owns).
- bool created_context_;
- bool created_surface_;
- bool initialized_;
-
- // Attachments that GL objects can add to the environment.
- std::map<int, ShaderProgram*> attached_shaders_;
- std::map<int, VertexFrame*> attached_vframes_;
-
- DISALLOW_COPY_AND_ASSIGN(GLEnv);
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_GL_ENV_H
diff --git a/mca/filterfw/native/core/gl_frame.cpp b/mca/filterfw/native/core/gl_frame.cpp
deleted file mode 100644
index 04cc15f..0000000
--- a/mca/filterfw/native/core/gl_frame.cpp
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "base/logging.h"
-
-#include "core/gl_env.h"
-#include "core/gl_frame.h"
-#include "core/shader_program.h"
-
-#include <vector>
-
-namespace android {
-namespace filterfw {
-
-static const int kIdentityShaderKey = 1;
-
-//
-// A GLFrame stores pixel data on the GPU. It uses two kinds of GL data
-// containers for this: Textures and Frame Buffer Objects (FBOs). Textures are
-// used whenever pixel data needs to be read into a shader or the host program,
-// and when pixel data is uploaded to a GLFrame. The FBO is used as a rendering
-// target for shaders.
-//
-
-GLFrame::GLFrame(GLEnv* gl_env)
- : gl_env_(gl_env),
- width_(0),
- height_(0),
- vp_x_(0),
- vp_y_(0),
- vp_width_(0),
- vp_height_(0),
- texture_id_(0),
- fbo_id_(0),
- texture_target_(GL_TEXTURE_2D),
- texture_state_(kStateUninitialized),
- fbo_state_(kStateUninitialized),
- owns_texture_(false),
- owns_fbo_(false) {
- SetDefaultTexParameters();
-}
-
-bool GLFrame::Init(int width, int height) {
- // Make sure we haven't been initialized already
- if (width_ == 0 && height_ == 0) {
- InitDimensions(width, height);
- return true;
- }
- return false;
-}
-
-bool GLFrame::InitWithTexture(GLint texture_id, int width, int height) {
- texture_id_ = texture_id;
- texture_state_ = glIsTexture(texture_id) ? kStateComplete : kStateGenerated;
- InitDimensions(width, height);
- return true;
-}
-
-bool GLFrame::InitWithFbo(GLint fbo_id, int width, int height) {
- fbo_id_ = fbo_id;
- fbo_state_ = glIsFramebuffer(fbo_id) ? kStateComplete : kStateGenerated;
- texture_state_ = kStateUnmanaged;
- InitDimensions(width, height);
- return true;
-}
-
-bool GLFrame::InitWithExternalTexture() {
- texture_target_ = GL_TEXTURE_EXTERNAL_OES;
- width_ = 0;
- height_ = 0;
- return GenerateTextureName();
-}
-
-void GLFrame::InitDimensions(int width, int height) {
- width_ = width;
- height_ = height;
- vp_width_ = width;
- vp_height_ = height;
-}
-
-GLFrame::~GLFrame() {
- // Delete texture
- if (owns_texture_) {
- // Bind FBO so that texture is unbound from it during deletion
- if (fbo_state_ == kStateComplete) {
- glBindFramebuffer(GL_FRAMEBUFFER, fbo_id_);
- }
- glDeleteTextures(1, &texture_id_);
- }
-
- // Delete FBO
- if (owns_fbo_) {
- glDeleteFramebuffers(1, &fbo_id_);
- }
-}
-
-bool GLFrame::GenerateMipMap() {
- if (FocusTexture()) {
- glGenerateMipmap(GL_TEXTURE_2D);
- return !GLEnv::CheckGLError("Generating MipMap!");
- }
- return false;
-}
-
-bool GLFrame::SetTextureParameter(GLenum pname, GLint value) {
- if (value != tex_params_[pname]) {
- if (FocusTexture()) {
- glTexParameteri(GL_TEXTURE_2D, pname, value);
- if (!GLEnv::CheckGLError("Setting texture parameter!")) {
- tex_params_[pname] = value;
- return true;
- }
- }
- } else {
- return true;
- }
- return false;
-}
-
-bool GLFrame::UpdateTexParameters() {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, tex_params_[GL_TEXTURE_MAG_FILTER]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, tex_params_[GL_TEXTURE_MIN_FILTER]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, tex_params_[GL_TEXTURE_WRAP_S]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, tex_params_[GL_TEXTURE_WRAP_T]);
- return !GLEnv::CheckGLError("Resetting texture parameters!");
-}
-
-bool GLFrame::TexParametersModifed() {
- return tex_params_[GL_TEXTURE_MAG_FILTER] != GL_LINEAR
- || tex_params_[GL_TEXTURE_MIN_FILTER] != GL_LINEAR
- || tex_params_[GL_TEXTURE_WRAP_S] != GL_CLAMP_TO_EDGE
- || tex_params_[GL_TEXTURE_WRAP_T] != GL_CLAMP_TO_EDGE;
-}
-
-void GLFrame::SetDefaultTexParameters() {
- tex_params_[GL_TEXTURE_MAG_FILTER] = GL_LINEAR;
- tex_params_[GL_TEXTURE_MIN_FILTER] = GL_LINEAR;
- tex_params_[GL_TEXTURE_WRAP_S] = GL_CLAMP_TO_EDGE;
- tex_params_[GL_TEXTURE_WRAP_T] = GL_CLAMP_TO_EDGE;
-}
-
-bool GLFrame::ResetTexParameters() {
- if (TexParametersModifed()) {
- if (BindTexture()) {
- SetDefaultTexParameters();
- return UpdateTexParameters();
- }
- return false;
- }
- return true;
-}
-
-bool GLFrame::CopyDataTo(uint8_t* buffer, int size) {
- return (size >= Size())
- ? CopyPixelsTo(buffer)
- : false;
-}
-
-bool GLFrame::CopyPixelsTo(uint8_t* buffer) {
- // Use one of the pixel reading methods below, ordered from most
- // efficient to least efficient.
- if (fbo_state_ == kStateComplete)
- return ReadFboPixels(buffer);
- else if (texture_state_ == kStateComplete)
- return ReadTexturePixels(buffer);
- else
- return false;
-}
-
-bool GLFrame::WriteData(const uint8_t* data, int data_size) {
- return (data_size == Size()) ? UploadTexturePixels(data) : false;
-}
-
-bool GLFrame::SetViewport(int x, int y, int width, int height) {
- vp_x_ = x;
- vp_y_ = y;
- vp_width_ = width;
- vp_height_ = height;
- return true;
-}
-
-GLFrame* GLFrame::Clone() const {
- GLFrame* target = new GLFrame(gl_env_);
- target->Init(width_, height_);
- target->CopyPixelsFrom(this);
- return target;
-}
-
-bool GLFrame::CopyPixelsFrom(const GLFrame* frame) {
- if (frame == this) {
- return true;
- } else if (frame && frame->width_ == width_ && frame->height_ == height_) {
- std::vector<const GLFrame*> sources;
- sources.push_back(frame);
- GetIdentity()->Process(sources, this);
- return true;
- }
- return false;
-}
-
-int GLFrame::Size() const {
- return width_ * height_ * 4;
-}
-
-ShaderProgram* GLFrame::GetIdentity() const {
- ShaderProgram* stored_shader = gl_env_->ShaderWithKey(kIdentityShaderKey);
- if (!stored_shader) {
- stored_shader = ShaderProgram::CreateIdentity(gl_env_);
- gl_env_->AttachShader(kIdentityShaderKey, stored_shader);
- }
- return stored_shader;
-}
-
-bool GLFrame::BindFrameBuffer() const {
- // Bind the FBO
- glBindFramebuffer(GL_FRAMEBUFFER, fbo_id_);
- if (GLEnv::CheckGLError("FBO Binding")) return false;
-
- // Set viewport
- glViewport(vp_x_, vp_y_, vp_width_, vp_height_);
- if (GLEnv::CheckGLError("ViewPort Setup")) return false;
-
- return true;
-}
-
-bool GLFrame::FocusFrameBuffer() {
- // Create texture backing if necessary
- if (texture_state_ == kStateUninitialized) {
- if (!GenerateTextureName())
- return false;
- }
-
- // Create and bind FBO to texture if necessary
- if (fbo_state_ != kStateComplete) {
- if (!GenerateFboName() || !AttachTextureToFbo())
- return false;
- }
-
- // And bind it.
- return BindFrameBuffer();
-}
-
-bool GLFrame::BindTexture() const {
- glBindTexture(GL_TEXTURE_2D, texture_id_);
- return !GLEnv::CheckGLError("Texture Binding");
-}
-
-GLuint GLFrame::GetTextureId() const {
- return texture_id_;
-}
-
-// Returns the held FBO id. Only call this if the GLFrame holds an FBO. You
-// can check this by calling HoldsFbo().
-GLuint GLFrame::GetFboId() const {
- return fbo_id_;
-}
-
-bool GLFrame::FocusTexture() {
- // Make sure we have a texture
- if (!GenerateTextureName())
- return false;
-
- // Bind the texture
- if (!BindTexture())
- return false;
-
- return !GLEnv::CheckGLError("Texture Binding");
-}
-
-bool GLFrame::GenerateTextureName() {
- if (texture_state_ == kStateUninitialized) {
- // Make sure texture not in use already
- if (glIsTexture(texture_id_)) {
- LOGE("GLFrame: Cannot generate texture id %d, as it is in use already!", texture_id_);
- return false;
- }
-
- // Generate the texture
- glGenTextures (1, &texture_id_);
- if (GLEnv::CheckGLError("Texture Generation"))
- return false;
- texture_state_ = kStateGenerated;
- owns_texture_ = true;
- }
-
- return true;
-}
-
-bool GLFrame::AllocateTexture() {
- // Allocate or re-allocate (if texture was deleted externally).
- if (texture_state_ == kStateGenerated || TextureWasDeleted()) {
- LOG_FRAME("GLFrame: Allocating texture: %d", texture_id_);
- glBindTexture(GL_TEXTURE_2D, texture_id_);
- glTexImage2D(GL_TEXTURE_2D,
- 0,
- GL_RGBA,
- width_,
- height_,
- 0,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- NULL);
- if (!GLEnv::CheckGLError("Texture Allocation")) {
- UpdateTexParameters();
- texture_state_ = kStateComplete;
- }
- }
- return texture_state_ == kStateComplete;
-}
-
-bool GLFrame::TextureWasDeleted() const {
- return texture_state_ == kStateComplete && !glIsTexture(texture_id_);
-}
-
-bool GLFrame::GenerateFboName() {
- if (fbo_state_ == kStateUninitialized) {
- // Make sure FBO not in use already
- if (glIsFramebuffer(fbo_id_)) {
- LOGE("GLFrame: Cannot generate FBO id %d, as it is in use already!", fbo_id_);
- return false;
- }
-
- // Create FBO
- glGenFramebuffers(1, &fbo_id_);
- if (GLEnv::CheckGLError("FBO Generation"))
- return false;
- fbo_state_ = kStateGenerated;
- owns_fbo_ = true;
- }
-
- return true;
-}
-
-bool GLFrame::ReadFboPixels(uint8_t* pixels) const {
- if (fbo_state_ == kStateComplete) {
- BindFrameBuffer();
- glReadPixels(0,
- 0,
- width_,
- height_,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- pixels);
- return !GLEnv::CheckGLError("FBO Pixel Readout");
- }
- return false;
-}
-
-bool GLFrame::ReadTexturePixels(uint8_t* pixels) const {
- // Read pixels from texture if we do not have an FBO
- // NOTE: OpenGL ES does NOT support glGetTexImage() for reading out texture
- // data. The only way for us to get texture data is to create a new FBO and
- // render the current texture frame into it. As this is quite inefficient,
- // and unnecessary (this can only happen if the user is reading out data
- // that was just set, and not run through a filter), we warn the user about
- // this here.
- LOGW("Warning: Reading pixel data from unfiltered GL frame. This is highly "
- "inefficient. Please consider using your original pixel buffer "
- "instead!");
-
- // Create source frame set (unfortunately this requires an ugly const-cast,
- // as we need to wrap ourselves in a frame-set. Still, as this set is used
- // as input only, we are certain we will not be modified).
- std::vector<const GLFrame*> sources;
- sources.push_back(this);
-
- // Create target frame
- GLFrame target(gl_env_);
- target.Init(width_, height_);
-
- // Render the texture to the target
- GetIdentity()->Process(sources, &target);
-
- // Get the pixel data
- return target.ReadFboPixels(pixels);
-}
-
-bool GLFrame::AttachTextureToFbo() {
- // Check FBO and texture state. We do not do anything if we are not managing the texture.
- if (fbo_state_ == kStateComplete || texture_state_ == kStateUnmanaged) {
- return true;
- } else if (fbo_state_ != kStateGenerated) {
- LOGE("Attempting to attach texture to FBO with no FBO in place!");
- return false;
- }
-
- // If texture has been generated, make sure it is allocated.
- if (!AllocateTexture())
- return false;
-
- // Bind the frame buffer, and check if we it is already bound
- glBindFramebuffer(GL_FRAMEBUFFER, fbo_id_);
-
- // Bind the texture to the frame buffer
- LOG_FRAME("Attaching tex %d w %d h %d to fbo %d", texture_id_, width_, height_, fbo_id_);
- glFramebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- texture_id_,
- 0);
-
- // Cleanup
- glBindTexture(GL_TEXTURE_2D, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- if (GLEnv::CheckGLError("Texture Binding to FBO"))
- return false;
- else
- fbo_state_ = kStateComplete;
-
- return true;
-}
-
-bool GLFrame::ReattachTextureToFbo() {
- return (fbo_state_ == kStateGenerated) ? AttachTextureToFbo() : true;
-}
-
-bool GLFrame::DetachTextureFromFbo() {
- if (fbo_state_ == kStateComplete && texture_state_ == kStateComplete) {
- LOG_FRAME("Detaching tex %d w %d h %d from fbo %d", texture_id_, width_, height_, fbo_id_);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo_id_);
- glFramebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- 0,
- 0);
- if (GLEnv::CheckGLError("Detaching texture to FBO"))
- return false;
- else
- fbo_state_ = kStateGenerated;
- }
- return true;
-}
-
-bool GLFrame::UploadTexturePixels(const uint8_t* pixels) {
- // Bind the texture object
- FocusTexture();
-
- // Load mipmap level 0
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width_, height_,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
- // Set the user specified texture parameters
- UpdateTexParameters();
-
- if (GLEnv::CheckGLError("Texture Pixel Upload"))
- return false;
-
- texture_state_ = kStateComplete;
- return true;
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/gl_frame.h b/mca/filterfw/native/core/gl_frame.h
deleted file mode 100644
index f2a1ad5..0000000
--- a/mca/filterfw/native/core/gl_frame.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_GL_FRAME_H
-#define ANDROID_FILTERFW_CORE_GL_FRAME_H
-
-#include <map>
-
-#include <GLES2/gl2.h>
-
-#include "core/gl_buffer_interface.h"
-
-namespace android {
-namespace filterfw {
-
-class GLEnv;
-class ShaderProgram;
-
-// A GLFrame stores pixel data on the GPU. While pixel data may be uploaded to
-// a GLFrame and also read out of a GLFrame (access in place is not supported),
-// it is strongly recommended to use ShaderProgram objects for any kind of
-// processing from one GLFrame to another.
-class GLFrame : public GLBufferHandle {
- public:
- // Create an empty GL frame in the specified GL environment. Note, that the GLFrame does NOT
- // take ownership. The caller must make sure the GLEnv stays valid as long as the GLFrame is
- // alive.
- GLFrame(GLEnv* gl_env);
-
- // Deallocate a GL frame.
- ~GLFrame();
-
- // Initialize a GL frame to the given width, height, format. Also specify
- // whether this is a read-only GL frame or not.
- bool Init(int width, int height);
-
- // Initialize as using an external texture.
- bool InitWithExternalTexture();
-
- // Initialize using an existing texture.
- bool InitWithTexture(GLint texture_id, int width, int height);
-
- // Initialize using an existing FBO.
- bool InitWithFbo(GLint fbo_id, int width, int height);
-
- // Write the data with the given size in bytes to the frame. The frame size must match the
- // size of the data.
- bool WriteData(const uint8_t* data, int size);
-
- // Copies the frame data to the given buffer.
- bool CopyDataTo(uint8_t* buffer, int size);
-
- // Copies the pixels from another GL frame to this frame.
- bool CopyPixelsFrom(const GLFrame* frame);
-
- // Returns the size of the buffer in bytes.
- int Size() const;
-
- // Clone the current frame by creating a new GL frame and copying all data to it.
- GLFrame* Clone() const;
-
- // Returns the held texture id. Only call this if the GLFrame holds a
- // texture. You can check this by calling HoldsTexture().
- // Note, that a texture is created only when needed. If you are creating a
- // new GLFrame, and you need it to be bound to a texture, upload (zeroed)
- // data to it first, before calling this method.
- GLuint GetTextureId() const;
-
- // Returns the held FBO id. Only call this if the GLFrame holds an FBO. You
- // can check this by calling HoldsFbo().
- GLuint GetFboId() const;
-
- // Returns the texture target: GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES.
- GLuint GetTextureTarget() const {
- return texture_target_;
- }
-
- // Set the viewport that will be used when focusing this frame for rendering. Defaults to
- // the dimensions of the frame.
- bool SetViewport(int x, int y, int width, int height);
-
- // Binds the held texture. This may result in creating the texture if it
- // is not yet available.
- bool FocusTexture();
-
- // Binds the held FBO. This may result in creating the FBO if it
- // is not yet available.
- bool FocusFrameBuffer();
-
- // Generates the mipmap chain of the held texture. Returns true, iff
- // generating was successful.
- bool GenerateMipMap();
-
- // Set a texture parameter (see glTextureParameter documentation). Returns
- // true iff the parameter was set successfully.
- bool SetTextureParameter(GLenum pname, GLint value);
-
- // Reset any modifed texture parameters.
- bool ResetTexParameters();
-
- // Detaches the internal texture from the FBO.
- bool DetachTextureFromFbo();
-
- // Reattaches the internal texture to the FBO after detachment.
- bool ReattachTextureToFbo();
-
- private:
- // Type to keep track of texture and FBO states
- enum GLObjectState {
- kStateUnmanaged, // We do not manage this object (externally managed)
- kStateUninitialized, // Not yet initialized
- kStateGenerated, // Tex/FBO id is generated
- kStateComplete // FBO has valid attachment / Tex has valid pixel data
- };
-
- // Sets the frame and viewport dimensions.
- void InitDimensions(int width, int height);
-
- // Generates the internal texture name.
- bool GenerateTextureName();
-
- // Allocates the internal texture.
- bool AllocateTexture();
-
- // Creates the internal FBO.
- bool GenerateFboName();
-
- // Copies pixels from texture or FBO to the specified buffer.
- bool CopyPixelsTo(uint8_t* buffer);
-
- // Reads the pixels from the internal texture to the given buffer.
- bool ReadTexturePixels(uint8_t* pixels) const;
-
- // Reads the pixels from the internal FBO to the given buffer.
- bool ReadFboPixels(uint8_t* pixels) const;
-
- // Writes the specified pixels to the internal texture.
- bool UploadTexturePixels(const uint8_t* pixels);
-
- // Binds the internal texture.
- bool BindTexture() const;
-
- // Binds the internal FBO.
- bool BindFrameBuffer() const;
-
- // Attaches the internal texture to the internal FBO.
- bool AttachTextureToFbo();
-
- // Update the texture parameters to the user specified parameters
- bool UpdateTexParameters();
-
- // Returns true if the current texture parameters are not the GLES2
- // default parameters.
- bool TexParametersModifed();
-
- // Sets the current texture parameters to the GLES2 default
- // parameters. This still requires a call to UpdateTexParameters()
- // for the changes to take effect.
- void SetDefaultTexParameters();
-
- // Returns true if the texture we assume to be allocated has been
- // deleted externally. In this case we assume the texture name is
- // still valid (otherwise we were provided with a bad texture id).
- bool TextureWasDeleted() const;
-
- // Get the (cached) identity shader.
- ShaderProgram* GetIdentity() const;
-
- // The GL environment this frame belongs to
- GLEnv* gl_env_;
-
- // The width, height and format of the frame
- int width_;
- int height_;
-
- // The viewport dimensions
- int vp_x_;
- int vp_y_;
- int vp_width_;
- int vp_height_;
-
- // The texture and FBO ids
- GLuint texture_id_;
- GLuint fbo_id_;
-
- // The texture target: GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES
- GLuint texture_target_;
-
- // Flags whether or not frame holds a texture and FBO
- GLObjectState texture_state_;
- GLObjectState fbo_state_;
-
- // Set of current texture parameters
- std::map<GLenum, GLint> tex_params_;
-
- // Flag whether frame owns the texture and FBO
- bool owns_texture_;
- bool owns_fbo_;
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_GL_FRAME_H
diff --git a/mca/filterfw/native/core/native_frame.cpp b/mca/filterfw/native/core/native_frame.cpp
deleted file mode 100644
index 957ecb1..0000000
--- a/mca/filterfw/native/core/native_frame.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "core/native_frame.h"
-
-namespace android {
-namespace filterfw {
-
-NativeFrame::NativeFrame(int size) : data_(NULL), size_(size), capacity_(size) {
- data_ = capacity_ == 0 ? NULL : new uint8_t[capacity_];
-}
-
-NativeFrame::~NativeFrame() {
- delete[] data_;
-}
-
-bool NativeFrame::WriteData(const uint8_t* data, int offset, int size) {
- if (size_ >= (offset + size)) {
- memcpy(data_ + offset, data, size);
- return true;
- }
- return false;
-}
-
-bool NativeFrame::SetData(uint8_t* data, int size) {
- delete[] data_;
- size_ = capacity_ = size;
- data_ = data;
- return true;
-}
-
-NativeFrame* NativeFrame::Clone() const {
- NativeFrame* result = new NativeFrame(size_);
- if (data_)
- result->WriteData(data_, 0, size_);
- return result;
-}
-
-bool NativeFrame::Resize(int newSize) {
- if (newSize <= capacity_ && newSize >= 0) {
- size_ = newSize;
- return true;
- }
- return false;
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/native_frame.h b/mca/filterfw/native/core/native_frame.h
deleted file mode 100644
index 0d335b3..0000000
--- a/mca/filterfw/native/core/native_frame.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_NATIVE_FRAME_H
-#define ANDROID_FILTERFW_CORE_NATIVE_FRAME_H
-
-#include "base/utilities.h"
-
-namespace android {
-namespace filterfw {
-
-// A NativeFrame stores data in a memory buffer (on the heap). It is used for
-// data processing on the CPU.
-class NativeFrame {
- public:
- // Create an empty native frame.
- NativeFrame(int size);
-
- ~NativeFrame();
-
- // Set the frame data and size in bytes. The NativeFrame object takes ownership of the data.
- // To copy data into an existing frame, use WriteData().
- bool SetData(uint8_t* data, int size);
-
- // Write the specified data of the given size to the frame at the specified offset. The
- // receiver must be large enough to hold the data.
- bool WriteData(const uint8_t* data, int offset, int size);
-
- // Returns a pointer to the data, or NULL if no data was set.
- const uint8_t* Data() const {
- return data_;
- }
-
- // Returns a non-const pointer to the data, or NULL if no data was set.
- uint8_t* MutableData() {
- return data_;
- }
-
- // Resize the frame. You can only resize to a size that fits within the frame's capacity.
- // Returns true if the resize was successful.
- bool Resize(int newSize);
-
- // Returns the size of the frame in bytes.
- int Size() {
- return size_;
- }
-
- // Returns the capacity of the frame in bytes.
- int Capacity() {
- return capacity_;
- }
-
- // Returns a new native frame
- NativeFrame* Clone() const;
-
- private:
- // Pointer to the data. Owned by the frame.
- uint8_t* data_;
-
- // Size of data buffer in bytes.
- int size_;
-
- // Capacity of data buffer in bytes.
- int capacity_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeFrame);
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_NATIVE_FRAME_H
diff --git a/mca/filterfw/native/core/native_program.cpp b/mca/filterfw/native/core/native_program.cpp
deleted file mode 100644
index e67a58d..0000000
--- a/mca/filterfw/native/core/native_program.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <dlfcn.h>
-
-#include "base/logging.h"
-#include "core/native_frame.h"
-#include "core/native_program.h"
-
-#include <string>
-#include <vector>
-
-namespace android {
-namespace filterfw {
-
-NativeProgram::NativeProgram()
- : lib_handle_(NULL),
- init_function_(NULL),
- setvalue_function_(NULL),
- getvalue_function_(NULL),
- process_function_(NULL),
- reset_function_(NULL),
- teardown_function_(NULL),
- user_data_(NULL) {
-}
-
-NativeProgram::~NativeProgram() {
- if (lib_handle_)
- dlclose(lib_handle_);
-}
-
-bool NativeProgram::OpenLibrary(const std::string& lib_name) {
- if (!lib_handle_) {
- lib_handle_ = dlopen(lib_name.c_str(), RTLD_NOW);
- if (!lib_handle_) {
- LOGE("NativeProgram: Error opening library: '%s': %s", lib_name.c_str(), dlerror());
- return false;
- }
- return true;
- }
- return false;
-}
-
-bool NativeProgram::BindProcessFunction(const std::string& func_name) {
- if (!lib_handle_)
- return false;
- process_function_ = reinterpret_cast<ProcessFunctionPtr>(dlsym(lib_handle_, func_name.c_str()));
- if (!process_function_) {
- LOGE("NativeProgram: Could not find process function symbol: '%s'!", func_name.c_str());
- return false;
- }
- return true;
-}
-
-bool NativeProgram::BindInitFunction(const std::string& func_name) {
- if (!lib_handle_)
- return false;
- init_function_ = reinterpret_cast<InitFunctionPtr>(dlsym(lib_handle_, func_name.c_str()));
- return init_function_ != NULL;
-}
-
-bool NativeProgram::BindSetValueFunction(const std::string& func_name) {
- if (!lib_handle_)
- return false;
- setvalue_function_ = reinterpret_cast<SetValueFunctionPtr>(dlsym(lib_handle_, func_name.c_str()));
- return setvalue_function_ != NULL;
-}
-
-bool NativeProgram::BindGetValueFunction(const std::string& func_name) {
- if (!lib_handle_)
- return false;
- getvalue_function_ = reinterpret_cast<GetValueFunctionPtr>(dlsym(lib_handle_, func_name.c_str()));
- return getvalue_function_ != NULL;
-}
-
-bool NativeProgram::BindResetFunction(const std::string& func_name) {
- if (!lib_handle_)
- return false;
- reset_function_ = reinterpret_cast<ResetFunctionPtr>(dlsym(lib_handle_, func_name.c_str()));
- return reset_function_ != NULL;
-}
-
-bool NativeProgram::BindTeardownFunction(const std::string& func_name) {
- if (!lib_handle_)
- return false;
- teardown_function_ = reinterpret_cast<TeardownFunctionPtr>(dlsym(lib_handle_, func_name.c_str()));
- return teardown_function_ != NULL;
-}
-
-bool NativeProgram::CallProcess(const std::vector<const char*>& inputs,
- const std::vector<int>& input_sizes,
- char* output,
- int output_size) {
- if (process_function_) {
- return process_function_(const_cast<const char**>(&inputs[0]),
- &input_sizes[0],
- inputs.size(),
- output,
- output_size,
- user_data_) == 1;
- }
- return false;
-}
-
-bool NativeProgram::CallInit() {
- if (init_function_) {
- init_function_(&user_data_);
- return true;
- }
- return false;
-}
-
-bool NativeProgram::CallSetValue(const std::string& key, const std::string& value) {
- if (setvalue_function_) {
- setvalue_function_(key.c_str(), value.c_str(), user_data_);
- return true;
- }
- return false;
-}
-
-std::string NativeProgram::CallGetValue(const std::string& key) {
- if (getvalue_function_) {
- static const int buffer_size = 1024;
- char result[buffer_size];
- result[buffer_size - 1] = '\0';
- getvalue_function_(key.c_str(), result, buffer_size, user_data_);
- return std::string(result);
- }
- return std::string();
-}
-
-bool NativeProgram::CallReset() {
- if (reset_function_) {
- reset_function_(user_data_);
- return true;
- }
- return false;
-}
-
-bool NativeProgram::CallTeardown() {
- if (teardown_function_) {
- teardown_function_(user_data_);
- return true;
- }
- return false;
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/native_program.h b/mca/filterfw/native/core/native_program.h
deleted file mode 100644
index ce704af..0000000
--- a/mca/filterfw/native/core/native_program.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_NATIVE_PROGRAM_H
-#define ANDROID_FILTERFW_CORE_NATIVE_PROGRAM_H
-
-#include <vector>
-#include <string>
-
-#include "base/utilities.h"
-
-namespace android {
-namespace filterfw {
-
-class NativeFrame;
-
-typedef void (*InitFunctionPtr)(void**);
-typedef void (*SetValueFunctionPtr)(const char*, const char*, void*);
-typedef void (*GetValueFunctionPtr)(const char*, char*, int, void*);
-typedef int (*ProcessFunctionPtr)(const char**, const int*, int, char*, int, void*);
-typedef void (*ResetFunctionPtr)(void*);
-typedef void (*TeardownFunctionPtr)(void*);
-
-class NativeProgram {
- public:
- // Create an empty native frame.
- NativeProgram();
-
- ~NativeProgram();
-
- bool OpenLibrary(const std::string& lib_name);
-
- bool BindInitFunction(const std::string& func_name);
- bool BindSetValueFunction(const std::string& func_name);
- bool BindGetValueFunction(const std::string& func_name);
- bool BindProcessFunction(const std::string& func_name);
- bool BindResetFunction(const std::string& func_name);
- bool BindTeardownFunction(const std::string& func_name);
-
- bool CallInit();
- bool CallSetValue(const std::string& key, const std::string& value);
- std::string CallGetValue(const std::string& key);
- bool CallProcess(const std::vector<const char*>& inputs,
- const std::vector<int>& input_sizes,
- char* output,
- int output_size);
- bool CallReset();
- bool CallTeardown();
-
- private:
- // Pointer to the data. Owned by the frame.
- void* lib_handle_;
-
- // The function pointers to the native function implementations.
- InitFunctionPtr init_function_;
- SetValueFunctionPtr setvalue_function_;
- GetValueFunctionPtr getvalue_function_;
- ProcessFunctionPtr process_function_;
- ResetFunctionPtr reset_function_;
- TeardownFunctionPtr teardown_function_;
-
- // Pointer to user data
- void* user_data_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeProgram);
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_NATIVE_PROGRAM_H
diff --git a/mca/filterfw/native/core/shader_program.cpp b/mca/filterfw/native/core/shader_program.cpp
deleted file mode 100644
index d008ae1..0000000
--- a/mca/filterfw/native/core/shader_program.cpp
+++ /dev/null
@@ -1,1122 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "base/logging.h"
-
-#include "core/geometry.h"
-#include "core/gl_buffer_interface.h"
-#include "core/gl_env.h"
-#include "core/gl_frame.h"
-#include "core/shader_program.h"
-#include "core/vertex_frame.h"
-
-#include <string>
-#include <sstream>
-#include <vector>
-
-namespace android {
-namespace filterfw {
-
-// VBO attachment keys
-static const int kDefaultVboKey = 1;
-
-static const char* s_default_vertex_shader_source_ =
- "attribute vec4 a_position;\n"
- "attribute vec2 a_texcoord;\n"
- "varying vec2 v_texcoord;\n"
- "void main() {\n"
- " gl_Position = a_position;\n"
- " v_texcoord = a_texcoord;\n"
- "}\n";
-
-// Helper Functions ////////////////////////////////////////////////////////////
-// Maps coordinates x,y in the unit rectangle over to the quadrangle specified
-// by the four points in b. The result coordinates are written to xt and yt.
-static void GetTileCoords(const float* b, float x, float y, float* xt, float* yt) {
- const float w0 = (1.0f - x) * (1.0f - y);
- const float w1 = x * (1.0f - y);
- const float w2 = (1.0f - x) * y;
- const float w3 = x * y;
-
- *xt = w0 * b[0] + w1 * b[2] + w2 * b[4] + w3 * b[6];
- *yt = w0 * b[1] + w1 * b[3] + w2 * b[5] + w3 * b[7];
-}
-
-static inline float AdjustRatio(float current, float next) {
- return (current + next) / 2.0;
-}
-
-// VertexAttrib implementation /////////////////////////////////////////////////
-ShaderProgram::VertexAttrib::VertexAttrib()
- : is_const(true),
- index(-1),
- normalized(false),
- stride(0),
- components(0),
- offset(0),
- type(GL_FLOAT),
- vbo(0),
- values(NULL),
- owned_data(NULL) {
-}
-
-// ShaderProgram implementation ////////////////////////////////////////////////
-ShaderProgram::ShaderProgram(GLEnv* gl_env, const std::string& fragment_shader)
- : fragment_shader_source_(fragment_shader),
- vertex_shader_source_(s_default_vertex_shader_source_),
- fragment_shader_(0),
- vertex_shader_(0),
- program_(0),
- gl_env_(gl_env),
- base_texture_unit_(GL_TEXTURE0),
- source_coords_(NULL),
- target_coords_(NULL),
- manage_coordinates_(false),
- tile_x_count_(1),
- tile_y_count_(1),
- vertex_count_(4),
- draw_mode_(GL_TRIANGLE_STRIP),
- clears_(false),
- blending_(false),
- sfactor_(GL_SRC_ALPHA),
- dfactor_(GL_ONE_MINUS_SRC_ALPHA) {
- SetDefaultCoords();
-}
-
-ShaderProgram::ShaderProgram(GLEnv* gl_env,
- const std::string& vertex_shader,
- const std::string& fragment_shader)
- : fragment_shader_source_(fragment_shader),
- vertex_shader_source_(vertex_shader),
- fragment_shader_(0),
- vertex_shader_(0),
- program_(0),
- gl_env_(gl_env),
- base_texture_unit_(GL_TEXTURE0),
- source_coords_(NULL),
- target_coords_(NULL),
- manage_coordinates_(false),
- tile_x_count_(1),
- tile_y_count_(1),
- vertex_count_(4),
- draw_mode_(GL_TRIANGLE_STRIP),
- clears_(false),
- blending_(false),
- sfactor_(GL_SRC_ALPHA),
- dfactor_(GL_ONE_MINUS_SRC_ALPHA) {
- SetDefaultCoords();
-}
-
-ShaderProgram::~ShaderProgram() {
- // Delete our vertex data
- delete[] source_coords_;
- delete[] target_coords_;
-
- // Delete any owned attribute data
- VertexAttribMap::const_iterator iter;
- for (iter = attrib_values_.begin(); iter != attrib_values_.end(); ++iter) {
- const VertexAttrib& attrib = iter->second;
- if (attrib.owned_data)
- delete[] attrib.owned_data;
- }
-}
-
-void ShaderProgram::SetDefaultCoords() {
- if (!source_coords_)
- source_coords_ = new float[8];
- if (!target_coords_)
- target_coords_ = new float[8];
-
- source_coords_[0] = 0.0f;
- source_coords_[1] = 0.0f;
- source_coords_[2] = 1.0f;
- source_coords_[3] = 0.0f;
- source_coords_[4] = 0.0f;
- source_coords_[5] = 1.0f;
- source_coords_[6] = 1.0f;
- source_coords_[7] = 1.0f;
-
- target_coords_[0] = -1.0f;
- target_coords_[1] = -1.0f;
- target_coords_[2] = 1.0f;
- target_coords_[3] = -1.0f;
- target_coords_[4] = -1.0f;
- target_coords_[5] = 1.0f;
- target_coords_[6] = 1.0f;
- target_coords_[7] = 1.0f;
-
-}
-
-ShaderProgram* ShaderProgram::CreateIdentity(GLEnv* gl_env) {
- const char* s_id_fragment_shader =
- "precision mediump float;\n"
- "uniform sampler2D tex_sampler_0;\n"
- "varying vec2 v_texcoord;\n"
- "void main() {\n"
- " gl_FragColor = texture2D(tex_sampler_0, v_texcoord);\n"
- "}\n";
- ShaderProgram* result = new ShaderProgram(gl_env, s_id_fragment_shader);
- result->CompileAndLink();
- return result;
-}
-
-bool ShaderProgram::IsVarValid(ProgramVar var) {
- return var != -1;
-}
-
-bool ShaderProgram::Process(const std::vector<const GLTextureHandle*>& input,
- GLFrameBufferHandle* output) {
- // TODO: This can be optimized: If the input and output are the same, as in
- // the last iteration (typical of a multi-pass filter), a lot of this setup
- // may be skipped.
-
- // Abort if program did not successfully compile and link
- if (!IsExecutable()) {
- LOGE("ShaderProgram: unexecutable program!");
- return false;
- }
-
- // Focus the FBO of the output
- if (!output->FocusFrameBuffer()) {
- LOGE("Unable to focus frame buffer");
- return false;
- }
-
- // Get all required textures
- std::vector<GLuint> textures;
- std::vector<GLenum> targets;
- for (unsigned i = 0; i < input.size(); ++i) {
- // Get the current input frame and make sure it is a GL frame
- if (input[i]) {
- // Get the texture bound to that frame
- const GLuint tex_id = input[i]->GetTextureId();
- const GLenum target = input[i]->GetTextureTarget();
- if (tex_id == 0) {
- LOGE("ShaderProgram: invalid texture id at input: %d!", i);
- return false;
- }
- textures.push_back(tex_id);
- targets.push_back(target);
- }
- }
-
- // And render!
- if (!RenderFrame(textures, targets)) {
- LOGE("Unable to render frame");
- return false;
- }
- return true;
-}
-
-bool ShaderProgram::Process(const std::vector<const GLFrame*>& input, GLFrame* output) {
- std::vector<const GLTextureHandle*> textures(input.size());
- std::copy(input.begin(), input.end(), textures.begin());
- return Process(textures, output);
-}
-
-void ShaderProgram::SetSourceRect(float x, float y, float width, float height) {
- Quad quad(Point(x, y),
- Point(x + width, y),
- Point(x, y + height),
- Point(x + width, y + height));
- SetSourceRegion(quad);
-}
-
-void ShaderProgram::SetSourceRegion(const Quad& quad) {
- int index = 0;
- for (int i = 0; i < 4; ++i, index += 2) {
- source_coords_[index] = quad.point(i).x();
- source_coords_[index+1] = quad.point(i).y();
- }
-}
-
-void ShaderProgram::SetTargetRect(float x, float y, float width, float height) {
- Quad quad(Point(x, y),
- Point(x + width, y),
- Point(x, y + height),
- Point(x + width, y + height));
- SetTargetRegion(quad);
-}
-
-void ShaderProgram::SetTargetRegion(const Quad& quad) {
- int index = 0;
- for (int i = 0; i < 4; ++i, index += 2) {
- target_coords_[index] = (quad.point(i).x() * 2.0) - 1.0;
- target_coords_[index+1] = (quad.point(i).y() * 2.0) - 1.0;
- }
-}
-
-bool ShaderProgram::CompileAndLink() {
- // Make sure we haven't compiled and linked already
- if (vertex_shader_ != 0 || fragment_shader_ != 0 || program_ != 0) {
- LOGE("Attempting to re-compile shaders!");
- return false;
- }
-
- // Compile vertex shader
- vertex_shader_ = CompileShader(GL_VERTEX_SHADER,
- vertex_shader_source_.c_str());
- if (!vertex_shader_) {
- LOGE("Shader compilation failed!");
- return false;
- }
-
- // Compile fragment shader
- fragment_shader_ = CompileShader(GL_FRAGMENT_SHADER,
- fragment_shader_source_.c_str());
- if (!fragment_shader_)
- return false;
-
- // Link
- GLuint shaders[2] = { vertex_shader_, fragment_shader_ };
- program_ = LinkProgram(shaders, 2);
-
- // Scan for all uniforms in the program
- ScanUniforms();
-
- // Check if we manage all coordinates
- if (program_ != 0) {
- ProgramVar tex_coord_attr = glGetAttribLocation(program_, TexCoordAttributeName().c_str());
- ProgramVar pos_coord_attr = glGetAttribLocation(program_, PositionAttributeName().c_str());
- manage_coordinates_ = (tex_coord_attr >= 0 && pos_coord_attr >= 0);
- } else {
- LOGE("Could not link shader program!");
- return false;
- }
-
- return true;
-}
-
-GLuint ShaderProgram::CompileShader(GLenum shader_type, const char* source) {
- LOG_FRAME("Compiling source:\n[%s]", source);
-
- // Create shader
- GLuint shader = glCreateShader(shader_type);
- if (shader) {
- // Compile source
- glShaderSource(shader, 1, &source, NULL);
- glCompileShader(shader);
-
- // Check for compilation errors
- GLint compiled = 0;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
- if (!compiled) {
- // Log the compilation error messages
- LOGE("Problem compiling shader! Source:");
- LOGE("%s", source);
- std::string src(source);
- unsigned int cur_pos = 0;
- unsigned int next_pos = 0;
- int line_number = 1;
- while ( (next_pos = src.find_first_of('\n', cur_pos)) != std::string::npos) {
- LOGE("%03d : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str());
- cur_pos = next_pos + 1;
- line_number++;
- }
- LOGE("%03d : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str());
-
- GLint log_length = 0;
- glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
- if (log_length) {
- char* error_log = new char[log_length];
- if (error_log) {
- glGetShaderInfoLog(shader, log_length, NULL, error_log);
- LOGE("Shader compilation error %d:\n%s\n", shader_type, error_log);
- delete[] error_log;
- }
- }
- glDeleteShader(shader);
- shader = 0;
- }
- }
- return shader;
-}
-
-GLuint ShaderProgram::LinkProgram(GLuint* shaders, GLuint count) {
- GLuint program = glCreateProgram();
- if (program) {
- // Attach all compiled shaders
- for (GLuint i = 0; i < count; ++i) {
- glAttachShader(program, shaders[i]);
- if (GLEnv::CheckGLError("glAttachShader")) return 0;
- }
-
- // Link
- glLinkProgram(program);
-
- // Check for linking errors
- GLint linked = 0;
- glGetProgramiv(program, GL_LINK_STATUS, &linked);
- if (linked != GL_TRUE) {
- // Log the linker error messages
- GLint log_length = 0;
- glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
- if (log_length) {
- char* error_log = new char[log_length];
- if (error_log) {
- glGetProgramInfoLog(program, log_length, NULL, error_log);
- LOGE("Program Linker Error:\n%s\n", error_log);
- delete[] error_log;
- }
- }
- glDeleteProgram(program);
- program = 0;
- }
- }
- return program;
-}
-
-void ShaderProgram::ScanUniforms() {
- int uniform_count;
- int buffer_size;
- GLenum type;
- GLint capacity;
- glGetProgramiv(program_, GL_ACTIVE_UNIFORMS, &uniform_count);
- glGetProgramiv(program_, GL_ACTIVE_UNIFORM_MAX_LENGTH, &buffer_size);
- std::vector<GLchar> name(buffer_size);
- for (int i = 0; i < uniform_count; ++i) {
- glGetActiveUniform(program_, i, buffer_size, NULL, &capacity, &type, &name[0]);
- ProgramVar uniform_id = glGetUniformLocation(program_, &name[0]);
- uniform_indices_[uniform_id] = i;
- }
-}
-
-bool ShaderProgram::PushCoords(ProgramVar attr, float* coords) {
- // If the shader does not define these, we simply ignore the coordinates, and assume that the
- // user is managing coordinates.
- if (attr >= 0) {
- const uint8_t* data = reinterpret_cast<const uint8_t*>(coords);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glVertexAttribPointer(attr, 2, GL_FLOAT, false, 2 * sizeof(float), data);
- glEnableVertexAttribArray(attr);
- return !GLEnv::CheckGLError("Pushing vertex coordinates");
- }
- return true;
-}
-
-bool ShaderProgram::PushSourceCoords(float* coords) {
- ProgramVar tex_coord_attr = glGetAttribLocation(program_, TexCoordAttributeName().c_str());
- return PushCoords(tex_coord_attr, coords);
-}
-
-bool ShaderProgram::PushTargetCoords(float* coords) {
- ProgramVar pos_coord_attr = glGetAttribLocation(program_, PositionAttributeName().c_str());
- return PushCoords(pos_coord_attr, coords);
-}
-
-std::string ShaderProgram::InputTextureUniformName(int index) {
- std::stringstream tex_name;
- tex_name << "tex_sampler_" << index;
- return tex_name.str();
-}
-
-bool ShaderProgram::BindInputTextures(const std::vector<GLuint>& textures,
- const std::vector<GLenum>& targets) {
- for (unsigned i = 0; i < textures.size(); ++i) {
- // Activate texture unit i
- glActiveTexture(BaseTextureUnit() + i);
- if (GLEnv::CheckGLError("Activating Texture Unit"))
- return false;
-
- // Bind our texture
- glBindTexture(targets[i], textures[i]);
- LOG_FRAME("Binding texture %d", textures[i]);
- if (GLEnv::CheckGLError("Binding Texture"))
- return false;
-
- // Set the texture handle in the shader to unit i
- ProgramVar tex_var = GetUniform(InputTextureUniformName(i));
- if (tex_var >= 0) {
- glUniform1i(tex_var, i);
- } else {
- LOGE("ShaderProgram: Shader does not seem to support %d number of "
- "inputs! Missing uniform 'tex_sampler_%d'!", textures.size(), i);
- return false;
- }
-
- if (GLEnv::CheckGLError("Texture Variable Binding"))
- return false;
- }
-
- return true;
-}
-
-bool ShaderProgram::UseProgram() {
- if (GLEnv::GetCurrentProgram() != program_) {
- LOG_FRAME("Using program %d", program_);
- glUseProgram(program_);
- return !GLEnv::CheckGLError("Use Program");
- }
- return true;
-}
-
-bool ShaderProgram::RenderFrame(const std::vector<GLuint>& textures,
- const std::vector<GLenum>& targets) {
- // Make sure we have enough texture units to accomodate the textures
- if (textures.size() > static_cast<unsigned>(MaxTextureUnits())) {
- LOGE("ShaderProgram: Number of input textures is unsupported on this "
- "platform!");
- return false;
- }
-
- // Prepare to render
- if (!BeginDraw()) {
- LOGE("ShaderProgram: couldn't initialize gl for drawing!");
- return false;
- }
-
- // Bind input textures
- if (!BindInputTextures(textures, targets)) {
- LOGE("BindInputTextures failed");
- return false;
- }
-
- if (LOG_EVERY_FRAME) {
- int fbo, program, buffer;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo);
- glGetIntegerv(GL_CURRENT_PROGRAM, &program);
- glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &buffer);
- LOGV("RenderFrame: fbo %d prog %d buff %d", fbo, program, buffer);
- }
-
- // Render!
- const bool requestTile = (tile_x_count_ != 1 || tile_y_count_ != 1);
- const bool success = (!requestTile || !manage_coordinates_ || vertex_count_ != 4)
- ? Draw()
- : DrawTiled();
-
- // Pop vertex attributes
- PopAttributes();
-
- return success && !GLEnv::CheckGLError("Rendering");
-}
-
-bool ShaderProgram::Draw() {
- if (PushSourceCoords(source_coords_) && PushTargetCoords(target_coords_)) {
- glDrawArrays(draw_mode_, 0, vertex_count_);
- return true;
- }
- return false;
-}
-
-bool ShaderProgram::DrawTiled() {
- // Target coordinate step size
- float s[8];
- float t[8];
-
- // Step sizes
- const float xs = 1.0f / static_cast<float>(tile_x_count_);
- const float ys = 1.0f / static_cast<float>(tile_y_count_);
-
- // Tile drawing loop
- for (int i = 0; i < tile_x_count_; ++i) {
- for (int j = 0; j < tile_y_count_; ++j) {
- // Current coordinates in unit rectangle
- const float x = i / static_cast<float>(tile_x_count_);
- const float y = j / static_cast<float>(tile_y_count_);
-
- // Source coords
- GetTileCoords(source_coords_, x, y, &s[0], &s[1]);
- GetTileCoords(source_coords_, x + xs, y, &s[2], &s[3]);
- GetTileCoords(source_coords_, x, y + ys, &s[4], &s[5]);
- GetTileCoords(source_coords_, x + xs, y + ys, &s[6], &s[7]);
-
- // Target coords
- GetTileCoords(target_coords_, x, y, &t[0], &t[1]);
- GetTileCoords(target_coords_, x + xs, y, &t[2], &t[3]);
- GetTileCoords(target_coords_, x, y + ys, &t[4], &t[5]);
- GetTileCoords(target_coords_, x + xs, y + ys, &t[6], &t[7]);
-
- if (PushSourceCoords(s) && PushTargetCoords(t)) {
- glDrawArrays(draw_mode_, 0, vertex_count_);
- Yield();
- } else {
- return false;
- }
- }
- }
- return true;
-}
-
-void ShaderProgram::Yield() {
- glFinish();
-}
-
-bool ShaderProgram::BeginDraw() {
- // Activate shader program
- if (!UseProgram())
- return false;
-
- // Push vertex attributes
- PushAttributes();
-
- // Clear output, if requested
- if (clears_) {
- glClearColor(clear_color_.red,
- clear_color_.green,
- clear_color_.blue,
- clear_color_.alpha);
- glClear(GL_COLOR_BUFFER_BIT);
- }
-
- // Enable/Disable blending
- if (blending_) {
- glEnable(GL_BLEND);
- glBlendFunc(sfactor_, dfactor_);
- } else glDisable(GL_BLEND);
-
- return true;
-}
-
-int ShaderProgram::MaxVaryingCount() {
- GLint result;
- glGetIntegerv(GL_MAX_VARYING_VECTORS, &result);
- return result;
-}
-
-int ShaderProgram::MaxTextureUnits() {
- return GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1;
-}
-
-void ShaderProgram::SetDrawMode(GLenum mode) {
- draw_mode_ = mode;
-}
-
-void ShaderProgram::SetClearsOutput(bool clears) {
- clears_ = clears;
-}
-
-void ShaderProgram::SetClearColor(float red, float green, float blue, float alpha) {
- clear_color_.red = red;
- clear_color_.green = green;
- clear_color_.blue = blue;
- clear_color_.alpha = alpha;
-}
-
-void ShaderProgram::SetTileCounts(int x_count, int y_count) {
- tile_x_count_ = x_count;
- tile_y_count_ = y_count;
-}
-
-// Variable Value Setting Helpers //////////////////////////////////////////////
-bool ShaderProgram::CheckValueCount(const std::string& var_type,
- const std::string& var_name,
- int expected_count,
- int components,
- int value_size) {
- if (expected_count != (value_size / components)) {
- LOGE("Shader Program: %s Value Error (%s): Expected value length %d "
- "(%d components), but received length of %d (%d components)!",
- var_type.c_str(), var_name.c_str(),
- expected_count, components * expected_count,
- value_size / components, value_size);
- return false;
- }
- return true;
-}
-
-bool ShaderProgram::CheckValueMult(const std::string& var_type,
- const std::string& var_name,
- int components,
- int value_size) {
- if (value_size % components != 0) {
- LOGE("Shader Program: %s Value Error (%s): Value must be multiple of %d, "
- "but %d elements were passed!", var_type.c_str(), var_name.c_str(),
- components, value_size);
- return false;
- }
- return true;
-}
-
-bool ShaderProgram::CheckVarValid(ProgramVar var) {
- if (!IsVarValid(var)) {
- LOGE("Shader Program: Attempting to access invalid variable!");
- return false;
- }
- return true;
-}
-
-// Uniforms ////////////////////////////////////////////////////////////////////
-bool ShaderProgram::CheckUniformValid(ProgramVar var) {
- if (!IsVarValid(var) || uniform_indices_.find(var) == uniform_indices_.end()) {
- LOGE("Shader Program: Attempting to access unknown uniform %d!", var);
- return false;
- }
- return true;
-}
-
-int ShaderProgram::MaxUniformCount() {
- // Here we return the minimum of the max uniform count for fragment and vertex
- // shaders.
- GLint count1, count2;
- glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &count1);
- glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &count2);
- return count1 < count2 ? count1 : count2;
-}
-
-ProgramVar ShaderProgram::GetUniform(const std::string& name) const {
- if (!IsExecutable()) {
- LOGE("ShaderProgram: Error: Must link program before querying uniforms!");
- return -1;
- }
- return glGetUniformLocation(program_, name.c_str());
-}
-
-bool ShaderProgram::SetUniformValue(ProgramVar var, int value) {
- if (!CheckVarValid(var))
- return false;
-
- // Uniforms are local to the currently used program.
- if (UseProgram()) {
- glUniform1i(var, value);
- return !GLEnv::CheckGLError("Set Uniform Value (int)");
- }
- return false;
-}
-
-bool ShaderProgram::SetUniformValue(ProgramVar var, float value) {
- if (!CheckVarValid(var))
- return false;
-
- // Uniforms are local to the currently used program.
- if (UseProgram()) {
- glUniform1f(var, value);
- return !GLEnv::CheckGLError("Set Uniform Value (float)");
- }
- return false;
-}
-
-bool ShaderProgram::SetUniformValue(ProgramVar var,
- const int* values,
- int count) {
- if (!CheckUniformValid(var))
- return false;
-
- // Make sure we have values at all
- if (count == 0)
- return false;
-
- // Uniforms are local to the currently used program.
- if (UseProgram()) {
- // Get uniform information
- GLint capacity;
- GLenum type;
- char name[128];
- glGetActiveUniform(program_, IndexOfUniform(var), 128, NULL, &capacity, &type, name);
-
- // Make sure passed values are compatible
- const int components = GLEnv::NumberOfComponents(type);
- if (!CheckValueCount("Uniform (int)", name, capacity, components, count)
- || !CheckValueMult ("Uniform (int)", name, components, count))
- return false;
-
- // Set value based on type
- const int n = count / components;
- switch(type) {
- case GL_INT:
- glUniform1iv(var, n, values);
- break;
-
- case GL_INT_VEC2:
- glUniform2iv(var, n, values);
- break;
-
- case GL_INT_VEC3:
- glUniform3iv(var, n, values);
- break;
-
- case GL_INT_VEC4:
- glUniform4iv(var, n, values);
- break;
-
- default:
- return false;
- };
- return !GLEnv::CheckGLError("Set Uniform Value");
- }
- return false;
-}
-
-bool ShaderProgram::SetUniformValue(ProgramVar var,
- const float* values,
- int count) {
- if (!CheckUniformValid(var))
- return false;
-
- // Make sure we have values at all
- if (count == 0)
- return false;
-
- // Uniforms are local to the currently used program.
- if (UseProgram()) {
- // Get uniform information
- GLint capacity;
- GLenum type;
- char name[128];
- glGetActiveUniform(program_, IndexOfUniform(var), 128, NULL, &capacity, &type, name);
-
- // Make sure passed values are compatible
- const int components = GLEnv::NumberOfComponents(type);
- if (!CheckValueCount("Uniform (float)", name, capacity, components, count)
- || !CheckValueMult ("Uniform (float)", name, components, count))
- return false;
-
- // Set value based on type
- const int n = count / components;
- switch(type) {
- case GL_FLOAT:
- glUniform1fv(var, n, values);
- break;
-
- case GL_FLOAT_VEC2:
- glUniform2fv(var, n, values);
- break;
-
- case GL_FLOAT_VEC3:
- glUniform3fv(var, n, values);
- break;
-
- case GL_FLOAT_VEC4:
- glUniform4fv(var, n, values);
- break;
-
- case GL_FLOAT_MAT2:
- glUniformMatrix2fv(var, n, GL_FALSE, values);
- break;
-
- case GL_FLOAT_MAT3:
- glUniformMatrix3fv(var, n, GL_FALSE, values);
- break;
-
- case GL_FLOAT_MAT4:
- glUniformMatrix4fv(var, n, GL_FALSE, values);
- break;
-
- default:
- return false;
- };
- return !GLEnv::CheckGLError("Set Uniform Value");
- }
- return false;
-}
-
-bool ShaderProgram::SetUniformValue(ProgramVar var, const std::vector<int>& values) {
- return SetUniformValue(var, &values[0], values.size());
-}
-
-bool ShaderProgram::SetUniformValue(ProgramVar var,
- const std::vector<float>& values) {
- return SetUniformValue(var, &values[0], values.size());
-}
-
-bool ShaderProgram::SetUniformValue(const std::string& name, const Value& value) {
- if (ValueIsFloat(value))
- return SetUniformValue(GetUniform(name), GetFloatValue(value));
- else if (ValueIsInt(value))
- return SetUniformValue(GetUniform(name), GetIntValue(value));
- else if (ValueIsFloatArray(value))
- return SetUniformValue(GetUniform(name), GetFloatArrayValue(value), GetValueCount(value));
- else if (ValueIsIntArray(value))
- return SetUniformValue(GetUniform(name), GetIntArrayValue(value), GetValueCount(value));
- else
- return false;
-}
-
-Value ShaderProgram::GetUniformValue(const std::string& name) {
- ProgramVar var = GetUniform(name);
- if (CheckUniformValid(var)) {
- // Get uniform information
- GLint capacity;
- GLenum type;
- glGetActiveUniform(program_, IndexOfUniform(var), 0, NULL, &capacity, &type, NULL);
- if (!GLEnv::CheckGLError("Get Active Uniform")) {
- // Get value based on type, and wrap in value object
- switch(type) {
- case GL_INT: {
- int value;
- glGetUniformiv(program_, var, &value);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeIntValue(value)
- : MakeNullValue();
- } break;
-
- case GL_INT_VEC2: {
- int value[2];
- glGetUniformiv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeIntArrayValue(value, 2)
- : MakeNullValue();
- } break;
-
- case GL_INT_VEC3: {
- int value[3];
- glGetUniformiv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeIntArrayValue(value, 3)
- : MakeNullValue();
- } break;
-
- case GL_INT_VEC4: {
- int value[4];
- glGetUniformiv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeIntArrayValue(value, 4)
- : MakeNullValue();
- } break;
-
- case GL_FLOAT: {
- float value;
- glGetUniformfv(program_, var, &value);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeFloatValue(value)
- : MakeNullValue();
- } break;
-
- case GL_FLOAT_VEC2: {
- float value[2];
- glGetUniformfv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeFloatArrayValue(value, 2)
- : MakeNullValue();
- } break;
-
- case GL_FLOAT_VEC3: {
- float value[3];
- glGetUniformfv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeFloatArrayValue(value, 3)
- : MakeNullValue();
- } break;
-
- case GL_FLOAT_VEC4: {
- float value[4];
- glGetUniformfv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeFloatArrayValue(value, 4)
- : MakeNullValue();
- } break;
-
- case GL_FLOAT_MAT2: {
- float value[4];
- glGetUniformfv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeFloatArrayValue(value, 4)
- : MakeNullValue();
- } break;
-
- case GL_FLOAT_MAT3: {
- float value[9];
- glGetUniformfv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeFloatArrayValue(value, 9)
- : MakeNullValue();
- } break;
-
- case GL_FLOAT_MAT4: {
- float value[16];
- glGetUniformfv(program_, var, &value[0]);
- return !GLEnv::CheckGLError("GetVariableValue") ? MakeFloatArrayValue(value, 16)
- : MakeNullValue();
- } break;
- }
- }
- }
- return MakeNullValue();
-}
-
-GLuint ShaderProgram::IndexOfUniform(ProgramVar var) {
- return uniform_indices_[var];
-}
-
-// Attributes //////////////////////////////////////////////////////////////////////////////////////
-int ShaderProgram::MaxAttributeCount() {
- GLint result;
- glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &result);
- return result;
-}
-
-ProgramVar ShaderProgram::GetAttribute(const std::string& name) const {
- if (!IsExecutable()) {
- LOGE("ShaderProgram: Error: Must link program before querying attributes!");
- return -1;
- } else if (name == PositionAttributeName() || name == TexCoordAttributeName()) {
- LOGW("ShaderProgram: Attempting to overwrite internal vertex attribute '%s'!", name.c_str());
- }
- return glGetAttribLocation(program_, name.c_str());
-}
-
-bool ShaderProgram::SetAttributeValues(ProgramVar var,
- const VertexFrame* vbo,
- GLenum type,
- int components,
- int stride,
- int offset,
- bool normalize) {
- if (!CheckVarValid(var))
- return false;
-
- if (vbo) {
- VertexAttrib attrib;
- attrib.is_const = false;
- attrib.index = var;
- attrib.components = components;
- attrib.normalized = normalize;
- attrib.stride = stride;
- attrib.type = type;
- attrib.vbo = vbo->GetVboId();
- attrib.offset = offset;
-
- return StoreAttribute(attrib);
- }
- return false;
-}
-
-bool ShaderProgram::SetAttributeValues(ProgramVar var,
- const uint8_t* data,
- GLenum type,
- int components,
- int stride,
- int offset,
- bool normalize) {
- if (!CheckVarValid(var))
- return false;
-
- if (data) {
- VertexAttrib attrib;
- attrib.is_const = false;
- attrib.index = var;
- attrib.components = components;
- attrib.normalized = normalize;
- attrib.stride = stride;
- attrib.type = type;
- attrib.values = data + offset;
-
- return StoreAttribute(attrib);
- }
- return false;
-}
-
-bool ShaderProgram::SetAttributeValues(ProgramVar var,
- const std::vector<float>& data,
- int components) {
- return SetAttributeValues(var, &data[0], data.size(), components);
-}
-
-bool ShaderProgram::SetAttributeValues(ProgramVar var,
- const float* data,
- int total,
- int components) {
- if (!CheckVarValid(var))
- return false;
-
- // Make sure the passed data vector has a valid size
- if (total % components != 0) {
- LOGE("ShaderProgram: Invalid attribute vector given! Specified a component "
- "count of %d, but passed a non-multiple vector of size %d!",
- components, total);
- return false;
- }
-
- // Copy the data to a buffer we own
- float* data_cpy = new float[total];
- memcpy(data_cpy, data, sizeof(float) * total);
-
- // Store the attribute
- VertexAttrib attrib;
- attrib.is_const = false;
- attrib.index = var;
- attrib.components = components;
- attrib.normalized = false;
- attrib.stride = components * sizeof(float);
- attrib.type = GL_FLOAT;
- attrib.values = data_cpy;
- attrib.owned_data = data_cpy; // Marks this for deletion later on
-
- return StoreAttribute(attrib);
-}
-
-bool ShaderProgram::StoreAttribute(VertexAttrib attrib) {
- if (attrib.index >= 0) {
- attrib_values_[attrib.index] = attrib;
- return true;
- }
- return false;
-}
-
-bool ShaderProgram::PushAttributes() {
- for (VertexAttribMap::const_iterator iter = attrib_values_.begin();
- iter != attrib_values_.end();
- ++iter) {
- const VertexAttrib& attrib = iter->second;
-
- if (attrib.is_const) {
- // Set constant attribute values (must be specified as host values)
- if (!attrib.values)
- return false;
-
- const float* values = reinterpret_cast<const float*>(attrib.values);
- switch (attrib.components) {
- case 1: glVertexAttrib1fv(attrib.index, values); break;
- case 2: glVertexAttrib2fv(attrib.index, values); break;
- case 3: glVertexAttrib3fv(attrib.index, values); break;
- case 4: glVertexAttrib4fv(attrib.index, values); break;
- default: return false;
- }
- glDisableVertexAttribArray(attrib.index);
- } else {
- // Set per-vertex values
- if (attrib.values) {
- // Make sure no buffer is bound and set attribute
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- glVertexAttribPointer(attrib.index,
- attrib.components,
- attrib.type,
- attrib.normalized,
- attrib.stride,
- attrib.values);
- } else if (attrib.vbo) {
- // Bind VBO and set attribute
- glBindBuffer(GL_ARRAY_BUFFER, attrib.vbo);
-
- glVertexAttribPointer(attrib.index,
- attrib.components,
- attrib.type,
- attrib.normalized,
- attrib.stride,
- reinterpret_cast<const void*>(attrib.offset));
- } else {
- return false;
- }
- glEnableVertexAttribArray(attrib.index);
- }
-
- // Make sure everything worked
- if (GLEnv::CheckGLError("Pushing Vertex Attributes"))
- return false;
- }
-
- return true;
-}
-
-bool ShaderProgram::PopAttributes() {
- // Disable vertex attributes
- for (VertexAttribMap::const_iterator iter = attrib_values_.begin();
- iter != attrib_values_.end();
- ++iter) {
- glDisableVertexAttribArray(iter->second.index);
- }
- // Unbind buffer: Very important as this greatly affects what glVertexAttribPointer does!
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- return !GLEnv::CheckGLError("Popping Vertex Attributes");
-}
-
-void ShaderProgram::SetVertexCount(int count) {
- vertex_count_ = count;
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/shader_program.h b/mca/filterfw/native/core/shader_program.h
deleted file mode 100644
index 2063175..0000000
--- a/mca/filterfw/native/core/shader_program.h
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_SHADER_PROGRAM_H
-#define ANDROID_FILTERFW_CORE_SHADER_PROGRAM_H
-
-#include <vector>
-#include <map>
-#include <string>
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <EGL/egl.h>
-
-#include "core/gl_env.h"
-#include "core/value.h"
-
-namespace android {
-namespace filterfw {
-
-class GLFrame;
-class GLFrameBufferHandle;
-class GLTextureHandle;
-class Quad;
-class VertexFrame;
-
-typedef GLint ProgramVar;
-
-// A ShaderProgram is a Program object that holds a GLSL shader implementation.
-// It provides functionality for compiling, linking, and executing the shader.
-// On top of that, it provides access to the shaders source code, uniforms,
-// attributes, and other properties.
-// By default a ShaderProgram provides its own vertex shader. However, a custom
-// vertex shader may be passed and used instead.
-// When implementing a vertex shader, the following attribute names have special
-// meaning:
-//
-// - a_position: The vertex position
-// - a_texcoord: The texture cooridnates
-//
-// The shader program will bind these attributes to the correct values, if they
-// are present in the vertex shader source code.
-//
-// When implementing the fragment shader, the following variable names must be
-// defined:
-//
-// - tex_sampler_<n>: The n'th input texture. For instance, use tex_sampler_0
-// for the first input texture. Must be a uniform sampler2D.
-// - v_texcoord: The current texture coordinate.
-//
-// If more input textures are given than the shader can handle, this will result
-// in an error.
-//
-class ShaderProgram {
- public:
- // General Functionality ///////////////////////////////////////////////////
- // Create a new shader program with the given fragment shader source code.
- // A default vertex shader is used, which renders the input texture to a
- // rectangular region of the output texture. You can modify the input and
- // output regions by using the SetSourceRegion(...) and SetTargetRegion(...)
- // (and related) functions below.
- // This program will not be executable until you have compiled and linked
- // it.
- // Note, that the ShaderProgram does NOT take ownership of the GLEnv. The
- // caller must make sure the GLEnv stays valid as long as the GLFrame is
- // alive.
- explicit ShaderProgram(GLEnv* gl_env, const std::string& fragment_shader);
-
- // Create a new shader program with the given fragment and vertex shader
- // source code. This program will not be executable until you have compiled
- // and linked it.
- // Note, that the ShaderProgram does NOT take ownership of the GLEnv. The
- // caller must make sure the GLEnv stays valid as long as the GLFrame is
- // alive.
- ShaderProgram(GLEnv* gl_env,
- const std::string& vertex_shader,
- const std::string& fragment_shader);
-
- // Destructor.
- ~ShaderProgram();
-
- // Process the given input frames and write the result to the output frame.
- // Returns false if there was an error processing.
- bool Process(const std::vector<const GLFrame*>& inputs, GLFrame* output);
-
- // Same as above, but pass GL interfaces rather than frame objects. Use this
- // only if you are not working on Frame objects, but rather directly on GL
- // textures and FBOs.
- bool Process(const std::vector<const GLTextureHandle*>& input,
- GLFrameBufferHandle* output);
-
- // Compile and link the shader source code. Returns true if compilation
- // and linkage was successful. Compilation and linking error messages are
- // written to the error log.
- bool CompileAndLink();
-
- // Returns true if this Program has been compiled and linked successfully.
- bool IsExecutable() const {
- return program_ != 0;
- }
-
- // Returns true if the shader program variable is valid.
- static bool IsVarValid(ProgramVar var);
-
- // Special ShaderPrograms //////////////////////////////////////////////////
- // A (compiled) shader program which assigns the sampled pixels from the
- // input to the output. Note that transformations may be applied to achieve
- // effects such as cropping, scaling or rotation.
- // The caller takes ownership of the result!
- static ShaderProgram* CreateIdentity(GLEnv* env);
-
- // Geometry ////////////////////////////////////////////////////////////////
- // These functions modify the source and target regions used during
- // rasterization. Note, that these functions will ONLY take effect if
- // the default vertex shader is used, or your custom vertex shader defines
- // the a_position and a_texcoord attributes.
-
- // Set the program to read from a subregion of the input frame, given by
- // the origin (x, y) and dimensions (width, height). Values are considered
- // normalized between 0.0 and 1.0. If this region exceeds the input frame
- // dimensions the results are undefined.
- void SetSourceRect(float x, float y, float width, float height) ;
-
- // Set the program to read from a subregion of the input frame, given by
- // the passed Quad. Values are considered normalized between 0.0 and 1.0.
- // The Quad points are expected to be in the order top-left, top-right,
- // bottom-left, bottom-right.
- // If this region exceeds the input frame dimensions the results are
- // undefined.
- void SetSourceRegion(const Quad& quad);
-
- // Set the program to write to a subregion of the output frame, given by
- // the origin (x, y) and dimensions (width, height). Values are considered
- // normalized between 0.0 and 1.0. If this region exceeds the output frame
- // dimensions the image will be clipped.
- void SetTargetRect(float x, float y, float width, float height);
-
- // Set the program to write to a subregion of the output frame, given by
- // the passed Quad. Values are considered normalized between 0.0 and 1.0.
- // The Quad points are expected to be in the order top-left, top-right,
- // bottom-left, bottom-right.
- // If this region exceeds the output frame dimensions the image will be
- // clipped.
- void SetTargetRegion(const Quad& quad);
-
- // Uniform Variable access /////////////////////////////////////////////////
- // Note: In order to get and set uniforms, the program must have been
- // successfully compiled and linked. Otherwise, the getters will return an
- // invalid ProgramVar variable (check with IsVarValid()).
- // When setting values, the value type must be match the type of the uniform
- // in the shader. For instance, a vector of 3 elements cannot be assigned to
- // a vec2. Similarly, an integer value cannot be assigned to a float value.
- // Such a type mismatch will result in failure to set the value (which will
- // remain untouched). Check the return value of the setters to determine
- // success.
-
- // Returns the maximum number of uniforms supported by this implementation.
- static int MaxUniformCount();
-
- // Returns a handle to the uniform with the given name, or invalid if no
- // such uniform variable exists in the shader.
- ProgramVar GetUniform(const std::string& name) const;
-
- // Set the specified uniform value to the given integer value. Returns true
- // if the assignment was successful.
- bool SetUniformValue(ProgramVar var, int value);
-
- // Set the specified uniform value to the given float value. Returns true
- // if the assignment was successful.
- bool SetUniformValue(ProgramVar var, float value);
-
- // Set the specified uniform value to the given values. Returns true
- // if the assignment was successful.
- bool SetUniformValue(ProgramVar var, const int* values, int count);
-
- // Set the specified uniform value to the given values. Returns true
- // if the assignment was successful.
- bool SetUniformValue(ProgramVar var, const float* values, int count);
-
- // Set the specified uniform value to the given vector value. Returns true
- // if the assignment was successful.
- bool SetUniformValue(ProgramVar var, const std::vector<int>& values);
-
- // Set the specified uniform value to the given vector value. Returns true
- // if the assignment was successful.
- bool SetUniformValue(ProgramVar var, const std::vector<float>& values);
-
- // Generic variable setter, which in the case of GL programs always attempts
- // to set the value of a uniform variable with the given name. Only values
- // of type float, float array (or vector), and int are supported.
- bool SetUniformValue(const std::string& name, const Value& value);
-
- // Generic variable getter, which in the case of GL programs always attempts
- // to get the value of a uniform variable with the given name.
- Value GetUniformValue(const std::string& name);
-
- // Returns the default name of the input texture uniform variable for the
- // given input index.
- static std::string InputTextureUniformName(int index);
-
- // Attribute access ////////////////////////////////////////////////////////
- // Note: In order to get and set attributes, the program must have been
- // successfully compiled and linked. Otherwise, the getters will return an
- // invalid ProgramVar variable (check with IsVarValid()). Constant attribute
- // values must be floats. Attribute pointers must be associated with a
- // specific type, which can be any of the following:
- // GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_FLOAT,
- // GL_FIXED, GL_HALF_FLOAT_OES.
- // When storing vertex data, it is recommended to use VertexFrames when
- // possible as these will be kept in GPU memory, and no copying of vertex
- // attributes between system and GPU memory needs to take place.
-
- // Returns the maximum number of attributes supported by this
- // implementation.
- static int MaxAttributeCount();
-
- // Returns a handle to the attribute with the given name, or invalid if no
- // such attribute exists in the vertex shader.
- ProgramVar GetAttribute(const std::string& name) const;
-
- // Set an attribute value that will be constant for each vertex. Returns
- // true if the assignment was successful.
- bool SetConstAttributeValue(ProgramVar var, float value);
-
- // Set an attribute vector value that will be constant for each vertex.
- // Returns true if the assignment was successful.
- bool SetConstAttributeValue(ProgramVar var, const std::vector<float>& value);
-
- // Set attribute values that differ across vertexes, using a VertexFrame.
- // This is the recommended method of specifying vertex data, that does not
- // change from iteration to iteration. The parameters are as follows:
- // var: The shader variable to bind the values to.
- // data: The vertex frame which holds the vertex data. This may be a
- // superset of the data required for this particular vertex. Use the
- // offset and stride to select the correct data portion.
- // type: The type of the data values. This may differ from the type of the
- // shader variables. See the normalize flag on how values are
- // converted.
- // components: The number of components per value. Valid values are 1-4.
- // stride: The delta of one element to the next in bytes.
- // offset: The offset of the first element.
- // normalize: True, if not float values should be normalized to the range
- // 0-1, when converted to a float.
- // Returns true, if the assignment was successful.
- bool SetAttributeValues(ProgramVar var,
- const VertexFrame* data,
- GLenum type,
- int components,
- int stride,
- int offset,
- bool normalize);
-
- // Set attribute values that differ across vertexes, using a data buffer.
- // This is the recommended method of specifying vertex data, if your data
- // changes often. Note that this data may need to be copied to GPU memory
- // for each render pass. Please see above for a description of the
- // parameters.
- // Note: The data passed here MUST be valid until all executions of this
- // Program instance have been completed!
- bool SetAttributeValues(ProgramVar var,
- const uint8_t* data,
- GLenum type,
- int components,
- int stride,
- int offset,
- bool normalize);
-
- // Convenience method for setting vertex values using a vector of floats.
- // The components parameter specifies how many elements per variable should
- // be assigned (The variable must be able to fit the number of components).
- // It must be a value between 1 and 4.
- // While this method is not as flexible as the methods above, this can be
- // used when more advanced methods are not necessary. Note, that if your
- // vertex data does not change, it is recommended to use a VertexFrame.
- bool SetAttributeValues(ProgramVar var,
- const std::vector<float>& data,
- int components);
-
- // Same as above, but using a float pointer instead of vector. Pass the
- // total number of elements in total.
- bool SetAttributeValues(ProgramVar var,
- const float* data,
- int total,
- int components);
-
- // By default, rendering only uses the first 4 vertices. You should only
- // adjust this value if you are providing your own vertex attributes with
- // a count unequal to 4. Adjust this value before calling Process().
- void SetVertexCount(int count);
-
- // Returns the default name of the attribute used to hold the texture
- // coordinates. Use this when you need to access the texture coordinate
- // attribute of the shader's default vertex shader.
- static const std::string& TexCoordAttributeName() {
- static std::string s_texcoord("a_texcoord");
- return s_texcoord;
- }
-
- // Returns the default name of the attribute used to hold the output
- // coordinates. Use this when you need to access the output coordinate
- // attribute of the shader's default vertex shader.
- static const std::string& PositionAttributeName() {
- static std::string s_position("a_position");
- return s_position;
- }
-
- // Rendering ///////////////////////////////////////////////////////////////
- // Set the draw mode, which can be any of GL_POINTS, GL_LINES,
- // GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP,
- // GL_TRIANGLE_FAN. The default is GL_TRIANGLE_STRIP.
- // Warning: Do NOT change this if you are not specifying your own vertex
- // data with SetAttributeValues(...).
- void SetDrawMode(GLenum mode);
-
- // If you are doing your own drawing you should call this before beginning
- // to draw. This will activate the program, push all used attributes, and
- // clear the frame if requested. You do not need to call this if you are
- // not doing your own GL drawing!
- bool BeginDraw();
-
- // Render a single frame with the given input textures. You may override
- // this, if you need custom rendering behavior. However, you must take
- // care of the following things when overriding:
- // - Use the correct program (e.g. by calling UseProgram()).
- // - Bind the given textures
- // - Bind vertex attributes
- // - Draw
- bool RenderFrame(const std::vector<GLuint>& textures,
- const std::vector<GLenum>& targets);
-
- // Pass true to clear the output frame before rendering. The color used
- // to clear is set in SetClearColor().
- void SetClearsOutput(bool clears);
-
- // Set the color used to clear the output frame before rendering. You
- // must activate clearing by calling SetClearsOutput(true).
- void SetClearColor(float red, float green, float blue, float alpha);
-
- // Set the number of tiles to split rendering into. Higher tile numbers
- // will affect performance negatively, but will allow other GPU threads
- // to render more frequently. Defaults to 1, 1.
- void SetTileCounts(int x_count, int y_count);
-
- // Enable or Disable Blending
- // Set to true to enable, false to disable.
- void SetBlendEnabled(bool enable) {
- blending_ = enable;
- }
-
- // Specify pixel arithmetic for blending
- // The values of sfactor and dfactor can be:
- // GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA,
- // GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA,
- // GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA_SATURATE
- // Default values for blending are set to:
- // sfactor = GL_SRC_ALPHA
- // dfactor = GL_ONE_MINUS_SRC_ALPHA
- void SetBlendFunc(int sfactor, int dfactor) {
- sfactor_ = sfactor;
- dfactor_ = dfactor;
- }
-
- // Accessing the Compiled Program //////////////////////////////////////////
- // Use the compiled and linked program for rendering. You should not need
- // to call this, unless you are implementing your own rendering method.
- bool UseProgram();
-
- // Other Properties ////////////////////////////////////////////////////////
- // Returns the maximum number of varyings supported by this implementation.
- static int MaxVaryingCount();
-
- // Returns the maximum number of texture units supported by this
- // implementation.
- static int MaxTextureUnits();
-
- // Lower level functionality ///////////////////////////////////////////////
- // Compile the shader with the given source. The shader_type must be either
- // GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
- static GLuint CompileShader(GLenum shader_type, const char* source);
-
- // Link the compiled shader objects and return the resulting program.
- static GLuint LinkProgram(GLuint* shaders, GLuint count);
-
- // Returns the lowest texture unit that will be used to bind textures.
- GLuint BaseTextureUnit() const {
- return base_texture_unit_;
- }
-
- // Sets the lowest texture unit that will be used to bind textures. The
- // default value is GL_TEXTURE0.
- void SetBaseTextureUnit(GLuint texture_unit) {
- base_texture_unit_ = texture_unit;
- }
-
- private:
- // Structure to store vertex attribute data.
- struct VertexAttrib {
- bool is_const;
- int index;
- bool normalized;
- int stride;
- int components;
- int offset;
- GLenum type;
- GLuint vbo;
- const void* values;
- float* owned_data;
-
- VertexAttrib();
- };
- typedef std::map<ProgramVar, VertexAttrib> VertexAttribMap;
-
- struct RGBAColor {
- float red;
- float green;
- float blue;
- float alpha;
-
- RGBAColor() : red(0), green(0), blue(0), alpha(1) {
- }
- };
-
- // Scans for all uniforms in the shader and creates index -> id map.
- void ScanUniforms();
-
- // Returns the index of the given uniform. The caller must make sure
- // that the variable id passed is valid.
- GLuint IndexOfUniform(ProgramVar var);
-
- // Binds the given input textures.
- bool BindInputTextures(const std::vector<GLuint>& textures,
- const std::vector<GLenum>& targets);
-
- // Sets the default source and target coordinates.
- void SetDefaultCoords();
-
- // Pushes the specified coordinates to the shader attribute.
- bool PushCoords(ProgramVar attr, float* coords);
-
- // Pushes the source coordinates.
- bool PushSourceCoords(float* coords);
-
- // Pushes the target coordinates.
- bool PushTargetCoords(float* coords);
-
- // Performs (simple) GL drawing.
- bool Draw();
-
- // Performs tiled GL drawing.
- bool DrawTiled();
-
- // Yields to other GPU threads.
- void Yield();
-
- // Helper method to assert that the variable value passed has the correct
- // total size.
- static bool CheckValueCount(const std::string& var_type,
- const std::string& var_name,
- int expected_count,
- int components,
- int value_size);
-
- // Helper method to assert that the variable value passed has a size, that
- // is compatible with the type size (must be divisible).
- static bool CheckValueMult(const std::string& var_type,
- const std::string& var_name,
- int components,
- int value_size);
-
- // Checks that the variable is valid. Logs an error and returns false if
- // not.
- static bool CheckVarValid(ProgramVar var);
-
- // Returns true if the uniform specified by var is an active uniform in the
- // program.
- bool CheckUniformValid(ProgramVar var);
-
- // Store an attribute to use when rendering.
- bool StoreAttribute(VertexAttrib attrib);
-
- // Push all assigned attributes before rendering.
- bool PushAttributes();
-
- // Pop all assigned attributes after rendering.
- bool PopAttributes();
-
- // The shader source code
- std::string fragment_shader_source_;
- std::string vertex_shader_source_;
-
- // The compiled shaders and linked program
- GLuint fragment_shader_;
- GLuint vertex_shader_;
- GLuint program_;
-
- // The GL environment this shader lives in.
- GLEnv* gl_env_;
-
- // The lowest texture unit this program will use
- GLuint base_texture_unit_;
-
- // The current source and target coordinates to render from/to.
- float* source_coords_;
- float* target_coords_;
-
- // True, if the program has control over both source and target coordinates.
- bool manage_coordinates_;
-
- // The number of tiles to split rendering into.
- int tile_x_count_;
- int tile_y_count_;
-
- // List of attribute data that we need to set before rendering
- VertexAttribMap attrib_values_;
-
- // The number of vertices to render
- int vertex_count_;
-
- // The draw mode used during rendering
- GLenum draw_mode_;
-
- // True, iff the output frame is cleared before rendering
- bool clears_;
-
- // The color used to clear the output frame.
- RGBAColor clear_color_;
-
- // Set to true to enable blending.
- bool blending_;
- int sfactor_;
- int dfactor_;
-
- // Map from uniform ids to indices
- std::map<ProgramVar, GLuint> uniform_indices_;
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_SHADER_PROGRAM_H
diff --git a/mca/filterfw/native/core/statistics.cpp b/mca/filterfw/native/core/statistics.cpp
deleted file mode 100644
index 6f7fee7..0000000
--- a/mca/filterfw/native/core/statistics.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "core/statistics.h"
-
-#include <math.h>
-
-namespace android {
-namespace filterfw {
-
-IncrementalGaussian::IncrementalGaussian()
- : n_(0),
- sum_x_(0.0f),
- sum_x2_(0.0f),
- mean_(0.0f),
- var_(0.0f),
- exp_denom_(0.0f),
- pdf_denom_(0.0f) {
-}
-
-void IncrementalGaussian::Add(float value) {
- ++n_;
- sum_x_ += value;
- sum_x2_ += value * value;
-
- mean_ = sum_x_ / n_;
- var_ = sum_x2_ / n_ - mean_ * mean_;
-
- exp_denom_ = 2.0f * var_;
- pdf_denom_ = sqrtf(M_PI * exp_denom_);
-}
-
-float IncrementalGaussian::Std() const {
- return sqrtf(var_);
-}
-
-float IncrementalGaussian::Pdf(float value) const {
- if (var_ == 0.0f) { return n_ > 0 ? value == mean_ : 0.0f; }
- const float diff = value - mean_;
- return expf(-diff * diff / exp_denom_) / pdf_denom_;
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/statistics.h b/mca/filterfw/native/core/statistics.h
deleted file mode 100644
index ce73b2b..0000000
--- a/mca/filterfw/native/core/statistics.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_STATISTICS_H
-#define ANDROID_FILTERFW_CORE_STATISTICS_H
-
-namespace android {
-namespace filterfw {
-
-// An incrementally-constructed Normal distribution.
-class IncrementalGaussian {
- public:
- IncrementalGaussian();
-
- void Add(float value);
-
- float NumSamples() const { return n_; }
- float Mean() const { return mean_; }
- float Var() const { return var_; }
- float Std() const;
- float Pdf(float value) const;
-
- private:
- int n_;
- float sum_x_;
- float sum_x2_;
- float mean_;
- float var_;
- float exp_denom_;
- float pdf_denom_;
-};
-
-// Discrete-time implementation of a simple RC low-pass filter:
-// exponentially-weighted moving average.
-class RCFilter {
- public:
- explicit RCFilter(float gain)
- : gain_(gain), n_(0), value_(0.0f) {}
-
- void Add(float measurement) {
- value_ = n_++ ? gain_ * measurement + (1.0f - gain_) * value_ : measurement;
- }
-
- void Reset() { n_ = 0; }
-
- int NumMeasurements() const { return n_; }
- float Output() const { return value_; }
-
- private:
- float gain_;
- int n_;
- float value_;
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_STATISTICS_H
diff --git a/mca/filterfw/native/core/time_util.cpp b/mca/filterfw/native/core/time_util.cpp
deleted file mode 100644
index 4133413..0000000
--- a/mca/filterfw/native/core/time_util.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "base/logging.h"
-#include "base/utilities.h"
-
-#include "core/time_util.h"
-
-#include <map>
-#include <string>
-#include <sys/time.h>
-
-namespace android {
-namespace filterfw {
-
-uint64_t getTimeUs() {
- static long basesec;
- struct timeval tv;
- uint64_t nowtime;
- gettimeofday(&tv, 0);
- if (basesec == 0) {
- basesec = tv.tv_sec;
- }
- nowtime = (uint64_t)(tv.tv_sec - basesec) * (uint64_t)1000000 +
- (uint64_t)tv.tv_usec;
- return nowtime;
-}
-
-const uint64_t NamedStopWatch::kDefaultLoggingPeriodInFrames = 100;
-
-NamedStopWatch::NamedStopWatch(const std::string& name)
- : mName(name),
- mLoggingPeriodInFrames(kDefaultLoggingPeriodInFrames),
- mStartUSec(0),
- mNumCalls(0),
- mTotalUSec(0) {
-}
-
-void NamedStopWatch::Start() {
- mStartUSec = getTimeUs();
-}
-
-void NamedStopWatch::Stop() {
- if (!mStartUSec) {
- return;
- }
- uint64_t stopUSec = getTimeUs();
- if (stopUSec > mStartUSec) {
- ++mNumCalls;
- mTotalUSec += stopUSec - mStartUSec;
- if (mNumCalls % mLoggingPeriodInFrames == 0) {
- const float mSec = TotalUSec() * 1.0E-3f / NumCalls();
- LOGE("%s: %f ms", Name().c_str(), mSec);
- }
- }
- mStartUSec = 0;
-}
-
-namespace {
-static NamedStopWatch* GetWatchForName(const string& watch_name) {
- // TODO: this leaks the NamedStopWatch objects. Replace it with a
- // singleton to avoid that and make it thread safe.
- static map<string, NamedStopWatch*> watches;
- NamedStopWatch* watch = FindPtrOrNull(watches, watch_name);
- if (!watch) {
- watch = new NamedStopWatch(watch_name);
- watches[watch_name] = watch;
- }
- return watch;
-};
-} // namespace
-
-ScopedTimer::ScopedTimer(const string& stop_watch_name) {
- mWatch = GetWatchForName(stop_watch_name);
- mWatch->Start();
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/time_util.h b/mca/filterfw/native/core/time_util.h
deleted file mode 100644
index 3cf2ec9..0000000
--- a/mca/filterfw/native/core/time_util.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_TIME_UTIL_H
-#define ANDROID_FILTERFW_CORE_TIME_UTIL_H
-
-#include <string>
-#include <utils/RefBase.h>
-
-#define LOG_MFF_RUNNING_TIMES 0
-
-namespace android {
-namespace filterfw {
-
-uint64_t getTimeUs();
-
-class NamedStopWatch : public RefBase {
- public:
- static const uint64_t kDefaultLoggingPeriodInFrames;
-
- explicit NamedStopWatch(const string& name);
- void Start();
- void Stop();
-
- void SetName(const string& name) { mName = name; }
- void SetLoggingPeriodInFrames(uint64_t numFrames) {
- mLoggingPeriodInFrames = numFrames;
- }
-
- const string& Name() const { return mName; }
- uint64_t NumCalls() const { return mNumCalls; }
- uint64_t TotalUSec() const { return mTotalUSec; }
-
- private:
- string mName;
- uint64_t mLoggingPeriodInFrames;
- uint64_t mStartUSec;
- uint64_t mNumCalls;
- uint64_t mTotalUSec;
-};
-
-class ScopedTimer {
- public:
- explicit ScopedTimer(const string& stop_watch_name);
- explicit ScopedTimer(NamedStopWatch* watch)
- : mWatch(watch) { mWatch->Start(); }
- ~ScopedTimer() { mWatch->Stop(); }
-
- private:
- NamedStopWatch* mWatch;
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_TIME_UTIL_H
diff --git a/mca/filterfw/native/core/value.cpp b/mca/filterfw/native/core/value.cpp
deleted file mode 100644
index 04bf0ef..0000000
--- a/mca/filterfw/native/core/value.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stddef.h>
-#include <stdlib.h>
-
-#include "value.h"
-
-#define NULL_VALUE_TYPE 0
-#define INT_VALUE_TYPE 1
-#define FLOAT_VALUE_TYPE 2
-#define STRING_VALUE_TYPE 3
-#define BUFFER_VALUE_TYPE 4
-#define MUTABLE_BUFFER_VALUE_TYPE 5
-#define INT_ARRAY_VALUE_TYPE 6
-#define FLOAT_ARRAY_VALUE_TYPE 7
-
-// Templated versions //////////////////////////////////////////////////////////////////////////////
-template<typename POD, int TYPEID>
-POD GetPODValue(Value value) {
- return value.type == TYPEID ? *reinterpret_cast<POD*>(value.value) : POD();
-}
-
-template<typename PTR, int TYPEID>
-PTR GetPtrValue(Value value) {
- return value.type == TYPEID ? reinterpret_cast<PTR>(value.value) : NULL;
-}
-
-template<typename POD, int TYPEID>
-Value MakePODValue(POD value) {
- Value result;
- result.type = TYPEID;
- result.value = malloc(sizeof(POD));
- result.count = 1;
- *reinterpret_cast<POD*>(result.value) = value;
- return result;
-}
-
-template<typename BASE, int TYPEID>
-Value MakePtrValue(const BASE* values, int count) {
- Value result;
- result.type = TYPEID;
- result.value = malloc(sizeof(BASE) * count);
- memcpy(result.value, values, sizeof(BASE) * count);
- result.count = count;
- return result;
-}
-
-template<typename POD, int TYPEID>
-int SetPODValue(Value* value, POD new_value) {
- if (value->type == NULL_VALUE_TYPE) {
- value->type = TYPEID;
- value->value = malloc(sizeof(POD));
- value->count = 1;
- }
- if (value->type == TYPEID) {
- *reinterpret_cast<POD*>(value->value) = new_value;
- return 1;
- }
- return 0;
-}
-
-template<typename BASE, int TYPEID>
-int SetPtrValue(Value* value, const BASE* new_values, int count) {
- if (value->type == NULL_VALUE_TYPE) {
- value->type = TYPEID;
- value->value = malloc(sizeof(BASE) * count);
- value->count = count;
- }
- if (value->type == TYPEID && value->count == count) {
- memcpy(value->value, new_values, sizeof(BASE) * count);
- return 1;
- }
- return 0;
-}
-
-// C Wrappers //////////////////////////////////////////////////////////////////////////////////////
-int GetIntValue(Value value) {
- return GetPODValue<int, INT_VALUE_TYPE>(value);
-}
-
-float GetFloatValue(Value value) {
- return GetPODValue<float, FLOAT_VALUE_TYPE>(value);
-}
-
-const char* GetStringValue(Value value) {
- return GetPtrValue<const char*, STRING_VALUE_TYPE>(value);
-}
-
-const char* GetBufferValue(Value value) {
- return (value.type == BUFFER_VALUE_TYPE || value.type == MUTABLE_BUFFER_VALUE_TYPE)
- ? (const char*)value.value
- : NULL;
-}
-
-char* GetMutableBufferValue(Value value) {
- return GetPtrValue<char*, MUTABLE_BUFFER_VALUE_TYPE>(value);
-}
-
-int* GetIntArrayValue(Value value) {
- return GetPtrValue<int*, INT_ARRAY_VALUE_TYPE>(value);
-}
-
-float* GetFloatArrayValue(Value value) {
- return GetPtrValue<float*, FLOAT_ARRAY_VALUE_TYPE>(value);
-}
-
-int ValueIsNull(Value value) {
- return value.type == NULL_VALUE_TYPE;
-}
-
-int ValueIsInt(Value value) {
- return value.type == INT_VALUE_TYPE;
-}
-
-int ValueIsFloat(Value value) {
- return value.type == FLOAT_VALUE_TYPE;
-}
-
-int ValueIsString(Value value) {
- return value.type == STRING_VALUE_TYPE;
-}
-
-int ValueIsBuffer(Value value) {
- return value.type == BUFFER_VALUE_TYPE || value.type == MUTABLE_BUFFER_VALUE_TYPE;
-}
-
-int ValueIsIntArray(Value value) {
- return value.type == INT_ARRAY_VALUE_TYPE;
-}
-
-int ValueIsFloatArray(Value value) {
- return value.type == FLOAT_ARRAY_VALUE_TYPE;
-}
-
-Value MakeNullValue() {
- Value result;
- result.type = NULL_VALUE_TYPE;
- result.value = NULL;
- result.count = 0;
- return result;
-}
-
-Value MakeIntValue(int value) {
- return MakePODValue<int, INT_VALUE_TYPE>(value);
-}
-
-Value MakeFloatValue(float value) {
- return MakePODValue<float, FLOAT_VALUE_TYPE>(value);
-}
-
-Value MakeStringValue(const char* value) {
- return MakePtrValue<char, STRING_VALUE_TYPE>(value, strlen(value) + 1);
-}
-
-Value MakeBufferValue(const char* buffer, int size) {
- return MakePtrValue<char, BUFFER_VALUE_TYPE>(buffer, size);
-}
-
-Value MakeBufferValueNoCopy(const char* buffer, int size) {
- Value result;
- result.type = BUFFER_VALUE_TYPE;
- result.value = (void*)buffer;
- result.count = size;
- return result;
-}
-
-Value MakeMutableBufferValue(const char* buffer, int size) {
- return MakePtrValue<const char, MUTABLE_BUFFER_VALUE_TYPE>(buffer, size);
-}
-
-Value MakeMutableBufferValueNoCopy(char* buffer, int size) {
- Value result;
- result.type = MUTABLE_BUFFER_VALUE_TYPE;
- result.value = (void*)buffer;
- result.count = size;
- return result;
-}
-
-Value MakeIntArrayValue(const int* values, int count) {
- return MakePtrValue<int, INT_ARRAY_VALUE_TYPE>(values, count);
-}
-
-Value MakeFloatArrayValue(const float* values, int count) {
- return MakePtrValue<float, FLOAT_ARRAY_VALUE_TYPE>(values, count);
-}
-
-int SetIntValue(Value* value, int new_value) {
- return SetPODValue<int, INT_VALUE_TYPE>(value, new_value);
-}
-
-int SetFloatValue(Value* value, float new_value) {
- return SetPODValue<float, FLOAT_VALUE_TYPE>(value, new_value);
-}
-
-int SetStringValue(Value* value, const char* new_value) {
- return SetPtrValue<char, STRING_VALUE_TYPE>(value, new_value, strlen(new_value) + 1);
-}
-
-int SetMutableBufferValue(Value* value, const char* new_data, int size) {
- return SetPtrValue<char, MUTABLE_BUFFER_VALUE_TYPE>(value, new_data, size);
-}
-
-int SetIntArrayValue(Value* value, const int* new_values, int count) {
- return SetPtrValue<int, INT_ARRAY_VALUE_TYPE>(value, new_values, count);
-}
-
-int SetFloatArrayValue(Value* value, const float* new_values, int count) {
- return SetPtrValue<float, FLOAT_ARRAY_VALUE_TYPE>(value, new_values, count);
-}
-
-int GetValueCount(Value value) {
- return value.count;
-}
-
-void ReleaseValue(Value* value) {
- if (value && value->value) {
- free(value->value);
- value->value = NULL;
- value->type = NULL_VALUE_TYPE;
- }
-}
-
diff --git a/mca/filterfw/native/core/value.h b/mca/filterfw/native/core/value.h
deleted file mode 100644
index 37e8800..0000000
--- a/mca/filterfw/native/core/value.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_VALUE_H
-#define ANDROID_FILTERFW_CORE_VALUE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// TODO: As this is no longer part of the proposed NDK, should we make this object-oriented (C++)
-// instead? We can also probably clean this up a bit.
-
-// TODO: Change this to an opaque handle?
-typedef struct {
- void* value;
- int type;
- int count;
-} Value;
-
-// TODO: Probably should make these const Value*?
-int GetIntValue(Value value);
-float GetFloatValue(Value value);
-const char* GetStringValue(Value value);
-const char* GetBufferValue(Value value);
-char* GetMutableBufferValue(Value value);
-int* GetIntArrayValue(Value value);
-float* GetFloatArrayValue(Value value);
-
-// TODO: Probably should make these const Value*?
-int ValueIsNull(Value value);
-int ValueIsInt(Value value);
-int ValueIsFloat(Value value);
-int ValueIsString(Value value);
-int ValueIsBuffer(Value value);
-int ValueIsMutableBuffer(Value value);
-int ValueIsIntArray(Value value);
-int ValueIsFloatArray(Value value);
-
-Value MakeNullValue();
-Value MakeIntValue(int value);
-Value MakeFloatValue(float value);
-Value MakeStringValue(const char* value);
-Value MakeBufferValue(const char* data, int size);
-Value MakeBufferValueNoCopy(const char* data, int size);
-Value MakeMutableBufferValue(const char* data, int size);
-Value MakeMutableBufferValueNoCopy(char* data, int size);
-Value MakeIntArrayValue(const int* values, int count);
-Value MakeFloatArrayValue(const float* values, int count);
-
-// Note: These only alloc if value is Null! Otherwise they overwrite, so data must fit!
-int SetIntValue(Value* value, int new_value);
-int SetFloatValue(Value* value, float new_value);
-int SetStringValue(Value* value, const char* new_value);
-int SetMutableBufferValue(Value* value, const char* new_data, int size);
-int SetIntArrayValue(Value* value, const int* new_values, int count);
-int SetFloatArrayValue(Value* value, const float* new_values, int count);
-
-int GetValueCount(Value value);
-
-void ReleaseValue(Value* value);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // ANDROID_FILTERFW_FILTER_VALUE_H
diff --git a/mca/filterfw/native/core/vertex_frame.cpp b/mca/filterfw/native/core/vertex_frame.cpp
deleted file mode 100644
index e5e7f01..0000000
--- a/mca/filterfw/native/core/vertex_frame.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "base/logging.h"
-
-#include "core/gl_env.h"
-#include "core/vertex_frame.h"
-
-#include <GLES2/gl2ext.h>
-#include <EGL/egl.h>
-
-namespace android {
-namespace filterfw {
-
-// GL Extensions that are dynamically looked up at runtime
-static PFNGLMAPBUFFEROESPROC GLMapBufferOES = NULL;
-static PFNGLUNMAPBUFFEROESPROC GLUnmapBufferOES = NULL;
-
-VertexFrame::VertexFrame(int size)
- : vbo_(0),
- size_(size) {
-}
-
-VertexFrame::~VertexFrame() {
- glDeleteBuffers(1, &vbo_);
-}
-
-bool VertexFrame::CreateBuffer() {
- glGenBuffers(1, &vbo_);
- return !GLEnv::CheckGLError("Generating VBO");
-}
-
-bool VertexFrame::WriteData(const uint8_t* data, int size) {
- // Create buffer if not created already
- const bool first_upload = !HasVBO();
- if (first_upload && !CreateBuffer()) {
- LOGE("VertexFrame: Could not create vertex buffer!");
- return false;
- }
-
- // Upload the data
- glBindBuffer(GL_ARRAY_BUFFER, vbo_);
- if (GLEnv::CheckGLError("VBO Bind Buffer"))
- return false;
-
- if (first_upload && size == size_)
- glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW);
- else if (!first_upload && size <= size_)
- glBufferSubData(GL_ARRAY_BUFFER, 0, size, data);
- else {
- LOGE("VertexFrame: Attempting to upload more data (%d bytes) than fits "
- "inside the vertex frame (%d bytes)!", size, size_);
- return false;
- }
-
- // Make sure it worked
- if (GLEnv::CheckGLError("VBO Data Upload"))
- return false;
-
- // Subsequent uploads are now bound to the size given here
- size_ = size;
-
- return true;
-}
-
-int VertexFrame::Size() const {
- return size_;
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterfw/native/core/vertex_frame.h b/mca/filterfw/native/core/vertex_frame.h
deleted file mode 100644
index 1205096..0000000
--- a/mca/filterfw/native/core/vertex_frame.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_CORE_VERTEXFRAME_H
-#define ANDROID_FILTERFW_CORE_VERTEXFRAME_H
-
-#include <GLES2/gl2.h>
-
-namespace android {
-namespace filterfw {
-
-// A VertexFrame stores vertex attribute data in a VBO. Unlike other frames,
-// you often create instances of VertexFrame yourself, to pass vertex data to
-// a ShaderProgram. Note, that any kind of reading from VertexFrames is NOT
-// supported. Once data is uploaded to a VertexFrame, it cannot be read from
-// again.
-class VertexFrame {
- public:
- // Create a VertexFrame of the specified size (in bytes).
- explicit VertexFrame(int size);
-
- ~VertexFrame();
-
- // Upload the given data to the vertex buffer. The size must match the size
- // passed in the constructor for the first upload. Subsequent uploads must
- // be able to fit within the allocated space (i.e. size must not exceed the
- // frame's size).
- bool WriteData(const uint8_t* data, int size);
-
- // The size of the vertex buffer in bytes.
- int Size() const;
-
- // Return the id of the internal VBO. Returns 0 if no VBO has been
- // generated yet. The internal VBO is generated the first time data is
- // uploaded.
- GLuint GetVboId() const {
- return vbo_;
- }
-
- // Returns true if the frame contains an allocated VBO.
- bool HasBuffer() const {
- return vbo_ != 0;
- }
-
- private:
- // Create the VBO
- bool CreateBuffer();
-
- // Returns true if the VBO has been created.
- bool HasVBO() const {
- return vbo_ != 0;
- }
-
- // The internal VBO handle
- GLuint vbo_;
-
- // The size of this frame in bytes
- int size_;
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_CORE_VERTEXFRAME_H
diff --git a/mca/filterfw/native/libfilterfw.mk b/mca/filterfw/native/libfilterfw.mk
deleted file mode 100644
index 4e88e6f..0000000
--- a/mca/filterfw/native/libfilterfw.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Add include paths for native code.
-FFW_PATH := $(call my-dir)
-
-# Uncomment the requirements below, once we need them:
-
-# STLport
-include external/stlport/libstlport.mk
-
-# Neven FaceDetect SDK
-#LOCAL_C_INCLUDES += external/neven/FaceRecEm/common/src/b_FDSDK \
-# external/neven/FaceRecEm/common/src \
-# external/neven/Embedded/common/conf \
-# external/neven/Embedded/common/src \
-# external/neven/unix/src
-
-# Finally, add this directory
-LOCAL_C_INCLUDES += $(FFW_PATH)
-
diff --git a/mca/filterpacks/Android.mk b/mca/filterpacks/Android.mk
deleted file mode 100644
index 24a558a..0000000
--- a/mca/filterpacks/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-TOP_LOCAL_PATH:= $(call my-dir)
-
-include $(call all-subdir-makefiles)
-
diff --git a/mca/filterpacks/base/Android.mk b/mca/filterpacks/base/Android.mk
deleted file mode 100644
index ab26a9f..0000000
--- a/mca/filterpacks/base/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-##
-# Build native code
-##
-
-#Build base library
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := libfilterpack_base
-LOCAL_SRC_FILES := native/geometry.cpp \
- native/time_util.cpp
-
-LOCAL_CFLAGS := -DANDROID
-
-include external/stlport/libstlport.mk
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/mca/filterpacks/base/native/geometry.cpp b/mca/filterpacks/base/native/geometry.cpp
deleted file mode 100644
index d744a0f..0000000
--- a/mca/filterpacks/base/native/geometry.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cutils/log.h>
-#include <cmath>
-
-#include "geometry.h"
-
-namespace android {
-namespace filterfw {
-
-float Point::Length() const {
- return std::sqrt(x_ * x_ + y_ * y_);
-}
-
-bool Point::ScaleTo(float new_length) {
- float length = Length();
- if (length == 0.0f) {
- return false;
- }
- x_ *= new_length / length;
- y_ *= new_length / length;
- return true;
-}
-
-float Point::Distance(const Point& p0, const Point& p1) {
- Point diff = p1 - p0;
- return diff.Length();
-}
-
-Point Point::operator+(const Point& other) const {
- Point out;
- out.x_ = x_ + other.x_;
- out.y_ = y_ + other.y_;
- return out;
-}
-
-Point Point::operator-(const Point& other) const {
- Point out;
- out.x_ = x_ - other.x_;
- out.y_ = y_ - other.y_;
- return out;
-}
-
-Point Point::operator*(float factor) const {
- Point out;
- out.x_ = factor * x_;
- out.y_ = factor * y_;
- return out;
-}
-
-void Point::Rotate90Clockwise() {
- const float x = x_;
- x_ = y_;
- y_ = -x;
-}
-
-bool Rect::ExpandToAspectRatio(float ratio) {
- if (width <= 0.0f || height <= 0.0f || ratio <= 0.0f) {
- return false;
- }
-
- const float current_ratio = width / height;
- if (current_ratio < ratio) {
- const float dx = width * (ratio / current_ratio - 1.0f);
- x -= dx / 2.0f;
- width += dx;
- } else {
- const float dy = height * (current_ratio / ratio - 1.0f);
- y -= dy / 2.0f;
- height += dy;
- }
- return true;
-}
-
-bool Rect::ExpandToMinLength(float length) {
- if (width <= 0.0f || height <= 0.0f || length <= 0.0f) {
- return false;
- }
-
- const float current_length = width > height ? width : height;
- if (length > current_length) {
- const float dx = width * (length / current_length - 1.0f);
- x -= dx / 2.0f;
- width += dx;
- const float dy = height * (length / current_length - 1.0f);
- y -= dy / 2.0f;
- height += dy;
- }
- return true;
-}
-
-bool Rect::ScaleWithLengthLimit(float factor, float max_length) {
- if (width <= 0.0f || height <= 0.0f || factor <= 0.0f) {
- return false;
- }
-
- const float current_length = width > height ? width : height;
- if (current_length >= max_length) {
- return true;
- }
-
- float f = factor;
- if (current_length * f > max_length) {
- f *= max_length / (current_length * f);
- }
-
- const float dx = width * (f - 1.0f);
- x -= dx / 2.0f;
- width += dx;
- const float dy = height * (f - 1.0f);
- y -= dy / 2.0f;
- height += dy;
- return true;
-}
-
-const Point& Quad::point(int ix) const {
- LOG_ASSERT(ix < static_cast<int>(points_.size()), "Access out of bounds");
- return points_[ix];
-}
-
-bool SlantedRect::FromCenterAxisAndLengths(const Point& center,
- const Point& vert_axis,
- const Point& lengths) {
- Point dy = vert_axis;
- if (!dy.ScaleTo(lengths.y() / 2.0f)) {
- LOGE("Illegal axis: %f %f", vert_axis.x(), vert_axis.y());
- return false;
- }
-
- Point dx = dy;
- dx.Rotate90Clockwise();
- dx.ScaleTo(lengths.x() / 2.0f);
-
- points_[0] = center - dx - dy;
- points_[1] = center + dx - dy;
- points_[2] = center - dx + dy;
- points_[3] = center + dx + dy;
-
- width_ = lengths.x();
- height_ = lengths.y();
-
- return true;
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterpacks/base/native/geometry.h b/mca/filterpacks/base/native/geometry.h
deleted file mode 100644
index 40a9343..0000000
--- a/mca/filterpacks/base/native/geometry.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_FILTERPACKS_BASE_GEOMETRY_H
-#define ANDROID_FILTERFW_FILTERPACKS_BASE_GEOMETRY_H
-
-#include <vector>
-
-namespace android {
-namespace filterfw {
-
-// This is an initial implementation of some geometrical structures. This is
-// likely to grow and become more sophisticated in the future.
-
-class Point {
- public:
- Point() : x_(0.0f), y_(0.0f) {}
- Point(float x, float y) : x_(x), y_(y) {}
-
- float x() const { return x_; }
- float y() const { return y_; }
-
- float Length() const;
- bool ScaleTo(float new_length);
- static float Distance(const Point& p0, const Point& p1);
-
- // Add more of these as needed:
- Point operator+(const Point& other) const;
- Point operator-(const Point& other) const;
- Point operator*(float factor) const;
-
- void Rotate90Clockwise();
-
- private:
- float x_, y_;
-};
-
-class Quad {
- public:
- Quad() : points_(4) {}
- virtual ~Quad() {}
-
- Quad(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
- : points_(4) {
- points_[0] = p0;
- points_[1] = p1;
- points_[2] = p2;
- points_[3] = p3;
- }
-
- const std::vector<Point>& points() const { return points_; }
- const Point& point(int ix) const;
-
- protected:
- std::vector<Point> points_;
-};
-
-class SlantedRect : public Quad {
- public:
- SlantedRect() : width_(0.0f), height_(0.0f) {}
- virtual ~SlantedRect() {}
-
- bool FromCenterAxisAndLengths(const Point& center,
- const Point& vert_axis,
- const Point& lenghts);
-
- float width() const { return width_; }
- float height() const { return height_; }
-
- private:
- float width_;
- float height_;
-};
-
-struct Rect {
- float x, y, width, height;
-
- Rect() {
- x = y = 0.0f;
- width = height = 1.0f;
- }
-
- Rect(float x, float y, float width, float height) {
- this->x = x;
- this->y = y;
- this->width = width;
- this->height = height;
- }
-
- bool ExpandToAspectRatio(float ratio);
- bool ExpandToMinLength(float length);
- bool ScaleWithLengthLimit(float factor, float max_length);
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_FILTERPACKS_BASE_GEOMETRY_H
diff --git a/mca/filterpacks/base/native/time_util.cpp b/mca/filterpacks/base/native/time_util.cpp
deleted file mode 100644
index 71ea9f1..0000000
--- a/mca/filterpacks/base/native/time_util.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "time_util.h"
-#include "utilities.h"
-
-#include <cutils/log.h>
-#include <sys/time.h>
-#include <map>
-
-namespace android {
-namespace filterfw {
-
-uint64_t getTimeUs() {
- static long basesec;
- struct timeval tv;
- uint64_t nowtime;
- gettimeofday(&tv, 0);
- if (basesec == 0) {
- basesec = tv.tv_sec;
- }
- nowtime = (uint64_t)(tv.tv_sec - basesec) * (uint64_t)1000000 +
- (uint64_t)tv.tv_usec;
- return nowtime;
-}
-
-const uint64_t NamedStopWatch::kDefaultLoggingPeriodInFrames = 100;
-
-NamedStopWatch::NamedStopWatch(const std::string& name)
- : mName(name),
- mLoggingPeriodInFrames(kDefaultLoggingPeriodInFrames),
- mStartUSec(0),
- mNumCalls(0),
- mTotalUSec(0) {
-}
-
-void NamedStopWatch::Start() {
- mStartUSec = getTimeUs();
-}
-
-void NamedStopWatch::Stop() {
- if (!mStartUSec) {
- return;
- }
- uint64_t stopUSec = getTimeUs();
- if (stopUSec > mStartUSec) {
- ++mNumCalls;
- mTotalUSec += stopUSec - mStartUSec;
- if (mNumCalls % mLoggingPeriodInFrames == 0) {
- const float mSec = TotalUSec() * 1.0E-3f / NumCalls();
- LOGE("%s: %f ms", Name().c_str(), mSec);
- }
- }
- mStartUSec = 0;
-}
-
-namespace {
-static NamedStopWatch* GetWatchForName(const std::string& watch_name) {
- // TODO: this leaks the NamedStopWatch objects. Replace it with a
- // singleton to avoid that and make it thread safe.
- static std::map<std::string, NamedStopWatch*> watches;
- NamedStopWatch* watch = FindPtrOrNull(watches, watch_name);
- if (!watch) {
- watch = new NamedStopWatch(watch_name);
- watches[watch_name] = watch;
- }
- return watch;
-};
-} // namespace
-
-ScopedTimer::ScopedTimer(const std::string& stop_watch_name) {
- mWatch = GetWatchForName(stop_watch_name);
- mWatch->Start();
-}
-
-} // namespace filterfw
-} // namespace android
diff --git a/mca/filterpacks/base/native/time_util.h b/mca/filterpacks/base/native/time_util.h
deleted file mode 100644
index 60d76c6..0000000
--- a/mca/filterpacks/base/native/time_util.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_FILTERPACKS_BASE_TIME_UTIL_H
-#define ANDROID_FILTERFW_FILTERPACKS_BASE_TIME_UTIL_H
-
-#include <string>
-#include <utils/RefBase.h>
-
-#define LOG_MFF_RUNNING_TIMES 0
-
-namespace android {
-namespace filterfw {
-
-uint64_t getTimeUs();
-
-class NamedStopWatch : public RefBase {
- public:
- static const uint64_t kDefaultLoggingPeriodInFrames;
-
- explicit NamedStopWatch(const std::string& name);
- void Start();
- void Stop();
-
- void SetName(const std::string& name) { mName = name; }
- void SetLoggingPeriodInFrames(uint64_t numFrames) {
- mLoggingPeriodInFrames = numFrames;
- }
-
- const std::string& Name() const { return mName; }
- uint64_t NumCalls() const { return mNumCalls; }
- uint64_t TotalUSec() const { return mTotalUSec; }
-
- private:
- std::string mName;
- uint64_t mLoggingPeriodInFrames;
- uint64_t mStartUSec;
- uint64_t mNumCalls;
- uint64_t mTotalUSec;
-};
-
-class ScopedTimer {
- public:
- explicit ScopedTimer(const std::string& stop_watch_name);
- explicit ScopedTimer(NamedStopWatch* watch)
- : mWatch(watch) { mWatch->Start(); }
- ~ScopedTimer() { mWatch->Stop(); }
-
- private:
- NamedStopWatch* mWatch;
-};
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_FILTERPACKS_BASE_TIME_UTIL_H
diff --git a/mca/filterpacks/base/native/utilities.h b/mca/filterpacks/base/native/utilities.h
deleted file mode 100644
index 302e177..0000000
--- a/mca/filterpacks/base/native/utilities.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_FILTERPACKS_BASE_UTILITIES_H
-#define ANDROID_FILTERFW_FILTERPACKS_BASE_UTILITIES_H
-
-#include <set>
-#include <utility>
-
-namespace android {
-namespace filterfw {
-
-// Convenience Macro to make copy constructor and assignment operator private
-// (thereby disallowing copying and assigning).
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName&); \
- void operator=(const TypeName&)
-
-// A macro to disallow all the implicit constructors, namely the
-// default constructor, copy constructor and operator= functions.
-#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
- TypeName(); \
- DISALLOW_COPY_AND_ASSIGN(TypeName)
-
-// STLDeleteContainerPointers()
-// For a range within a container of pointers, calls delete
-// (non-array version) on these pointers.
-// NOTE: for these three functions, we could just implement a DeleteObject
-// functor and then call for_each() on the range and functor, but this
-// requires us to pull in all of algorithm.h, which seems expensive.
-// For hash_[multi]set, it is important that this deletes behind the iterator
-// because the hash_set may call the hash function on the iterator when it is
-// advanced, which could result in the hash function trying to deference a
-// stale pointer.
-template <class ForwardIterator>
-void STLDeleteContainerPointers(ForwardIterator begin,
- ForwardIterator end) {
- while (begin != end) {
- ForwardIterator temp = begin;
- ++begin;
- delete *temp;
- }
-}
-
-// Given an STL container consisting of (key, value) pairs, STLDeleteValues
-// deletes all the "value" components and clears the container. Does nothing
-// in the case it's given a NULL pointer.
-template <class T>
-void STLDeleteValues(T *v) {
- if (!v) return;
- for (typename T::iterator i = v->begin(); i != v->end(); ++i) {
- delete i->second;
- }
- v->clear();
-}
-
-// Perform a lookup in a map or hash_map.
-// If the key is present a const pointer to the associated value is returned,
-// otherwise a NULL pointer is returned.
-template <class Collection>
-const typename Collection::value_type::second_type*
-FindOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return &it->second;
-}
-
-// A simple class that gives checklist functionality: There are essemtially two
-// operations defined on a CheckList:
-// - Adding a new (unchecked) item.
-// - Checking off an item.
-// When checking off the last remaining item CheckItem() returns true.
-template<typename T>
-class CheckList {
- public:
- // Add a new unchecked item. Does nothing if item is already in checklist.
- void AddItem(const T& item);
-
- // Check off an item in the checklist. Returns true if all items have been
- // checked.
- bool CheckItem(const T& item);
-
- // Clear the checklist.
- void Clear() {
- items_.clear();
- }
-
- private:
- std::set<T> items_;
-};
-
-template<typename T>
-void CheckList<T>::AddItem(const T& item) {
- if (!ContainsKey(items_, item))
- items_.insert(item);
-}
-
-template<typename T>
-bool CheckList<T>::CheckItem(const T& item) {
- typename std::set<T>::iterator iter = items_.find(item);
- if (iter != items_.end())
- items_.erase(iter);
- return items_.empty();
-}
-
-// Perform a lookup in a map or hash_map whose values are pointers.
-// If the key is present a const pointer to the associated value is returned,
-// otherwise a NULL pointer is returned.
-// This function does not distinguish between a missing key and a key mapped
-// to a NULL value.
-template <class Collection>
-const typename Collection::value_type::second_type
-FindPtrOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return it->second;
-}
-
-// Test to see if a set, map, hash_set or hash_map contains a particular key.
-// Returns true if the key is in the collection.
-template <typename Collection, typename Key>
-bool ContainsKey(const Collection& collection, const Key& key) {
- return collection.find(key) != collection.end();
-}
-
-// Insert a new key and value into a map or hash_map.
-// If the key is not present in the map the key and value are
-// inserted, otherwise nothing happens. True indicates that an insert
-// took place, false indicates the key was already present.
-template <class Collection, class Key, class Value>
-bool InsertIfNotPresent(Collection * const collection,
- const Key& key, const Value& value) {
- std::pair<typename Collection::iterator, bool> ret =
- collection->insert(typename Collection::value_type(key, value));
- return ret.second;
-}
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_FILTERPACKS_BASE_UTILITIES_H
diff --git a/mca/filterpacks/base/native/vec_types.h b/mca/filterpacks/base/native/vec_types.h
deleted file mode 100644
index 65967c9..0000000
--- a/mca/filterpacks/base/native/vec_types.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_FILTERFW_FILTERPACKS_BASE_VEC_TYPES_H
-#define ANDROID_FILTERFW_FILTERPACKS_BASE_VEC_TYPES_H
-
-namespace android {
-namespace filterfw {
-
-template < class T, int dim>
-class VecBase {
- public:
- T data[dim];
- VecBase() {}
- VecBase<T,dim>& operator = (const VecBase<T, dim> &x) {
- memcpy(data, x.data, sizeof(T)*dim);
- return *this;
- }
- T & operator [] (int i) {
- // out of boundary not checked
- return data[i];
- }
- const T & operator [] (int i) const {
- // out of boundary not checked
- return data[i];
- }
- T Length() {
- double sum = 0;
- for (int i = 0; i < dim; ++i)
- sum += static_cast<double> (data[i] * data[i]);
- return static_cast<T>(sqrt(sum));
- }
-};
-
-template < class T, int dim>
-class Vec : public VecBase<T,dim> {
- public:
- Vec() {}
- Vec<T,dim>& operator = (const Vec<T, dim> &x) {
- memcpy(this->data, x.data, sizeof(T)*dim);
- return *this;
- }
-};
-
-template <class T, int dim>
-Vec<T, dim> operator + (const Vec<T,dim> &x, const Vec<T,dim> &y) {
- Vec<T, dim> out;
- for (int i = 0; i < dim; i++)
- out.data[i] = x.data[i] + y.data[i];
- return out;
-}
-
-template <class T, int dim>
-Vec<T, dim> operator - (const Vec<T,dim> &x, const Vec<T,dim> &y) {
- Vec<T, dim> out;
- for (int i = 0; i < dim; i++)
- out.data[i] = x.data[i] - y.data[i];
- return out;
-}
-
-template <class T, int dim>
-Vec<T, dim> operator * (const Vec<T,dim> &x, const Vec<T,dim> &y) {
- Vec<T, dim> out;
- for (int i = 0; i < dim; i++)
- out.data[i] = x.data[i] * y.data[i];
- return out;
-}
-
-template <class T, int dim>
-Vec<T, dim> operator / (const Vec<T,dim> &x, const Vec<T,dim> &y) {
- Vec<T, dim> out;
- for (int i = 0; i < dim; i++)
- out.data[i] = x.data[i] / y.data[i];
- return out;
-}
-
-template <class T, int dim>
-T dot(const Vec<T,dim> &x, const Vec<T,dim> &y) {
- T out = 0;
- for (int i = 0; i < dim; i++)
- out += x.data[i] * y.data[i];
- return out;
-}
-
-template <class T, int dim>
-Vec<T, dim> operator * (const Vec<T,dim> &x, T scale) {
- Vec<T, dim> out;
- for (int i = 0; i < dim; i++)
- out.data[i] = x.data[i] * scale;
- return out;
-}
-
-template <class T, int dim>
-Vec<T, dim> operator / (const Vec<T,dim> &x, T scale) {
- Vec<T, dim> out;
- for (int i = 0; i < dim; i++)
- out.data[i] = x.data[i] / scale;
- return out;
-}
-
-template <class T, int dim>
-Vec<T, dim> operator + (const Vec<T,dim> &x, T val) {
- Vec<T, dim> out;
- for (int i = 0; i < dim; i++)
- out.data[i] = x.data[i] + val;
- return out;
-}
-
-// specialization for vec2, vec3, vec4 float
-template<>
-class Vec<float, 2> : public VecBase<float, 2> {
-public:
- Vec() {}
- Vec(float x, float y) {
- data[0] = x;
- data[1] = y;
- }
- Vec<float, 2>& operator = (const Vec<float, 2> &x) {
- memcpy(data, x.data, sizeof(float)*2);
- return *this;
- }
-};
-
-template<>
-class Vec<float, 3> {
-public:
- float data[3];
- Vec() {}
- Vec(float x, float y, float z) {
- data[0] = x;
- data[1] = y;
- data[2] = z;
- }
- Vec<float, 3>& operator = (const Vec<float, 3> &x) {
- memcpy(data, x.data, sizeof(float)*3);
- return *this;
- }
-};
-
-template<>
-class Vec<float, 4> {
-public:
- float data[4];
- Vec() {}
- Vec(float x, float y, float z, float w) {
- data[0] = x;
- data[1] = y;
- data[2] = z;
- data[3] = w;
- }
- Vec<float, 4>& operator = (const Vec<float, 4> &x) {
- memcpy(data, x.data, sizeof(float)*4);
- return *this;
- }
-};
-
-typedef Vec<float,2> Vec2f;
-typedef Vec<float,3> Vec3f;
-typedef Vec<float,4> Vec4f;
-
-} // namespace filterfw
-} // namespace android
-
-#endif // ANDROID_FILTERFW_FILTERPACKS_BASE_VEC_TYPES_H
diff --git a/mca/filterpacks/imageproc/Android.mk b/mca/filterpacks/imageproc/Android.mk
deleted file mode 100644
index 6c62142..0000000
--- a/mca/filterpacks/imageproc/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-##
-# Build native code
-##
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := libfilterpack_imageproc
-
-LOCAL_SRC_FILES += native/brightness.c \
- native/contrast.c \
- native/invert.c \
- native/to_rgba.c
-
-LOCAL_SHARED_LIBRARIES := libutils libfilterfw
-
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/mca/filterpacks/imageproc/java/AlphaBlendFilter.java b/mca/filterpacks/imageproc/java/AlphaBlendFilter.java
deleted file mode 100644
index 473369c..0000000
--- a/mca/filterpacks/imageproc/java/AlphaBlendFilter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Set;
-
-/**
- * @hide
- */
-public class AlphaBlendFilter extends ImageCombineFilter {
-
- private final String mAlphaBlendShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform sampler2D tex_sampler_2;\n" +
- "uniform float weight;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 colorL = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec4 colorR = texture2D(tex_sampler_1, v_texcoord);\n" +
- " float blend = texture2D(tex_sampler_2, v_texcoord).r * weight;\n" +
- " gl_FragColor = colorL * (1.0 - blend) + colorR * blend;\n" +
- "}\n";
-
- public AlphaBlendFilter(String name) {
- super(name, new String[] { "source", "overlay", "mask" }, "blended", "weight");
- }
-
- @Override
- protected Program getNativeProgram(FilterContext context) {
- throw new RuntimeException("TODO: Write native implementation for AlphaBlend!");
- }
-
- @Override
- protected Program getShaderProgram(FilterContext context) {
- return new ShaderProgram(context, mAlphaBlendShader);
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/AutoFixFilter.java b/mca/filterpacks/imageproc/java/AutoFixFilter.java
deleted file mode 100644
index c71c1c9..0000000
--- a/mca/filterpacks/imageproc/java/AutoFixFilter.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-public class AutoFixFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- @GenerateFieldPort(name = "scale")
- private float mScale;
-
- private static final int normal_cdf[] = {
- 9, 33, 50, 64, 75, 84, 92, 99, 106, 112, 117, 122, 126, 130, 134, 138, 142,
- 145, 148, 150, 154, 157, 159, 162, 164, 166, 169, 170, 173, 175, 177, 179,
- 180, 182, 184, 186, 188, 189, 190, 192, 194, 195, 197, 198, 199, 200, 202,
- 203, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 218, 219,
- 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 229, 230, 231, 232, 233,
- 234, 235, 236, 236, 237, 238, 239, 239, 240, 240, 242, 242, 243, 244, 245,
- 245, 246, 247, 247, 248, 249, 249, 250, 250, 251, 252, 253, 253, 254, 255,
- 255, 256, 256, 257, 258, 258, 259, 259, 259, 260, 261, 262, 262, 263, 263,
- 264, 264, 265, 265, 266, 267, 267, 268, 268, 269, 269, 269, 270, 270, 271,
- 272, 272, 273, 273, 274, 274, 275, 275, 276, 276, 277, 277, 277, 278, 278,
- 279, 279, 279, 280, 280, 281, 282, 282, 282, 283, 283, 284, 284, 285, 285,
- 285, 286, 286, 287, 287, 288, 288, 288, 289, 289, 289, 290, 290, 290, 291,
- 292, 292, 292, 293, 293, 294, 294, 294, 295, 295, 296, 296, 296, 297, 297,
- 297, 298, 298, 298, 299, 299, 299, 299, 300, 300, 301, 301, 302, 302, 302,
- 303, 303, 304, 304, 304, 305, 305, 305, 306, 306, 306, 307, 307, 307, 308,
- 308, 308, 309, 309, 309, 309, 310, 310, 310, 310, 311, 312, 312, 312, 313,
- 313, 313, 314, 314, 314, 315, 315, 315, 315, 316, 316, 316, 317, 317, 317,
- 318, 318, 318, 319, 319, 319, 319, 319, 320, 320, 320, 321, 321, 322, 322,
- 322, 323, 323, 323, 323, 324, 324, 324, 325, 325, 325, 325, 326, 326, 326,
- 327, 327, 327, 327, 328, 328, 328, 329, 329, 329, 329, 329, 330, 330, 330,
- 330, 331, 331, 332, 332, 332, 333, 333, 333, 333, 334, 334, 334, 334, 335,
- 335, 335, 336, 336, 336, 336, 337, 337, 337, 337, 338, 338, 338, 339, 339,
- 339, 339, 339, 339, 340, 340, 340, 340, 341, 341, 342, 342, 342, 342, 343,
- 343, 343, 344, 344, 344, 344, 345, 345, 345, 345, 346, 346, 346, 346, 347,
- 347, 347, 347, 348, 348, 348, 348, 349, 349, 349, 349, 349, 349, 350, 350,
- 350, 350, 351, 351, 352, 352, 352, 352, 353, 353, 353, 353, 354, 354, 354,
- 354, 355, 355, 355, 355, 356, 356, 356, 356, 357, 357, 357, 357, 358, 358,
- 358, 358, 359, 359, 359, 359, 359, 359, 359, 360, 360, 360, 360, 361, 361,
- 362, 362, 362, 362, 363, 363, 363, 363, 364, 364, 364, 364, 365, 365, 365,
- 365, 366, 366, 366, 366, 366, 367, 367, 367, 367, 368, 368, 368, 368, 369,
- 369, 369, 369, 369, 369, 370, 370, 370, 370, 370, 371, 371, 372, 372, 372,
- 372, 373, 373, 373, 373, 374, 374, 374, 374, 374, 375, 375, 375, 375, 376,
- 376, 376, 376, 377, 377, 377, 377, 378, 378, 378, 378, 378, 379, 379, 379,
- 379, 379, 379, 380, 380, 380, 380, 381, 381, 381, 382, 382, 382, 382, 383,
- 383, 383, 383, 384, 384, 384, 384, 385, 385, 385, 385, 385, 386, 386, 386,
- 386, 387, 387, 387, 387, 388, 388, 388, 388, 388, 389, 389, 389, 389, 389,
- 389, 390, 390, 390, 390, 391, 391, 392, 392, 392, 392, 392, 393, 393, 393,
- 393, 394, 394, 394, 394, 395, 395, 395, 395, 396, 396, 396, 396, 396, 397,
- 397, 397, 397, 398, 398, 398, 398, 399, 399, 399, 399, 399, 399, 400, 400,
- 400, 400, 400, 401, 401, 402, 402, 402, 402, 403, 403, 403, 403, 404, 404,
- 404, 404, 405, 405, 405, 405, 406, 406, 406, 406, 406, 407, 407, 407, 407,
- 408, 408, 408, 408, 409, 409, 409, 409, 409, 409, 410, 410, 410, 410, 411,
- 411, 412, 412, 412, 412, 413, 413, 413, 413, 414, 414, 414, 414, 415, 415,
- 415, 415, 416, 416, 416, 416, 417, 417, 417, 417, 418, 418, 418, 418, 419,
- 419, 419, 419, 419, 419, 420, 420, 420, 420, 421, 421, 422, 422, 422, 422,
- 423, 423, 423, 423, 424, 424, 424, 425, 425, 425, 425, 426, 426, 426, 426,
- 427, 427, 427, 427, 428, 428, 428, 429, 429, 429, 429, 429, 429, 430, 430,
- 430, 430, 431, 431, 432, 432, 432, 433, 433, 433, 433, 434, 434, 434, 435,
- 435, 435, 435, 436, 436, 436, 436, 437, 437, 437, 438, 438, 438, 438, 439,
- 439, 439, 439, 439, 440, 440, 440, 441, 441, 442, 442, 442, 443, 443, 443,
- 443, 444, 444, 444, 445, 445, 445, 446, 446, 446, 446, 447, 447, 447, 448,
- 448, 448, 449, 449, 449, 449, 449, 450, 450, 450, 451, 451, 452, 452, 452,
- 453, 453, 453, 454, 454, 454, 455, 455, 455, 456, 456, 456, 457, 457, 457,
- 458, 458, 458, 459, 459, 459, 459, 460, 460, 460, 461, 461, 462, 462, 462,
- 463, 463, 463, 464, 464, 465, 465, 465, 466, 466, 466, 467, 467, 467, 468,
- 468, 469, 469, 469, 469, 470, 470, 470, 471, 472, 472, 472, 473, 473, 474,
- 474, 474, 475, 475, 476, 476, 476, 477, 477, 478, 478, 478, 479, 479, 479,
- 480, 480, 480, 481, 482, 482, 483, 483, 484, 484, 484, 485, 485, 486, 486,
- 487, 487, 488, 488, 488, 489, 489, 489, 490, 490, 491, 492, 492, 493, 493,
- 494, 494, 495, 495, 496, 496, 497, 497, 498, 498, 499, 499, 499, 500, 501,
- 502, 502, 503, 503, 504, 504, 505, 505, 506, 507, 507, 508, 508, 509, 509,
- 510, 510, 511, 512, 513, 513, 514, 515, 515, 516, 517, 517, 518, 519, 519,
- 519, 520, 521, 522, 523, 524, 524, 525, 526, 526, 527, 528, 529, 529, 530,
- 531, 532, 533, 534, 535, 535, 536, 537, 538, 539, 539, 540, 542, 543, 544,
- 545, 546, 547, 548, 549, 549, 550, 552, 553, 554, 555, 556, 558, 559, 559,
- 561, 562, 564, 565, 566, 568, 569, 570, 572, 574, 575, 577, 578, 579, 582,
- 583, 585, 587, 589, 590, 593, 595, 597, 599, 602, 604, 607, 609, 612, 615,
- 618, 620, 624, 628, 631, 635, 639, 644, 649, 654, 659, 666, 673, 680, 690,
- 700, 714 };
-
- private final String mAutoFixShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform sampler2D tex_sampler_2;\n" +
- "uniform float scale;\n" +
- "uniform float shift_scale;\n" +
- "uniform float hist_offset;\n" +
- "uniform float hist_scale;\n" +
- "uniform float density_offset;\n" +
- "uniform float density_scale;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " const vec3 weights = vec3(0.33333, 0.33333, 0.33333);\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float energy = dot(color.rgb, weights);\n" +
- " float mask_value = energy - 0.5;\n" +
- " float alpha;\n" +
- " if (mask_value > 0.0) {\n" +
- " alpha = (pow(2.0 * mask_value, 1.5) - 1.0) * scale + 1.0;\n" +
- " } else { \n" +
- " alpha = (pow(2.0 * mask_value, 2.0) - 1.0) * scale + 1.0;\n" +
- " }\n" +
- " float index = energy * hist_scale + hist_offset;\n" +
- " vec4 temp = texture2D(tex_sampler_1, vec2(index, 0.5));\n" +
- " float value = temp.g + temp.r * shift_scale;\n" +
- " index = value * density_scale + density_offset;\n" +
- " temp = texture2D(tex_sampler_2, vec2(index, 0.5));\n" +
- " value = temp.g + temp.r * shift_scale;\n" +
- " float dst_energy = energy * alpha + value * (1.0 - alpha);\n" +
- " float max_energy = energy / max(color.r, max(color.g, color.b));\n" +
- " if (dst_energy > max_energy) {\n" +
- " dst_energy = max_energy;\n" +
- " }\n" +
- " if (energy == 0.0) {\n" +
- " gl_FragColor = color;\n" +
- " } else {\n" +
- " gl_FragColor = vec4(color.rgb * dst_energy / energy, color.a);\n" +
- " }\n" +
- "}\n";
-
- private Program mShaderProgram;
- private Program mNativeProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private Frame mHistFrame;
- private Frame mDensityFrame;
-
- public AutoFixFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mAutoFixShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mShaderProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- private void initParameters() {
- mShaderProgram.setHostValue("shift_scale", 1.0f / 256f);
- mShaderProgram.setHostValue("hist_offset", 0.5f / 766f);
- mShaderProgram.setHostValue("hist_scale", 765f / 766f);
- mShaderProgram.setHostValue("density_offset", 0.5f / 1024f);
- mShaderProgram.setHostValue("density_scale", 1023f / 1024f);
- mShaderProgram.setHostValue("scale", mScale);
- }
-
- @Override
- protected void prepare(FilterContext context) {
- int densityDim = 1024;
- int histDim = 255 * 3 + 1;
- long precision = (256l * 256l - 1l);
-
- int[] densityTable = new int[densityDim];
- for (int i = 0; i < densityDim; ++i) {
- long temp = normal_cdf[i] * precision / histDim;
- densityTable[i] = (int) temp;
- }
-
- FrameFormat densityFormat = ImageFormat.create(densityDim, 1,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- mDensityFrame = context.getFrameManager().newFrame(densityFormat);
- mDensityFrame.setInts(densityTable);
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mDensityFrame != null) {
- mDensityFrame.release();
- mDensityFrame = null;
- }
-
- if (mHistFrame != null) {
- mHistFrame.release();
- mHistFrame = null;
- }
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mShaderProgram != null) {
- mShaderProgram.setHostValue("scale", mScale);
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mShaderProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- initParameters();
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
- createHistogramFrame(context, mWidth, mHeight, input.getInts());
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- Frame[] inputs = {input, mHistFrame, mDensityFrame};
- mShaderProgram.process(inputs, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void createHistogramFrame(FilterContext context, int width, int height, int[] data) {
- int histDims = 255 * 3 + 1;
- int[] histArray = new int[histDims];
-
- float border_thickness_ratio = 0.05f;
- int y_border_thickness = (int) (height * border_thickness_ratio);
- int x_border_thickness = (int) (width * border_thickness_ratio);
- int pixels = (width - 2 * x_border_thickness) * (height - 2 * y_border_thickness);
-
- float count = 0f;
- for (int y = y_border_thickness; y < height - y_border_thickness; ++y) {
- for (int x = x_border_thickness; x < width - x_border_thickness; ++x) {
- int index = y * width + x;
- int energy = (data[index] & 0xFF) + ((data[index] >> 8) & 0xFF) +
- ((data[index] >> 16) & 0xFF);
- histArray[energy] ++;
- }
- }
-
- for (int i = 1; i < histDims; i++) {
- histArray[i] += histArray[i-1];
- }
-
- for (int i = 0; i < histDims; i++) {
- long temp = (256 * 256 - 1l) * histArray[i] / pixels;
- histArray[i] = (int) temp;
- }
-
- FrameFormat shaderHistFormat = ImageFormat.create(histDims, 1,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- if (mHistFrame != null)
- mHistFrame.release();
-
- mHistFrame = context.getFrameManager().newFrame(shaderHistFormat);
- mHistFrame.setInts(histArray);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/BitmapOverlayFilter.java b/mca/filterpacks/imageproc/java/BitmapOverlayFilter.java
deleted file mode 100644
index d4c901f..0000000
--- a/mca/filterpacks/imageproc/java/BitmapOverlayFilter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.filterpacks.imageproc.ImageCombineFilter;
-import android.graphics.Bitmap;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class BitmapOverlayFilter extends Filter {
-
- @GenerateFieldPort(name = "bitmap")
- private Bitmap mBitmap;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private Frame mFrame;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mOverlayShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 original = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec4 mask = texture2D(tex_sampler_1, v_texcoord);\n" +
- " gl_FragColor = vec4(original.rgb * (1.0 - mask.a) + mask.rgb, 1.0);\n" +
- "}\n";
-
- public BitmapOverlayFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mOverlayShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter FisheyeFilter does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mFrame != null) {
- mFrame.release();
- mFrame = null;
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
-
- createBitmapFrame(context);
- }
-
- // Process
- Frame[] inputs = {input, mFrame};
- mProgram.process(inputs, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void createBitmapFrame(FilterContext context) {
- if (mBitmap != null) {
- FrameFormat format = ImageFormat.create(mBitmap.getWidth(),
- mBitmap.getHeight(),
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
-
- if (mFrame != null) {
- mFrame.release();
- }
-
- mFrame = context.getFrameManager().newFrame(format);
- mFrame.setBitmap(mBitmap);
-
- mBitmap.recycle();
- mBitmap = null;
- }
- }
-}
diff --git a/mca/filterpacks/imageproc/java/BitmapSource.java b/mca/filterpacks/imageproc/java/BitmapSource.java
deleted file mode 100644
index 978fc94..0000000
--- a/mca/filterpacks/imageproc/java/BitmapSource.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.content.Context;
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.format.ImageFormat;
-import android.graphics.Bitmap;
-
-/**
- * @hide
- */
-public class BitmapSource extends Filter {
-
- @GenerateFieldPort(name = "target")
- String mTargetString;
-
- @GenerateFieldPort(name = "bitmap")
- private Bitmap mBitmap;
-
- @GenerateFieldPort(name = "recycleBitmap", hasDefault = true)
- private boolean mRecycleBitmap = true;
-
- @GenerateFieldPort(name = "repeatFrame", hasDefault = true)
- boolean mRepeatFrame = false;
-
- private int mTarget;
- private Frame mImageFrame;
-
- public BitmapSource(String name) {
- super(name);
- }
-
-
- @Override
- public void setupPorts() {
- // Setup output format
- FrameFormat outputFormat = ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_UNSPECIFIED);
-
- // Add output port
- addOutputPort("image", outputFormat);
- }
-
- public void loadImage(FilterContext filterContext) {
- // Create frame with bitmap
- mTarget = FrameFormat.readTargetString(mTargetString);
- FrameFormat outputFormat = ImageFormat.create(mBitmap.getWidth(),
- mBitmap.getHeight(),
- ImageFormat.COLORSPACE_RGBA,
- mTarget);
- mImageFrame = filterContext.getFrameManager().newFrame(outputFormat);
- mImageFrame.setBitmap(mBitmap);
- mImageFrame.setTimestamp(Frame.TIMESTAMP_UNKNOWN);
-
- // Free up space used by bitmap
- if (mRecycleBitmap) {
- mBitmap.recycle();
- }
- mBitmap = null;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- // Clear image (to trigger reload) in case parameters have been changed
- if (name.equals("bitmap") || name.equals("target")) {
- if (mImageFrame != null) {
- mImageFrame.release();
- mImageFrame = null;
- }
- }
- }
-
- @Override
- public void process(FilterContext context) {
- if (mImageFrame == null) {
- loadImage(context);
- }
-
- pushOutput("image", mImageFrame);
-
- if (!mRepeatFrame) {
- closeOutputPort("image");
- }
- }
-
- @Override
- public void tearDown(FilterContext env) {
- if (mImageFrame != null) {
- mImageFrame.release();
- mImageFrame = null;
- }
- }
-}
diff --git a/mca/filterpacks/imageproc/java/BlackWhiteFilter.java b/mca/filterpacks/imageproc/java/BlackWhiteFilter.java
deleted file mode 100644
index a1cec01..0000000
--- a/mca/filterpacks/imageproc/java/BlackWhiteFilter.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Random;
-
-public class BlackWhiteFilter extends Filter {
-
- @GenerateFieldPort(name = "black", hasDefault = true)
- private float mBlack = 0f;
-
- @GenerateFieldPort(name = "white", hasDefault = true)
- private float mWhite = 1f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private Frame mNoiseFrame = null;
- private Random mRandom;
-
- private final String mBlackWhiteShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float black;\n" +
- "uniform float scale;\n" +
- "uniform float stepsize;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" +
- " vec3 xform = clamp((color.rgb - black) * scale, 0.0, 1.0);\n" +
- " vec3 temp = clamp((color.rgb + stepsize - black) * scale, 0.0, 1.0);\n" +
- " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" +
- " gl_FragColor = vec4(new_color, color.a);\n" +
- "}\n";
-
- public BlackWhiteFilter(String name) {
- super(name);
-
- mRandom = new Random();
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- mNoiseFrame = null;
- }
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mBlackWhiteShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- updateParameters();
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- private void updateParameters() {
- float scale = (mBlack != mWhite) ? 1.0f / (mWhite - mBlack) : 2000f;
- float stepsize = 1.0f / 255.0f;
-
- mProgram.setHostValue("black", mBlack);
- mProgram.setHostValue("scale", scale);
- mProgram.setHostValue("stepsize", stepsize);
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
-
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- }
-
- int[] buffer = new int[mWidth * mHeight];
- for (int i = 0; i < mWidth * mHeight; ++i) {
- buffer[i] = mRandom.nextInt(255);
- }
- FrameFormat format = ImageFormat.create(mWidth, mHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- mNoiseFrame = context.getFrameManager().newFrame(format);
- mNoiseFrame.setInts(buffer);
- }
-
- if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth ||
- mNoiseFrame.getFormat().getHeight() != mHeight)) {
- throw new RuntimeException("Random map and imput image size mismatch!");
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- Frame[] inputs = {input, mNoiseFrame};
- mProgram.process(inputs, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/BlendFilter.java b/mca/filterpacks/imageproc/java/BlendFilter.java
deleted file mode 100644
index 29bc8a3..0000000
--- a/mca/filterpacks/imageproc/java/BlendFilter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Set;
-
-/**
- * The filter linearly blends "left" and "right" frames. The blending weight is
- * the multiplication of parameter "blend" and the alpha value in "right" frame.
- * @hide
- */
-public class BlendFilter extends ImageCombineFilter {
-
- private final String mBlendShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float blend;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 colorL = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec4 colorR = texture2D(tex_sampler_1, v_texcoord);\n" +
- " float weight = colorR.a * blend;\n" +
- " gl_FragColor = mix(colorL, colorR, weight);\n" +
- "}\n";
-
- public BlendFilter(String name) {
- super(name, new String[] { "left", "right" }, "blended", "blend");
- }
-
- @Override
- protected Program getNativeProgram(FilterContext context) {
- throw new RuntimeException("TODO: Write native implementation for Blend!");
- }
-
- @Override
- protected Program getShaderProgram(FilterContext context) {
- return new ShaderProgram(context, mBlendShader);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/BrightnessFilter.java b/mca/filterpacks/imageproc/java/BrightnessFilter.java
deleted file mode 100644
index 046e69d..0000000
--- a/mca/filterpacks/imageproc/java/BrightnessFilter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-
-/**
- * @hide
- */
-public class BrightnessFilter extends SimpleImageFilter {
-
- private static final String mBrightnessShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float brightness;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " gl_FragColor = brightness * color;\n" +
- "}\n";
-
- public BrightnessFilter(String name) {
- super(name, "brightness");
- }
-
- @Override
- protected Program getNativeProgram(FilterContext context) {
- return new NativeProgram("filterpack_imageproc", "brightness");
- }
-
- @Override
- protected Program getShaderProgram(FilterContext context) {
- return new ShaderProgram(context, mBrightnessShader);
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/ColorTemperatureFilter.java b/mca/filterpacks/imageproc/java/ColorTemperatureFilter.java
deleted file mode 100644
index 19da006..0000000
--- a/mca/filterpacks/imageproc/java/ColorTemperatureFilter.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.util.Log;
-
-public class ColorTemperatureFilter extends Filter {
-
- @GenerateFieldPort(name = "scale", hasDefault = true)
- private float mScale = 0.5f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mColorTemperatureShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float scale;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec3 new_color = color.rgb;\n" +
- " new_color.r = color.r + color.r * ( 1.0 - color.r) * scale;\n" +
- " new_color.b = color.b - color.b * ( 1.0 - color.b) * scale;\n" +
- " if (scale > 0.0) { \n" +
- " color.g = color.g + color.g * ( 1.0 - color.g) * scale * 0.25;\n" +
- " }\n" +
- " float max_value = max(new_color.r, max(new_color.g, new_color.b));\n" +
- " if (max_value > 1.0) { \n" +
- " new_color /= max_value;\n" +
- " } \n" +
- " gl_FragColor = vec4(new_color, color.a);\n" +
- "}\n";
-
- public ColorTemperatureFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mColorTemperatureShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- updateParameters();
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void updateParameters() {
- mProgram.setHostValue("scale", 2.0f * mScale - 1.0f);
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-}
diff --git a/mca/filterpacks/imageproc/java/ContrastFilter.java b/mca/filterpacks/imageproc/java/ContrastFilter.java
deleted file mode 100644
index 70e987f..0000000
--- a/mca/filterpacks/imageproc/java/ContrastFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-
-import java.util.Set;
-
-/**
- * @hide
- */
-public class ContrastFilter extends SimpleImageFilter {
-
- private static final String mContrastShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float contrast;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " color -= 0.5;\n" +
- " color *= contrast;\n" +
- " color += 0.5;\n" +
- " gl_FragColor = color;\n" + // this will clamp
- "}\n";
-
- public ContrastFilter(String name) {
- super(name, "contrast");
- }
-
- @Override
- protected Program getNativeProgram(FilterContext context) {
- return new NativeProgram("filterpack_imageproc", "contrast");
- }
-
- @Override
- protected Program getShaderProgram(FilterContext context) {
- return new ShaderProgram(context, mContrastShader);
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/CropFilter.java b/mca/filterpacks/imageproc/java/CropFilter.java
deleted file mode 100644
index 5222d9c..0000000
--- a/mca/filterpacks/imageproc/java/CropFilter.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.geometry.Point;
-import android.filterfw.geometry.Quad;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.format.ObjectFormat;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class CropFilter extends Filter {
-
- private Program mProgram;
- private FrameFormat mLastFormat = null;
-
- @GenerateFieldPort(name = "owidth")
- private int mOutputWidth = -1;
-
- @GenerateFieldPort(name = "oheight")
- private int mOutputHeight = -1;
-
- @GenerateFieldPort(name = "fillblack")
- private boolean mFillBlack = false;
-
- public CropFilter(String name) {
- super(name);
- }
-
- private final String mFragShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " const vec2 lo = vec2(0.0, 0.0);\n" +
- " const vec2 hi = vec2(1.0, 1.0);\n" +
- " const vec4 black = vec4(0.0, 0.0, 0.0, 1.0);\n" +
- " bool out_of_bounds =\n" +
- " any(lessThan(v_texcoord, lo)) ||\n" +
- " any(greaterThan(v_texcoord, hi));\n" +
- " if (out_of_bounds) {\n" +
- " gl_FragColor = black;\n" +
- " } else {\n" +
- " gl_FragColor = texture2D(tex_sampler_0, v_texcoord);\n" +
- " }\n" +
- "}\n";
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addMaskedInputPort("box", ObjectFormat.fromClass(Quad.class, FrameFormat.TARGET_SIMPLE));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- // Make sure output size is set to unspecified, as we do not know what we will be resizing
- // to.
- MutableFrameFormat outputFormat = inputFormat.mutableCopy();
- outputFormat.setDimensions(FrameFormat.SIZE_UNSPECIFIED, FrameFormat.SIZE_UNSPECIFIED);
- return outputFormat;
- }
-
- protected void createProgram(FilterContext context, FrameFormat format) {
- // TODO: Add CPU version
- if (mLastFormat != null && mLastFormat.getTarget() == format.getTarget()) return;
- mLastFormat = format;
- mProgram = null;
- switch (format.getTarget()) {
- case FrameFormat.TARGET_GPU:
- if(mFillBlack)
- mProgram = new ShaderProgram(context, mFragShader);
- else
- mProgram = ShaderProgram.createIdentity(context);
-
- break;
- }
- if (mProgram == null) {
- throw new RuntimeException("Could not create a program for crop filter " + this + "!");
- }
- }
-
- @Override
- public void process(FilterContext env) {
- // Get input frame
- Frame imageFrame = pullInput("image");
- Frame boxFrame = pullInput("box");
-
- createProgram(env, imageFrame.getFormat());
-
- // Get the box
- Quad box = (Quad)boxFrame.getObjectValue();
-
- // Create output format
- MutableFrameFormat outputFormat = imageFrame.getFormat().mutableCopy();
- outputFormat.setDimensions(mOutputWidth == -1 ? outputFormat.getWidth() : mOutputWidth,
- mOutputHeight == -1 ? outputFormat.getHeight() : mOutputHeight);
-
- // Create output frame
- Frame output = env.getFrameManager().newFrame(outputFormat);
-
- // Set the program parameters
- if (mProgram instanceof ShaderProgram) {
- ShaderProgram shaderProgram = (ShaderProgram)mProgram;
- shaderProgram.setSourceRegion(box);
- }
-
- mProgram.process(imageFrame, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
-
-}
diff --git a/mca/filterpacks/imageproc/java/CropRectFilter.java b/mca/filterpacks/imageproc/java/CropRectFilter.java
deleted file mode 100644
index d423d06..0000000
--- a/mca/filterpacks/imageproc/java/CropRectFilter.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class CropRectFilter extends Filter {
-
- @GenerateFieldPort(name = "xorigin")
- private int mXorigin;
-
- @GenerateFieldPort(name = "yorigin")
- private int mYorigin;
-
- @GenerateFieldPort(name = "width")
- private int mOutputWidth;
-
- @GenerateFieldPort(name = "height")
- private int mOutputHeight;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
-
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- public CropRectFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = ShaderProgram.createIdentity(context);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateSourceRect(mWidth, mHeight);
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- FrameFormat outputFormat = ImageFormat.create(mOutputWidth, mOutputHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- Frame output = context.getFrameManager().newFrame(outputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- updateSourceRect(inputFormat.getWidth(), inputFormat.getHeight());
- }
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- void updateSourceRect(int width, int height) {
- mWidth = width;
- mHeight = height;
-
- /*
- Log.e("CropFilter", mWidth + ", " + mHeight + ", " +
- (float) mXorigin / mWidth + ", " +
- (float) mYorigin / mHeight + ", " +
- (float) mOutputWidth / mWidth + ", " +
- (float) mOutputHeight / mHeight);
- */
-
- ((ShaderProgram) mProgram).setSourceRect((float) mXorigin / mWidth,
- (float) mYorigin / mHeight,
- (float) mOutputWidth / mWidth,
- (float) mOutputHeight / mHeight);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/CrossProcessFilter.java b/mca/filterpacks/imageproc/java/CrossProcessFilter.java
deleted file mode 100644
index e0514f8..0000000
--- a/mca/filterpacks/imageproc/java/CrossProcessFilter.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-public class CrossProcessFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mCrossProcessShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec3 ncolor = vec3(0.0, 0.0, 0.0);\n" +
- " float value;\n" +
- " if (color.r < 0.5) {\n" +
- " value = color.r;\n" +
- " } else {\n" +
- " value = 1.0 - color.r;\n" +
- " }\n" +
- " float red = 4.0 * value * value * value;\n" +
- " if (color.r < 0.5) {\n" +
- " ncolor.r = red;\n" +
- " } else {\n" +
- " ncolor.r = 1.0 - red;\n" +
- " }\n" +
- " if (color.g < 0.5) {\n" +
- " value = color.g;\n" +
- " } else {\n" +
- " value = 1.0 - color.g;\n" +
- " }\n" +
- " float green = 2.0 * value * value;\n" +
- " if (color.g < 0.5) {\n" +
- " ncolor.g = green;\n" +
- " } else {\n" +
- " ncolor.g = 1.0 - green;\n" +
- " }\n" +
- " ncolor.b = color.b * 0.5 + 0.25;\n" +
- " gl_FragColor = vec4(ncolor.rgb, color.a);\n" +
- "}\n";
-
- public CrossProcessFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mCrossProcessShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter CrossProcess does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/DocumentaryFilter.java b/mca/filterpacks/imageproc/java/DocumentaryFilter.java
deleted file mode 100644
index 3c7b846..0000000
--- a/mca/filterpacks/imageproc/java/DocumentaryFilter.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Random;
-
-public class DocumentaryFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private Frame mNoiseFrame;
- private Random mRandom;
-
- private final String mDocumentaryShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float stepsize;\n" +
- "uniform float inv_max_dist;\n" +
- "uniform vec2 center;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- // black white
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" +
- " vec3 xform = clamp(2.0 * color.rgb, 0.0, 1.0);\n" +
- " vec3 temp = clamp(2.0 * (color.rgb + stepsize), 0.0, 1.0);\n" +
- " vec3 new_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" +
- // grayscale
- " float gray = dot(new_color, vec3(0.299, 0.587, 0.114));\n" +
- " new_color = vec3(gray, gray, gray);\n" +
- // vignette
- " float dist = distance(gl_FragCoord.xy, center);\n" +
- " float lumen = 0.85 / (1.0 + exp((dist * inv_max_dist - 0.83) * 20.0)) + 0.15;\n" +
- " gl_FragColor = vec4(new_color * lumen, color.a);\n" +
- "}\n";
-
- public DocumentaryFilter(String name) {
- super(name);
-
- mRandom = new Random();
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- mNoiseFrame = null;
- }
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mDocumentaryShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
-
- int[] buffer = new int[mWidth * mHeight];
- for (int i = 0; i < mWidth * mHeight; ++i) {
- buffer[i] = mRandom.nextInt(255);
- }
- FrameFormat format = ImageFormat.create(mWidth, mHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- }
- mNoiseFrame = context.getFrameManager().newFrame(format);
- mNoiseFrame.setInts(buffer);
-
- initParameters();
- }
-
- if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth ||
- mNoiseFrame.getFormat().getHeight() != mHeight)) {
- throw new RuntimeException("Random map and imput image size mismatch!");
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- Frame[] inputs = {input, mNoiseFrame};
- mProgram.process(inputs, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void initParameters() {
- if (mProgram != null) {
- float centerX = (float) (0.5 * mWidth);
- float centerY = (float) (0.5 * mHeight);
- float center[] = {centerX, centerY};
- float max_dist = (float) Math.sqrt(centerX * centerX + centerY * centerY);
-
- mProgram.setHostValue("center", center);
- mProgram.setHostValue("inv_max_dist", 1.0f / max_dist);
- mProgram.setHostValue("stepsize", 1.0f / 255.0f);
- }
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/DrawOverlayFilter.java b/mca/filterpacks/imageproc/java/DrawOverlayFilter.java
deleted file mode 100644
index 3f1711e..0000000
--- a/mca/filterpacks/imageproc/java/DrawOverlayFilter.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.geometry.Quad;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.format.ObjectFormat;
-
-import android.opengl.GLES20;
-
-/**
- * @hide
- */
-public class DrawOverlayFilter extends Filter {
-
- private ShaderProgram mProgram;
-
- public DrawOverlayFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- FrameFormat imageFormatMask = ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- addMaskedInputPort("source", imageFormatMask);
- addMaskedInputPort("overlay", imageFormatMask);
- addMaskedInputPort("box", ObjectFormat.fromClass(Quad.class, FrameFormat.TARGET_SIMPLE));
- addOutputBasedOnInput("image", "source");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void prepare(FilterContext context) {
- mProgram = ShaderProgram.createIdentity(context);
- }
-
- @Override
- public void process(FilterContext env) {
- // Get input frame
- Frame sourceFrame = pullInput("source");
- Frame overlayFrame = pullInput("overlay");
- Frame boxFrame = pullInput("box");
-
- // Get the box
- Quad box = (Quad)boxFrame.getObjectValue();
- box = box.translated(1.0f, 1.0f).scaled(2.0f);
-
- mProgram.setTargetRegion(box);
-
- // Create output frame with copy of input
- Frame output = env.getFrameManager().newFrame(sourceFrame.getFormat());
- output.setDataFromFrame(sourceFrame);
-
- // Draw onto output
- mProgram.process(overlayFrame, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/DrawRectFilter.java b/mca/filterpacks/imageproc/java/DrawRectFilter.java
deleted file mode 100644
index 83c9348..0000000
--- a/mca/filterpacks/imageproc/java/DrawRectFilter.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.geometry.Quad;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.format.ObjectFormat;
-
-import android.opengl.GLES20;
-
-/**
- * @hide
- */
-public class DrawRectFilter extends Filter {
-
- @GenerateFieldPort(name = "colorRed", hasDefault = true)
- private float mColorRed = 0.8f;
-
- @GenerateFieldPort(name = "colorGreen", hasDefault = true)
- private float mColorGreen = 0.8f;
-
- @GenerateFieldPort(name = "colorBlue", hasDefault = true)
- private float mColorBlue = 0.0f;
-
- private final String mVertexShader =
- "attribute vec4 aPosition;\n" +
- "void main() {\n" +
- " gl_Position = aPosition;\n" +
- "}\n";
-
- private final String mFixedColorFragmentShader =
- "precision mediump float;\n" +
- "uniform vec4 color;\n" +
- "void main() {\n" +
- " gl_FragColor = color;\n" +
- "}\n";
-
- private ShaderProgram mProgram;
-
-
- public DrawRectFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- addMaskedInputPort("box", ObjectFormat.fromClass(Quad.class, FrameFormat.TARGET_SIMPLE));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void prepare(FilterContext context) {
- mProgram = new ShaderProgram(context, mVertexShader, mFixedColorFragmentShader);
- }
-
- @Override
- public void process(FilterContext env) {
- // Get input frame
- Frame imageFrame = pullInput("image");
- Frame boxFrame = pullInput("box");
-
- // Get the box
- Quad box = (Quad)boxFrame.getObjectValue();
- box = box.scaled(2.0f).translated(-1.0f, -1.0f);
-
- // Create output frame with copy of input
- GLFrame output = (GLFrame)env.getFrameManager().duplicateFrame(imageFrame);
-
- // Draw onto output
- output.focus();
- renderBox(box);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void renderBox(Quad box) {
- final int FLOAT_SIZE = 4;
-
- // Get current values
- float[] color = {mColorRed, mColorGreen, mColorBlue, 1f};
- float[] vertexValues = { box.p0.x, box.p0.y,
- box.p1.x, box.p1.y,
- box.p3.x, box.p3.y,
- box.p2.x, box.p2.y };
-
- // Set the program variables
- mProgram.setHostValue("color", color);
- mProgram.setAttributeValues("aPosition", vertexValues, 2);
- mProgram.setVertexCount(4);
-
- // Draw
- mProgram.beginDrawing();
- GLES20.glLineWidth(1.0f);
- GLES20.glDrawArrays(GLES20.GL_LINE_LOOP, 0, 4);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/DuotoneFilter.java b/mca/filterpacks/imageproc/java/DuotoneFilter.java
deleted file mode 100644
index d8c88ee..0000000
--- a/mca/filterpacks/imageproc/java/DuotoneFilter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.graphics.Color;
-
-public class DuotoneFilter extends Filter {
-
- @GenerateFieldPort(name = "first_color", hasDefault = true)
- private int mFirstColor = 0xFFFF0000;
-
- @GenerateFieldPort(name = "second_color", hasDefault = true)
- private int mSecondColor = 0xFFFFFF00;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mDuotoneShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform vec3 first;\n" +
- "uniform vec3 second;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float energy = (color.r + color.g + color.b) * 0.3333;\n" +
- " vec3 new_color = (1.0 - energy) * first + energy * second;\n" +
- " gl_FragColor = vec4(new_color.rgb, color.a);\n" +
- "}\n";
-
- public DuotoneFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mDuotoneShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Duotone does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
- updateParameters();
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void updateParameters() {
- float first[] = { Color.red(mFirstColor)/255f,
- Color.green(mFirstColor)/255f,
- Color.blue(mFirstColor)/255f };
- float second[] = { Color.red(mSecondColor)/255f,
- Color.green(mSecondColor)/255f,
- Color.blue(mSecondColor)/255f };
-
- mProgram.setHostValue("first", first);
- mProgram.setHostValue("second", second);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/FillLightFilter.java b/mca/filterpacks/imageproc/java/FillLightFilter.java
deleted file mode 100644
index fc917a1..0000000
--- a/mca/filterpacks/imageproc/java/FillLightFilter.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-public class FillLightFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- @GenerateFieldPort(name = "strength", hasDefault = true)
- private float mBacklight = 0f;
-
- private Program mProgram;
-
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mFillLightShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float mult;\n" +
- "uniform float igamma;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main()\n" +
- "{\n" +
- " const vec3 color_weights = vec3(0.25, 0.5, 0.25);\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float lightmask = dot(color.rgb, color_weights);\n" +
- " float backmask = (1.0 - lightmask);\n" +
- " vec3 ones = vec3(1.0, 1.0, 1.0);\n" +
- " vec3 diff = pow(mult * color.rgb, igamma * ones) - color.rgb;\n" +
- " diff = min(diff, 1.0);\n" +
- " vec3 new_color = min(color.rgb + diff * backmask, 1.0);\n" +
- " gl_FragColor = vec4(new_color, color.a);\n" +
- "}\n";
-
- public FillLightFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mFillLightShader);
- Log.e("FillLight", "tile size: " + mTileSize);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter FillLight does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- updateParameters();
- }
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- private void updateParameters() {
- float fade_gamma = 0.3f;
- float amt = 1.0f - mBacklight;
- float mult = 1.0f / (amt * 0.7f + 0.3f);
- float faded = fade_gamma + (1.0f -fade_gamma) *mult;
- float igamma = 1.0f / faded;
-
- mProgram.setHostValue("mult", mult);
- mProgram.setHostValue("igamma", igamma);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/FisheyeFilter.java b/mca/filterpacks/imageproc/java/FisheyeFilter.java
deleted file mode 100644
index 8d38f98..0000000
--- a/mca/filterpacks/imageproc/java/FisheyeFilter.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-import java.lang.Math;
-import java.util.Set;
-
-/**
- * @hide
- */
-public class FisheyeFilter extends Filter {
- private static final String TAG = "FisheyeFilter";
-
- // This parameter has range between 0 and 1. It controls the effect of radial distortion.
- // The larger the value, the more prominent the distortion effect becomes (a straight line
- // becomes a curve).
- @GenerateFieldPort(name = "scale", hasDefault = true)
- private float mScale = 0f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private static final String mFisheyeShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform vec2 center;\n" +
- "uniform float alpha;\n" +
- "uniform float bound;\n" +
- "uniform float radius2;\n" +
- "uniform float factor;\n" +
- "uniform float inv_height;\n" +
- "uniform float inv_width;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " const float m_pi_2 = 1.570963;\n" +
- " float dist = distance(gl_FragCoord.xy, center);\n" +
- " float radian = m_pi_2 - atan(alpha * sqrt(radius2 - dist * dist), dist);\n" +
- " float scale = radian * factor / dist;\n" +
- " vec2 new_coord = gl_FragCoord.xy * scale + (1.0 - scale) * center;\n" +
- " new_coord.x *= inv_width;\n" +
- " new_coord.y *= inv_height;\n" +
- " vec4 color = texture2D(tex_sampler_0, new_coord);\n" +
- " gl_FragColor = color;\n" +
- "}\n";
-
- public FisheyeFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mFisheyeShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter FisheyeFilter does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- updateFrameSize(inputFormat.getWidth(), inputFormat.getHeight());
- }
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateProgramParams();
- }
- }
-
- private void updateFrameSize(int width, int height) {
- float center[] = {0.5f * width, 0.5f * height};
-
- mProgram.setHostValue("center", center);
- mProgram.setHostValue("inv_width", 1.0f / width);
- mProgram.setHostValue("inv_height", 1.0f / height);
-
- mWidth = width;
- mHeight = height;
-
- updateProgramParams();
- }
-
- private void updateProgramParams() {
- final float pi = 3.14159265f;
-
- float alpha = mScale * 2.0f + 0.75f;
- float bound2 = 0.25f * (mWidth * mWidth + mHeight * mHeight);
- float bound = (float) Math.sqrt(bound2);
- float radius = 1.15f * bound;
- float radius2 = radius * radius;
- float max_radian = 0.5f * pi -
- (float) Math.atan(alpha / bound * (float) Math.sqrt(radius2 - bound2));
- float factor = bound / max_radian;
-
- mProgram.setHostValue("radius2",radius2);
- mProgram.setHostValue("factor", factor);
- mProgram.setHostValue("alpha", (float) (mScale * 2.0 + 0.75));
- }
-
-
-}
diff --git a/mca/filterpacks/imageproc/java/FixedRotationFilter.java b/mca/filterpacks/imageproc/java/FixedRotationFilter.java
deleted file mode 100644
index 3d319ea..0000000
--- a/mca/filterpacks/imageproc/java/FixedRotationFilter.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.geometry.Point;
-import android.filterfw.geometry.Quad;
-
-/**
- * The FixedRotationFilter rotates the input image clockwise, it only accepts
- * 4 rotation angles: 0, 90, 180, 270
- * @hide
- */
-public class FixedRotationFilter extends Filter {
-
- @GenerateFieldPort(name = "rotation", hasDefault = true)
- private int mRotation = 0;
-
- private ShaderProgram mProgram = null;
-
- public FixedRotationFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void process(FilterContext context) {
- Frame input = pullInput("image");
- if (mRotation == 0) {
- pushOutput("image", input);
- return;
- }
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null) {
- mProgram = ShaderProgram.createIdentity(context);
- }
- MutableFrameFormat outputFormat = inputFormat.mutableCopy();
- int width = inputFormat.getWidth();
- int height = inputFormat.getHeight();
- Point p1 = new Point(0.0f, 0.0f);
- Point p2 = new Point(1.0f, 0.0f);
- Point p3 = new Point(0.0f, 1.0f);
- Point p4 = new Point(1.0f, 1.0f);
- Quad sourceRegion;
- switch (((int)Math.round(mRotation / 90f)) % 4) {
- case 1:
- sourceRegion = new Quad(p3,p1,p4,p2);
- outputFormat.setDimensions(height, width);
- break;
- case 2:
- sourceRegion = new Quad(p4,p3,p2,p1);
- break;
- case 3:
- sourceRegion = new Quad(p2,p4,p1,p3);
- outputFormat.setDimensions(height, width);
- break;
- case 0:
- default:
- sourceRegion = new Quad(p1,p2,p3,p4);
- break;
- }
- // Create output frame
- Frame output = context.getFrameManager().newFrame(outputFormat);
-
- // Set the source region
- mProgram.setSourceRegion(sourceRegion);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/FlipFilter.java b/mca/filterpacks/imageproc/java/FlipFilter.java
deleted file mode 100644
index f8b857b..0000000
--- a/mca/filterpacks/imageproc/java/FlipFilter.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-/**
- * @hide
- */
-public class FlipFilter extends Filter {
-
- @GenerateFieldPort(name = "vertical", hasDefault = true)
- private boolean mVertical = false;
-
- @GenerateFieldPort(name = "horizontal", hasDefault = true)
- private boolean mHorizontal = false;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- public FlipFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = ShaderProgram.createIdentity(context);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- updateParameters();
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void updateParameters() {
- float x_origin = (mHorizontal) ? 1.0f : 0.0f;
- float y_origin = (mVertical) ? 1.0f : 0.0f;
-
- float width = (mHorizontal) ? -1.0f : 1.0f;
- float height = (mVertical) ? -1.0f : 1.0f;
-
- ((ShaderProgram) mProgram).setSourceRect(x_origin, y_origin, width, height);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/GrainFilter.java b/mca/filterpacks/imageproc/java/GrainFilter.java
deleted file mode 100644
index 168a9c6..0000000
--- a/mca/filterpacks/imageproc/java/GrainFilter.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.geometry.Quad;
-import android.filterfw.geometry.Point;
-
-import java.util.Random;
-
-public class GrainFilter extends Filter {
-
- private static final int RAND_THRESHOLD = 128;
-
- @GenerateFieldPort(name = "strength", hasDefault = true)
- private float mScale = 0f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private Frame mNoiseFrame = null;
- private Random mRandom;
-
- private final String mGrainShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float scale;\n" +
- "uniform float stepX;\n" +
- "uniform float stepY;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " float noise = texture2D(tex_sampler_1, v_texcoord + vec2(-stepX, -stepY)).r * 0.224;\n" +
- " noise += texture2D(tex_sampler_1, v_texcoord + vec2(-stepX, stepY)).r * 0.224;\n" +
- " noise += texture2D(tex_sampler_1, v_texcoord + vec2(stepX, -stepY)).r * 0.224;\n" +
- " noise += texture2D(tex_sampler_1, v_texcoord + vec2(stepX, stepY)).r * 0.224;\n" +
- " noise += 0.4448;\n" +
- " noise *= scale;\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float energy = 0.33333 * color.r + 0.33333 * color.g + 0.33333 * color.b;\n" +
- " float mask = (1.0 - sqrt(energy));\n" +
- " float weight = 1.0 - 1.333 * mask * noise;\n" +
- " gl_FragColor = vec4(color.rgb * weight, color.a);\n" +
- "}\n";
-
- public GrainFilter(String name) {
- super(name);
-
- mRandom = new Random();
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mGrainShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- private void updateParameters() {
- mProgram.setHostValue("scale", mScale);
- }
-
- private void updateFrameSize(int width, int height) {
- mWidth = width;
- mHeight = height;
-
- if (mProgram != null) {
- mProgram.setHostValue("stepX", 0.5f / mWidth);
- mProgram.setHostValue("stepY", 0.5f / mHeight);
- updateParameters();
- }
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- mNoiseFrame = null;
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- updateParameters();
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- updateFrameSize(inputFormat.getWidth(), inputFormat.getHeight());
-
- int[] buffer = new int[mWidth * mHeight];
- for (int i = 0; i < mWidth * mHeight; ++i) {
- buffer[i] = (mRandom.nextInt(256) < RAND_THRESHOLD) ?
- mRandom.nextInt(256) : 0;
- }
- FrameFormat format = ImageFormat.create(mWidth, mHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- }
- mNoiseFrame = context.getFrameManager().newFrame(format);
- mNoiseFrame.setInts(buffer);
- }
-
- if (mNoiseFrame.getFormat().getWidth() != mWidth ||
- mNoiseFrame.getFormat().getHeight() != mHeight) {
- throw new RuntimeException("Random map and imput image size mismatch!");
- }
-
- // Process
- Frame[] inputs = {input, mNoiseFrame};
- mProgram.process(inputs, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/ImageCombineFilter.java b/mca/filterpacks/imageproc/java/ImageCombineFilter.java
deleted file mode 100644
index 858489b..0000000
--- a/mca/filterpacks/imageproc/java/ImageCombineFilter.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.lang.reflect.Field;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @hide
- */
-public abstract class ImageCombineFilter extends Filter {
-
- protected Program mProgram;
- protected String[] mInputNames;
- protected String mOutputName;
- protected String mParameterName;
- protected int mCurrentTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- public ImageCombineFilter(String name,
- String[] inputNames,
- String outputName,
- String parameterName) {
- super(name);
- mInputNames = inputNames;
- mOutputName = outputName;
- mParameterName = parameterName;
- }
-
- @Override
- public void setupPorts() {
- if (mParameterName != null) {
- try {
- Field programField = ImageCombineFilter.class.getDeclaredField("mProgram");
- addProgramPort(mParameterName, mParameterName, programField, float.class, false);
- } catch (NoSuchFieldException e) {
- throw new RuntimeException("Internal Error: mProgram field not found!");
- }
- }
- for (String inputName : mInputNames) {
- addMaskedInputPort(inputName, ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- }
- addOutputBasedOnInput(mOutputName, mInputNames[0]);
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- private void assertAllInputTargetsMatch() {
- int target = getInputFormat(mInputNames[0]).getTarget();
- for (String inputName : mInputNames) {
- if (target != getInputFormat(inputName).getTarget()) {
- throw new RuntimeException("Type mismatch of input formats in filter " + this
- + ". All input frames must have the same target!");
- }
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Pull input frames
- int i = 0;
- Frame[] inputs = new Frame[mInputNames.length];
- for (String inputName : mInputNames) {
- inputs[i++] = pullInput(inputName);
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputs[0].getFormat());
-
- // Make sure we have a program
- updateProgramWithTarget(inputs[0].getFormat().getTarget(), context);
-
- // Process
- mProgram.process(inputs, output);
-
- // Push output
- pushOutput(mOutputName, output);
-
- // Release pushed frame
- output.release();
- }
-
- protected void updateProgramWithTarget(int target, FilterContext context) {
- if (target != mCurrentTarget) {
- switch (target) {
- case FrameFormat.TARGET_NATIVE:
- mProgram = getNativeProgram(context);
- break;
-
- case FrameFormat.TARGET_GPU:
- mProgram = getShaderProgram(context);
- break;
-
- default:
- mProgram = null;
- break;
- }
- if (mProgram == null) {
- throw new RuntimeException("Could not create a program for image filter "
- + this + "!");
- }
- initProgramInputs(mProgram, context);
- mCurrentTarget = target;
- }
- }
-
- protected abstract Program getNativeProgram(FilterContext context);
-
- protected abstract Program getShaderProgram(FilterContext context);
-}
diff --git a/mca/filterpacks/imageproc/java/ImageEncoder.java b/mca/filterpacks/imageproc/java/ImageEncoder.java
deleted file mode 100644
index a5405cb..0000000
--- a/mca/filterpacks/imageproc/java/ImageEncoder.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.content.Context;
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.format.ImageFormat;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
-
-import android.util.Log;
-
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * @hide
- */
-public class ImageEncoder extends Filter {
-
- @GenerateFieldPort(name = "stream")
- private OutputStream mOutputStream;
-
- @GenerateFieldPort(name = "quality", hasDefault = true)
- private int mQuality = 80;
-
- public ImageEncoder(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_UNSPECIFIED));
- }
-
- @Override
- public void process(FilterContext env) {
- Frame input = pullInput("image");
- Bitmap bitmap = input.getBitmap();
- bitmap.compress(CompressFormat.JPEG, mQuality, mOutputStream);
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/ImageSlicer.java b/mca/filterpacks/imageproc/java/ImageSlicer.java
deleted file mode 100644
index b996eb8..0000000
--- a/mca/filterpacks/imageproc/java/ImageSlicer.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-public class ImageSlicer extends Filter {
-
- @GenerateFieldPort(name = "xSlices")
- private int mXSlices;
-
- @GenerateFieldPort(name = "ySlices")
- private int mYSlices;
-
- @GenerateFieldPort(name = "padSize")
- private int mPadSize;
-
- // The current slice index from 0 to xSlices * ySlices
- private int mSliceIndex;
-
- private Frame mOriginalFrame;
-
- private Program mProgram;
-
- private int mInputWidth;
- private int mInputHeight;
-
- private int mSliceWidth;
- private int mSliceHeight;
-
- private int mOutputWidth;
- private int mOutputHeight;
-
- public ImageSlicer(String name) {
- super(name);
- mSliceIndex = 0;
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- private void calcOutputFormatForInput(Frame frame) {
-
- // calculate the output size based on input size, xSlices, and ySlices
- mInputWidth = frame.getFormat().getWidth();
- mInputHeight = frame.getFormat().getHeight();
-
- mSliceWidth = (mInputWidth + mXSlices - 1) / mXSlices;
- mSliceHeight = (mInputHeight + mYSlices - 1)/ mYSlices;
-
- mOutputWidth = mSliceWidth + mPadSize * 2;
- mOutputHeight = mSliceHeight + mPadSize * 2;
- }
-
-
- @Override
- public void process(FilterContext context) {
-
- // Get input frame
- if (mSliceIndex == 0) {
- mOriginalFrame = pullInput("image");
- calcOutputFormatForInput(mOriginalFrame);
- }
-
- FrameFormat inputFormat = mOriginalFrame.getFormat();
- MutableFrameFormat outputFormat = inputFormat.mutableCopy();
- outputFormat.setDimensions(mOutputWidth, mOutputHeight);
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(outputFormat);
-
- // Create the program if not created already
- if (mProgram == null) {
- mProgram = ShaderProgram.createIdentity(context);
- }
-
- // Calculate the four corner of the source region
- int xSliceIndex = mSliceIndex % mXSlices;
- int ySliceIndex = mSliceIndex / mXSlices;
-
- // TODO(rslin) : not sure shifting by 0.5 is needed.
- float x0 = (xSliceIndex * mSliceWidth - mPadSize) / ((float) mInputWidth);
- float y0 = (ySliceIndex * mSliceHeight - mPadSize) / ((float) mInputHeight);
-
- ((ShaderProgram) mProgram).setSourceRect(x0, y0,
- ((float) mOutputWidth) / mInputWidth,
- ((float) mOutputHeight) / mInputHeight);
-
- // Process
- mProgram.process(mOriginalFrame, output);
- mSliceIndex++;
-
- if (mSliceIndex == mXSlices * mYSlices) {
- mSliceIndex = 0;
- mOriginalFrame.release();
- setWaitsOnInputPort("image", true);
- } else {
- // Retain the original frame so it can be used next time.
- mOriginalFrame.retain();
- setWaitsOnInputPort("image", false);
- }
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/ImageStitcher.java b/mca/filterpacks/imageproc/java/ImageStitcher.java
deleted file mode 100644
index 20aba91..0000000
--- a/mca/filterpacks/imageproc/java/ImageStitcher.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-public class ImageStitcher extends Filter {
-
- @GenerateFieldPort(name = "xSlices")
- private int mXSlices;
-
- @GenerateFieldPort(name = "ySlices")
- private int mYSlices;
-
- @GenerateFieldPort(name = "padSize")
- private int mPadSize;
-
- private Program mProgram;
- private Frame mOutputFrame;
-
- private int mInputWidth;
- private int mInputHeight;
-
- private int mImageWidth;
- private int mImageHeight;
-
- private int mSliceWidth;
- private int mSliceHeight;
-
- private int mSliceIndex;
-
- public ImageStitcher(String name) {
- super(name);
- mSliceIndex = 0;
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- private FrameFormat calcOutputFormatForInput(FrameFormat format) {
- MutableFrameFormat outputFormat = format.mutableCopy();
-
- mInputWidth = format.getWidth();
- mInputHeight = format.getHeight();
-
- mSliceWidth = mInputWidth - 2 * mPadSize;
- mSliceHeight = mInputHeight - 2 * mPadSize;
-
- mImageWidth = mSliceWidth * mXSlices;
- mImageHeight = mSliceHeight * mYSlices;
-
- outputFormat.setDimensions(mImageWidth, mImageHeight);
- return outputFormat;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat format = input.getFormat();
-
- // Create output frame
- if (mSliceIndex == 0) {
- mOutputFrame = context.getFrameManager().newFrame(calcOutputFormatForInput(format));
- } else {
- if ((format.getWidth() != mInputWidth) ||
- (format.getHeight() != mInputHeight)) {
- // CHECK input format here
- throw new RuntimeException("Image size should not change.");
- }
- }
-
- // Create the program if not created already
- if (mProgram == null) {
- mProgram = ShaderProgram.createIdentity(context);
- }
-
- // TODO(rslin) : not sure shifting by 0.5 is needed.
- float x0 = ((float) mPadSize) / mInputWidth;
- float y0 = ((float) mPadSize) / mInputHeight;
-
- int outputOffsetX = (mSliceIndex % mXSlices) * mSliceWidth;
- int outputOffsetY = (mSliceIndex / mXSlices) * mSliceHeight;
-
- float outputWidth = (float) Math.min(mSliceWidth, mImageWidth - outputOffsetX);
- float outputHeight = (float) Math.min(mSliceHeight, mImageHeight - outputOffsetY);
-
- // We need to set the source rect as well because the input are padded images.
- ((ShaderProgram) mProgram).setSourceRect(x0, y0,
- outputWidth / mInputWidth,
- outputHeight / mInputHeight);
-
- ((ShaderProgram) mProgram).setTargetRect(((float) outputOffsetX)/ mImageWidth,
- ((float) outputOffsetY) / mImageHeight,
- outputWidth / mImageWidth,
- outputHeight / mImageHeight);
-
- // Process this tile
- mProgram.process(input, mOutputFrame);
- mSliceIndex++;
-
- // Push output
- if (mSliceIndex == mXSlices * mYSlices) {
- pushOutput("image", mOutputFrame);
- mOutputFrame.release();
- mSliceIndex = 0;
- }
- }
-}
diff --git a/mca/filterpacks/imageproc/java/Invert.java b/mca/filterpacks/imageproc/java/Invert.java
deleted file mode 100644
index 400fd5d..0000000
--- a/mca/filterpacks/imageproc/java/Invert.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-
-/**
- * @hide
- */
-public class Invert extends SimpleImageFilter {
-
- private static final String mInvertShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " gl_FragColor.r = 1.0 - color.r;\n" +
- " gl_FragColor.g = 1.0 - color.g;\n" +
- " gl_FragColor.b = 1.0 - color.b;\n" +
- " gl_FragColor.a = color.a;\n" +
- "}\n";
-
- public Invert(String name) {
- super(name, null);
- }
-
- @Override
- protected Program getNativeProgram(FilterContext context) {
- return new NativeProgram("filterpack_imageproc", "invert");
- }
-
- @Override
- protected Program getShaderProgram(FilterContext context) {
- return new ShaderProgram(context, mInvertShader);
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/LomoishFilter.java b/mca/filterpacks/imageproc/java/LomoishFilter.java
deleted file mode 100644
index 452a833..0000000
--- a/mca/filterpacks/imageproc/java/LomoishFilter.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Random;
-
-public class LomoishFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private Frame mNoiseFrame;
- private Random mRandom;
-
- private final String mLomoishShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float stepsizeX;\n" +
- "uniform float stepsizeY;\n" +
- "uniform float stepsize;\n" +
- "uniform vec2 center;\n" +
- "uniform float inv_max_dist;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- // sharpen
- " vec3 nbr_color = vec3(0.0, 0.0, 0.0);\n" +
- " vec2 coord;\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " coord.x = v_texcoord.x - 0.5 * stepsizeX;\n" +
- " coord.y = v_texcoord.y - stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " coord.x = v_texcoord.x - stepsizeX;\n" +
- " coord.y = v_texcoord.y + 0.5 * stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " coord.x = v_texcoord.x + stepsizeX;\n" +
- " coord.y = v_texcoord.y - 0.5 * stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " coord.x = v_texcoord.x + stepsizeX;\n" +
- " coord.y = v_texcoord.y + 0.5 * stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " vec3 s_color = vec3(color.rgb + 0.3 * nbr_color);\n" +
- // cross process
- " vec3 c_color = vec3(0.0, 0.0, 0.0);\n" +
- " float value;\n" +
- " if (s_color.r < 0.5) {\n" +
- " value = s_color.r;\n" +
- " } else {\n" +
- " value = 1.0 - s_color.r;\n" +
- " }\n" +
- " float red = 4.0 * value * value * value;\n" +
- " if (s_color.r < 0.5) {\n" +
- " c_color.r = red;\n" +
- " } else {\n" +
- " c_color.r = 1.0 - red;\n" +
- " }\n" +
- " if (s_color.g < 0.5) {\n" +
- " value = s_color.g;\n" +
- " } else {\n" +
- " value = 1.0 - s_color.g;\n" +
- " }\n" +
- " float green = 2.0 * value * value;\n" +
- " if (s_color.g < 0.5) {\n" +
- " c_color.g = green;\n" +
- " } else {\n" +
- " c_color.g = 1.0 - green;\n" +
- " }\n" +
- " c_color.b = s_color.b * 0.5 + 0.25;\n" +
- // blackwhite
- " float dither = texture2D(tex_sampler_1, v_texcoord).r;\n" +
- " vec3 xform = clamp((c_color.rgb - 0.15) * 1.53846, 0.0, 1.0);\n" +
- " vec3 temp = clamp((color.rgb + stepsize - 0.15) * 1.53846, 0.0, 1.0);\n" +
- " vec3 bw_color = clamp(xform + (temp - xform) * (dither - 0.5), 0.0, 1.0);\n" +
- // vignette
- " float dist = distance(gl_FragCoord.xy, center);\n" +
- " float lumen = 0.85 / (1.0 + exp((dist * inv_max_dist - 0.73) * 20.0)) + 0.15;\n" +
- " gl_FragColor = vec4(bw_color * lumen, color.a);\n" +
- "}\n";
-
- public LomoishFilter(String name) {
- super(name);
-
- mRandom = new Random();
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- mNoiseFrame = null;
- }
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mLomoishShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- private void initParameters() {
- if (mProgram !=null) {
- float centerX = (float) (0.5 * mWidth);
- float centerY = (float) (0.5 * mHeight);
- float center[] = {centerX, centerY};
- float max_dist = (float) Math.sqrt(centerX * centerX + centerY * centerY);
-
- mProgram.setHostValue("center", center);
- mProgram.setHostValue("inv_max_dist", 1.0f / max_dist);
-
- mProgram.setHostValue("stepsize", 1.0f / 255.0f);
- mProgram.setHostValue("stepsizeX", 1.0f / mWidth);
- mProgram.setHostValue("stepsizeY", 1.0f / mHeight);
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
-
- int[] buffer = new int[mWidth * mHeight];
- for (int i = 0; i < mWidth * mHeight; ++i) {
- buffer[i] = mRandom.nextInt(255);
- }
- FrameFormat format = ImageFormat.create(mWidth, mHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- if (mNoiseFrame != null) {
- mNoiseFrame.release();
- }
- mNoiseFrame = context.getFrameManager().newFrame(format);
- mNoiseFrame.setInts(buffer);
-
- initParameters();
- }
-
- if (mNoiseFrame != null && (mNoiseFrame.getFormat().getWidth() != mWidth ||
- mNoiseFrame.getFormat().getHeight() != mHeight)) {
- throw new RuntimeException("Random map and imput image size mismatch!");
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- Frame[] inputs = {input, mNoiseFrame};
- mProgram.process(inputs, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/NegativeFilter.java b/mca/filterpacks/imageproc/java/NegativeFilter.java
deleted file mode 100644
index 440d6a6..0000000
--- a/mca/filterpacks/imageproc/java/NegativeFilter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-
-public class NegativeFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mNegativeShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " gl_FragColor = vec4(1.0 - color.rgb, color.a);\n" +
- "}\n";
-
- public NegativeFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mNegativeShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/PosterizeFilter.java b/mca/filterpacks/imageproc/java/PosterizeFilter.java
deleted file mode 100644
index bc2e553..0000000
--- a/mca/filterpacks/imageproc/java/PosterizeFilter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-public class PosterizeFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mPosterizeShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec3 pcolor;\n" +
- " pcolor.r = (color.r >= 0.5) ? 0.75 : 0.25;\n" +
- " pcolor.g = (color.g >= 0.5) ? 0.75 : 0.25;\n" +
- " pcolor.b = (color.b >= 0.5) ? 0.75 : 0.25;\n" +
- " gl_FragColor = vec4(pcolor, color.a);\n" +
- "}\n";
-
- public PosterizeFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mPosterizeShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/RedEyeFilter.java b/mca/filterpacks/imageproc/java/RedEyeFilter.java
deleted file mode 100644
index 5632a5e..0000000
--- a/mca/filterpacks/imageproc/java/RedEyeFilter.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.PointF;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class RedEyeFilter extends Filter {
-
- private static final float RADIUS_RATIO = 0.06f;
- private static final float MIN_RADIUS = 10.0f;
- private static final float DEFAULT_RED_INTENSITY = 1.30f;
-
- @GenerateFieldPort(name = "centers")
- private float[] mCenters;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Frame mRedEyeFrame;
- private Bitmap mRedEyeBitmap;
-
- private final Canvas mCanvas = new Canvas();
- private final Paint mPaint = new Paint();
-
- private float mRadius;
-
- private int mWidth = 0;
- private int mHeight = 0;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mRedEyeShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float intensity;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec4 mask = texture2D(tex_sampler_1, v_texcoord);\n" +
- " gl_FragColor = vec4(mask.a, mask.a, mask.a, 1.0) * intensity + color * (1.0 - intensity);\n" +
- " if (mask.a > 0.0) {\n" +
- " gl_FragColor.r = 0.0;\n" +
- " float green_blue = color.g + color.b;\n" +
- " float red_intensity = color.r / green_blue;\n" +
- " if (red_intensity > intensity) {\n" +
- " color.r = 0.5 * green_blue;\n" +
- " }\n" +
- " }\n" +
- " gl_FragColor = color;\n" +
- "}\n";
-
- public RedEyeFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mRedEyeShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter RedEye does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mRedEyeBitmap != null) {
- mRedEyeBitmap.recycle();
- mRedEyeBitmap = null;
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
-
- createRedEyeBitmap();
- }
-
- createRedEyeFrame(context);
-
- // Process
- Frame[] inputs = {input, mRedEyeFrame};
- mProgram.process(inputs, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
-
- // Release unused frame
- mRedEyeFrame.release();
- mRedEyeFrame = null;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateProgramParams();
- }
- }
-
- private void createRedEyeBitmap() {
- if (mRedEyeBitmap != null) {
- mRedEyeBitmap.recycle();
- }
-
- int bitmapWidth = mWidth / 2;
- int bitmapHeight = mHeight / 2;
-
- mRedEyeBitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
- mCanvas.setBitmap(mRedEyeBitmap);
- mPaint.setColor(Color.WHITE);
- mRadius = Math.max(MIN_RADIUS, RADIUS_RATIO * Math.min(bitmapWidth, bitmapHeight));
-
- updateProgramParams();
- }
-
- private void createRedEyeFrame(FilterContext context) {
- FrameFormat format = ImageFormat.create(mRedEyeBitmap.getWidth() ,
- mRedEyeBitmap.getHeight(),
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- mRedEyeFrame = context.getFrameManager().newFrame(format);
- mRedEyeFrame.setBitmap(mRedEyeBitmap);
- }
-
- private void updateProgramParams() {
- mProgram.setHostValue("intensity", DEFAULT_RED_INTENSITY);
-
- if ( mCenters.length % 2 == 1) {
- throw new RuntimeException("The size of center array must be even.");
- }
-
- if (mRedEyeBitmap != null) {
- for (int i = 0; i < mCenters.length; i += 2) {
- mCanvas.drawCircle(mCenters[i] * mRedEyeBitmap.getWidth(),
- mCenters[i + 1] * mRedEyeBitmap.getHeight(),
- mRadius, mPaint);
- }
- }
- }
-}
diff --git a/mca/filterpacks/imageproc/java/ResizeFilter.java b/mca/filterpacks/imageproc/java/ResizeFilter.java
deleted file mode 100644
index 411e061..0000000
--- a/mca/filterpacks/imageproc/java/ResizeFilter.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.opengl.GLES20;
-
-/**
- * @hide
- */
-public class ResizeFilter extends Filter {
-
- @GenerateFieldPort(name = "owidth")
- private int mOWidth;
- @GenerateFieldPort(name = "oheight")
- private int mOHeight;
- @GenerateFieldPort(name = "keepAspectRatio", hasDefault = true)
- private boolean mKeepAspectRatio = false;
- @GenerateFieldPort(name = "generateMipMap", hasDefault = true)
- private boolean mGenerateMipMap = false;
-
- private Program mProgram;
- private FrameFormat mLastFormat = null;
-
- private MutableFrameFormat mOutputFormat;
- private int mInputChannels;
-
- public ResizeFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- protected void createProgram(FilterContext context, FrameFormat format) {
- if (mLastFormat != null && mLastFormat.getTarget() == format.getTarget()) return;
- mLastFormat = format;
- switch (format.getTarget()) {
- case FrameFormat.TARGET_NATIVE:
- throw new RuntimeException("Native ResizeFilter not implemented yet!");
-
-
- case FrameFormat.TARGET_GPU:
- ShaderProgram prog = ShaderProgram.createIdentity(context);
- mProgram = prog;
- break;
-
- default:
- throw new RuntimeException("ResizeFilter could not create suitable program!");
- }
- }
- @Override
- public void process(FilterContext env) {
- // Get input frame
- Frame input = pullInput("image");
- createProgram(env, input.getFormat());
-
- // Create output frame
- MutableFrameFormat outputFormat = input.getFormat().mutableCopy();
- if (mKeepAspectRatio) {
- FrameFormat inputFormat = input.getFormat();
- mOHeight = mOWidth * inputFormat.getHeight() / inputFormat.getWidth();
- }
- outputFormat.setDimensions(mOWidth, mOHeight);
- Frame output = env.getFrameManager().newFrame(outputFormat);
-
- // Process
- if (mGenerateMipMap) {
- GLFrame mipmapped = (GLFrame)env.getFrameManager().newFrame(input.getFormat());
- mipmapped.setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
- mipmapped.setDataFromFrame(input);
- mipmapped.generateMipMap();
- mProgram.process(mipmapped, output);
- mipmapped.release();
- } else {
- mProgram.process(input, output);
- }
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
-
-}
diff --git a/mca/filterpacks/imageproc/java/RotateFilter.java b/mca/filterpacks/imageproc/java/RotateFilter.java
deleted file mode 100644
index 3da7939..0000000
--- a/mca/filterpacks/imageproc/java/RotateFilter.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.geometry.Quad;
-import android.filterfw.geometry.Point;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class RotateFilter extends Filter {
-
- @GenerateFieldPort(name = "angle")
- private int mAngle;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private int mOutputWidth;
- private int mOutputHeight;
-
- public RotateFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = ShaderProgram.createIdentity(context);
- shaderProgram.setMaximumTileSize(mTileSize);
- shaderProgram.setClearsOutput(true);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
- mOutputWidth = mWidth;
- mOutputHeight = mHeight;
-
- updateParameters();
- }
-
- // Create output frame
- FrameFormat outputFormat = ImageFormat.create(mOutputWidth, mOutputHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
-
- Frame output = context.getFrameManager().newFrame(outputFormat);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void updateParameters() {
- float sinTheta;
- float cosTheta;
-
- if (mAngle % 90 == 0) {
- if (mAngle % 180 == 0) {
- sinTheta = 0f;
- cosTheta = (mAngle % 360 == 0) ? 1f:-1f;
- } else {
- cosTheta = 0f;
- sinTheta = ((mAngle + 90) % 360 == 0) ? -1f:1f;
-
- mOutputWidth = mHeight;
- mOutputHeight = mWidth;
- }
- } else {
- throw new RuntimeException("degree has to be multiply of 90.");
- }
-
- Point x0 = new Point(0.5f * (-cosTheta + sinTheta + 1f),
- 0.5f * (-sinTheta - cosTheta + 1f));
- Point x1 = new Point(0.5f * (cosTheta + sinTheta + 1f),
- 0.5f * (sinTheta - cosTheta + 1f));
- Point x2 = new Point(0.5f * (-cosTheta - sinTheta + 1f),
- 0.5f * (-sinTheta + cosTheta + 1f));
- Point x3 = new Point(0.5f * (cosTheta - sinTheta + 1f),
- 0.5f * (sinTheta + cosTheta + 1f));
- Quad quad = new Quad(x0, x1, x2, x3);
- ((ShaderProgram) mProgram).setTargetRegion(quad);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/SaturateFilter.java b/mca/filterpacks/imageproc/java/SaturateFilter.java
deleted file mode 100644
index b83af39..0000000
--- a/mca/filterpacks/imageproc/java/SaturateFilter.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-public class SaturateFilter extends Filter {
-
- @GenerateFieldPort(name = "scale", hasDefault = true)
- private float mScale = 0f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mBenProgram;
- private Program mHerfProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mBenSaturateShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float scale;\n" +
- "uniform float shift;\n" +
- "uniform vec3 weights;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float kv = dot(color.rgb, weights) + shift;\n" +
- " vec3 new_color = scale * color.rgb + (1.0 - scale) * kv;\n" +
- " gl_FragColor = vec4(new_color, color.a);\n" +
- "}\n";
-
- private final String mHerfSaturateShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform vec3 weights;\n" +
- "uniform vec3 exponents;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float de = dot(color.rgb, weights);\n" +
- " float inv_de = 1.0 / de;\n" +
- " vec3 new_color = de * pow(color.rgb * inv_de, exponents);\n" +
- " float max_color = max(max(max(new_color.r, new_color.g), new_color.b), 1.0);\n" +
- " gl_FragColor = vec4(new_color / max_color, color.a);\n" +
- "}\n";
-
-
- public SaturateFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mBenSaturateShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mBenProgram = shaderProgram;
-
- shaderProgram = new ShaderProgram(context, mHerfSaturateShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mHerfProgram = shaderProgram;
-
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mBenProgram != null && mHerfProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mBenProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- initParameters();
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- if (mScale > 0.0f) {
- mHerfProgram.process(input, output);
- } else {
- mBenProgram.process(input, output);
- }
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void initParameters() {
- float shift = 1.0f / 255.0f;
- float weights[] = { 2f/8f, 5f/8f, 1f/8f};
-
- mBenProgram.setHostValue("weights", weights);
- mBenProgram.setHostValue("shift", shift);
-
- mHerfProgram.setHostValue("weights", weights);
-
- updateParameters();
- }
-
- private void updateParameters() {
-
- if (mScale > 0.0f) {
- float exponents[] = new float[3];
-
- exponents[0] = (0.9f * mScale) + 1.0f;
- exponents[1] = (2.1f * mScale) + 1.0f;
- exponents[2] = (2.7f * mScale) + 1.0f;
-
- mHerfProgram.setHostValue("exponents", exponents);
- } else {
- mBenProgram.setHostValue("scale", 1.0f + mScale);
- }
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/SepiaFilter.java b/mca/filterpacks/imageproc/java/SepiaFilter.java
deleted file mode 100644
index 7a83fdf..0000000
--- a/mca/filterpacks/imageproc/java/SepiaFilter.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-public class SepiaFilter extends Filter {
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mSepiaShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform mat3 matrix;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec3 new_color = min(matrix * color.rgb, 1.0);\n" +
- " gl_FragColor = vec4(new_color.rgb, color.a);\n" +
- "}\n";
-
- public SepiaFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mSepiaShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- initParameters();
- }
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void initParameters() {
- float weights[] = { 805.0f / 2048.0f, 715.0f / 2048.0f, 557.0f / 2048.0f,
- 1575.0f / 2048.0f, 1405.0f / 2048.0f, 1097.0f / 2048.0f,
- 387.0f / 2048.0f, 344.0f / 2048.0f, 268.0f / 2048.0f };
- mProgram.setHostValue("matrix", weights);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/SharpenFilter.java b/mca/filterpacks/imageproc/java/SharpenFilter.java
deleted file mode 100644
index 256b769..0000000
--- a/mca/filterpacks/imageproc/java/SharpenFilter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.util.Set;
-
-public class SharpenFilter extends Filter {
-
- @GenerateFieldPort(name = "scale", hasDefault = true)
- private float mScale = 0f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mSharpenShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float scale;\n" +
- "uniform float stepsizeX;\n" +
- "uniform float stepsizeY;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec3 nbr_color = vec3(0.0, 0.0, 0.0);\n" +
- " vec2 coord;\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " coord.x = v_texcoord.x - 0.5 * stepsizeX;\n" +
- " coord.y = v_texcoord.y - stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " coord.x = v_texcoord.x - stepsizeX;\n" +
- " coord.y = v_texcoord.y + 0.5 * stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " coord.x = v_texcoord.x + stepsizeX;\n" +
- " coord.y = v_texcoord.y - 0.5 * stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " coord.x = v_texcoord.x + stepsizeX;\n" +
- " coord.y = v_texcoord.y + 0.5 * stepsizeY;\n" +
- " nbr_color += texture2D(tex_sampler_0, coord).rgb - color.rgb;\n" +
- " gl_FragColor = vec4(color.rgb - 2.0 * scale * nbr_color, color.a);\n" +
- "}\n";
-
- public SharpenFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mSharpenShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- updateFrameSize(inputFormat.getWidth(), inputFormat.getHeight());
- }
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void updateFrameSize(int width, int height) {
- mWidth = width;
- mHeight = height;
-
- if (mProgram != null) {
- mProgram.setHostValue("stepsizeX", 1.0f / mWidth);
- mProgram.setHostValue("stepsizeY", 1.0f / mHeight);
- updateParameters();
- }
- }
-
- private void updateParameters() {
- mProgram.setHostValue("scale", mScale);
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-}
diff --git a/mca/filterpacks/imageproc/java/SimpleImageFilter.java b/mca/filterpacks/imageproc/java/SimpleImageFilter.java
deleted file mode 100644
index f4fc271..0000000
--- a/mca/filterpacks/imageproc/java/SimpleImageFilter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import java.lang.reflect.Field;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @hide
- */
-public abstract class SimpleImageFilter extends Filter {
-
- protected int mCurrentTarget = FrameFormat.TARGET_UNSPECIFIED;
- protected Program mProgram;
- protected String mParameterName;
-
- public SimpleImageFilter(String name, String parameterName) {
- super(name);
- mParameterName = parameterName;
- }
-
- @Override
- public void setupPorts() {
- if (mParameterName != null) {
- try {
- Field programField = SimpleImageFilter.class.getDeclaredField("mProgram");
- addProgramPort(mParameterName, mParameterName, programField, float.class, false);
- } catch (NoSuchFieldException e) {
- throw new RuntimeException("Internal Error: mProgram field not found!");
- }
- }
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Create program if not created already
- updateProgramWithTarget(inputFormat.getTarget(), context);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- protected void updateProgramWithTarget(int target, FilterContext context) {
- if (target != mCurrentTarget) {
- switch (target) {
- case FrameFormat.TARGET_NATIVE:
- mProgram = getNativeProgram(context);
- break;
-
- case FrameFormat.TARGET_GPU:
- mProgram = getShaderProgram(context);
- break;
-
- default:
- mProgram = null;
- break;
- }
- if (mProgram == null) {
- throw new RuntimeException("Could not create a program for image filter " + this + "!");
- }
- initProgramInputs(mProgram, context);
- mCurrentTarget = target;
- }
- }
-
- protected abstract Program getNativeProgram(FilterContext context);
-
- protected abstract Program getShaderProgram(FilterContext context);
-}
diff --git a/mca/filterpacks/imageproc/java/StraightenFilter.java b/mca/filterpacks/imageproc/java/StraightenFilter.java
deleted file mode 100644
index c9f097d..0000000
--- a/mca/filterpacks/imageproc/java/StraightenFilter.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.geometry.Quad;
-import android.filterfw.geometry.Point;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class StraightenFilter extends Filter {
-
- @GenerateFieldPort(name = "angle", hasDefault = true)
- private float mAngle = 0f;
-
- @GenerateFieldPort(name = "maxAngle", hasDefault = true)
- private float mMaxAngle = 45f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private static final float DEGREE_TO_RADIAN = (float) Math.PI / 180.0f;
-
- public StraightenFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = ShaderProgram.createIdentity(context);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Create output frame
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
- updateParameters();
- }
-
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void updateParameters() {
- float cosTheta = (float) Math.cos(mAngle * DEGREE_TO_RADIAN);
- float sinTheta = (float) Math.sin(mAngle * DEGREE_TO_RADIAN);
-
- if (mMaxAngle <= 0)
- throw new RuntimeException("Max angle is out of range (0-180).");
- mMaxAngle = (mMaxAngle > 90) ? 90 : mMaxAngle;
-
- Point p0 = new Point(-cosTheta * mWidth + sinTheta * mHeight,
- -sinTheta * mWidth - cosTheta * mHeight);
-
- Point p1 = new Point(cosTheta * mWidth + sinTheta * mHeight,
- sinTheta * mWidth - cosTheta * mHeight);
-
- Point p2 = new Point(-cosTheta * mWidth - sinTheta * mHeight,
- -sinTheta * mWidth + cosTheta * mHeight);
-
- Point p3 = new Point(cosTheta * mWidth - sinTheta * mHeight,
- sinTheta * mWidth + cosTheta * mHeight);
-
- float maxWidth = (float) Math.max(Math.abs(p0.x), Math.abs(p1.x));
- float maxHeight = (float) Math.max(Math.abs(p0.y), Math.abs(p1.y));
-
- float scale = 0.5f * Math.min( mWidth / maxWidth,
- mHeight / maxHeight);
-
- p0.set(scale * p0.x / mWidth + 0.5f, scale * p0.y / mHeight + 0.5f);
- p1.set(scale * p1.x / mWidth + 0.5f, scale * p1.y / mHeight + 0.5f);
- p2.set(scale * p2.x / mWidth + 0.5f, scale * p2.y / mHeight + 0.5f);
- p3.set(scale * p3.x / mWidth + 0.5f, scale * p3.y / mHeight + 0.5f);
-
- Quad quad = new Quad(p0, p1, p2, p3);
- ((ShaderProgram) mProgram).setSourceRegion(quad);
- }
-}
diff --git a/mca/filterpacks/imageproc/java/TintFilter.java b/mca/filterpacks/imageproc/java/TintFilter.java
deleted file mode 100644
index 0da54a5..0000000
--- a/mca/filterpacks/imageproc/java/TintFilter.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.graphics.Color;
-
-public class TintFilter extends Filter {
-
- @GenerateFieldPort(name = "tint", hasDefault = true)
- private int mTint = 0xFF0000FF;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final String mTintShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform vec3 tint;\n" +
- "uniform vec3 color_ratio;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float avg_color = dot(color_ratio, color.rgb);\n" +
- " vec3 new_color = min(0.8 * avg_color + 0.2 * tint, 1.0);\n" +
- " gl_FragColor = vec4(new_color.rgb, color.a);\n" +
- "}\n";
-
- public TintFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mTintShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- initParameters();
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
- private void initParameters() {
- float color_ratio[] = {0.21f, 0.71f, 0.07f};
- mProgram.setHostValue("color_ratio", color_ratio);
-
- updateParameters();
- }
-
- private void updateParameters() {
- float tint_color[] = {Color.red(mTint) / 255f,
- Color.green(mTint) / 255f,
- Color.blue(mTint) / 255f };
-
- mProgram.setHostValue("tint", tint_color);
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/ToGrayFilter.java b/mca/filterpacks/imageproc/java/ToGrayFilter.java
deleted file mode 100644
index 00e7bf4..0000000
--- a/mca/filterpacks/imageproc/java/ToGrayFilter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-import java.lang.reflect.Field;
-
-/**
- * @hide
- */
-public class ToGrayFilter extends SimpleImageFilter {
-
- @GenerateFieldPort(name = "invertSource", hasDefault = true)
- private boolean mInvertSource = false;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private MutableFrameFormat mOutputFormat;
-
- private static final String mColorToGray4Shader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " float y = dot(color, vec4(0.299, 0.587, 0.114, 0));\n" +
- " gl_FragColor = vec4(y, y, y, color.a);\n" +
- "}\n";
-
- public ToGrayFilter(String name) {
- super(name, null);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- protected Program getNativeProgram(FilterContext context) {
- throw new RuntimeException("Native toGray not implemented yet!");
- }
-
- @Override
- protected Program getShaderProgram(FilterContext context) {
- int inputChannels = getInputFormat("image").getBytesPerSample();
- if (inputChannels != 4) {
- throw new RuntimeException("Unsupported GL input channels: " +
- inputChannels + "! Channels must be 4!");
- }
- ShaderProgram program = new ShaderProgram(context, mColorToGray4Shader);
- program.setMaximumTileSize(mTileSize);
- if (mInvertSource)
- program.setSourceRect(0.0f, 1.0f, 1.0f, -1.0f);
- return program;
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/ToPackedGrayFilter.java b/mca/filterpacks/imageproc/java/ToPackedGrayFilter.java
deleted file mode 100644
index 3489dd4..0000000
--- a/mca/filterpacks/imageproc/java/ToPackedGrayFilter.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-import java.lang.Math;
-/**
- * @hide
- */
-public class ToPackedGrayFilter extends Filter {
-
- @GenerateFieldPort(name = "owidth", hasDefault = true)
- private int mOWidth = FrameFormat.SIZE_UNSPECIFIED;
- @GenerateFieldPort(name = "oheight", hasDefault = true)
- private int mOHeight = FrameFormat.SIZE_UNSPECIFIED;
- @GenerateFieldPort(name = "keepAspectRatio", hasDefault = true)
- private boolean mKeepAspectRatio = false;
-
- private Program mProgram;
-
- private final String mColorToPackedGrayShader =
- "precision mediump float;\n" +
- "const vec4 coeff_y = vec4(0.299, 0.587, 0.114, 0);\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float pix_stride;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " for (int i = 0; i < 4; ++i) {\n" +
- " vec4 p = texture2D(tex_sampler_0,\n" +
- " v_texcoord + vec2(pix_stride * float(i), 0.0));\n" +
- " gl_FragColor[i] = dot(p, coeff_y);\n" +
- " }\n" +
- "}\n";
-
- public ToPackedGrayFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return convertInputFormat(inputFormat);
- }
-
- private void checkOutputDimensions(int outputWidth, int outputHeight) {
- if (outputWidth <= 0 || outputHeight <= 0) {
- throw new RuntimeException("Invalid output dimensions: " +
- outputWidth + " " + outputHeight);
- }
- }
-
- private FrameFormat convertInputFormat(FrameFormat inputFormat) {
- int ow = mOWidth;
- int oh = mOHeight;
- int w = inputFormat.getWidth();
- int h = inputFormat.getHeight();
- if (mOWidth == FrameFormat.SIZE_UNSPECIFIED) {
- ow = w;
- }
- if (mOHeight == FrameFormat.SIZE_UNSPECIFIED) {
- oh = h;
- }
- if (mKeepAspectRatio) {
- // if keep aspect ratio, use the bigger dimension to determine the
- // final output size
- if (w > h) {
- ow = Math.max(ow, oh);
- oh = ow * h / w;
- } else {
- oh = Math.max(ow, oh);
- ow = oh * w / h;
- }
- }
- ow = (ow / 4) * 4; // ensure width is multiply of 4
- return ImageFormat.create(ow, oh,
- ImageFormat.COLORSPACE_GRAY,
- FrameFormat.TARGET_NATIVE);
- }
-
- @Override
- public void prepare(FilterContext context) {
- mProgram = new ShaderProgram(context, mColorToPackedGrayShader);
- }
-
- @Override
- public void process(FilterContext context) {
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
- FrameFormat outputFormat = convertInputFormat(inputFormat);
- int ow = outputFormat.getWidth();
- int oh = outputFormat.getHeight();
- checkOutputDimensions(ow, oh);
- mProgram.setHostValue("pix_stride", 1.0f / ow);
-
- // Do the RGBA to luminance conversion.
- MutableFrameFormat tempFrameFormat = inputFormat.mutableCopy();
- tempFrameFormat.setDimensions(ow / 4, oh);
- Frame temp = context.getFrameManager().newFrame(tempFrameFormat);
- mProgram.process(input, temp);
-
- // Read frame from GPU to CPU.
- Frame output = context.getFrameManager().newFrame(outputFormat);
- output.setDataFromFrame(temp);
- temp.release();
-
- // Push output and yield ownership.
- pushOutput("image", output);
- output.release();
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/ToRGBAFilter.java b/mca/filterpacks/imageproc/java/ToRGBAFilter.java
deleted file mode 100644
index ab4814f..0000000
--- a/mca/filterpacks/imageproc/java/ToRGBAFilter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class ToRGBAFilter extends Filter {
-
- private int mInputBPP;
- private Program mProgram;
- private FrameFormat mLastFormat = null;
-
- public ToRGBAFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- MutableFrameFormat mask = new MutableFrameFormat(FrameFormat.TYPE_BYTE,
- FrameFormat.TARGET_NATIVE);
- mask.setDimensionCount(2);
- addMaskedInputPort("image", mask);
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return getConvertedFormat(inputFormat);
- }
-
- public FrameFormat getConvertedFormat(FrameFormat format) {
- MutableFrameFormat result = format.mutableCopy();
- result.setMetaValue(ImageFormat.COLORSPACE_KEY, ImageFormat.COLORSPACE_RGBA);
- result.setBytesPerSample(4);
- return result;
- }
-
- public void createProgram(FilterContext context, FrameFormat format) {
- mInputBPP = format.getBytesPerSample();
- if (mLastFormat != null && mLastFormat.getBytesPerSample() == mInputBPP) return;
- mLastFormat = format;
- switch (mInputBPP) {
- case 1:
- mProgram = new NativeProgram("filterpack_imageproc", "gray_to_rgba");
- break;
- case 3:
- mProgram = new NativeProgram("filterpack_imageproc", "rgb_to_rgba");
- break;
- default:
- throw new RuntimeException("Unsupported BytesPerPixel: " + mInputBPP + "!");
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- createProgram(context, input.getFormat());
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(getConvertedFormat(input.getFormat()));
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/ToRGBFilter.java b/mca/filterpacks/imageproc/java/ToRGBFilter.java
deleted file mode 100644
index 9258502..0000000
--- a/mca/filterpacks/imageproc/java/ToRGBFilter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class ToRGBFilter extends Filter {
-
- private int mInputBPP;
- private Program mProgram;
- private FrameFormat mLastFormat = null;
-
- public ToRGBFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- MutableFrameFormat mask = new MutableFrameFormat(FrameFormat.TYPE_BYTE,
- FrameFormat.TARGET_NATIVE);
- mask.setDimensionCount(2);
- addMaskedInputPort("image", mask);
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return getConvertedFormat(inputFormat);
- }
-
- public FrameFormat getConvertedFormat(FrameFormat format) {
- MutableFrameFormat result = format.mutableCopy();
- result.setMetaValue(ImageFormat.COLORSPACE_KEY, ImageFormat.COLORSPACE_RGB);
- result.setBytesPerSample(3);
- return result;
- }
-
- public void createProgram(FilterContext context, FrameFormat format) {
- mInputBPP = format.getBytesPerSample();
- if (mLastFormat != null && mLastFormat.getBytesPerSample() == mInputBPP) return;
- mLastFormat = format;
- switch (mInputBPP) {
- case 1:
- mProgram = new NativeProgram("filterpack_imageproc", "gray_to_rgb");
- break;
- case 4:
- mProgram = new NativeProgram("filterpack_imageproc", "rgba_to_rgb");
- break;
- default:
- throw new RuntimeException("Unsupported BytesPerPixel: " + mInputBPP + "!");
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- createProgram(context, input.getFormat());
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(getConvertedFormat(input.getFormat()));
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-
-}
diff --git a/mca/filterpacks/imageproc/java/VignetteFilter.java b/mca/filterpacks/imageproc/java/VignetteFilter.java
deleted file mode 100644
index 2d78fff..0000000
--- a/mca/filterpacks/imageproc/java/VignetteFilter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.imageproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-public class VignetteFilter extends Filter {
-
- @GenerateFieldPort(name = "scale", hasDefault = true)
- private float mScale = 0f;
-
- @GenerateFieldPort(name = "tile_size", hasDefault = true)
- private int mTileSize = 640;
-
- private Program mProgram;
-
- private int mWidth = 0;
- private int mHeight = 0;
- private int mTarget = FrameFormat.TARGET_UNSPECIFIED;
-
- private final float mSlope = 20.0f;
- private final float mShade = 0.85f;
-
- private final String mVignetteShader =
- "precision mediump float;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float range;\n" +
- "uniform float inv_max_dist;\n" +
- "uniform float shade;\n" +
- "uniform vec2 center;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " const float slope = 20.0;\n" +
- " float dist = distance(gl_FragCoord.xy, center);\n" +
- " float lumen = shade / (1.0 + exp((dist * inv_max_dist - range) * slope)) + (1.0 - shade);\n" +
- " vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
- " gl_FragColor = vec4(color.rgb * lumen, color.a);\n" +
- "}\n";
-
- public VignetteFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- addOutputBasedOnInput("image", "image");
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- public void initProgram(FilterContext context, int target) {
- switch (target) {
- case FrameFormat.TARGET_GPU:
- ShaderProgram shaderProgram = new ShaderProgram(context, mVignetteShader);
- shaderProgram.setMaximumTileSize(mTileSize);
- mProgram = shaderProgram;
- break;
-
- default:
- throw new RuntimeException("Filter Sharpen does not support frames of " +
- "target " + target + "!");
- }
- mTarget = target;
- }
-
- private void initParameters() {
- if (mProgram != null) {
- float centerX = (float) (0.5 * mWidth);
- float centerY = (float) (0.5 * mHeight);
- float center[] = {centerX, centerY};
- float max_dist = (float) Math.sqrt(centerX * centerX + centerY * centerY);
-
- mProgram.setHostValue("center", center);
- mProgram.setHostValue("inv_max_dist", 1.0f / max_dist);
- mProgram.setHostValue("shade", mShade);
-
- updateParameters();
- }
- }
-
- private void updateParameters() {
- // The 'range' is between 1.3 to 0.6. When scale is zero then range is 1.3
- // which means no vignette at all because the luminousity difference is
- // less than 1/256 and will cause nothing.
- mProgram.setHostValue("range", 1.30f - (float) Math.sqrt(mScale) * 0.7f);
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mProgram != null) {
- updateParameters();
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Get input frame
- Frame input = pullInput("image");
- FrameFormat inputFormat = input.getFormat();
-
- // Create program if not created already
- if (mProgram == null || inputFormat.getTarget() != mTarget) {
- initProgram(context, inputFormat.getTarget());
- }
-
- // Check if the frame size has changed
- if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
- mWidth = inputFormat.getWidth();
- mHeight = inputFormat.getHeight();
- initParameters();
- }
-
- // Create output frame
- Frame output = context.getFrameManager().newFrame(inputFormat);
-
- // Process
- mProgram.process(input, output);
-
- // Push output
- pushOutput("image", output);
-
- // Release pushed frame
- output.release();
- }
-}
diff --git a/mca/filterpacks/imageproc/java/package-info.java b/mca/filterpacks/imageproc/java/package-info.java
deleted file mode 100644
index 1cf48b0..0000000
--- a/mca/filterpacks/imageproc/java/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterpacks.imageproc;
diff --git a/mca/filterpacks/imageproc/native/brightness.c b/mca/filterpacks/imageproc/native/brightness.c
deleted file mode 100644
index f4addf1..0000000
--- a/mca/filterpacks/imageproc/native/brightness.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <android/log.h>
-#include <stdlib.h>
-
-#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "MCA", __VA_ARGS__)
-#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "MCA", __VA_ARGS__)
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "MCA", __VA_ARGS__)
-
-typedef struct {
- float brightness;
-} BrightnessParameters;
-
-typedef union {
- int value;
- char rgba[4];
-} Pixel;
-
-void brightness_init(void** user_data) {
- (*user_data) = malloc(sizeof(BrightnessParameters));
-}
-
-void brightness_teardown(void* user_data) {
- free(user_data);
-}
-
-void brightness_setvalue(const char* key, const char* value, void* user_data) {
- if (strcmp(key, "brightness") == 0)
- ((BrightnessParameters*)user_data)->brightness = atof(value);
- else
- LOGE("Unknown parameter: %s!", key);
-}
-
-int brightness_process(const char** inputs,
- const int* input_sizes,
- int input_count,
- char* output,
- int output_size,
- void* user_data) {
- // Make sure we have exactly one input
- if (input_count != 1) {
- LOGE("Brightness: Incorrect input count! Expected 1 but got %d!", input_count);
- return 0;
- }
-
- // Make sure sizes match up
- if (input_sizes[0] != output_size) {
- LOGE("Brightness: Input-output sizes do not match up. %d vs. %d!", input_sizes[0], output_size);
- return 0;
- }
-
- // Get the input and output pointers
- const int* input_ptr = (int*)inputs[0];
- int* output_ptr = (int*)output;
- const int* end_ptr = input_ptr + (output_size / 4);
- if (!input_ptr || !output_ptr) {
- LOGE("Brightness: No input or output pointer found!");
- return 0;
- }
-
- // Get the parameters
- BrightnessParameters* params = (BrightnessParameters*)user_data;
- const float brightness = params->brightness;
-
- // Run the brightness adjustment
- const int factor = (int)(brightness * 255.0f);
- Pixel pixel;
- while (input_ptr < end_ptr) {
- pixel.value = *(input_ptr++);
-
- const short r = (pixel.rgba[0] * factor) / 255;
- const short g = (pixel.rgba[1] * factor) / 255;
- const short b = (pixel.rgba[2] * factor) / 255;
-
- *(output_ptr++) = (r > 255 ? 255 : r)
- | ((g > 255 ? 255 : g) << 8)
- | ((b > 255 ? 255 : b) << 16)
- | (pixel.rgba[3] << 24);
- }
-
- return 1;
-}
-
diff --git a/mca/filterpacks/imageproc/native/contrast.c b/mca/filterpacks/imageproc/native/contrast.c
deleted file mode 100644
index ea8c8d2..0000000
--- a/mca/filterpacks/imageproc/native/contrast.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <android/log.h>
-#include <stdlib.h>
-
-#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "MCA", __VA_ARGS__)
-#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "MCA", __VA_ARGS__)
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "MCA", __VA_ARGS__)
-
-typedef struct {
- float contrast;
-} ContrastParameters;
-
-void contrast_init(void** user_data) {
- (*user_data) = malloc(sizeof(ContrastParameters));
-}
-
-void contrast_teardown(void* user_data) {
- free(user_data);
-}
-
-void contrast_setvalue(const char* key, const char* value, void* user_data) {
- if (strcmp(key, "contrast") == 0)
- ((ContrastParameters*)user_data)->contrast = atof(value);
- else
- LOGE("Unknown parameter: %s!", key);
-}
-
-int contrast_process(const char** inputs,
- const int* input_sizes,
- int input_count,
- char* output,
- int output_size,
- void* user_data) {
- // Make sure we have exactly one input
- if (input_count != 1) {
- LOGE("Contrast: Incorrect input count! Expected 1 but got %d!", input_count);
- return 0;
- }
-
- // Make sure sizes match up
- if (input_sizes[0] != output_size) {
- LOGE("Contrast: Input-output sizes do not match up. %d vs. %d!", input_sizes[0], output_size);
- return 0;
- }
-
- // Get the input and output pointers
- const char* input_ptr = inputs[0];
- char* output_ptr = output;
- if (!input_ptr || !output_ptr) {
- LOGE("Contrast: No input or output pointer found!");
- return 0;
- }
-
- // Get the parameters
- ContrastParameters* params = (ContrastParameters*)user_data;
- const float contrast = params->contrast;
-
- // Run the contrast adjustment
- int i;
- for (i = 0; i < output_size; ++i) {
- float px = *(input_ptr++) / 255.0;
- px -= 0.5;
- px *= contrast;
- px += 0.5;
- *(output_ptr++) = (char)(px > 1.0 ? 255.0 : (px < 0.0 ? 0.0 : px * 255.0));
- }
-
- return 1;
-}
-
diff --git a/mca/filterpacks/imageproc/native/invert.c b/mca/filterpacks/imageproc/native/invert.c
deleted file mode 100644
index 5938aac..0000000
--- a/mca/filterpacks/imageproc/native/invert.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <android/log.h>
-
-int invert_process(const char** inputs,
- const int* input_sizes,
- int input_count,
- char* output,
- int output_size,
- void* user_data) {
- // Make sure we have exactly one input
- if (input_count != 1)
- return 0;
-
- // Make sure sizes match up
- if (input_sizes[0] != output_size)
- return 0;
-
- // Get the input and output pointers
- const char* input_ptr = inputs[0];
- char* output_ptr = output;
- if (!input_ptr || !output_ptr)
- return 0;
-
- // Run the inversion
- int i;
- for (i = 0; i < output_size; ++i)
- *(output_ptr++) = 255 - *(input_ptr++);
-
- return 1;
-}
-
diff --git a/mca/filterpacks/imageproc/native/to_rgba.c b/mca/filterpacks/imageproc/native/to_rgba.c
deleted file mode 100644
index bf4db2a..0000000
--- a/mca/filterpacks/imageproc/native/to_rgba.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-
-int gray_to_rgb_process(const char** inputs,
- const int* input_sizes,
- int input_count,
- char* output,
- int output_size,
- void* user_data) {
- // Make sure we have exactly one input
- if (input_count != 1)
- return 0;
-
- // Make sure sizes match up
- if (input_sizes[0] != output_size/3)
- return 0;
-
- // Get the input and output pointers
- const char* input_ptr = inputs[0];
- char* output_ptr = output;
- if (!input_ptr || !output_ptr)
- return 0;
-
- // Run the conversion
- int i;
- for (i = 0; i < input_sizes[0]; ++i) {
- *(output_ptr++) = *(input_ptr);
- *(output_ptr++) = *(input_ptr);
- *(output_ptr++) = *(input_ptr++);
- }
-
- return 1;
-}
-
-int rgba_to_rgb_process(const char** inputs,
- const int* input_sizes,
- int input_count,
- char* output,
- int output_size,
- void* user_data) {
- // Make sure we have exactly one input
- if (input_count != 1)
- return 0;
-
- // Make sure sizes match up
- if (input_sizes[0]/4 != output_size/3)
- return 0;
-
- // Get the input and output pointers
- const char* input_ptr = inputs[0];
- char* output_ptr = output;
- if (!input_ptr || !output_ptr)
- return 0;
-
- // Run the conversion
- int i;
- for (i = 0; i < input_sizes[0] / 4; ++i) {
- *(output_ptr++) = *(input_ptr++);
- *(output_ptr++) = *(input_ptr++);
- *(output_ptr++) = *(input_ptr++);
- ++input_ptr;
- }
-
- return 1;
-}
-
-int gray_to_rgba_process(const char** inputs,
- const int* input_sizes,
- int input_count,
- char* output,
- int output_size,
- void* user_data) {
- // Make sure we have exactly one input
- if (input_count != 1)
- return 0;
-
- // Make sure sizes match up
- if (input_sizes[0] != output_size/4)
- return 0;
-
- // Get the input and output pointers
- const char* input_ptr = inputs[0];
- char* output_ptr = output;
- if (!input_ptr || !output_ptr)
- return 0;
-
- // Run the conversion
- int i;
- for (i = 0; i < input_sizes[0]; ++i) {
- *(output_ptr++) = *(input_ptr);
- *(output_ptr++) = *(input_ptr);
- *(output_ptr++) = *(input_ptr++);
- *(output_ptr++) = 255;
- }
-
- return 1;
-}
-
-int rgb_to_rgba_process(const char** inputs,
- const int* input_sizes,
- int input_count,
- char* output,
- int output_size,
- void* user_data) {
- // Make sure we have exactly one input
- if (input_count != 1)
- return 0;
-
- // Make sure sizes match up
- if (input_sizes[0]/3 != output_size/4)
- return 0;
-
- // Get the input and output pointers
- const char* input_ptr = inputs[0];
- char* output_ptr = output;
- if (!input_ptr || !output_ptr)
- return 0;
-
- // Run the conversion
- int i;
- for (i = 0; i < output_size / 4; ++i) {
- *(output_ptr++) = *(input_ptr++);
- *(output_ptr++) = *(input_ptr++);
- *(output_ptr++) = *(input_ptr++);
- *(output_ptr++) = 255;
- }
-
- return 1;
-}
-
diff --git a/mca/filterpacks/numeric/java/SinWaveFilter.java b/mca/filterpacks/numeric/java/SinWaveFilter.java
deleted file mode 100644
index 7e2b4cf..0000000
--- a/mca/filterpacks/numeric/java/SinWaveFilter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.numeric;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.format.ObjectFormat;
-
-import java.lang.Math;
-
-/**
- * @hide
- */
-public class SinWaveFilter extends Filter {
-
- @GenerateFieldPort(name = "stepSize", hasDefault = true)
- private float mStepSize = 0.05f;
-
- private float mValue = 0.0f;
-
- private FrameFormat mOutputFormat;
-
- public SinWaveFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- mOutputFormat = ObjectFormat.fromClass(Float.class, FrameFormat.TARGET_SIMPLE);
- addOutputPort("value", mOutputFormat);
- }
-
- @Override
- public void open(FilterContext env) {
- mValue = 0.0f;
- }
-
- @Override
- public void process(FilterContext env) {
- Frame output = env.getFrameManager().newFrame(mOutputFormat);
- output.setObjectValue(((float)Math.sin(mValue) + 1.0f) / 2.0f);
- pushOutput("value", output);
- mValue += mStepSize;
- output.release();
- }
-
-
-}
diff --git a/mca/filterpacks/numeric/java/package-info.java b/mca/filterpacks/numeric/java/package-info.java
deleted file mode 100644
index 55088eb..0000000
--- a/mca/filterpacks/numeric/java/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterpacks.numeric;
diff --git a/mca/filterpacks/performance/java/Throughput.java b/mca/filterpacks/performance/java/Throughput.java
deleted file mode 100644
index 51f29f3..0000000
--- a/mca/filterpacks/performance/java/Throughput.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.performance;
-
-/**
- * @hide
- */
-public class Throughput {
-
- private final int mTotalFrames;
- private final int mPeriodFrames;
- private final int mPeriodTime;
- private final int mPixels;
-
- public Throughput(int totalFrames, int periodFrames, int periodTime, int pixels) {
- mTotalFrames = totalFrames;
- mPeriodFrames = periodFrames;
- mPeriodTime = periodTime;
- mPixels = pixels;
- }
-
- public int getTotalFrameCount() {
- return mTotalFrames;
- }
-
- public int getPeriodFrameCount() {
- return mPeriodFrames;
- }
-
- public int getPeriodTime() {
- return mPeriodTime;
- }
-
- public float getFramesPerSecond() {
- return mPeriodFrames / (float)mPeriodTime;
- }
-
- public float getNanosPerPixel() {
- double frameTimeInNanos = (mPeriodTime / (double)mPeriodFrames) * 1000000.0;
- return (float)(frameTimeInNanos / mPixels);
- }
-
- public String toString() {
- return getFramesPerSecond() + " FPS";
- }
-}
diff --git a/mca/filterpacks/performance/java/ThroughputFilter.java b/mca/filterpacks/performance/java/ThroughputFilter.java
deleted file mode 100644
index ac837ed..0000000
--- a/mca/filterpacks/performance/java/ThroughputFilter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.performance;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.format.ObjectFormat;
-import android.os.SystemClock;
-
-/**
- * @hide
- */
-public class ThroughputFilter extends Filter {
-
- @GenerateFieldPort(name = "period", hasDefault = true)
- private int mPeriod = 5;
-
- private long mLastTime = 0;
-
- private int mTotalFrameCount = 0;
- private int mPeriodFrameCount = 0;
-
- private FrameFormat mOutputFormat;
-
- public ThroughputFilter(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- // Add input ports
- addInputPort("frame");
-
- // Add output ports
- mOutputFormat = ObjectFormat.fromClass(Throughput.class, FrameFormat.TARGET_SIMPLE);
- addOutputBasedOnInput("frame", "frame");
- addOutputPort("throughput", mOutputFormat);
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- return inputFormat;
- }
-
- @Override
- public void open(FilterContext env) {
- mTotalFrameCount = 0;
- mPeriodFrameCount = 0;
- mLastTime = 0;
- }
-
- @Override
- public void process(FilterContext context) {
- // Pass through input frame
- Frame input = pullInput("frame");
- pushOutput("frame", input);
-
- // Update stats
- ++mTotalFrameCount;
- ++mPeriodFrameCount;
-
- // Check clock
- if (mLastTime == 0) {
- mLastTime = SystemClock.elapsedRealtime();
- }
- long curTime = SystemClock.elapsedRealtime();
-
- // Output throughput info if time period is up
- if ((curTime - mLastTime) >= (mPeriod * 1000)) {
- FrameFormat inputFormat = input.getFormat();
- int pixelCount = inputFormat.getWidth() * inputFormat.getHeight();
- Throughput throughput = new Throughput(mTotalFrameCount,
- mPeriodFrameCount,
- mPeriod,
- pixelCount);
- Frame throughputFrame = context.getFrameManager().newFrame(mOutputFormat);
- throughputFrame.setObjectValue(throughput);
- pushOutput("throughput", throughputFrame);
- mLastTime = curTime;
- mPeriodFrameCount = 0;
- }
- }
-
-
-}
diff --git a/mca/filterpacks/performance/java/package-info.java b/mca/filterpacks/performance/java/package-info.java
deleted file mode 100644
index 8b77bbb..0000000
--- a/mca/filterpacks/performance/java/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterpacks.performance;
diff --git a/mca/filterpacks/text/java/StringLogger.java b/mca/filterpacks/text/java/StringLogger.java
deleted file mode 100644
index 8c7cd69..0000000
--- a/mca/filterpacks/text/java/StringLogger.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.text;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.format.ObjectFormat;
-import android.util.Log;
-
-/**
- * @hide
- */
-public class StringLogger extends Filter {
-
- public StringLogger(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- addMaskedInputPort("string", ObjectFormat.fromClass(Object.class,
- FrameFormat.TARGET_SIMPLE));
- }
-
- @Override
- public void process(FilterContext env) {
- Frame input = pullInput("string");
- String inputString = input.getObjectValue().toString();
- Log.i("StringLogger", inputString);
- }
-
-}
diff --git a/mca/filterpacks/text/java/StringSource.java b/mca/filterpacks/text/java/StringSource.java
deleted file mode 100644
index cc33b89..0000000
--- a/mca/filterpacks/text/java/StringSource.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.text;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.format.ObjectFormat;
-
-/**
- * @hide
- */
-public class StringSource extends Filter {
-
- @GenerateFieldPort(name = "stringValue")
- private String mString;
-
- private FrameFormat mOutputFormat;
-
- public StringSource(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- mOutputFormat = ObjectFormat.fromClass(String.class, FrameFormat.TARGET_SIMPLE);
- addOutputPort("string", mOutputFormat);
- }
-
- @Override
- public void process(FilterContext env) {
- Frame output = env.getFrameManager().newFrame(mOutputFormat);
- output.setObjectValue(mString);
- output.setTimestamp(Frame.TIMESTAMP_UNKNOWN);
- pushOutput("string", output);
- closeOutputPort("string");
- }
-
-
-}
diff --git a/mca/filterpacks/text/java/ToUpperCase.java b/mca/filterpacks/text/java/ToUpperCase.java
deleted file mode 100644
index 0cf3477..0000000
--- a/mca/filterpacks/text/java/ToUpperCase.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.text;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.format.ObjectFormat;
-
-/**
- * @hide
- */
-public class ToUpperCase extends Filter {
-
- private FrameFormat mOutputFormat;
-
- public ToUpperCase(String name) {
- super(name);
- }
-
- @Override
- public void setupPorts() {
- mOutputFormat = ObjectFormat.fromClass(String.class, FrameFormat.TARGET_SIMPLE);
- addMaskedInputPort("mixedcase", mOutputFormat);
- addOutputPort("uppercase", mOutputFormat);
- }
-
- @Override
- public void process(FilterContext env) {
- Frame input = pullInput("mixedcase");
- String inputString = (String)input.getObjectValue();
-
- Frame output = env.getFrameManager().newFrame(mOutputFormat);
- output.setObjectValue(inputString.toUpperCase());
-
- pushOutput("uppercase", output);
- }
-
-}
diff --git a/mca/filterpacks/text/java/package-info.java b/mca/filterpacks/text/java/package-info.java
deleted file mode 100644
index 371d3c1..0000000
--- a/mca/filterpacks/text/java/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterpacks.text;
diff --git a/mca/filterpacks/ui/java/SurfaceRenderFilter.java b/mca/filterpacks/ui/java/SurfaceRenderFilter.java
deleted file mode 100644
index a5c1ccb..0000000
--- a/mca/filterpacks/ui/java/SurfaceRenderFilter.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.ui;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.FilterSurfaceView;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GLEnvironment;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-import android.graphics.Rect;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class SurfaceRenderFilter extends Filter implements SurfaceHolder.Callback {
-
- private final int RENDERMODE_STRETCH = 0;
- private final int RENDERMODE_FIT = 1;
- private final int RENDERMODE_FILL_CROP = 2;
-
- /** Required. Sets the destination filter surface view for this
- * node.
- */
- @GenerateFinalPort(name = "surfaceView")
- private FilterSurfaceView mSurfaceView;
-
- /** Optional. Control how the incoming frames are rendered onto the
- * output. Default is FIT.
- * RENDERMODE_STRETCH: Just fill the output surfaceView.
- * RENDERMODE_FIT: Keep aspect ratio and fit without cropping. May
- * have black bars.
- * RENDERMODE_FILL_CROP: Keep aspect ratio and fit without black
- * bars. May crop.
- */
- @GenerateFieldPort(name = "renderMode", hasDefault = true)
- private String mRenderModeString;
-
- private boolean mIsBound = false;
-
- private ShaderProgram mProgram;
- private GLFrame mScreen;
- private int mRenderMode = RENDERMODE_FIT;
- private float mAspectRatio = 1.f;
-
- private int mScreenWidth;
- private int mScreenHeight;
-
- private boolean mLogVerbose;
- private static final String TAG = "SurfaceRenderFilter";
-
- public SurfaceRenderFilter(String name) {
- super(name);
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void setupPorts() {
- // Make sure we have a SurfaceView
- if (mSurfaceView == null) {
- throw new RuntimeException("NULL SurfaceView passed to SurfaceRenderFilter");
- }
-
- // Add input port
- addMaskedInputPort("frame", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- }
-
- public void updateRenderMode() {
- if (mRenderModeString != null) {
- if (mRenderModeString.equals("stretch")) {
- mRenderMode = RENDERMODE_STRETCH;
- } else if (mRenderModeString.equals("fit")) {
- mRenderMode = RENDERMODE_FIT;
- } else if (mRenderModeString.equals("fill_crop")) {
- mRenderMode = RENDERMODE_FILL_CROP;
- } else {
- throw new RuntimeException("Unknown render mode '" + mRenderModeString + "'!");
- }
- }
- updateTargetRect();
- }
-
- @Override
- public void prepare(FilterContext context) {
- // Create identity shader to render, and make sure to render upside-down, as textures
- // are stored internally bottom-to-top.
- mProgram = ShaderProgram.createIdentity(context);
- mProgram.setSourceRect(0, 1, 1, -1);
- mProgram.setClearsOutput(true);
- mProgram.setClearColor(0.0f, 0.0f, 0.0f);
-
- updateRenderMode();
-
- // Create a frame representing the screen
- MutableFrameFormat screenFormat = ImageFormat.create(mSurfaceView.getWidth(),
- mSurfaceView.getHeight(),
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- mScreen = (GLFrame)context.getFrameManager().newBoundFrame(screenFormat,
- GLFrame.EXISTING_FBO_BINDING,
- 0);
- }
-
- @Override
- public void open(FilterContext context) {
- // Bind surface view to us. This will emit a surfaceCreated and surfaceChanged call that
- // will update our screen width and height.
- mSurfaceView.unbind();
- mSurfaceView.bindToListener(this, context.getGLEnvironment());
- }
-
- @Override
- public void process(FilterContext context) {
- // Make sure we are bound to a surface before rendering
- if (!mIsBound) {
- Log.w("SurfaceRenderFilter",
- this + ": Ignoring frame as there is no surface to render to!");
- return;
- }
-
- if (mLogVerbose) Log.v(TAG, "Starting frame processing");
-
- GLEnvironment glEnv = mSurfaceView.getGLEnv();
- if (glEnv != context.getGLEnvironment()) {
- throw new RuntimeException("Surface created under different GLEnvironment!");
- }
-
-
- // Get input frame
- Frame input = pullInput("frame");
- boolean createdFrame = false;
-
- float currentAspectRatio = (float)input.getFormat().getWidth() / input.getFormat().getHeight();
- if (currentAspectRatio != mAspectRatio) {
- if (mLogVerbose) Log.v(TAG, "New aspect ratio: " + currentAspectRatio +", previously: " + mAspectRatio);
- mAspectRatio = currentAspectRatio;
- updateTargetRect();
- }
-
- // See if we need to copy to GPU
- Frame gpuFrame = null;
- if (mLogVerbose) Log.v("SurfaceRenderFilter", "Got input format: " + input.getFormat());
- int target = input.getFormat().getTarget();
- if (target != FrameFormat.TARGET_GPU) {
- gpuFrame = context.getFrameManager().duplicateFrameToTarget(input,
- FrameFormat.TARGET_GPU);
- createdFrame = true;
- } else {
- gpuFrame = input;
- }
-
- // Activate our surface
- glEnv.activateSurfaceWithId(mSurfaceView.getSurfaceId());
-
- // Process
- mProgram.process(gpuFrame, mScreen);
-
- // And swap buffers
- glEnv.swapBuffers();
-
- if (createdFrame) {
- gpuFrame.release();
- }
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- updateTargetRect();
- }
-
- @Override
- public void close(FilterContext context) {
- mSurfaceView.unbind();
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mScreen != null) {
- mScreen.release();
- }
- }
-
- @Override
- public synchronized void surfaceCreated(SurfaceHolder holder) {
- mIsBound = true;
- }
-
- @Override
- public synchronized void surfaceChanged(SurfaceHolder holder,
- int format,
- int width,
- int height) {
- // If the screen is null, we do not care about surface changes (yet). Once we have a
- // screen object, we need to keep track of these changes.
- if (mScreen != null) {
- mScreenWidth = width;
- mScreenHeight = height;
- mScreen.setViewport(0, 0, mScreenWidth, mScreenHeight);
- updateTargetRect();
- }
- }
-
- @Override
- public synchronized void surfaceDestroyed(SurfaceHolder holder) {
- mIsBound = false;
- }
-
- private void updateTargetRect() {
- if (mScreenWidth > 0 && mScreenHeight > 0 && mProgram != null) {
- float screenAspectRatio = (float)mScreenWidth / mScreenHeight;
- float relativeAspectRatio = screenAspectRatio / mAspectRatio;
-
- switch (mRenderMode) {
- case RENDERMODE_STRETCH:
- mProgram.setTargetRect(0, 0, 1, 1);
- break;
- case RENDERMODE_FIT:
- if (relativeAspectRatio > 1.0f) {
- // Screen is wider than the camera, scale down X
- mProgram.setTargetRect(0.5f - 0.5f / relativeAspectRatio, 0.0f,
- 1.0f / relativeAspectRatio, 1.0f);
- } else {
- // Screen is taller than the camera, scale down Y
- mProgram.setTargetRect(0.0f, 0.5f - 0.5f * relativeAspectRatio,
- 1.0f, relativeAspectRatio);
- }
- break;
- case RENDERMODE_FILL_CROP:
- if (relativeAspectRatio > 1) {
- // Screen is wider than the camera, crop in Y
- mProgram.setTargetRect(0.0f, 0.5f - 0.5f * relativeAspectRatio,
- 1.0f, relativeAspectRatio);
- } else {
- // Screen is taller than the camera, crop in X
- mProgram.setTargetRect(0.5f - 0.5f / relativeAspectRatio, 0.0f,
- 1.0f / relativeAspectRatio, 1.0f);
- }
- break;
- }
- }
- }
-}
diff --git a/mca/filterpacks/ui/java/SurfaceTargetFilter.java b/mca/filterpacks/ui/java/SurfaceTargetFilter.java
deleted file mode 100644
index 308d168..0000000
--- a/mca/filterpacks/ui/java/SurfaceTargetFilter.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.ui;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GLEnvironment;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-import android.graphics.Rect;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class SurfaceTargetFilter extends Filter {
-
- private final int RENDERMODE_STRETCH = 0;
- private final int RENDERMODE_FIT = 1;
- private final int RENDERMODE_FILL_CROP = 2;
-
- /** Required. Sets the destination surface for this node. This assumes that
- * higher-level code is ensuring that the surface is valid, and properly
- * updates Surface parameters if they change.
- */
- @GenerateFinalPort(name = "surface")
- private Surface mSurface;
-
- /** Required. Width of the output surface */
- @GenerateFieldPort(name = "owidth")
- private int mScreenWidth;
-
- /** Required. Height of the output surface */
- @GenerateFieldPort(name = "oheight")
- private int mScreenHeight;
-
- /** Optional. Control how the incoming frames are rendered onto the
- * output. Default is FIT.
- * RENDERMODE_STRETCH: Just fill the output surfaceView.
- * RENDERMODE_FIT: Keep aspect ratio and fit without cropping. May
- * have black bars.
- * RENDERMODE_FILL_CROP: Keep aspect ratio and fit without black
- * bars. May crop.
- */
- @GenerateFieldPort(name = "renderMode", hasDefault = true)
- private String mRenderModeString;
-
- private ShaderProgram mProgram;
- private GLEnvironment mGlEnv;
- private GLFrame mScreen;
- private int mRenderMode = RENDERMODE_FIT;
- private float mAspectRatio = 1.f;
-
- private int mSurfaceId = -1;
-
- private boolean mLogVerbose;
- private static final String TAG = "SurfaceRenderFilter";
-
- public SurfaceTargetFilter(String name) {
- super(name);
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void setupPorts() {
- // Make sure we have a Surface
- if (mSurface == null) {
- throw new RuntimeException("NULL Surface passed to SurfaceTargetFilter");
- }
-
- // Add input port
- addMaskedInputPort("frame", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- }
-
- public void updateRenderMode() {
- if (mRenderModeString != null) {
- if (mRenderModeString.equals("stretch")) {
- mRenderMode = RENDERMODE_STRETCH;
- } else if (mRenderModeString.equals("fit")) {
- mRenderMode = RENDERMODE_FIT;
- } else if (mRenderModeString.equals("fill_crop")) {
- mRenderMode = RENDERMODE_FILL_CROP;
- } else {
- throw new RuntimeException("Unknown render mode '" + mRenderModeString + "'!");
- }
- }
- updateTargetRect();
- }
-
- @Override
- public void prepare(FilterContext context) {
- mGlEnv = context.getGLEnvironment();
-
- // Create identity shader to render, and make sure to render upside-down, as textures
- // are stored internally bottom-to-top.
- mProgram = ShaderProgram.createIdentity(context);
- mProgram.setSourceRect(0, 1, 1, -1);
- mProgram.setClearsOutput(true);
- mProgram.setClearColor(0.0f, 0.0f, 0.0f);
-
- MutableFrameFormat screenFormat = ImageFormat.create(mScreenWidth,
- mScreenHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- mScreen = (GLFrame)context.getFrameManager().newBoundFrame(screenFormat,
- GLFrame.EXISTING_FBO_BINDING,
- 0);
-
- // Set up cropping
- updateRenderMode();
- }
-
- @Override
- public void open(FilterContext context) {
- registerSurface();
- }
-
- @Override
- public void process(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Starting frame processing");
-
- // Get input frame
- Frame input = pullInput("frame");
- boolean createdFrame = false;
-
- float currentAspectRatio = (float)input.getFormat().getWidth() / input.getFormat().getHeight();
- if (currentAspectRatio != mAspectRatio) {
- if (mLogVerbose) Log.v(TAG, "New aspect ratio: " + currentAspectRatio +", previously: " + mAspectRatio);
- mAspectRatio = currentAspectRatio;
- updateTargetRect();
- }
-
- // See if we need to copy to GPU
- Frame gpuFrame = null;
- if (mLogVerbose) Log.v("SurfaceRenderFilter", "Got input format: " + input.getFormat());
- int target = input.getFormat().getTarget();
- if (target != FrameFormat.TARGET_GPU) {
- gpuFrame = context.getFrameManager().duplicateFrameToTarget(input,
- FrameFormat.TARGET_GPU);
- createdFrame = true;
- } else {
- gpuFrame = input;
- }
-
- // Activate our surface
- mGlEnv.activateSurfaceWithId(mSurfaceId);
-
- // Process
- mProgram.process(gpuFrame, mScreen);
-
- // And swap buffers
- mGlEnv.swapBuffers();
-
- if (createdFrame) {
- gpuFrame.release();
- }
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- mScreen.setViewport(0, 0, mScreenWidth, mScreenHeight);
- updateTargetRect();
- }
-
- @Override
- public void close(FilterContext context) {
- unregisterSurface();
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mScreen != null) {
- mScreen.release();
- }
- }
-
- private void updateTargetRect() {
- if (mScreenWidth > 0 && mScreenHeight > 0 && mProgram != null) {
- float screenAspectRatio = (float)mScreenWidth / mScreenHeight;
- float relativeAspectRatio = screenAspectRatio / mAspectRatio;
-
- switch (mRenderMode) {
- case RENDERMODE_STRETCH:
- mProgram.setTargetRect(0, 0, 1, 1);
- break;
- case RENDERMODE_FIT:
- if (relativeAspectRatio > 1.0f) {
- // Screen is wider than the camera, scale down X
- mProgram.setTargetRect(0.5f - 0.5f / relativeAspectRatio, 0.0f,
- 1.0f / relativeAspectRatio, 1.0f);
- } else {
- // Screen is taller than the camera, scale down Y
- mProgram.setTargetRect(0.0f, 0.5f - 0.5f * relativeAspectRatio,
- 1.0f, relativeAspectRatio);
- }
- break;
- case RENDERMODE_FILL_CROP:
- if (relativeAspectRatio > 1) {
- // Screen is wider than the camera, crop in Y
- mProgram.setTargetRect(0.0f, 0.5f - 0.5f * relativeAspectRatio,
- 1.0f, relativeAspectRatio);
- } else {
- // Screen is taller than the camera, crop in X
- mProgram.setTargetRect(0.5f - 0.5f / relativeAspectRatio, 0.0f,
- 1.0f / relativeAspectRatio, 1.0f);
- }
- break;
- }
- }
- }
-
- private void registerSurface() {
- mSurfaceId = mGlEnv.registerSurface(mSurface);
- if (mSurfaceId < 0) {
- throw new RuntimeException("Could not register Surface: " + mSurface);
- }
- }
-
- private void unregisterSurface() {
- if (mSurfaceId > 0) {
- mGlEnv.unregisterSurfaceId(mSurfaceId);
- }
- }
-
-}
diff --git a/mca/filterpacks/ui/java/package-info.java b/mca/filterpacks/ui/java/package-info.java
deleted file mode 100644
index 9ed7d51..0000000
--- a/mca/filterpacks/ui/java/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterpacks.ui;
diff --git a/mca/filterpacks/videoproc/java/BackDropperFilter.java b/mca/filterpacks/videoproc/java/BackDropperFilter.java
deleted file mode 100644
index 52c9fda..0000000
--- a/mca/filterpacks/videoproc/java/BackDropperFilter.java
+++ /dev/null
@@ -1,976 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.videoproc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.Frame;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.opengl.GLES20;
-import android.os.SystemClock;
-import android.util.Log;
-
-import java.lang.ArrayIndexOutOfBoundsException;
-import java.lang.Math;
-import java.util.Arrays;
-import java.nio.ByteBuffer;
-
-/**
- * @hide
- */
-public class BackDropperFilter extends Filter {
- /** User-visible parameters */
-
- private final int BACKGROUND_STRETCH = 0;
- private final int BACKGROUND_FIT = 1;
- private final int BACKGROUND_FILL_CROP = 2;
-
- @GenerateFieldPort(name = "backgroundFitMode", hasDefault = true)
- private int mBackgroundFitMode = BACKGROUND_FILL_CROP;
- @GenerateFieldPort(name = "learningDuration", hasDefault = true)
- private int mLearningDuration = DEFAULT_LEARNING_DURATION;
- @GenerateFieldPort(name = "learningVerifyDuration", hasDefault = true)
- private int mLearningVerifyDuration = DEFAULT_LEARNING_VERIFY_DURATION;
- @GenerateFieldPort(name = "acceptStddev", hasDefault = true)
- private float mAcceptStddev = DEFAULT_ACCEPT_STDDEV;
- @GenerateFieldPort(name = "hierLrgScale", hasDefault = true)
- private float mHierarchyLrgScale = DEFAULT_HIER_LRG_SCALE;
- @GenerateFieldPort(name = "hierMidScale", hasDefault = true)
- private float mHierarchyMidScale = DEFAULT_HIER_MID_SCALE;
- @GenerateFieldPort(name = "hierSmlScale", hasDefault = true)
- private float mHierarchySmlScale = DEFAULT_HIER_SML_SCALE;
-
- // Dimensions of foreground / background mask. Optimum value should take into account only
- // image contents, NOT dimensions of input video stream.
- @GenerateFieldPort(name = "maskWidthExp", hasDefault = true)
- private int mMaskWidthExp = DEFAULT_MASK_WIDTH_EXPONENT;
- @GenerateFieldPort(name = "maskHeightExp", hasDefault = true)
- private int mMaskHeightExp = DEFAULT_MASK_HEIGHT_EXPONENT;
-
- // Levels at which to compute foreground / background decision. Think of them as are deltas
- // SUBTRACTED from maskWidthExp and maskHeightExp.
- @GenerateFieldPort(name = "hierLrgExp", hasDefault = true)
- private int mHierarchyLrgExp = DEFAULT_HIER_LRG_EXPONENT;
- @GenerateFieldPort(name = "hierMidExp", hasDefault = true)
- private int mHierarchyMidExp = DEFAULT_HIER_MID_EXPONENT;
- @GenerateFieldPort(name = "hierSmlExp", hasDefault = true)
- private int mHierarchySmlExp = DEFAULT_HIER_SML_EXPONENT;
-
- @GenerateFieldPort(name = "lumScale", hasDefault = true)
- private float mLumScale = DEFAULT_Y_SCALE_FACTOR;
- @GenerateFieldPort(name = "chromaScale", hasDefault = true)
- private float mChromaScale = DEFAULT_UV_SCALE_FACTOR;
- @GenerateFieldPort(name = "maskBg", hasDefault = true)
- private float mMaskBg = DEFAULT_MASK_BLEND_BG;
- @GenerateFieldPort(name = "maskFg", hasDefault = true)
- private float mMaskFg = DEFAULT_MASK_BLEND_FG;
- @GenerateFieldPort(name = "exposureChange", hasDefault = true)
- private float mExposureChange = DEFAULT_EXPOSURE_CHANGE;
- @GenerateFieldPort(name = "whitebalanceredChange", hasDefault = true)
- private float mWhiteBalanceRedChange = DEFAULT_WHITE_BALANCE_RED_CHANGE;
- @GenerateFieldPort(name = "whitebalanceblueChange", hasDefault = true)
- private float mWhiteBalanceBlueChange = DEFAULT_WHITE_BALANCE_BLUE_CHANGE;
- @GenerateFieldPort(name = "autowbToggle", hasDefault = true)
- private int mAutoWBToggle = DEFAULT_WHITE_BALANCE_TOGGLE;
-
- // TODO: These are not updatable:
- @GenerateFieldPort(name = "learningAdaptRate", hasDefault = true)
- private float mAdaptRateLearning = DEFAULT_LEARNING_ADAPT_RATE;
- @GenerateFieldPort(name = "adaptRateBg", hasDefault = true)
- private float mAdaptRateBg = DEFAULT_ADAPT_RATE_BG;
- @GenerateFieldPort(name = "adaptRateFg", hasDefault = true)
- private float mAdaptRateFg = DEFAULT_ADAPT_RATE_FG;
- @GenerateFieldPort(name = "maskVerifyRate", hasDefault = true)
- private float mVerifyRate = DEFAULT_MASK_VERIFY_RATE;
- @GenerateFieldPort(name = "learningDoneListener", hasDefault = true)
- private LearningDoneListener mLearningDoneListener = null;
-
- @GenerateFieldPort(name = "useTheForce", hasDefault = true)
- private boolean mUseTheForce = false;
-
- @GenerateFinalPort(name = "provideDebugOutputs", hasDefault = true)
- private boolean mProvideDebugOutputs = false;
-
- // Whether to mirror the background or not. For ex, the Camera app
- // would mirror the preview for the front camera
- @GenerateFieldPort(name = "mirrorBg", hasDefault = true)
- private boolean mMirrorBg = false;
-
- // The orientation of the display. This will change the flipping
- // coordinates, if we were to mirror the background
- @GenerateFieldPort(name = "orientation", hasDefault = true)
- private int mOrientation = 0;
-
- /** Default algorithm parameter values, for non-shader use */
-
- // Frame count for learning bg model
- private static final int DEFAULT_LEARNING_DURATION = 40;
- // Frame count for learning verification
- private static final int DEFAULT_LEARNING_VERIFY_DURATION = 10;
- // Maximum distance (in standard deviations) for considering a pixel as background
- private static final float DEFAULT_ACCEPT_STDDEV = 0.85f;
- // Variance threshold scale factor for large scale of hierarchy
- private static final float DEFAULT_HIER_LRG_SCALE = 0.7f;
- // Variance threshold scale factor for medium scale of hierarchy
- private static final float DEFAULT_HIER_MID_SCALE = 0.6f;
- // Variance threshold scale factor for small scale of hierarchy
- private static final float DEFAULT_HIER_SML_SCALE = 0.5f;
- // Width of foreground / background mask.
- private static final int DEFAULT_MASK_WIDTH_EXPONENT = 8;
- // Height of foreground / background mask.
- private static final int DEFAULT_MASK_HEIGHT_EXPONENT = 8;
- // Area over which to average for large scale (length in pixels = 2^HIERARCHY_*_EXPONENT)
- private static final int DEFAULT_HIER_LRG_EXPONENT = 3;
- // Area over which to average for medium scale
- private static final int DEFAULT_HIER_MID_EXPONENT = 2;
- // Area over which to average for small scale
- private static final int DEFAULT_HIER_SML_EXPONENT = 0;
- // Scale factor for luminance channel in distance calculations (larger = more significant)
- private static final float DEFAULT_Y_SCALE_FACTOR = 0.40f;
- // Scale factor for chroma channels in distance calculations
- private static final float DEFAULT_UV_SCALE_FACTOR = 1.35f;
- // Mask value to start blending away from background
- private static final float DEFAULT_MASK_BLEND_BG = 0.65f;
- // Mask value to start blending away from foreground
- private static final float DEFAULT_MASK_BLEND_FG = 0.95f;
- // Exposure stop number to change the brightness of foreground
- private static final float DEFAULT_EXPOSURE_CHANGE = 1.0f;
- // White balance change in Red channel for foreground
- private static final float DEFAULT_WHITE_BALANCE_RED_CHANGE = 0.0f;
- // White balance change in Blue channel for foreground
- private static final float DEFAULT_WHITE_BALANCE_BLUE_CHANGE = 0.0f;
- // Variable to control automatic white balance effect
- // 0.f -> Auto WB is off; 1.f-> Auto WB is on
- private static final int DEFAULT_WHITE_BALANCE_TOGGLE = 0;
-
- // Default rate at which to learn bg model during learning period
- private static final float DEFAULT_LEARNING_ADAPT_RATE = 0.2f;
- // Default rate at which to learn bg model from new background pixels
- private static final float DEFAULT_ADAPT_RATE_BG = 0.0f;
- // Default rate at which to learn bg model from new foreground pixels
- private static final float DEFAULT_ADAPT_RATE_FG = 0.0f;
- // Default rate at which to verify whether background is stable
- private static final float DEFAULT_MASK_VERIFY_RATE = 0.25f;
- // Default rate at which to verify whether background is stable
- private static final int DEFAULT_LEARNING_DONE_THRESHOLD = 20;
-
- // Default 3x3 matrix, column major, for fitting background 1:1
- private static final float[] DEFAULT_BG_FIT_TRANSFORM = new float[] {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f
- };
-
- /** Default algorithm parameter values, for shader use */
-
- // Area over which to blur binary mask values (length in pixels = 2^MASK_SMOOTH_EXPONENT)
- private static final String MASK_SMOOTH_EXPONENT = "2.0";
- // Scale value for mapping variance distance to fit nicely to 0-1, 8-bit
- private static final String DISTANCE_STORAGE_SCALE = "0.6";
- // Scale value for mapping variance to fit nicely to 0-1, 8-bit
- private static final String VARIANCE_STORAGE_SCALE = "5.0";
- // Default scale of auto white balance parameters
- private static final String DEFAULT_AUTO_WB_SCALE = "0.25";
- // Minimum variance (0-255 scale)
- private static final String MIN_VARIANCE = "3.0";
- // Column-major array for 4x4 matrix converting RGB to YCbCr, JPEG definition (no pedestal)
- private static final String RGB_TO_YUV_MATRIX = "0.299, -0.168736, 0.5, 0.000, " +
- "0.587, -0.331264, -0.418688, 0.000, " +
- "0.114, 0.5, -0.081312, 0.000, " +
- "0.000, 0.5, 0.5, 1.000 ";
- /** Stream names */
-
- private static final String[] mInputNames = {"video",
- "background"};
-
- private static final String[] mOutputNames = {"video"};
-
- private static final String[] mDebugOutputNames = {"debug1",
- "debug2"};
-
- /** Other private variables */
-
- private FrameFormat mOutputFormat;
- private MutableFrameFormat mMemoryFormat;
- private MutableFrameFormat mMaskFormat;
- private MutableFrameFormat mAverageFormat;
-
- private final boolean mLogVerbose;
- private static final String TAG = "BackDropperFilter";
-
- /** Shader source code */
-
- // Shared uniforms and utility functions
- private static String mSharedUtilShader =
- "precision mediump float;\n" +
- "uniform float fg_adapt_rate;\n" +
- "uniform float bg_adapt_rate;\n" +
- "const mat4 coeff_yuv = mat4(" + RGB_TO_YUV_MATRIX + ");\n" +
- "const float dist_scale = " + DISTANCE_STORAGE_SCALE + ";\n" +
- "const float inv_dist_scale = 1. / dist_scale;\n" +
- "const float var_scale=" + VARIANCE_STORAGE_SCALE + ";\n" +
- "const float inv_var_scale = 1. / var_scale;\n" +
- "const float min_variance = inv_var_scale *" + MIN_VARIANCE + "/ 256.;\n" +
- "const float auto_wb_scale = " + DEFAULT_AUTO_WB_SCALE + ";\n" +
- "\n" +
- // Variance distance in luminance between current pixel and background model
- "float gauss_dist_y(float y, float mean, float variance) {\n" +
- " float dist = (y - mean) * (y - mean) / variance;\n" +
- " return dist;\n" +
- "}\n" +
- // Sum of variance distances in chroma between current pixel and background
- // model
- "float gauss_dist_uv(vec2 uv, vec2 mean, vec2 variance) {\n" +
- " vec2 dist = (uv - mean) * (uv - mean) / variance;\n" +
- " return dist.r + dist.g;\n" +
- "}\n" +
- // Select learning rate for pixel based on smoothed decision mask alpha
- "float local_adapt_rate(float alpha) {\n" +
- " return mix(bg_adapt_rate, fg_adapt_rate, alpha);\n" +
- "}\n" +
- "\n";
-
- // Distance calculation shader. Calculates a distance metric between the foreground and the
- // current background model, in both luminance and in chroma (yuv space). Distance is
- // measured in variances from the mean background value. For chroma, the distance is the sum
- // of the two individual color channel distances. The distances are output on the b and alpha
- // channels, r and g are for debug information.
- // Inputs:
- // tex_sampler_0: Mip-map for foreground (live) video frame.
- // tex_sampler_1: Background mean mask.
- // tex_sampler_2: Background variance mask.
- // subsample_level: Level on foreground frame's mip-map.
- private static final String mBgDistanceShader =
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform sampler2D tex_sampler_2;\n" +
- "uniform float subsample_level;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 fg_rgb = texture2D(tex_sampler_0, v_texcoord, subsample_level);\n" +
- " vec4 fg = coeff_yuv * vec4(fg_rgb.rgb, 1.);\n" +
- " vec4 mean = texture2D(tex_sampler_1, v_texcoord);\n" +
- " vec4 variance = inv_var_scale * texture2D(tex_sampler_2, v_texcoord);\n" +
- "\n" +
- " float dist_y = gauss_dist_y(fg.r, mean.r, variance.r);\n" +
- " float dist_uv = gauss_dist_uv(fg.gb, mean.gb, variance.gb);\n" +
- " gl_FragColor = vec4(0.5*fg.rg, dist_scale*dist_y, dist_scale*dist_uv);\n" +
- "}\n";
-
- // Foreground/background mask decision shader. Decides whether a frame is in the foreground or
- // the background using a hierarchical threshold on the distance. Binary foreground/background
- // mask is placed in the alpha channel. The RGB channels contain debug information.
- private static final String mBgMaskShader =
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform float accept_variance;\n" +
- "uniform vec2 yuv_weights;\n" +
- "uniform float scale_lrg;\n" +
- "uniform float scale_mid;\n" +
- "uniform float scale_sml;\n" +
- "uniform float exp_lrg;\n" +
- "uniform float exp_mid;\n" +
- "uniform float exp_sml;\n" +
- "varying vec2 v_texcoord;\n" +
- // Decide whether pixel is foreground or background based on Y and UV
- // distance and maximum acceptable variance.
- // yuv_weights.x is smaller than yuv_weights.y to discount the influence of shadow
- "bool is_fg(vec2 dist_yc, float accept_variance) {\n" +
- " return ( dot(yuv_weights, dist_yc) >= accept_variance );\n" +
- "}\n" +
- "void main() {\n" +
- " vec4 dist_lrg_sc = texture2D(tex_sampler_0, v_texcoord, exp_lrg);\n" +
- " vec4 dist_mid_sc = texture2D(tex_sampler_0, v_texcoord, exp_mid);\n" +
- " vec4 dist_sml_sc = texture2D(tex_sampler_0, v_texcoord, exp_sml);\n" +
- " vec2 dist_lrg = inv_dist_scale * dist_lrg_sc.ba;\n" +
- " vec2 dist_mid = inv_dist_scale * dist_mid_sc.ba;\n" +
- " vec2 dist_sml = inv_dist_scale * dist_sml_sc.ba;\n" +
- " vec2 norm_dist = 0.75 * dist_sml / accept_variance;\n" + // For debug viz
- " bool is_fg_lrg = is_fg(dist_lrg, accept_variance * scale_lrg);\n" +
- " bool is_fg_mid = is_fg_lrg || is_fg(dist_mid, accept_variance * scale_mid);\n" +
- " float is_fg_sml =\n" +
- " float(is_fg_mid || is_fg(dist_sml, accept_variance * scale_sml));\n" +
- " float alpha = 0.5 * is_fg_sml + 0.3 * float(is_fg_mid) + 0.2 * float(is_fg_lrg);\n" +
- " gl_FragColor = vec4(alpha, norm_dist, is_fg_sml);\n" +
- "}\n";
-
- // Automatic White Balance parameter decision shader
- // Use the Gray World assumption that in a white balance corrected image, the average of R, G, B
- // channel will be a common gray value.
- // To match the white balance of foreground and background, the average of R, G, B channel of
- // two videos should match.
- // Inputs:
- // tex_sampler_0: Mip-map for foreground (live) video frame.
- // tex_sampler_1: Mip-map for background (playback) video frame.
- // pyramid_depth: Depth of input frames' mip-maps.
- private static final String mAutomaticWhiteBalance =
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float pyramid_depth;\n" +
- "uniform bool autowb_toggle;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 mean_video = texture2D(tex_sampler_0, v_texcoord, pyramid_depth);\n"+
- " vec4 mean_bg = texture2D(tex_sampler_1, v_texcoord, pyramid_depth);\n" +
- // If Auto WB is toggled off, the return texture will be a unicolor texture of value 1
- // If Auto WB is toggled on, the return texture will be a unicolor texture with
- // adjustment parameters for R and B channels stored in the corresponding channel
- " float green_normalizer = mean_video.g / mean_bg.g;\n"+
- " vec4 adjusted_value = vec4(mean_bg.r / mean_video.r * green_normalizer, 1., \n" +
- " mean_bg.b / mean_video.b * green_normalizer, 1.) * auto_wb_scale; \n" +
- " gl_FragColor = autowb_toggle ? adjusted_value : vec4(auto_wb_scale);\n" +
- "}\n";
-
-
- // Background subtraction shader. Uses a mipmap of the binary mask map to blend smoothly between
- // foreground and background
- // Inputs:
- // tex_sampler_0: Foreground (live) video frame.
- // tex_sampler_1: Background (playback) video frame.
- // tex_sampler_2: Foreground/background mask.
- // tex_sampler_3: Auto white-balance factors.
- private static final String mBgSubtractShader =
- "uniform mat3 bg_fit_transform;\n" +
- "uniform float mask_blend_bg;\n" +
- "uniform float mask_blend_fg;\n" +
- "uniform float exposure_change;\n" +
- "uniform float whitebalancered_change;\n" +
- "uniform float whitebalanceblue_change;\n" +
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform sampler2D tex_sampler_2;\n" +
- "uniform sampler2D tex_sampler_3;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec2 bg_texcoord = (bg_fit_transform * vec3(v_texcoord, 1.)).xy;\n" +
- " vec4 bg_rgb = texture2D(tex_sampler_1, bg_texcoord);\n" +
- // The foreground texture is modified by multiplying both manual and auto white balance changes in R and B
- // channel and multiplying exposure change in all R, G, B channels.
- " vec4 wb_auto_scale = texture2D(tex_sampler_3, v_texcoord) * exposure_change / auto_wb_scale;\n" +
- " vec4 wb_manual_scale = vec4(1. + whitebalancered_change, 1., 1. + whitebalanceblue_change, 1.);\n" +
- " vec4 fg_rgb = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec4 fg_adjusted = fg_rgb * wb_manual_scale * wb_auto_scale;\n"+
- " vec4 mask = texture2D(tex_sampler_2, v_texcoord, \n" +
- " " + MASK_SMOOTH_EXPONENT + ");\n" +
- " float alpha = smoothstep(mask_blend_bg, mask_blend_fg, mask.a);\n" +
- " gl_FragColor = mix(bg_rgb, fg_adjusted, alpha);\n";
-
- // May the Force... Makes the foreground object translucent blue, with a bright
- // blue-white outline
- private static final String mBgSubtractForceShader =
- " vec4 ghost_rgb = (fg_adjusted * 0.7 + vec4(0.3,0.3,0.4,0.))*0.65 + \n" +
- " 0.35*bg_rgb;\n" +
- " float glow_start = 0.75 * mask_blend_bg; \n"+
- " float glow_max = mask_blend_bg; \n"+
- " gl_FragColor = mask.a < glow_start ? bg_rgb : \n" +
- " mask.a < glow_max ? mix(bg_rgb, vec4(0.9,0.9,1.0,1.0), \n" +
- " (mask.a - glow_start) / (glow_max - glow_start) ) : \n" +
- " mask.a < mask_blend_fg ? mix(vec4(0.9,0.9,1.0,1.0), ghost_rgb, \n" +
- " (mask.a - glow_max) / (mask_blend_fg - glow_max) ) : \n" +
- " ghost_rgb;\n" +
- "}\n";
-
- // Background model mean update shader. Skews the current model mean toward the most recent pixel
- // value for a pixel, weighted by the learning rate and by whether the pixel is classified as
- // foreground or background.
- // Inputs:
- // tex_sampler_0: Mip-map for foreground (live) video frame.
- // tex_sampler_1: Background mean mask.
- // tex_sampler_2: Foreground/background mask.
- // subsample_level: Level on foreground frame's mip-map.
- private static final String mUpdateBgModelMeanShader =
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform sampler2D tex_sampler_2;\n" +
- "uniform float subsample_level;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 fg_rgb = texture2D(tex_sampler_0, v_texcoord, subsample_level);\n" +
- " vec4 fg = coeff_yuv * vec4(fg_rgb.rgb, 1.);\n" +
- " vec4 mean = texture2D(tex_sampler_1, v_texcoord);\n" +
- " vec4 mask = texture2D(tex_sampler_2, v_texcoord, \n" +
- " " + MASK_SMOOTH_EXPONENT + ");\n" +
- "\n" +
- " float alpha = local_adapt_rate(mask.a);\n" +
- " vec4 new_mean = mix(mean, fg, alpha);\n" +
- " gl_FragColor = new_mean;\n" +
- "}\n";
-
- // Background model variance update shader. Skews the current model variance toward the most
- // recent variance for the pixel, weighted by the learning rate and by whether the pixel is
- // classified as foreground or background.
- // Inputs:
- // tex_sampler_0: Mip-map for foreground (live) video frame.
- // tex_sampler_1: Background mean mask.
- // tex_sampler_2: Background variance mask.
- // tex_sampler_3: Foreground/background mask.
- // subsample_level: Level on foreground frame's mip-map.
- // TODO: to improve efficiency, use single mark for mean + variance, then merge this into
- // mUpdateBgModelMeanShader.
- private static final String mUpdateBgModelVarianceShader =
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform sampler2D tex_sampler_2;\n" +
- "uniform sampler2D tex_sampler_3;\n" +
- "uniform float subsample_level;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 fg_rgb = texture2D(tex_sampler_0, v_texcoord, subsample_level);\n" +
- " vec4 fg = coeff_yuv * vec4(fg_rgb.rgb, 1.);\n" +
- " vec4 mean = texture2D(tex_sampler_1, v_texcoord);\n" +
- " vec4 variance = inv_var_scale * texture2D(tex_sampler_2, v_texcoord);\n" +
- " vec4 mask = texture2D(tex_sampler_3, v_texcoord, \n" +
- " " + MASK_SMOOTH_EXPONENT + ");\n" +
- "\n" +
- " float alpha = local_adapt_rate(mask.a);\n" +
- " vec4 cur_variance = (fg-mean)*(fg-mean);\n" +
- " vec4 new_variance = mix(variance, cur_variance, alpha);\n" +
- " new_variance = max(new_variance, vec4(min_variance));\n" +
- " gl_FragColor = var_scale * new_variance;\n" +
- "}\n";
-
- // Background verification shader. Skews the current background verification mask towards the
- // most recent frame, weighted by the learning rate.
- private static final String mMaskVerifyShader =
- "uniform sampler2D tex_sampler_0;\n" +
- "uniform sampler2D tex_sampler_1;\n" +
- "uniform float verify_rate;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " vec4 lastmask = texture2D(tex_sampler_0, v_texcoord);\n" +
- " vec4 mask = texture2D(tex_sampler_1, v_texcoord);\n" +
- " float newmask = mix(lastmask.a, mask.a, verify_rate);\n" +
- " gl_FragColor = vec4(0., 0., 0., newmask);\n" +
- "}\n";
-
- /** Shader program objects */
-
- private ShaderProgram mBgDistProgram;
- private ShaderProgram mBgMaskProgram;
- private ShaderProgram mBgSubtractProgram;
- private ShaderProgram mBgUpdateMeanProgram;
- private ShaderProgram mBgUpdateVarianceProgram;
- private ShaderProgram mCopyOutProgram;
- private ShaderProgram mAutomaticWhiteBalanceProgram;
- private ShaderProgram mMaskVerifyProgram;
- private ShaderProgram copyShaderProgram;
-
- /** Background model storage */
-
- private boolean mPingPong;
- private GLFrame mBgMean[];
- private GLFrame mBgVariance[];
- private GLFrame mMaskVerify[];
- private GLFrame mDistance;
- private GLFrame mAutoWB;
- private GLFrame mMask;
- private GLFrame mVideoInput;
- private GLFrame mBgInput;
- private GLFrame mMaskAverage;
-
- /** Overall filter state */
-
- private boolean isOpen;
- private int mFrameCount;
- private boolean mStartLearning;
- private boolean mBackgroundFitModeChanged;
- private float mRelativeAspect;
- private int mPyramidDepth;
- private int mSubsampleLevel;
-
- /** Learning listener object */
-
- public interface LearningDoneListener {
- public void onLearningDone(BackDropperFilter filter);
- }
-
- /** Public Filter methods */
-
- public BackDropperFilter(String name) {
- super(name);
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void setupPorts() {
- // Inputs.
- // TODO: Target should be GPU, but relaxed for now.
- FrameFormat imageFormat = ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_UNSPECIFIED);
- for (String inputName : mInputNames) {
- addMaskedInputPort(inputName, imageFormat);
- }
- // Normal outputs
- for (String outputName : mOutputNames) {
- addOutputBasedOnInput(outputName, "video");
- }
-
- // Debug outputs
- if (mProvideDebugOutputs) {
- for (String outputName : mDebugOutputNames) {
- addOutputBasedOnInput(outputName, "video");
- }
- }
- }
-
- @Override
- public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
- // Create memory format based on video input.
- MutableFrameFormat format = inputFormat.mutableCopy();
- // Is this a debug output port? If so, leave dimensions unspecified.
- if (!Arrays.asList(mOutputNames).contains(portName)) {
- format.setDimensions(FrameFormat.SIZE_UNSPECIFIED, FrameFormat.SIZE_UNSPECIFIED);
- }
- return format;
- }
-
- private boolean createMemoryFormat(FrameFormat inputFormat) {
- // We can't resize because that would require re-learning.
- if (mMemoryFormat != null) {
- return false;
- }
-
- if (inputFormat.getWidth() == FrameFormat.SIZE_UNSPECIFIED ||
- inputFormat.getHeight() == FrameFormat.SIZE_UNSPECIFIED) {
- throw new RuntimeException("Attempting to process input frame with unknown size");
- }
-
- mMaskFormat = inputFormat.mutableCopy();
- int maskWidth = (int)Math.pow(2, mMaskWidthExp);
- int maskHeight = (int)Math.pow(2, mMaskHeightExp);
- mMaskFormat.setDimensions(maskWidth, maskHeight);
-
- mPyramidDepth = Math.max(mMaskWidthExp, mMaskHeightExp);
- mMemoryFormat = mMaskFormat.mutableCopy();
- int widthExp = Math.max(mMaskWidthExp, pyramidLevel(inputFormat.getWidth()));
- int heightExp = Math.max(mMaskHeightExp, pyramidLevel(inputFormat.getHeight()));
- mPyramidDepth = Math.max(widthExp, heightExp);
- int memWidth = Math.max(maskWidth, (int)Math.pow(2, widthExp));
- int memHeight = Math.max(maskHeight, (int)Math.pow(2, heightExp));
- mMemoryFormat.setDimensions(memWidth, memHeight);
- mSubsampleLevel = mPyramidDepth - Math.max(mMaskWidthExp, mMaskHeightExp);
-
- if (mLogVerbose) {
- Log.v(TAG, "Mask frames size " + maskWidth + " x " + maskHeight);
- Log.v(TAG, "Pyramid levels " + widthExp + " x " + heightExp);
- Log.v(TAG, "Memory frames size " + memWidth + " x " + memHeight);
- }
-
- mAverageFormat = inputFormat.mutableCopy();
- mAverageFormat.setDimensions(1,1);
- return true;
- }
-
- public void prepare(FilterContext context){
- if (mLogVerbose) Log.v(TAG, "Preparing BackDropperFilter!");
-
- mBgMean = new GLFrame[2];
- mBgVariance = new GLFrame[2];
- mMaskVerify = new GLFrame[2];
- copyShaderProgram = ShaderProgram.createIdentity(context);
- }
-
- private void allocateFrames(FrameFormat inputFormat, FilterContext context) {
- if (!createMemoryFormat(inputFormat)) {
- return; // All set.
- }
- if (mLogVerbose) Log.v(TAG, "Allocating BackDropperFilter frames");
-
- // Create initial background model values
- int numBytes = mMaskFormat.getSize();
- byte[] initialBgMean = new byte[numBytes];
- byte[] initialBgVariance = new byte[numBytes];
- byte[] initialMaskVerify = new byte[numBytes];
- for (int i = 0; i < numBytes; i++) {
- initialBgMean[i] = (byte)128;
- initialBgVariance[i] = (byte)10;
- initialMaskVerify[i] = (byte)0;
- }
-
- // Get frames to store background model in
- for (int i = 0; i < 2; i++) {
- mBgMean[i] = (GLFrame)context.getFrameManager().newFrame(mMaskFormat);
- mBgMean[i].setData(initialBgMean, 0, numBytes);
-
- mBgVariance[i] = (GLFrame)context.getFrameManager().newFrame(mMaskFormat);
- mBgVariance[i].setData(initialBgVariance, 0, numBytes);
-
- mMaskVerify[i] = (GLFrame)context.getFrameManager().newFrame(mMaskFormat);
- mMaskVerify[i].setData(initialMaskVerify, 0, numBytes);
- }
-
- // Get frames to store other textures in
- if (mLogVerbose) Log.v(TAG, "Done allocating texture for Mean and Variance objects!");
-
- mDistance = (GLFrame)context.getFrameManager().newFrame(mMaskFormat);
- mMask = (GLFrame)context.getFrameManager().newFrame(mMaskFormat);
- mAutoWB = (GLFrame)context.getFrameManager().newFrame(mAverageFormat);
- mVideoInput = (GLFrame)context.getFrameManager().newFrame(mMemoryFormat);
- mBgInput = (GLFrame)context.getFrameManager().newFrame(mMemoryFormat);
- mMaskAverage = (GLFrame)context.getFrameManager().newFrame(mAverageFormat);
-
- // Create shader programs
- mBgDistProgram = new ShaderProgram(context, mSharedUtilShader + mBgDistanceShader);
- mBgDistProgram.setHostValue("subsample_level", (float)mSubsampleLevel);
-
- mBgMaskProgram = new ShaderProgram(context, mSharedUtilShader + mBgMaskShader);
- mBgMaskProgram.setHostValue("accept_variance", mAcceptStddev * mAcceptStddev);
- float[] yuvWeights = { mLumScale, mChromaScale };
- mBgMaskProgram.setHostValue("yuv_weights", yuvWeights );
- mBgMaskProgram.setHostValue("scale_lrg", mHierarchyLrgScale);
- mBgMaskProgram.setHostValue("scale_mid", mHierarchyMidScale);
- mBgMaskProgram.setHostValue("scale_sml", mHierarchySmlScale);
- mBgMaskProgram.setHostValue("exp_lrg", (float)(mSubsampleLevel + mHierarchyLrgExp));
- mBgMaskProgram.setHostValue("exp_mid", (float)(mSubsampleLevel + mHierarchyMidExp));
- mBgMaskProgram.setHostValue("exp_sml", (float)(mSubsampleLevel + mHierarchySmlExp));
-
- if (mUseTheForce) {
- mBgSubtractProgram = new ShaderProgram(context, mSharedUtilShader + mBgSubtractShader + mBgSubtractForceShader);
- } else {
- mBgSubtractProgram = new ShaderProgram(context, mSharedUtilShader + mBgSubtractShader + "}\n");
- }
- mBgSubtractProgram.setHostValue("bg_fit_transform", DEFAULT_BG_FIT_TRANSFORM);
- mBgSubtractProgram.setHostValue("mask_blend_bg", mMaskBg);
- mBgSubtractProgram.setHostValue("mask_blend_fg", mMaskFg);
- mBgSubtractProgram.setHostValue("exposure_change", mExposureChange);
- mBgSubtractProgram.setHostValue("whitebalanceblue_change", mWhiteBalanceBlueChange);
- mBgSubtractProgram.setHostValue("whitebalancered_change", mWhiteBalanceRedChange);
-
-
- mBgUpdateMeanProgram = new ShaderProgram(context, mSharedUtilShader + mUpdateBgModelMeanShader);
- mBgUpdateMeanProgram.setHostValue("subsample_level", (float)mSubsampleLevel);
-
- mBgUpdateVarianceProgram = new ShaderProgram(context, mSharedUtilShader + mUpdateBgModelVarianceShader);
- mBgUpdateVarianceProgram.setHostValue("subsample_level", (float)mSubsampleLevel);
-
- mCopyOutProgram = ShaderProgram.createIdentity(context);
-
- mAutomaticWhiteBalanceProgram = new ShaderProgram(context, mSharedUtilShader + mAutomaticWhiteBalance);
- mAutomaticWhiteBalanceProgram.setHostValue("pyramid_depth", (float)mPyramidDepth);
- mAutomaticWhiteBalanceProgram.setHostValue("autowb_toggle", mAutoWBToggle);
-
- mMaskVerifyProgram = new ShaderProgram(context, mSharedUtilShader + mMaskVerifyShader);
- mMaskVerifyProgram.setHostValue("verify_rate", mVerifyRate);
-
- if (mLogVerbose) Log.v(TAG, "Shader width set to " + mMemoryFormat.getWidth());
-
- mRelativeAspect = 1.f;
-
- mFrameCount = 0;
- mStartLearning = true;
- }
-
- public void process(FilterContext context) {
- // Grab inputs and ready intermediate frames and outputs.
- Frame video = pullInput("video");
- Frame background = pullInput("background");
- allocateFrames(video.getFormat(), context);
-
- // Update learning rate after initial learning period
- if (mStartLearning) {
- if (mLogVerbose) Log.v(TAG, "Starting learning");
- mBgUpdateMeanProgram.setHostValue("bg_adapt_rate", mAdaptRateLearning);
- mBgUpdateMeanProgram.setHostValue("fg_adapt_rate", mAdaptRateLearning);
- mBgUpdateVarianceProgram.setHostValue("bg_adapt_rate", mAdaptRateLearning);
- mBgUpdateVarianceProgram.setHostValue("fg_adapt_rate", mAdaptRateLearning);
- mFrameCount = 0;
- mStartLearning = false;
- }
-
- // Select correct pingpong buffers
- int inputIndex = mPingPong ? 0 : 1;
- int outputIndex = mPingPong ? 1 : 0;
- mPingPong = !mPingPong;
-
- // Check relative aspect ratios
- updateBgScaling(video, background, mBackgroundFitModeChanged);
- mBackgroundFitModeChanged = false;
-
- // Make copies for input frames to GLFrames
-
- copyShaderProgram.process(video, mVideoInput);
- copyShaderProgram.process(background, mBgInput);
-
- mVideoInput.generateMipMap();
- mVideoInput.setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
-
- mBgInput.generateMipMap();
- mBgInput.setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
-
- // Process shaders
- Frame[] distInputs = { mVideoInput, mBgMean[inputIndex], mBgVariance[inputIndex] };
- mBgDistProgram.process(distInputs, mDistance);
- mDistance.generateMipMap();
- mDistance.setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
-
- mBgMaskProgram.process(mDistance, mMask);
- mMask.generateMipMap();
- mMask.setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
-
- Frame[] autoWBInputs = { mVideoInput, mBgInput };
- mAutomaticWhiteBalanceProgram.process(autoWBInputs, mAutoWB);
-
- if (mFrameCount <= mLearningDuration) {
- // During learning
- pushOutput("video", video);
-
- if (mFrameCount == mLearningDuration - mLearningVerifyDuration) {
- copyShaderProgram.process(mMask, mMaskVerify[outputIndex]);
-
- mBgUpdateMeanProgram.setHostValue("bg_adapt_rate", mAdaptRateBg);
- mBgUpdateMeanProgram.setHostValue("fg_adapt_rate", mAdaptRateFg);
- mBgUpdateVarianceProgram.setHostValue("bg_adapt_rate", mAdaptRateBg);
- mBgUpdateVarianceProgram.setHostValue("fg_adapt_rate", mAdaptRateFg);
-
-
- } else if (mFrameCount > mLearningDuration - mLearningVerifyDuration) {
- // In the learning verification stage, compute background masks and a weighted average
- // with weights grow exponentially with time
- Frame[] maskVerifyInputs = {mMaskVerify[inputIndex], mMask};
- mMaskVerifyProgram.process(maskVerifyInputs, mMaskVerify[outputIndex]);
- mMaskVerify[outputIndex].generateMipMap();
- mMaskVerify[outputIndex].setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
- }
-
- if (mFrameCount == mLearningDuration) {
- // In the last verification frame, verify if the verification mask is almost blank
- // If not, restart learning
- copyShaderProgram.process(mMaskVerify[outputIndex], mMaskAverage);
- ByteBuffer mMaskAverageByteBuffer = mMaskAverage.getData();
- byte[] mask_average = mMaskAverageByteBuffer.array();
- int bi = (int)(mask_average[3] & 0xFF);
- if (mLogVerbose) Log.v(TAG, String.format("Mask_average is %d", bi));
-
- if (bi >= DEFAULT_LEARNING_DONE_THRESHOLD) {
- mStartLearning = true; // Restart learning
- } else {
- if (mLogVerbose) Log.v(TAG, "Learning done");
- if (mLearningDoneListener != null) {
- mLearningDoneListener.onLearningDone(this);
- }
- }
- }
- } else {
- Frame output = context.getFrameManager().newFrame(video.getFormat());
- Frame[] subtractInputs = { video, background, mMask, mAutoWB };
- mBgSubtractProgram.process(subtractInputs, output);
- pushOutput("video", output);
- output.release();
- }
-
- // Compute mean and variance of the background
- if (mFrameCount < mLearningDuration - mLearningVerifyDuration ||
- mAdaptRateBg > 0.0 || mAdaptRateFg > 0.0) {
- Frame[] meanUpdateInputs = { mVideoInput, mBgMean[inputIndex], mMask };
- mBgUpdateMeanProgram.process(meanUpdateInputs, mBgMean[outputIndex]);
- mBgMean[outputIndex].generateMipMap();
- mBgMean[outputIndex].setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
-
- Frame[] varianceUpdateInputs = {
- mVideoInput, mBgMean[inputIndex], mBgVariance[inputIndex], mMask
- };
- mBgUpdateVarianceProgram.process(varianceUpdateInputs, mBgVariance[outputIndex]);
- mBgVariance[outputIndex].generateMipMap();
- mBgVariance[outputIndex].setTextureParameter(GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR_MIPMAP_NEAREST);
- }
-
- // Provide debug output to two smaller viewers
- if (mProvideDebugOutputs) {
- Frame dbg1 = context.getFrameManager().newFrame(video.getFormat());
- mCopyOutProgram.process(video, dbg1);
- pushOutput("debug1", dbg1);
- dbg1.release();
-
- Frame dbg2 = context.getFrameManager().newFrame(mMemoryFormat);
- mCopyOutProgram.process(mMask, dbg2);
- pushOutput("debug2", dbg2);
- dbg2.release();
- }
-
- mFrameCount++;
-
- if (mLogVerbose) {
- if (mFrameCount % 30 == 0) {
- if (startTime == -1) {
- context.getGLEnvironment().activate();
- GLES20.glFinish();
- startTime = SystemClock.elapsedRealtime();
- } else {
- context.getGLEnvironment().activate();
- GLES20.glFinish();
- long endTime = SystemClock.elapsedRealtime();
- Log.v(TAG, "Avg. frame duration: " + String.format("%.2f",(endTime-startTime)/30.) +
- " ms. Avg. fps: " + String.format("%.2f", 1000./((endTime-startTime)/30.)) );
- startTime = endTime;
- }
- }
- }
- }
-
- private long startTime = -1;
-
- public void close(FilterContext context) {
- if (mMemoryFormat == null) {
- return;
- }
-
- if (mLogVerbose) Log.v(TAG, "Filter Closing!");
- for (int i = 0; i < 2; i++) {
- mBgMean[i].release();
- mBgVariance[i].release();
- mMaskVerify[i].release();
- }
- mDistance.release();
- mMask.release();
- mAutoWB.release();
- mVideoInput.release();
- mBgInput.release();
- mMaskAverage.release();
-
- mMemoryFormat = null;
- }
-
- // Relearn background model
- synchronized public void relearn() {
- // Let the processing thread know about learning restart
- mStartLearning = true;
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- // TODO: Many of these can be made ProgramPorts!
- if (name.equals("backgroundFitMode")) {
- mBackgroundFitModeChanged = true;
- } else if (name.equals("acceptStddev")) {
- mBgMaskProgram.setHostValue("accept_variance", mAcceptStddev * mAcceptStddev);
- } else if (name.equals("hierLrgScale")) {
- mBgMaskProgram.setHostValue("scale_lrg", mHierarchyLrgScale);
- } else if (name.equals("hierMidScale")) {
- mBgMaskProgram.setHostValue("scale_mid", mHierarchyMidScale);
- } else if (name.equals("hierSmlScale")) {
- mBgMaskProgram.setHostValue("scale_sml", mHierarchySmlScale);
- } else if (name.equals("hierLrgExp")) {
- mBgMaskProgram.setHostValue("exp_lrg", (float)(mSubsampleLevel + mHierarchyLrgExp));
- } else if (name.equals("hierMidExp")) {
- mBgMaskProgram.setHostValue("exp_mid", (float)(mSubsampleLevel + mHierarchyMidExp));
- } else if (name.equals("hierSmlExp")) {
- mBgMaskProgram.setHostValue("exp_sml", (float)(mSubsampleLevel + mHierarchySmlExp));
- } else if (name.equals("lumScale") || name.equals("chromaScale")) {
- float[] yuvWeights = { mLumScale, mChromaScale };
- mBgMaskProgram.setHostValue("yuv_weights", yuvWeights );
- } else if (name.equals("maskBg")) {
- mBgSubtractProgram.setHostValue("mask_blend_bg", mMaskBg);
- } else if (name.equals("maskFg")) {
- mBgSubtractProgram.setHostValue("mask_blend_fg", mMaskFg);
- } else if (name.equals("exposureChange")) {
- mBgSubtractProgram.setHostValue("exposure_change", mExposureChange);
- } else if (name.equals("whitebalanceredChange")) {
- mBgSubtractProgram.setHostValue("whitebalancered_change", mWhiteBalanceRedChange);
- } else if (name.equals("whitebalanceblueChange")) {
- mBgSubtractProgram.setHostValue("whitebalanceblue_change", mWhiteBalanceBlueChange);
- } else if (name.equals("autowbToggle")){
- mAutomaticWhiteBalanceProgram.setHostValue("autowb_toggle", mAutoWBToggle);
- }
- }
-
- private void updateBgScaling(Frame video, Frame background, boolean fitModeChanged) {
- float foregroundAspect = (float)video.getFormat().getWidth() / video.getFormat().getHeight();
- float backgroundAspect = (float)background.getFormat().getWidth() / background.getFormat().getHeight();
- float currentRelativeAspect = foregroundAspect/backgroundAspect;
- if (currentRelativeAspect != mRelativeAspect || fitModeChanged) {
- mRelativeAspect = currentRelativeAspect;
- float xMin = 0.f, xWidth = 1.f, yMin = 0.f, yWidth = 1.f;
- switch (mBackgroundFitMode) {
- case BACKGROUND_STRETCH:
- // Just map 1:1
- break;
- case BACKGROUND_FIT:
- if (mRelativeAspect > 1.0f) {
- // Foreground is wider than background, scale down
- // background in X
- xMin = 0.5f - 0.5f * mRelativeAspect;
- xWidth = 1.f * mRelativeAspect;
- } else {
- // Foreground is taller than background, scale down
- // background in Y
- yMin = 0.5f - 0.5f / mRelativeAspect;
- yWidth = 1 / mRelativeAspect;
- }
- break;
- case BACKGROUND_FILL_CROP:
- if (mRelativeAspect > 1.0f) {
- // Foreground is wider than background, crop
- // background in Y
- yMin = 0.5f - 0.5f / mRelativeAspect;
- yWidth = 1.f / mRelativeAspect;
- } else {
- // Foreground is taller than background, crop
- // background in X
- xMin = 0.5f - 0.5f * mRelativeAspect;
- xWidth = mRelativeAspect;
- }
- break;
- }
- // If mirroring is required (for ex. the camera mirrors the preview
- // in the front camera)
- // TODO: Backdropper does not attempt to apply any other transformation
- // than just flipping. However, in the current state, it's "x-axis" is always aligned
- // with the Camera's width. Hence, we need to define the mirroring based on the camera
- // orientation. In the future, a cleaner design would be to cast away all the rotation
- // in a separate place.
- if (mMirrorBg) {
- if (mLogVerbose) Log.v(TAG, "Mirroring the background!");
- // Mirroring in portrait
- if (mOrientation == 0 || mOrientation == 180) {
- xWidth = -xWidth;
- xMin = 1.0f - xMin;
- } else {
- // Mirroring in landscape
- yWidth = -yWidth;
- yMin = 1.0f - yMin;
- }
- }
- if (mLogVerbose) Log.v(TAG, "bgTransform: xMin, yMin, xWidth, yWidth : " +
- xMin + ", " + yMin + ", " + xWidth + ", " + yWidth +
- ", mRelAspRatio = " + mRelativeAspect);
- // The following matrix is the transpose of the actual matrix
- float[] bgTransform = {xWidth, 0.f, 0.f,
- 0.f, yWidth, 0.f,
- xMin, yMin, 1.f};
- mBgSubtractProgram.setHostValue("bg_fit_transform", bgTransform);
- }
- }
-
- private int pyramidLevel(int size) {
- return (int)Math.floor(Math.log10(size) / Math.log10(2)) - 1;
- }
-
-}
diff --git a/mca/filterpacks/videosink/java/MediaEncoderFilter.java b/mca/filterpacks/videosink/java/MediaEncoderFilter.java
deleted file mode 100644
index 3657d8a..0000000
--- a/mca/filterpacks/videosink/java/MediaEncoderFilter.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.videosink;
-
-import android.content.Context;
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.filterfw.geometry.Point;
-import android.filterfw.geometry.Quad;
-import android.os.ConditionVariable;
-import android.media.MediaRecorder;
-import android.media.CamcorderProfile;
-import android.filterfw.core.GLEnvironment;
-
-import java.io.IOException;
-import java.io.FileDescriptor;
-import java.util.List;
-import java.util.Set;
-
-import android.util.Log;
-
-/** @hide */
-public class MediaEncoderFilter extends Filter {
-
- /** User-visible parameters */
-
- /** Recording state. When set to false, recording will stop, or will not
- * start if not yet running the graph. Instead, frames are simply ignored.
- * When switched back to true, recording will restart. This allows a single
- * graph to both provide preview and to record video. If this is false,
- * recording settings can be updated while the graph is running.
- */
- @GenerateFieldPort(name = "recording", hasDefault = true)
- private boolean mRecording = true;
-
- /** Filename to save the output. */
- @GenerateFieldPort(name = "outputFile", hasDefault = true)
- private String mOutputFile = new String("/sdcard/MediaEncoderOut.mp4");
-
- /** File Descriptor to save the output. */
- @GenerateFieldPort(name = "outputFileDescriptor", hasDefault = true)
- private FileDescriptor mFd = null;
-
- /** Input audio source. If not set, no audio will be recorded.
- * Select from the values in MediaRecorder.AudioSource
- */
- @GenerateFieldPort(name = "audioSource", hasDefault = true)
- private int mAudioSource = NO_AUDIO_SOURCE;
-
- /** Media recorder info listener, which needs to implement
- * MediaRecorder.OnInfoListener. Set this to receive notifications about
- * recording events.
- */
- @GenerateFieldPort(name = "infoListener", hasDefault = true)
- private MediaRecorder.OnInfoListener mInfoListener = null;
-
- /** Media recorder error listener, which needs to implement
- * MediaRecorder.OnErrorListener. Set this to receive notifications about
- * recording errors.
- */
- @GenerateFieldPort(name = "errorListener", hasDefault = true)
- private MediaRecorder.OnErrorListener mErrorListener = null;
-
- /** Media recording done callback, which needs to implement OnRecordingDoneListener.
- * Set this to finalize media upon completion of media recording.
- */
- @GenerateFieldPort(name = "recordingDoneListener", hasDefault = true)
- private OnRecordingDoneListener mRecordingDoneListener = null;
-
- /** Orientation hint. Used for indicating proper video playback orientation.
- * Units are in degrees of clockwise rotation, valid values are (0, 90, 180,
- * 270).
- */
- @GenerateFieldPort(name = "orientationHint", hasDefault = true)
- private int mOrientationHint = 0;
-
- /** Camcorder profile to use. Select from the profiles available in
- * android.media.CamcorderProfile. If this field is set, it overrides
- * settings to width, height, framerate, outputFormat, and videoEncoder.
- */
- @GenerateFieldPort(name = "recordingProfile", hasDefault = true)
- private CamcorderProfile mProfile = null;
-
- /** Frame width to be encoded, defaults to 320.
- * Actual received frame size has to match this */
- @GenerateFieldPort(name = "width", hasDefault = true)
- private int mWidth = 320;
-
- /** Frame height to to be encoded, defaults to 240.
- * Actual received frame size has to match */
- @GenerateFieldPort(name = "height", hasDefault = true)
- private int mHeight = 240;
-
- /** Stream framerate to encode the frames at.
- * By default, frames are encoded at 30 FPS*/
- @GenerateFieldPort(name = "framerate", hasDefault = true)
- private int mFps = 30;
-
- /** The output format to encode the frames in.
- * Choose an output format from the options in
- * android.media.MediaRecorder.OutputFormat */
- @GenerateFieldPort(name = "outputFormat", hasDefault = true)
- private int mOutputFormat = MediaRecorder.OutputFormat.MPEG_4;
-
- /** The videoencoder to encode the frames with.
- * Choose a videoencoder from the options in
- * android.media.MediaRecorder.VideoEncoder */
- @GenerateFieldPort(name = "videoEncoder", hasDefault = true)
- private int mVideoEncoder = MediaRecorder.VideoEncoder.H264;
-
- /** The input region to read from the frame. The corners of this quad are
- * mapped to the output rectangle. The input frame ranges from (0,0)-(1,1),
- * top-left to bottom-right. The corners of the quad are specified in the
- * order bottom-left, bottom-right, top-left, top-right.
- */
- @GenerateFieldPort(name = "inputRegion", hasDefault = true)
- private Quad mSourceRegion;
-
- /** The maximum filesize (in bytes) of the recording session.
- * By default, it will be 0 and will be passed on to the MediaRecorder.
- * If the limit is zero or negative, MediaRecorder will disable the limit*/
- @GenerateFieldPort(name = "maxFileSize", hasDefault = true)
- private long mMaxFileSize = 0;
-
- /** The maximum duration (in milliseconds) of the recording session.
- * By default, it will be 0 and will be passed on to the MediaRecorder.
- * If the limit is zero or negative, MediaRecorder will record indefinitely*/
- @GenerateFieldPort(name = "maxDurationMs", hasDefault = true)
- private int mMaxDurationMs = 0;
-
- /** TimeLapse Interval between frames.
- * By default, it will be 0. Whether the recording is timelapsed
- * is inferred based on its value being greater than 0 */
- @GenerateFieldPort(name = "timelapseRecordingIntervalUs", hasDefault = true)
- private long mTimeBetweenTimeLapseFrameCaptureUs = 0;
-
- // End of user visible parameters
-
- private static final int NO_AUDIO_SOURCE = -1;
-
- private int mSurfaceId;
- private ShaderProgram mProgram;
- private GLFrame mScreen;
-
- private boolean mRecordingActive = false;
- private long mTimestampNs = 0;
- private long mLastTimeLapseFrameRealTimestampNs = 0;
- private int mNumFramesEncoded = 0;
- // Used to indicate whether recording is timelapsed.
- // Inferred based on (mTimeBetweenTimeLapseFrameCaptureUs > 0)
- private boolean mCaptureTimeLapse = false;
-
- private boolean mLogVerbose;
- private static final String TAG = "MediaEncoderFilter";
-
- // Our hook to the encoder
- private MediaRecorder mMediaRecorder;
-
- /** Callback to be called when media recording completes. */
-
- public interface OnRecordingDoneListener {
- public void onRecordingDone();
- }
-
- public MediaEncoderFilter(String name) {
- super(name);
- Point bl = new Point(0, 0);
- Point br = new Point(1, 0);
- Point tl = new Point(0, 1);
- Point tr = new Point(1, 1);
- mSourceRegion = new Quad(bl, br, tl, tr);
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void setupPorts() {
- // Add input port- will accept RGBA GLFrames
- addMaskedInputPort("videoframe", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Port " + name + " has been updated");
- if (name.equals("recording")) return;
- if (name.equals("inputRegion")) {
- if (isOpen()) updateSourceRegion();
- return;
- }
- // TODO: Not sure if it is possible to update the maxFileSize
- // when the recording is going on. For now, not doing that.
- if (isOpen() && mRecordingActive) {
- throw new RuntimeException("Cannot change recording parameters"
- + " when the filter is recording!");
- }
- }
-
- private void updateSourceRegion() {
- // Flip source quad to map to OpenGL origin
- Quad flippedRegion = new Quad();
- flippedRegion.p0 = mSourceRegion.p2;
- flippedRegion.p1 = mSourceRegion.p3;
- flippedRegion.p2 = mSourceRegion.p0;
- flippedRegion.p3 = mSourceRegion.p1;
- mProgram.setSourceRegion(flippedRegion);
- }
-
- // update the MediaRecorderParams based on the variables.
- // These have to be in certain order as per the MediaRecorder
- // documentation
- private void updateMediaRecorderParams() {
- mCaptureTimeLapse = mTimeBetweenTimeLapseFrameCaptureUs > 0;
- final int GRALLOC_BUFFER = 2;
- mMediaRecorder.setVideoSource(GRALLOC_BUFFER);
- if (!mCaptureTimeLapse && (mAudioSource != NO_AUDIO_SOURCE)) {
- mMediaRecorder.setAudioSource(mAudioSource);
- }
- if (mProfile != null) {
- mMediaRecorder.setProfile(mProfile);
- mFps = mProfile.videoFrameRate;
- } else {
- mMediaRecorder.setOutputFormat(mOutputFormat);
- mMediaRecorder.setVideoEncoder(mVideoEncoder);
- mMediaRecorder.setVideoSize(mWidth, mHeight);
- mMediaRecorder.setVideoFrameRate(mFps);
- }
- mMediaRecorder.setOrientationHint(mOrientationHint);
- mMediaRecorder.setOnInfoListener(mInfoListener);
- mMediaRecorder.setOnErrorListener(mErrorListener);
- if (mFd != null) {
- mMediaRecorder.setOutputFile(mFd);
- } else {
- mMediaRecorder.setOutputFile(mOutputFile);
- }
- try {
- mMediaRecorder.setMaxFileSize(mMaxFileSize);
- } catch (Exception e) {
- // Following the logic in VideoCamera.java (in Camera app)
- // We are going to ignore failure of setMaxFileSize here, as
- // a) The composer selected may simply not support it, or
- // b) The underlying media framework may not handle 64-bit range
- // on the size restriction.
- Log.w(TAG, "Setting maxFileSize on MediaRecorder unsuccessful! "
- + e.getMessage());
- }
- mMediaRecorder.setMaxDuration(mMaxDurationMs);
- }
-
- @Override
- public void prepare(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Preparing");
-
- mProgram = ShaderProgram.createIdentity(context);
-
- mRecordingActive = false;
- }
-
- @Override
- public void open(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Opening");
- updateSourceRegion();
- if (mRecording) startRecording(context);
- }
-
- private void startRecording(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Starting recording");
-
- // Create a frame representing the screen
- MutableFrameFormat screenFormat = new MutableFrameFormat(
- FrameFormat.TYPE_BYTE, FrameFormat.TARGET_GPU);
- screenFormat.setBytesPerSample(4);
-
- int width, height;
- if (mProfile != null) {
- width = mProfile.videoFrameWidth;
- height = mProfile.videoFrameHeight;
- } else {
- width = mWidth;
- height = mHeight;
- }
- screenFormat.setDimensions(width, height);
- mScreen = (GLFrame)context.getFrameManager().newBoundFrame(
- screenFormat, GLFrame.EXISTING_FBO_BINDING, 0);
-
- // Initialize the media recorder
-
- mMediaRecorder = new MediaRecorder();
- updateMediaRecorderParams();
-
- try {
- mMediaRecorder.prepare();
- } catch (IllegalStateException e) {
- throw e;
- } catch (IOException e) {
- throw new RuntimeException("IOException in"
- + "MediaRecorder.prepare()!", e);
- } catch (Exception e) {
- throw new RuntimeException("Unknown Exception in"
- + "MediaRecorder.prepare()!", e);
- }
- // Make sure start() is called before trying to
- // register the surface. The native window handle needed to create
- // the surface is initiated in start()
- mMediaRecorder.start();
- if (mLogVerbose) Log.v(TAG, "Open: registering surface from Mediarecorder");
- mSurfaceId = context.getGLEnvironment().
- registerSurfaceFromMediaRecorder(mMediaRecorder);
- mNumFramesEncoded = 0;
- mRecordingActive = true;
- }
-
- public boolean skipFrameAndModifyTimestamp(long timestampNs) {
- // first frame- encode. Don't skip
- if (mNumFramesEncoded == 0) {
- mLastTimeLapseFrameRealTimestampNs = timestampNs;
- mTimestampNs = timestampNs;
- if (mLogVerbose) Log.v(TAG, "timelapse: FIRST frame, last real t= "
- + mLastTimeLapseFrameRealTimestampNs +
- ", setting t = " + mTimestampNs );
- return false;
- }
-
- // Workaround to bypass the first 2 input frames for skipping.
- // The first 2 output frames from the encoder are: decoder specific info and
- // the compressed video frame data for the first input video frame.
- if (mNumFramesEncoded >= 2 && timestampNs <
- (mLastTimeLapseFrameRealTimestampNs + 1000L * mTimeBetweenTimeLapseFrameCaptureUs)) {
- // If 2 frames have been already encoded,
- // Skip all frames from last encoded frame until
- // sufficient time (mTimeBetweenTimeLapseFrameCaptureUs) has passed.
- if (mLogVerbose) Log.v(TAG, "timelapse: skipping intermediate frame");
- return true;
- } else {
- // Desired frame has arrived after mTimeBetweenTimeLapseFrameCaptureUs time:
- // - Reset mLastTimeLapseFrameRealTimestampNs to current time.
- // - Artificially modify timestampNs to be one frame time (1/framerate) ahead
- // of the last encoded frame's time stamp.
- if (mLogVerbose) Log.v(TAG, "timelapse: encoding frame, Timestamp t = " + timestampNs +
- ", last real t= " + mLastTimeLapseFrameRealTimestampNs +
- ", interval = " + mTimeBetweenTimeLapseFrameCaptureUs);
- mLastTimeLapseFrameRealTimestampNs = timestampNs;
- mTimestampNs = mTimestampNs + (1000000000L / (long)mFps);
- if (mLogVerbose) Log.v(TAG, "timelapse: encoding frame, setting t = "
- + mTimestampNs + ", delta t = " + (1000000000L / (long)mFps) +
- ", fps = " + mFps );
- return false;
- }
- }
-
- @Override
- public void process(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Starting frame processing");
-
- GLEnvironment glEnv = context.getGLEnvironment();
- // Get input frame
- Frame input = pullInput("videoframe");
-
- // Check if recording needs to start
- if (!mRecordingActive && mRecording) {
- startRecording(context);
- }
- // Check if recording needs to stop
- if (mRecordingActive && !mRecording) {
- stopRecording(context);
- }
-
- if (!mRecordingActive) return;
-
- if (mCaptureTimeLapse) {
- if (skipFrameAndModifyTimestamp(input.getTimestamp())) {
- return;
- }
- } else {
- mTimestampNs = input.getTimestamp();
- }
-
- // Activate our surface
- glEnv.activateSurfaceWithId(mSurfaceId);
-
- // Process
- mProgram.process(input, mScreen);
-
- // Set timestamp from input
- glEnv.setSurfaceTimestamp(mTimestampNs);
- // And swap buffers
- glEnv.swapBuffers();
- mNumFramesEncoded++;
- if (mLogVerbose) Log.v(TAG, "numFramesEncoded = " + mNumFramesEncoded);
- }
-
- private void stopRecording(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Stopping recording");
-
- mRecordingActive = false;
- mNumFramesEncoded = 0;
- GLEnvironment glEnv = context.getGLEnvironment();
- // The following call will switch the surface_id to 0
- // (thus, calling eglMakeCurrent on surface with id 0) and
- // then call eglDestroy on the surface. Hence, this will
- // call disconnect the SurfaceMediaSource, which is needed to
- // be called before calling Stop on the mediarecorder
- if (mLogVerbose) Log.v(TAG, String.format("Unregistering surface %d", mSurfaceId));
- glEnv.unregisterSurfaceId(mSurfaceId);
- try {
- mMediaRecorder.stop();
- } catch (RuntimeException e) {
- throw new MediaRecorderStopException("MediaRecorder.stop() failed!", e);
- }
- mMediaRecorder.release();
- mMediaRecorder = null;
-
- mScreen.release();
- mScreen = null;
-
- // Use an EffectsRecorder callback to forward a media finalization
- // call so that it creates the video thumbnail, and whatever else needs
- // to be done to finalize media.
- if (mRecordingDoneListener != null) {
- mRecordingDoneListener.onRecordingDone();
- }
- }
-
- @Override
- public void close(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Closing");
- if (mRecordingActive) stopRecording(context);
- }
-
- @Override
- public void tearDown(FilterContext context) {
- // Release all the resources associated with the MediaRecorder
- // and GLFrame members
- if (mMediaRecorder != null) {
- mMediaRecorder.release();
- }
- if (mScreen != null) {
- mScreen.release();
- }
-
- }
-
-}
diff --git a/mca/filterpacks/videosink/java/MediaRecorderStopException.java b/mca/filterpacks/videosink/java/MediaRecorderStopException.java
deleted file mode 100644
index dbf9768..0000000
--- a/mca/filterpacks/videosink/java/MediaRecorderStopException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.videosink;
-
-import java.lang.RuntimeException;
-import android.util.Log;
-
-/** @hide **/
-public class MediaRecorderStopException extends RuntimeException {
-
- private static final String TAG = "MediaRecorderStopException";
-
- public MediaRecorderStopException(String msg) {
- super(msg);
- }
-
- public MediaRecorderStopException() {
- super();
- }
-
- public MediaRecorderStopException(String msg, Throwable t) {
- super(msg, t);
- }
-
- public MediaRecorderStopException(Throwable t) {
- super(t);
- }
-}
-
diff --git a/mca/filterpacks/videosrc/java/CameraSource.java b/mca/filterpacks/videosrc/java/CameraSource.java
deleted file mode 100644
index 2c474ab..0000000
--- a/mca/filterpacks/videosrc/java/CameraSource.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.videosrc;
-
-import android.content.Context;
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera;
-import android.os.ConditionVariable;
-import android.opengl.Matrix;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class CameraSource extends Filter {
-
- /** User-visible parameters */
-
- /** Camera ID to use for input. Defaults to 0. */
- @GenerateFieldPort(name = "id", hasDefault = true)
- private int mCameraId = 0;
-
- /** Frame width to request from camera. Actual size may not match requested. */
- @GenerateFieldPort(name = "width", hasDefault = true)
- private int mWidth = 320;
-
- /** Frame height to request from camera. Actual size may not match requested. */
- @GenerateFieldPort(name = "height", hasDefault = true)
- private int mHeight = 240;
-
- /** Stream framerate to request from camera. Actual frame rate may not match requested. */
- @GenerateFieldPort(name = "framerate", hasDefault = true)
- private int mFps = 30;
-
- /** Whether the filter should always wait for a new frame from the camera
- * before providing output. If set to false, the filter will keep
- * outputting the last frame it received from the camera if multiple process
- * calls are received before the next update from the Camera. Defaults to true.
- */
- @GenerateFinalPort(name = "waitForNewFrame", hasDefault = true)
- private boolean mWaitForNewFrame = true;
-
- private Camera mCamera;
- private GLFrame mCameraFrame;
- private SurfaceTexture mSurfaceTexture;
- private ShaderProgram mFrameExtractor;
- private MutableFrameFormat mOutputFormat;
-
- private float[] mCameraTransform;
- private float[] mMappedCoords;
- // These default source coordinates perform the necessary flip
- // for converting from OpenGL origin to MFF/Bitmap origin.
- private static final float[] mSourceCoords = { 0, 1, 0, 1,
- 1, 1, 0, 1,
- 0, 0, 0, 1,
- 1, 0, 0, 1 };
-
- private static final int NEWFRAME_TIMEOUT = 100; //ms
- private static final int NEWFRAME_TIMEOUT_REPEAT = 10;
-
- private boolean mNewFrameAvailable;
-
- private Camera.Parameters mCameraParameters;
-
- private static final String mFrameShader =
- "#extension GL_OES_EGL_image_external : require\n" +
- "precision mediump float;\n" +
- "uniform samplerExternalOES tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " gl_FragColor = texture2D(tex_sampler_0, v_texcoord);\n" +
- "}\n";
-
- private final boolean mLogVerbose;
- private static final String TAG = "CameraSource";
-
- public CameraSource(String name) {
- super(name);
- mCameraTransform = new float[16];
- mMappedCoords = new float[16];
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void setupPorts() {
- // Add input port
- addOutputPort("video", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- }
-
- private void createFormats() {
- mOutputFormat = ImageFormat.create(mWidth, mHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- }
-
- @Override
- public void prepare(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Preparing");
- // Compile shader TODO: Move to onGLEnvSomething?
- mFrameExtractor = new ShaderProgram(context, mFrameShader);
- }
-
- @Override
- public void open(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Opening");
- // Open camera
- mCamera = Camera.open(mCameraId);
-
- // Set parameters
- getCameraParameters();
- mCamera.setParameters(mCameraParameters);
-
- // Create frame formats
- createFormats();
-
- // Bind it to our camera frame
- mCameraFrame = (GLFrame)context.getFrameManager().newBoundFrame(mOutputFormat,
- GLFrame.EXTERNAL_TEXTURE,
- 0);
- mSurfaceTexture = new SurfaceTexture(mCameraFrame.getTextureId());
- try {
- mCamera.setPreviewTexture(mSurfaceTexture);
- } catch (IOException e) {
- throw new RuntimeException("Could not bind camera surface texture: " +
- e.getMessage() + "!");
- }
-
- // Connect SurfaceTexture to callback
- mSurfaceTexture.setOnFrameAvailableListener(onCameraFrameAvailableListener);
- // Start the preview
- mNewFrameAvailable = false;
- mCamera.startPreview();
- }
-
- @Override
- public void process(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Processing new frame");
-
- if (mWaitForNewFrame) {
- int waitCount = 0;
- while (!mNewFrameAvailable) {
- if (waitCount == NEWFRAME_TIMEOUT_REPEAT) {
- throw new RuntimeException("Timeout waiting for new frame");
- }
- try {
- this.wait(NEWFRAME_TIMEOUT);
- } catch (InterruptedException e) {
- if (mLogVerbose) Log.v(TAG, "Interrupted while waiting for new frame");
- }
- }
- mNewFrameAvailable = false;
- if (mLogVerbose) Log.v(TAG, "Got new frame");
- }
-
- mSurfaceTexture.updateTexImage();
-
- if (mLogVerbose) Log.v(TAG, "Using frame extractor in thread: " + Thread.currentThread());
- mSurfaceTexture.getTransformMatrix(mCameraTransform);
- Matrix.multiplyMM(mMappedCoords, 0,
- mCameraTransform, 0,
- mSourceCoords, 0);
- mFrameExtractor.setSourceRegion(mMappedCoords[0], mMappedCoords[1],
- mMappedCoords[4], mMappedCoords[5],
- mMappedCoords[8], mMappedCoords[9],
- mMappedCoords[12], mMappedCoords[13]);
-
- Frame output = context.getFrameManager().newFrame(mOutputFormat);
- mFrameExtractor.process(mCameraFrame, output);
-
- long timestamp = mSurfaceTexture.getTimestamp();
- if (mLogVerbose) Log.v(TAG, "Timestamp: " + (timestamp / 1000000000.0) + " s");
- output.setTimestamp(timestamp);
-
- pushOutput("video", output);
-
- // Release pushed frame
- output.release();
-
- if (mLogVerbose) Log.v(TAG, "Done processing new frame");
- }
-
- @Override
- public void close(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Closing");
-
- mCamera.release();
- mCamera = null;
- mSurfaceTexture.release();
- mSurfaceTexture = null;
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mCameraFrame != null) {
- mCameraFrame.release();
- }
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (name.equals("framerate")) {
- getCameraParameters();
- int closestRange[] = findClosestFpsRange(mFps, mCameraParameters);
- mCameraParameters.setPreviewFpsRange(closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
- closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
- mCamera.setParameters(mCameraParameters);
- }
- }
-
- synchronized public Camera.Parameters getCameraParameters() {
- boolean closeCamera = false;
- if (mCameraParameters == null) {
- if (mCamera == null) {
- mCamera = Camera.open(mCameraId);
- closeCamera = true;
- }
- mCameraParameters = mCamera.getParameters();
-
- if (closeCamera) {
- mCamera.release();
- mCamera = null;
- }
- }
-
- int closestSize[] = findClosestSize(mWidth, mHeight, mCameraParameters);
- mWidth = closestSize[0];
- mHeight = closestSize[1];
- mCameraParameters.setPreviewSize(mWidth, mHeight);
-
- int closestRange[] = findClosestFpsRange(mFps, mCameraParameters);
-
- mCameraParameters.setPreviewFpsRange(closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
- closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
-
- return mCameraParameters;
- }
-
- /** Update camera parameters. Image resolution cannot be changed. */
- synchronized public void setCameraParameters(Camera.Parameters params) {
- params.setPreviewSize(mWidth, mHeight);
- mCameraParameters = params;
- if (isOpen()) {
- mCamera.setParameters(mCameraParameters);
- }
- }
-
- private int[] findClosestSize(int width, int height, Camera.Parameters parameters) {
- List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
- int closestWidth = -1;
- int closestHeight = -1;
- int smallestWidth = previewSizes.get(0).width;
- int smallestHeight = previewSizes.get(0).height;
- for (Camera.Size size : previewSizes) {
- // Best match defined as not being larger in either dimension than
- // the requested size, but as close as possible. The below isn't a
- // stable selection (reording the size list can give different
- // results), but since this is a fallback nicety, that's acceptable.
- if ( size.width <= width &&
- size.height <= height &&
- size.width >= closestWidth &&
- size.height >= closestHeight) {
- closestWidth = size.width;
- closestHeight = size.height;
- }
- if ( size.width < smallestWidth &&
- size.height < smallestHeight) {
- smallestWidth = size.width;
- smallestHeight = size.height;
- }
- }
- if (closestWidth == -1) {
- // Requested size is smaller than any listed size; match with smallest possible
- closestWidth = smallestWidth;
- closestHeight = smallestHeight;
- }
-
- if (mLogVerbose) {
- Log.v(TAG,
- "Requested resolution: (" + width + ", " + height
- + "). Closest match: (" + closestWidth + ", "
- + closestHeight + ").");
- }
- int[] closestSize = {closestWidth, closestHeight};
- return closestSize;
- }
-
- private int[] findClosestFpsRange(int fps, Camera.Parameters params) {
- List<int[]> supportedFpsRanges = params.getSupportedPreviewFpsRange();
- int[] closestRange = supportedFpsRanges.get(0);
- for (int[] range : supportedFpsRanges) {
- if (range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX] < fps*1000 &&
- range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX] > fps*1000 &&
- range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX] >
- closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX] &&
- range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX] <
- closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]) {
- closestRange = range;
- }
- }
- if (mLogVerbose) Log.v(TAG, "Requested fps: " + fps
- + ".Closest frame rate range: ["
- + closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX] / 1000.
- + ","
- + closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX] / 1000.
- + "]");
-
- return closestRange;
- }
-
- private SurfaceTexture.OnFrameAvailableListener onCameraFrameAvailableListener =
- new SurfaceTexture.OnFrameAvailableListener() {
- @Override
- public void onFrameAvailable(SurfaceTexture surfaceTexture) {
- if (mLogVerbose) Log.v(TAG, "New frame from camera");
- synchronized(CameraSource.this) {
- mNewFrameAvailable = true;
- CameraSource.this.notify();
- }
- }
- };
-
-}
diff --git a/mca/filterpacks/videosrc/java/MediaSource.java b/mca/filterpacks/videosrc/java/MediaSource.java
deleted file mode 100644
index 9c40cec..0000000
--- a/mca/filterpacks/videosrc/java/MediaSource.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.videosrc;
-
-import android.content.Context;
-import android.content.res.AssetFileDescriptor;
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.graphics.SurfaceTexture;
-import android.media.MediaPlayer;
-import android.os.ConditionVariable;
-import android.opengl.Matrix;
-import android.view.Surface;
-
-import java.io.IOException;
-import java.io.FileDescriptor;
-import java.lang.IllegalArgumentException;
-import java.util.List;
-import java.util.Set;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class MediaSource extends Filter {
-
- /** User-visible parameters */
-
- /** The source URL for the media source. Can be an http: link to a remote
- * resource, or a file: link to a local media file
- */
- @GenerateFieldPort(name = "sourceUrl", hasDefault = true)
- private String mSourceUrl = "";
-
- /** An open asset file descriptor to a local media source. Default is null */
- @GenerateFieldPort(name = "sourceAsset", hasDefault = true)
- private AssetFileDescriptor mSourceAsset = null;
-
- /** Whether the media source is a URL or an asset file descriptor. Defaults
- * to false.
- */
- @GenerateFieldPort(name = "sourceIsUrl", hasDefault = true)
- private boolean mSelectedIsUrl = false;
-
- /** Whether the filter will always wait for a new video frame, or whether it
- * will output an old frame again if a new frame isn't available. Defaults
- * to true.
- */
- @GenerateFinalPort(name = "waitForNewFrame", hasDefault = true)
- private boolean mWaitForNewFrame = true;
-
- /** Whether the media source should loop automatically or not. Defaults to
- * true.
- */
- @GenerateFieldPort(name = "loop", hasDefault = true)
- private boolean mLooping = true;
-
- /** Volume control. Currently sound is piped directly to the speakers, so
- * this defaults to mute.
- */
- @GenerateFieldPort(name = "volume", hasDefault = true)
- private float mVolume = 0.f;
-
- /** Orientation. This controls the output orientation of the video. Valid
- * values are 0, 90, 180, 270
- */
- @GenerateFieldPort(name = "orientation", hasDefault = true)
- private int mOrientation = 0;
-
- private MediaPlayer mMediaPlayer;
- private GLFrame mMediaFrame;
- private SurfaceTexture mSurfaceTexture;
- private ShaderProgram mFrameExtractor;
- private MutableFrameFormat mOutputFormat;
- private int mWidth, mHeight;
-
- // Total timeouts will be PREP_TIMEOUT*PREP_TIMEOUT_REPEAT
- private static final int PREP_TIMEOUT = 100; // ms
- private static final int PREP_TIMEOUT_REPEAT = 100;
- private static final int NEWFRAME_TIMEOUT = 100; //ms
- private static final int NEWFRAME_TIMEOUT_REPEAT = 10;
-
- // This is an identity shader; not using the default identity
- // shader because reading from a SurfaceTexture requires the
- // GL_OES_EGL_image_external extension.
- private final String mFrameShader =
- "#extension GL_OES_EGL_image_external : require\n" +
- "precision mediump float;\n" +
- "uniform samplerExternalOES tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " gl_FragColor = texture2D(tex_sampler_0, v_texcoord);\n" +
- "}\n";
-
- // The following transforms enable rotation of the decoded source.
- // These are multiplied with the transform obtained from the
- // SurfaceTexture to get the final transform to be set on the media source.
- // Currently, given a device orientation, the MediaSource rotates in such a way
- // that the source is displayed upright. A particular use case
- // is "Background Replacement" feature in the Camera app
- // where the MediaSource rotates the source to align with the camera feed and pass it
- // on to the backdropper filter. The backdropper only does the blending
- // and does not have to do any rotation
- // (except for mirroring in case of front camera).
- // TODO: Currently the rotations are spread over a bunch of stages in the
- // pipeline. A cleaner design
- // could be to cast away all the rotation in a separate filter or attach a transform
- // to the frame so that MediaSource itself need not know about any rotation.
- private static final float[] mSourceCoords_0 = { 1, 1, 0, 1,
- 0, 1, 0, 1,
- 1, 0, 0, 1,
- 0, 0, 0, 1 };
- private static final float[] mSourceCoords_270 = { 0, 1, 0, 1,
- 0, 0, 0, 1,
- 1, 1, 0, 1,
- 1, 0, 0, 1 };
- private static final float[] mSourceCoords_180 = { 0, 0, 0, 1,
- 1, 0, 0, 1,
- 0, 1, 0, 1,
- 1, 1, 0, 1 };
- private static final float[] mSourceCoords_90 = { 1, 0, 0, 1,
- 1, 1, 0, 1,
- 0, 0, 0, 1,
- 0, 1, 0, 1 };
-
- private boolean mGotSize;
- private boolean mPrepared;
- private boolean mPlaying;
- private boolean mNewFrameAvailable;
- private boolean mOrientationUpdated;
- private boolean mPaused;
- private boolean mCompleted;
-
- private final boolean mLogVerbose;
- private static final String TAG = "MediaSource";
-
- public MediaSource(String name) {
- super(name);
- mNewFrameAvailable = false;
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void setupPorts() {
- // Add input port
- addOutputPort("video", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- }
-
- private void createFormats() {
- mOutputFormat = ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- }
-
- @Override
- protected void prepare(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Preparing MediaSource");
-
- mFrameExtractor = new ShaderProgram(context, mFrameShader);
- // SurfaceTexture defines (0,0) to be bottom-left. The filter framework
- // defines (0,0) as top-left, so do the flip here.
- mFrameExtractor.setSourceRect(0, 1, 1, -1);
-
- createFormats();
- }
-
- @Override
- public void open(FilterContext context) {
- if (mLogVerbose) {
- Log.v(TAG, "Opening MediaSource");
- if (mSelectedIsUrl) {
- Log.v(TAG, "Current URL is " + mSourceUrl);
- } else {
- Log.v(TAG, "Current source is Asset!");
- }
- }
-
- mMediaFrame = (GLFrame)context.getFrameManager().newBoundFrame(
- mOutputFormat,
- GLFrame.EXTERNAL_TEXTURE,
- 0);
-
- mSurfaceTexture = new SurfaceTexture(mMediaFrame.getTextureId());
-
- if (!setupMediaPlayer(mSelectedIsUrl)) {
- throw new RuntimeException("Error setting up MediaPlayer!");
- }
- }
-
- @Override
- public void process(FilterContext context) {
- // Note: process is synchronized by its caller in the Filter base class
- if (mLogVerbose) Log.v(TAG, "Processing new frame");
-
- if (mMediaPlayer == null) {
- // Something went wrong in initialization or parameter updates
- throw new NullPointerException("Unexpected null media player!");
- }
-
- if (mCompleted) {
- // Video playback is done, so close us down
- closeOutputPort("video");
- return;
- }
-
- if (!mPlaying) {
- int waitCount = 0;
- if (mLogVerbose) Log.v(TAG, "Waiting for preparation to complete");
- while (!mGotSize || !mPrepared) {
- try {
- this.wait(PREP_TIMEOUT);
- } catch (InterruptedException e) {
- // ignoring
- }
- if (mCompleted) {
- // Video playback is done, so close us down
- closeOutputPort("video");
- return;
- }
- waitCount++;
- if (waitCount == PREP_TIMEOUT_REPEAT) {
- mMediaPlayer.release();
- throw new RuntimeException("MediaPlayer timed out while preparing!");
- }
- }
- if (mLogVerbose) Log.v(TAG, "Starting playback");
- mMediaPlayer.start();
- }
-
- // Use last frame if paused, unless just starting playback, in which case
- // we want at least one valid frame before pausing
- if (!mPaused || !mPlaying) {
- if (mWaitForNewFrame) {
- if (mLogVerbose) Log.v(TAG, "Waiting for new frame");
-
- int waitCount = 0;
- while (!mNewFrameAvailable) {
- if (waitCount == NEWFRAME_TIMEOUT_REPEAT) {
- if (mCompleted) {
- // Video playback is done, so close us down
- closeOutputPort("video");
- return;
- } else {
- throw new RuntimeException("Timeout waiting for new frame!");
- }
- }
- try {
- this.wait(NEWFRAME_TIMEOUT);
- } catch (InterruptedException e) {
- if (mLogVerbose) Log.v(TAG, "interrupted");
- // ignoring
- }
- waitCount++;
- }
- mNewFrameAvailable = false;
- if (mLogVerbose) Log.v(TAG, "Got new frame");
- }
-
- mSurfaceTexture.updateTexImage();
- mOrientationUpdated = true;
- }
- if (mOrientationUpdated) {
- float[] surfaceTransform = new float[16];
- mSurfaceTexture.getTransformMatrix(surfaceTransform);
-
- float[] sourceCoords = new float[16];
- switch (mOrientation) {
- default:
- case 0:
- Matrix.multiplyMM(sourceCoords, 0,
- surfaceTransform, 0,
- mSourceCoords_0, 0);
- break;
- case 90:
- Matrix.multiplyMM(sourceCoords, 0,
- surfaceTransform, 0,
- mSourceCoords_90, 0);
- break;
- case 180:
- Matrix.multiplyMM(sourceCoords, 0,
- surfaceTransform, 0,
- mSourceCoords_180, 0);
- break;
- case 270:
- Matrix.multiplyMM(sourceCoords, 0,
- surfaceTransform, 0,
- mSourceCoords_270, 0);
- break;
- }
- if (mLogVerbose) {
- Log.v(TAG, "OrientationHint = " + mOrientation);
- String temp = String.format("SetSourceRegion: %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f",
- sourceCoords[4], sourceCoords[5],sourceCoords[0], sourceCoords[1],
- sourceCoords[12], sourceCoords[13],sourceCoords[8], sourceCoords[9]);
- Log.v(TAG, temp);
- }
- mFrameExtractor.setSourceRegion(sourceCoords[4], sourceCoords[5],
- sourceCoords[0], sourceCoords[1],
- sourceCoords[12], sourceCoords[13],
- sourceCoords[8], sourceCoords[9]);
- mOrientationUpdated = false;
- }
-
- Frame output = context.getFrameManager().newFrame(mOutputFormat);
- mFrameExtractor.process(mMediaFrame, output);
-
- long timestamp = mSurfaceTexture.getTimestamp();
- if (mLogVerbose) Log.v(TAG, "Timestamp: " + (timestamp / 1000000000.0) + " s");
- output.setTimestamp(timestamp);
-
- pushOutput("video", output);
- output.release();
-
- mPlaying = true;
- }
-
- @Override
- public void close(FilterContext context) {
- if (mMediaPlayer.isPlaying()) {
- mMediaPlayer.stop();
- }
- mPrepared = false;
- mGotSize = false;
- mPlaying = false;
- mPaused = false;
- mCompleted = false;
- mNewFrameAvailable = false;
-
- mMediaPlayer.release();
- mMediaPlayer = null;
- mSurfaceTexture.release();
- mSurfaceTexture = null;
- if (mLogVerbose) Log.v(TAG, "MediaSource closed");
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mMediaFrame != null) {
- mMediaFrame.release();
- }
- }
-
- // When updating the port values of the filter, users can update sourceIsUrl to switch
- // between using URL objects or Assets.
- // If updating only sourceUrl/sourceAsset, MediaPlayer gets reset if the current player
- // uses Url objects/Asset.
- // Otherwise the new sourceUrl/sourceAsset is stored and will be used when users switch
- // sourceIsUrl next time.
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Parameter update");
- if (name.equals("sourceUrl")) {
- if (isOpen()) {
- if (mLogVerbose) Log.v(TAG, "Opening new source URL");
- if (mSelectedIsUrl) {
- setupMediaPlayer(mSelectedIsUrl);
- }
- }
- } else if (name.equals("sourceAsset") ) {
- if (isOpen()) {
- if (mLogVerbose) Log.v(TAG, "Opening new source FD");
- if (!mSelectedIsUrl) {
- setupMediaPlayer(mSelectedIsUrl);
- }
- }
- } else if (name.equals("loop")) {
- if (isOpen()) {
- mMediaPlayer.setLooping(mLooping);
- }
- } else if (name.equals("sourceIsUrl")) {
- if (isOpen()){
- if (mSelectedIsUrl){
- if (mLogVerbose) Log.v(TAG, "Opening new source URL");
- } else {
- if (mLogVerbose) Log.v(TAG, "Opening new source Asset");
- }
- setupMediaPlayer(mSelectedIsUrl);
- }
- } else if (name.equals("volume")) {
- if (isOpen()) {
- mMediaPlayer.setVolume(mVolume, mVolume);
- }
- } else if (name.equals("orientation") && mGotSize) {
- if (mOrientation == 0 || mOrientation == 180) {
- mOutputFormat.setDimensions(mWidth, mHeight);
- } else {
- mOutputFormat.setDimensions(mHeight, mWidth);
- }
- mOrientationUpdated = true;
- }
- }
-
- synchronized public void pauseVideo(boolean pauseState) {
- if (isOpen()) {
- if (pauseState && !mPaused) {
- mMediaPlayer.pause();
- } else if (!pauseState && mPaused) {
- mMediaPlayer.start();
- }
- }
- mPaused = pauseState;
- }
-
- /** Creates a media player, sets it up, and calls prepare */
- synchronized private boolean setupMediaPlayer(boolean useUrl) {
- mPrepared = false;
- mGotSize = false;
- mPlaying = false;
- mPaused = false;
- mCompleted = false;
- mNewFrameAvailable = false;
-
- if (mLogVerbose) Log.v(TAG, "Setting up playback.");
-
- if (mMediaPlayer != null) {
- // Clean up existing media players
- if (mLogVerbose) Log.v(TAG, "Resetting existing MediaPlayer.");
- mMediaPlayer.reset();
- } else {
- // Create new media player
- if (mLogVerbose) Log.v(TAG, "Creating new MediaPlayer.");
- mMediaPlayer = new MediaPlayer();
- }
-
- if (mMediaPlayer == null) {
- throw new RuntimeException("Unable to create a MediaPlayer!");
- }
-
- // Set up data sources, etc
- try {
- if (useUrl) {
- if (mLogVerbose) Log.v(TAG, "Setting MediaPlayer source to URI " + mSourceUrl);
- mMediaPlayer.setDataSource(mSourceUrl);
- } else {
- if (mLogVerbose) Log.v(TAG, "Setting MediaPlayer source to asset " + mSourceAsset);
- mMediaPlayer.setDataSource(mSourceAsset.getFileDescriptor(), mSourceAsset.getStartOffset(), mSourceAsset.getLength());
- }
- } catch(IOException e) {
- mMediaPlayer.release();
- mMediaPlayer = null;
- if (useUrl) {
- throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
- } else {
- throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
- }
- } catch(IllegalArgumentException e) {
- mMediaPlayer.release();
- mMediaPlayer = null;
- if (useUrl) {
- throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
- } else {
- throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
- }
- }
-
- mMediaPlayer.setLooping(mLooping);
- mMediaPlayer.setVolume(mVolume, mVolume);
-
- // Bind it to our media frame
- Surface surface = new Surface(mSurfaceTexture);
- mMediaPlayer.setSurface(surface);
- surface.release();
-
- // Connect Media Player to callbacks
-
- mMediaPlayer.setOnVideoSizeChangedListener(onVideoSizeChangedListener);
- mMediaPlayer.setOnPreparedListener(onPreparedListener);
- mMediaPlayer.setOnCompletionListener(onCompletionListener);
-
- // Connect SurfaceTexture to callback
- mSurfaceTexture.setOnFrameAvailableListener(onMediaFrameAvailableListener);
-
- if (mLogVerbose) Log.v(TAG, "Preparing MediaPlayer.");
- mMediaPlayer.prepareAsync();
-
- return true;
- }
-
- private MediaPlayer.OnVideoSizeChangedListener onVideoSizeChangedListener =
- new MediaPlayer.OnVideoSizeChangedListener() {
- public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
- if (mLogVerbose) Log.v(TAG, "MediaPlayer sent dimensions: " + width + " x " + height);
- if (!mGotSize) {
- if (mOrientation == 0 || mOrientation == 180) {
- mOutputFormat.setDimensions(width, height);
- } else {
- mOutputFormat.setDimensions(height, width);
- }
- mWidth = width;
- mHeight = height;
- } else {
- if (mOutputFormat.getWidth() != width ||
- mOutputFormat.getHeight() != height) {
- Log.e(TAG, "Multiple video size change events received!");
- }
- }
- synchronized(MediaSource.this) {
- mGotSize = true;
- MediaSource.this.notify();
- }
- }
- };
-
- private MediaPlayer.OnPreparedListener onPreparedListener =
- new MediaPlayer.OnPreparedListener() {
- public void onPrepared(MediaPlayer mp) {
- if (mLogVerbose) Log.v(TAG, "MediaPlayer is prepared");
- synchronized(MediaSource.this) {
- mPrepared = true;
- MediaSource.this.notify();
- }
- }
- };
-
- private MediaPlayer.OnCompletionListener onCompletionListener =
- new MediaPlayer.OnCompletionListener() {
- public void onCompletion(MediaPlayer mp) {
- if (mLogVerbose) Log.v(TAG, "MediaPlayer has completed playback");
- synchronized(MediaSource.this) {
- mCompleted = true;
- }
- }
- };
-
- private SurfaceTexture.OnFrameAvailableListener onMediaFrameAvailableListener =
- new SurfaceTexture.OnFrameAvailableListener() {
- public void onFrameAvailable(SurfaceTexture surfaceTexture) {
- if (mLogVerbose) Log.v(TAG, "New frame from media player");
- synchronized(MediaSource.this) {
- if (mLogVerbose) Log.v(TAG, "New frame: notify");
- mNewFrameAvailable = true;
- MediaSource.this.notify();
- if (mLogVerbose) Log.v(TAG, "New frame: notify done");
- }
- }
- };
-
-}
diff --git a/mca/filterpacks/videosrc/java/SurfaceTextureSource.java b/mca/filterpacks/videosrc/java/SurfaceTextureSource.java
deleted file mode 100644
index 37fa242..0000000
--- a/mca/filterpacks/videosrc/java/SurfaceTextureSource.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.filterpacks.videosrc;
-
-import android.content.Context;
-import android.content.res.AssetFileDescriptor;
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.FrameManager;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-import android.graphics.SurfaceTexture;
-import android.media.MediaPlayer;
-import android.os.ConditionVariable;
-import android.opengl.Matrix;
-
-import java.io.IOException;
-import java.io.FileDescriptor;
-import java.lang.IllegalArgumentException;
-import java.util.List;
-import java.util.Set;
-
-import android.util.Log;
-
-/** <p>A filter that converts textures from a SurfaceTexture object into frames for
- * processing in the filter framework.</p>
- *
- * <p>To use, connect up the sourceListener callback, and then when executing
- * the graph, use the SurfaceTexture object passed to the callback to feed
- * frames into the filter graph. For example, pass the SurfaceTexture into
- * {#link
- * android.hardware.Camera.setPreviewTexture(android.graphics.SurfaceTexture)}.
- * This filter is intended for applications that need for flexibility than the
- * CameraSource and MediaSource provide. Note that the application needs to
- * provide width and height information for the SurfaceTextureSource, which it
- * should obtain from wherever the SurfaceTexture data is coming from to avoid
- * unnecessary resampling.</p>
- *
- * @hide
- */
-public class SurfaceTextureSource extends Filter {
-
- /** User-visible parameters */
-
- /** The callback interface for the sourceListener parameter */
- public interface SurfaceTextureSourceListener {
- public void onSurfaceTextureSourceReady(SurfaceTexture source);
- }
- /** A callback to send the internal SurfaceTexture object to, once it is
- * created. This callback will be called when the the filter graph is
- * preparing to execute, but before any processing has actually taken
- * place. The SurfaceTexture object passed to this callback is the only way
- * to feed this filter. When the filter graph is shutting down, this
- * callback will be called again with null as the source.
- *
- * This callback may be called from an arbitrary thread, so it should not
- * assume it is running in the UI thread in particular.
- */
- @GenerateFinalPort(name = "sourceListener")
- private SurfaceTextureSourceListener mSourceListener;
-
- /** The width of the output image frame. If the texture width for the
- * SurfaceTexture source is known, use it here to minimize resampling. */
- @GenerateFieldPort(name = "width")
- private int mWidth;
-
- /** The height of the output image frame. If the texture height for the
- * SurfaceTexture source is known, use it here to minimize resampling. */
- @GenerateFieldPort(name = "height")
- private int mHeight;
-
- /** Whether the filter will always wait for a new frame from its
- * SurfaceTexture, or whether it will output an old frame again if a new
- * frame isn't available. The filter will always wait for the first frame,
- * to avoid outputting a blank frame. Defaults to true.
- */
- @GenerateFieldPort(name = "waitForNewFrame", hasDefault = true)
- private boolean mWaitForNewFrame = true;
-
- /** Maximum timeout before signaling error when waiting for a new frame. Set
- * this to zero to disable the timeout and wait indefinitely. In milliseconds.
- */
- @GenerateFieldPort(name = "waitTimeout", hasDefault = true)
- private int mWaitTimeout = 1000;
-
- /** Whether a timeout is an exception-causing failure, or just causes the
- * filter to close.
- */
- @GenerateFieldPort(name = "closeOnTimeout", hasDefault = true)
- private boolean mCloseOnTimeout = false;
-
- // Variables for input->output conversion
- private GLFrame mMediaFrame;
- private ShaderProgram mFrameExtractor;
- private SurfaceTexture mSurfaceTexture;
- private MutableFrameFormat mOutputFormat;
- private ConditionVariable mNewFrameAvailable;
- private boolean mFirstFrame;
-
- private float[] mFrameTransform;
- private float[] mMappedCoords;
- // These default source coordinates perform the necessary flip
- // for converting from MFF/Bitmap origin to OpenGL origin.
- private static final float[] mSourceCoords = { 0, 1, 0, 1,
- 1, 1, 0, 1,
- 0, 0, 0, 1,
- 1, 0, 0, 1 };
- // Shader for output
- private final String mRenderShader =
- "#extension GL_OES_EGL_image_external : require\n" +
- "precision mediump float;\n" +
- "uniform samplerExternalOES tex_sampler_0;\n" +
- "varying vec2 v_texcoord;\n" +
- "void main() {\n" +
- " gl_FragColor = texture2D(tex_sampler_0, v_texcoord);\n" +
- "}\n";
-
- // Variables for logging
-
- private static final String TAG = "SurfaceTextureSource";
- private static final boolean mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
-
- public SurfaceTextureSource(String name) {
- super(name);
- mNewFrameAvailable = new ConditionVariable();
- mFrameTransform = new float[16];
- mMappedCoords = new float[16];
- }
-
- @Override
- public void setupPorts() {
- // Add input port
- addOutputPort("video", ImageFormat.create(ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU));
- }
-
- private void createFormats() {
- mOutputFormat = ImageFormat.create(mWidth, mHeight,
- ImageFormat.COLORSPACE_RGBA,
- FrameFormat.TARGET_GPU);
- }
-
- @Override
- protected void prepare(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Preparing SurfaceTextureSource");
-
- createFormats();
-
- // Prepare input
- mMediaFrame = (GLFrame)context.getFrameManager().newBoundFrame(mOutputFormat,
- GLFrame.EXTERNAL_TEXTURE,
- 0);
-
- // Prepare output
- mFrameExtractor = new ShaderProgram(context, mRenderShader);
- }
-
- @Override
- public void open(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Opening SurfaceTextureSource");
- // Create SurfaceTexture anew each time - it can use substantial memory.
- mSurfaceTexture = new SurfaceTexture(mMediaFrame.getTextureId());
- // Connect SurfaceTexture to callback
- mSurfaceTexture.setOnFrameAvailableListener(onFrameAvailableListener);
- // Connect SurfaceTexture to source
- mSourceListener.onSurfaceTextureSourceReady(mSurfaceTexture);
- mFirstFrame = true;
- }
-
- @Override
- public void process(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Processing new frame");
-
- // First, get new frame if available
- if (mWaitForNewFrame || mFirstFrame) {
- boolean gotNewFrame;
- if (mWaitTimeout != 0) {
- gotNewFrame = mNewFrameAvailable.block(mWaitTimeout);
- if (!gotNewFrame) {
- if (!mCloseOnTimeout) {
- throw new RuntimeException("Timeout waiting for new frame");
- } else {
- if (mLogVerbose) Log.v(TAG, "Timeout waiting for a new frame. Closing.");
- closeOutputPort("video");
- return;
- }
- }
- } else {
- mNewFrameAvailable.block();
- }
- mNewFrameAvailable.close();
- mFirstFrame = false;
- }
-
- mSurfaceTexture.updateTexImage();
-
- mSurfaceTexture.getTransformMatrix(mFrameTransform);
- Matrix.multiplyMM(mMappedCoords, 0,
- mFrameTransform, 0,
- mSourceCoords, 0);
- mFrameExtractor.setSourceRegion(mMappedCoords[0], mMappedCoords[1],
- mMappedCoords[4], mMappedCoords[5],
- mMappedCoords[8], mMappedCoords[9],
- mMappedCoords[12], mMappedCoords[13]);
- // Next, render to output
- Frame output = context.getFrameManager().newFrame(mOutputFormat);
- mFrameExtractor.process(mMediaFrame, output);
-
- output.setTimestamp(mSurfaceTexture.getTimestamp());
-
- pushOutput("video", output);
- output.release();
- }
-
- @Override
- public void close(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "SurfaceTextureSource closed");
- mSourceListener.onSurfaceTextureSourceReady(null);
- mSurfaceTexture.release();
- mSurfaceTexture = null;
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mMediaFrame != null) {
- mMediaFrame.release();
- }
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- if (name.equals("width") || name.equals("height") ) {
- mOutputFormat.setDimensions(mWidth, mHeight);
- }
- }
-
- private SurfaceTexture.OnFrameAvailableListener onFrameAvailableListener =
- new SurfaceTexture.OnFrameAvailableListener() {
- public void onFrameAvailable(SurfaceTexture surfaceTexture) {
- if (mLogVerbose) Log.v(TAG, "New frame from SurfaceTexture");
- mNewFrameAvailable.open();
- }
- };
-}
diff --git a/mca/filterpacks/videosrc/java/SurfaceTextureTarget.java b/mca/filterpacks/videosrc/java/SurfaceTextureTarget.java
deleted file mode 100644
index 436caab..0000000
--- a/mca/filterpacks/videosrc/java/SurfaceTextureTarget.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterpacks.videosrc;
-
-import android.filterfw.core.Filter;
-import android.filterfw.core.FilterContext;
-import android.filterfw.core.FilterSurfaceView;
-import android.filterfw.core.Frame;
-import android.filterfw.core.FrameFormat;
-import android.filterfw.core.GenerateFieldPort;
-import android.filterfw.core.GenerateFinalPort;
-import android.filterfw.core.GLEnvironment;
-import android.filterfw.core.GLFrame;
-import android.filterfw.core.KeyValueMap;
-import android.filterfw.core.MutableFrameFormat;
-import android.filterfw.core.NativeProgram;
-import android.filterfw.core.NativeFrame;
-import android.filterfw.core.Program;
-import android.filterfw.core.ShaderProgram;
-import android.filterfw.format.ImageFormat;
-
-import android.filterfw.geometry.Quad;
-import android.filterfw.geometry.Point;
-
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-import android.graphics.Rect;
-import android.graphics.SurfaceTexture;
-
-import android.util.Log;
-
-/**
- * @hide
- */
-public class SurfaceTextureTarget extends Filter {
-
- private final int RENDERMODE_STRETCH = 0;
- private final int RENDERMODE_FIT = 1;
- private final int RENDERMODE_FILL_CROP = 2;
- private final int RENDERMODE_CUSTOMIZE = 3;
-
- /** Required. Sets the destination surfaceTexture.
- */
- @GenerateFinalPort(name = "surfaceTexture")
- private SurfaceTexture mSurfaceTexture;
-
- /** Required. Sets the width of the output surfaceTexture images */
- @GenerateFinalPort(name = "width")
- private int mScreenWidth;
-
- /** Required. Sets the height of the output surfaceTexture images */
- @GenerateFinalPort(name = "height")
- private int mScreenHeight;
-
-
- /** Optional. Control how the incoming frames are rendered onto the
- * output. Default is FIT.
- * RENDERMODE_STRETCH: Just fill the output surfaceView.
- * RENDERMODE_FIT: Keep aspect ratio and fit without cropping. May
- * have black bars.
- * RENDERMODE_FILL_CROP: Keep aspect ratio and fit without black
- * bars. May crop.
- */
- @GenerateFieldPort(name = "renderMode", hasDefault = true)
- private String mRenderModeString;
-
- @GenerateFieldPort(name = "sourceQuad", hasDefault = true)
- private Quad mSourceQuad = new Quad(new Point(0.0f, 1.0f),
- new Point(1.0f, 1.0f),
- new Point(0.0f, 0.0f),
- new Point(1.0f, 0.0f));
-
- @GenerateFieldPort(name = "targetQuad", hasDefault = true)
- private Quad mTargetQuad = new Quad(new Point(0.0f, 0.0f),
- new Point(1.0f, 0.0f),
- new Point(0.0f, 1.0f),
- new Point(1.0f, 1.0f));
-
- private int mSurfaceId;
-
- private ShaderProgram mProgram;
- private GLFrame mScreen;
- private int mRenderMode = RENDERMODE_FIT;
- private float mAspectRatio = 1.f;
-
- private boolean mLogVerbose;
- private static final String TAG = "SurfaceTextureTarget";
-
- public SurfaceTextureTarget(String name) {
- super(name);
-
- mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
- }
-
- @Override
- public void setupPorts() {
- // Make sure we have a SurfaceView
- if (mSurfaceTexture == null) {
- throw new RuntimeException("Null SurfaceTexture passed to SurfaceTextureTarget");
- }
-
- // Add input port - will accept anything that's 4-channel.
- addMaskedInputPort("frame", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
- }
-
- public void updateRenderMode() {
- if (mRenderModeString != null) {
- if (mRenderModeString.equals("stretch")) {
- mRenderMode = RENDERMODE_STRETCH;
- } else if (mRenderModeString.equals("fit")) {
- mRenderMode = RENDERMODE_FIT;
- } else if (mRenderModeString.equals("fill_crop")) {
- mRenderMode = RENDERMODE_FILL_CROP;
- } else if (mRenderModeString.equals("customize")) {
- mRenderMode = RENDERMODE_CUSTOMIZE;
- } else {
- throw new RuntimeException("Unknown render mode '" + mRenderModeString + "'!");
- }
- }
- updateTargetRect();
- }
-
- @Override
- public void prepare(FilterContext context) {
- // Create identity shader to render, and make sure to render upside-down, as textures
- // are stored internally bottom-to-top.
- mProgram = ShaderProgram.createIdentity(context);
- mProgram.setSourceRect(0, 1, 1, -1);
- mProgram.setClearColor(0.0f, 0.0f, 0.0f);
-
- updateRenderMode();
-
- // Create a frame representing the screen
- MutableFrameFormat screenFormat = new MutableFrameFormat(FrameFormat.TYPE_BYTE,
- FrameFormat.TARGET_GPU);
- screenFormat.setBytesPerSample(4);
- screenFormat.setDimensions(mScreenWidth, mScreenHeight);
- mScreen = (GLFrame)context.getFrameManager().newBoundFrame(screenFormat,
- GLFrame.EXISTING_FBO_BINDING,
- 0);
- }
-
- @Override
- public void open(FilterContext context) {
- // Set up SurfaceTexture internals
- mSurfaceId = context.getGLEnvironment().registerSurfaceTexture(mSurfaceTexture, mScreenWidth, mScreenHeight);
- }
-
- @Override
- public void process(FilterContext context) {
- if (mLogVerbose) Log.v(TAG, "Starting frame processing");
-
- GLEnvironment glEnv = context.getGLEnvironment();
-
- // Get input frame
- Frame input = pullInput("frame");
- boolean createdFrame = false;
-
- float currentAspectRatio = (float)input.getFormat().getWidth() / input.getFormat().getHeight();
- if (currentAspectRatio != mAspectRatio) {
- if (mLogVerbose) Log.v(TAG, "New aspect ratio: " + currentAspectRatio +", previously: " + mAspectRatio);
- mAspectRatio = currentAspectRatio;
- updateTargetRect();
- }
-
- // See if we need to copy to GPU
- Frame gpuFrame = null;
- if (mLogVerbose) Log.v("SurfaceTextureTarget", "Got input format: " + input.getFormat());
-
- int target = input.getFormat().getTarget();
- if (target != FrameFormat.TARGET_GPU) {
- gpuFrame = context.getFrameManager().duplicateFrameToTarget(input,
- FrameFormat.TARGET_GPU);
- createdFrame = true;
- } else {
- gpuFrame = input;
- }
-
- // Activate our surface
- glEnv.activateSurfaceWithId(mSurfaceId);
-
- // Process
- mProgram.process(gpuFrame, mScreen);
-
- glEnv.setSurfaceTimestamp(input.getTimestamp());
-
- // And swap buffers
- glEnv.swapBuffers();
-
- if (createdFrame) {
- gpuFrame.release();
- }
- }
-
- @Override
- public void fieldPortValueUpdated(String name, FilterContext context) {
- updateRenderMode();
- }
-
- @Override
- public void tearDown(FilterContext context) {
- if (mScreen != null) {
- mScreen.release();
- }
- }
-
- private void updateTargetRect() {
- if (mScreenWidth > 0 && mScreenHeight > 0 && mProgram != null) {
- float screenAspectRatio = (float)mScreenWidth / mScreenHeight;
- float relativeAspectRatio = screenAspectRatio / mAspectRatio;
-
- if (relativeAspectRatio == 1.0f && mRenderMode != RENDERMODE_CUSTOMIZE) {
- mProgram.setClearsOutput(false);
- } else {
- switch (mRenderMode) {
- case RENDERMODE_STRETCH:
- mProgram.setTargetRect(0, 0, 1, 1);
- mTargetQuad.p0.set(0f, 0.0f);
- mTargetQuad.p1.set(1f, 0.0f);
- mTargetQuad.p2.set(0f, 1.0f);
- mTargetQuad.p3.set(1f, 1.0f);
- mProgram.setClearsOutput(false);
- break;
- case RENDERMODE_FIT:
- if (relativeAspectRatio > 1.0f) {
- // Screen is wider than the camera, scale down X
- mTargetQuad.p0.set(0.5f - 0.5f / relativeAspectRatio, 0.0f);
- mTargetQuad.p1.set(0.5f + 0.5f / relativeAspectRatio, 0.0f);
- mTargetQuad.p2.set(0.5f - 0.5f / relativeAspectRatio, 1.0f);
- mTargetQuad.p3.set(0.5f + 0.5f / relativeAspectRatio, 1.0f);
-
- } else {
- // Screen is taller than the camera, scale down Y
- mTargetQuad.p0.set(0.0f, 0.5f - 0.5f * relativeAspectRatio);
- mTargetQuad.p1.set(1.0f, 0.5f - 0.5f * relativeAspectRatio);
- mTargetQuad.p2.set(0.0f, 0.5f + 0.5f * relativeAspectRatio);
- mTargetQuad.p3.set(1.0f, 0.5f + 0.5f * relativeAspectRatio);
- }
- mProgram.setClearsOutput(true);
- break;
- case RENDERMODE_FILL_CROP:
- if (relativeAspectRatio > 1) {
- // Screen is wider than the camera, crop in Y
- mTargetQuad.p0.set(0.0f, 0.5f - 0.5f * relativeAspectRatio);
- mTargetQuad.p1.set(1.0f, 0.5f - 0.5f * relativeAspectRatio);
- mTargetQuad.p2.set(0.0f, 0.5f + 0.5f * relativeAspectRatio);
- mTargetQuad.p3.set(1.0f, 0.5f + 0.5f * relativeAspectRatio);
- } else {
- // Screen is taller than the camera, crop in X
- mTargetQuad.p0.set(0.5f - 0.5f / relativeAspectRatio, 0.0f);
- mTargetQuad.p1.set(0.5f + 0.5f / relativeAspectRatio, 0.0f);
- mTargetQuad.p2.set(0.5f - 0.5f / relativeAspectRatio, 1.0f);
- mTargetQuad.p3.set(0.5f + 0.5f / relativeAspectRatio, 1.0f);
- }
- mProgram.setClearsOutput(true);
- break;
- case RENDERMODE_CUSTOMIZE:
- ((ShaderProgram) mProgram).setSourceRegion(mSourceQuad);
- break;
- }
- ((ShaderProgram) mProgram).setTargetRegion(mTargetQuad);
- }
- }
- }
-}
diff --git a/mca/filterpacks/videosrc/java/package-info.java b/mca/filterpacks/videosrc/java/package-info.java
deleted file mode 100644
index d8fd0bd..0000000
--- a/mca/filterpacks/videosrc/java/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * @hide
- */
-package android.filterpacks.videosrc;
diff --git a/mca/samples/Android.mk b/mca/samples/Android.mk
deleted file mode 100644
index b1ce91e..0000000
--- a/mca/samples/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# Build all native libraries
-#
-include $(call all-subdir-makefiles)
-
-
diff --git a/mca/samples/CameraEffectsRecordingSample/Android.mk b/mca/samples/CameraEffectsRecordingSample/Android.mk
deleted file mode 100644
index d3c4336..0000000
--- a/mca/samples/CameraEffectsRecordingSample/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Build activity
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_PACKAGE_NAME := CameraEffectsRecordingSample
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-include $(BUILD_PACKAGE)
-
-# ============================================================
-
-# Also build all of the sub-targets under this one: the shared library.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/mca/samples/CameraEffectsRecordingSample/AndroidManifest.xml b/mca/samples/CameraEffectsRecordingSample/AndroidManifest.xml
deleted file mode 100644
index a65129d..0000000
--- a/mca/samples/CameraEffectsRecordingSample/AndroidManifest.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- android:versionCode="1"
- android:versionName="1.0" package="android.media.filterfw.samples">
- <uses-sdk android:minSdkVersion="3" />
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-feature android:name="android.hardware.camera" />
- <uses-feature android:name="android.hardware.camera.autofocus" />
- <application android:label="@string/app_name"
- android:debuggable="true">
- <activity android:name=".CameraEffectsRecordingSample"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/mca/samples/CameraEffectsRecordingSample/java/android/media/filterfw/samples/CameraEffectsRecordingSample.java b/mca/samples/CameraEffectsRecordingSample/java/android/media/filterfw/samples/CameraEffectsRecordingSample.java
deleted file mode 100644
index c0c3034..0000000
--- a/mca/samples/CameraEffectsRecordingSample/java/android/media/filterfw/samples/CameraEffectsRecordingSample.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.media.filterfw.samples;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.Environment;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.widget.Button;
-import android.filterfw.GraphEnvironment;
-import android.filterfw.core.GraphRunner;
-import android.filterpacks.videosink.MediaEncoderFilter;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.content.Intent;
-
-public class CameraEffectsRecordingSample extends Activity {
-
- private Button mRunButton;
- private SurfaceView mCameraView;
-
- private GraphRunner mRunner;
- private int mCameraId = 0;
- private String mOutFileName = Environment.getExternalStorageDirectory().toString() +
- "/CameraEffectsRecordingSample.mp4";
-
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- mRunButton = (Button) findViewById(R.id.runbutton);
- mCameraView = (SurfaceView) findViewById(R.id.cameraview);
- mRunButton.setOnClickListener(mRunButtonClick);
-
- Intent intent = getIntent();
- if (intent.hasExtra("OUTPUT_FILENAME")) {
- mOutFileName = intent.getStringExtra("OUTPUT_FILENAME");
- }
- // Set up the references and load the filter graph
- createGraph();
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_CAMERA:
- mRunButton.performClick();
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
-
- private void createGraph() {
- Bitmap sourceBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.android);
- GraphEnvironment graphEnvironment = new GraphEnvironment();
- graphEnvironment.createGLEnvironment();
- graphEnvironment.addReferences("cameraView", mCameraView);
- graphEnvironment.addReferences("cameraId", mCameraId);
- graphEnvironment.addReferences("outputFileName", mOutFileName);
- int graphId = graphEnvironment.loadGraph(this, R.raw.cameraeffectsrecordingsample);
- mRunner = graphEnvironment.getRunner(graphId, GraphEnvironment.MODE_ASYNCHRONOUS);
- }
-
- protected void onPause() {
- super.onPause();
- if (mRunner.isRunning()) {
- mRunner.stop();
- mRunButton.setText("Record");
- }
- }
-
- private OnClickListener mRunButtonClick = new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mRunner.isRunning()) {
- mRunner.stop();
- mRunButton.setText("Record");
- } else {
- mRunner.run();
- mRunButton.setText("Stop");
- }
- }
- };
-}
diff --git a/mca/samples/CameraEffectsRecordingSample/res/drawable/android.jpg b/mca/samples/CameraEffectsRecordingSample/res/drawable/android.jpg
deleted file mode 100644
index 7c26a8d..0000000
--- a/mca/samples/CameraEffectsRecordingSample/res/drawable/android.jpg
+++ /dev/null
Binary files differ
diff --git a/mca/samples/CameraEffectsRecordingSample/res/layout/main.xml b/mca/samples/CameraEffectsRecordingSample/res/layout/main.xml
deleted file mode 100644
index 0cc07ce..0000000
--- a/mca/samples/CameraEffectsRecordingSample/res/layout/main.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <Button
- android:id="@+id/runbutton"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Record" />
- <android.filterfw.core.FilterSurfaceView
- android:id="@+id/cameraview"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"
- android:layout_weight="1" />
-</LinearLayout>
diff --git a/mca/samples/CameraEffectsRecordingSample/res/raw/cameraeffectsrecordingsample.graph b/mca/samples/CameraEffectsRecordingSample/res/raw/cameraeffectsrecordingsample.graph
deleted file mode 100644
index f3ed667..0000000
--- a/mca/samples/CameraEffectsRecordingSample/res/raw/cameraeffectsrecordingsample.graph
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2011 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// A simple graph that displays the raw camera stream.
-
-@setting autoBranch = "synced";
-
-// Imports ---------------------------------------------------
-@import android.filterpacks.videosrc;
-@import android.filterpacks.ui;
-@import android.filterpacks.videosink;
-@import android.filterpacks.base;
-
-// Externals -------------------------------------------------
-@external cameraView;
-@external outputFileName;
-@external cameraId;
-
-@set widthLoc = 320;
-@set heightLoc = 240;
-
-// Filters ---------------------------------------------------
-@filter CameraSource camera {
- id = $cameraId;
- width = $widthLoc;
- height = $heightLoc;
- waitForNewFrame = false;
-}
-
-@filter MediaEncoderFilter mediaEncoder {
- width = $widthLoc;
- height = $heightLoc;
- outputFile = $outputFileName;
-}
-
-@filter SurfaceRenderFilter renderer {
- surfaceView = $cameraView;
-}
-
-
-// Connections -----------------------------------------------
-// Camera->Preview, Camera->Encoder
-// Render camera output on to a surface
-@connect camera[video] => renderer[frame];
-// Also pass it to an encoder
-@connect camera[video] => mediaEncoder[videoframe];
diff --git a/mca/samples/CameraEffectsRecordingSample/res/values/strings.xml b/mca/samples/CameraEffectsRecordingSample/res/values/strings.xml
deleted file mode 100644
index 6491043..0000000
--- a/mca/samples/CameraEffectsRecordingSample/res/values/strings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- -->
-<resources>
- <string name="app_name">CameraEffectsRecordingSample</string>
-</resources>
diff --git a/mca/structgen.py b/mca/structgen.py
deleted file mode 100755
index 34af238..0000000
--- a/mca/structgen.py
+++ /dev/null
@@ -1,360 +0,0 @@
-#!/usr/bin/env python
-
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import os
-import sys
-
-hFileTemplate = """/**
- * This file is auto-generated by platform/system/media/mca/structgen.py! Do NOT modify!
- **/
-
-#ifndef %s
-#define %s
-
-%s
-
-#endif // %s
-"""
-
-jniFileTemplate = """/**
- * This file is auto-generated by platform/system/media/mca/structgen.py! Do NOT modify!
- **/
-
-#include <stdint.h>
-#include "native/%s.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "jni.h"
-
-// Helper functions ////////////////////////////////////////////////////////////////////////////////
-%s* Get%sAtIndex(JNIEnv* env, jobject buffer, int index) {
- jclass base_class = (*env)->FindClass(env, "android/filterfw/core/NativeBuffer");
- jfieldID ptr_field = (*env)->GetFieldID(env, base_class, "mDataPointer", "J");
- uintptr_t data_ptr = (*env)->GetLongField(env, buffer, ptr_field);
- %s* array = (%s*)data_ptr;
- (*env)->DeleteLocalRef(env, base_class);
- return &array[index];
-}
-
-// Declarations ////////////////////////////////////////////////////////////////////////////////////
-JNIEXPORT jint JNICALL
-Java_%s_getElementSize(JNIEnv* env, jobject thiz);
-
-%s
-
-#ifdef __cplusplus
-}
-#endif
-
-// Implementation //////////////////////////////////////////////////////////////////////////////////
-jint Java_%s_getElementSize(JNIEnv* env, jobject thiz) {
- return sizeof(%s);
-}
-
-%s
-"""
-
-javaFileTemplate = """/**
- * This file is auto-generated by platform/system/media/mca/structgen.py! Do NOT modify!
- **/
-
-package %s;
-
-import android.filterfw.core.NativeBuffer;
-
-%s
-"""
-
-
-def ToJavaName(cname, start_upper_at = 1):
- lower = cname.split("_")
- upper = [c.title() for c in lower]
- return "".join(lower[:start_upper_at] + upper[start_upper_at:])
-
-def ToJNIPackage(package, jclassname):
- return "%s_%s" % (package.replace(".", "_"), jclassname)
-
-def ToMacroDefName(cname, pname):
- return "%s_%s" % (pname.replace(".", "_").upper(), cname.upper())
-
-class ParseError:
- def __init__(self, lineno, message):
- self.lineno = lineno
- self.message = message
-
- def __str__(self):
- return "On line %d: %s" % (self.lineno, self.message)
-
-class FieldType_BasePOD:
- def __init__(self, name, structname, jclassname, package, ctype, jtype, defval):
- self.name = name
- self.structname = structname
- self.jclassname = jclassname
- self.package = package
- self.ctype = ctype
- self.jtype = jtype
- self.defval = defval
-
- def cString(self):
- return " %s %s;" % (self.ctype, self.name)
-
- def javaGetter(self):
- return " public %s get%s(int index) {\n"\
- " assertReadable();\n"\
- " return nativeGet%s(index);\n"\
- " }" % (self.ctype, ToJavaName(self.name, 0), ToJavaName(self.name, 0))
-
- def javaSetter(self):
- return " public void set%s(int index, %s value) {\n"\
- " assertWritable();\n"\
- " nativeSet%s(index, value);\n"\
- " }" % (ToJavaName(self.name, 0), self.ctype, ToJavaName(self.name, 0))
-
- def javaNativeGetter(self):
- return " private native %s nativeGet%s(int index);"\
- % (self.ctype, ToJavaName(self.name, 0))
-
- def javaNativeSetter(self):
- return " private native boolean nativeSet%s(int index, %s value);"\
- % (ToJavaName(self.name, 0), self.ctype)
-
- def jniGetterDefString(self):
- return "JNIEXPORT %s JNICALL\n" \
- "Java_%s_nativeGet%s(JNIEnv* env, jobject thiz, jint index);" \
- % (self.jtype, ToJNIPackage(self.package, self.jclassname), ToJavaName(self.name, 0))
-
- def jniGetterImplString(self):
- return \
- "%s Java_%s_nativeGet%s(JNIEnv* env, jobject thiz, jint index) {\n"\
- " %s* instance = Get%sAtIndex(env, thiz, index);\n"\
- " return instance ? instance->%s : %s;\n"\
- "}\n" % (self.jtype, ToJNIPackage(self.package, self.jclassname), ToJavaName(self.name, 0),\
- self.structname, self.structname, self.name, self.defval)
-
- def jniSetterDefString(self):
- return "JNIEXPORT jboolean JNICALL\n" \
- "Java_%s_nativeSet%s(JNIEnv* env, jobject thiz, jint index, %s value);" \
- % (ToJNIPackage(self.package, self.jclassname), ToJavaName(self.name, 0), self.jtype)
-
- def jniSetterImplString(self):
- return \
- "jboolean Java_%s_nativeSet%s(JNIEnv* env, jobject thiz, jint index, %s value) {\n"\
- " %s* instance = Get%sAtIndex(env, thiz, index);\n"\
- " if (instance) {\n"\
- " instance->%s = value;\n"\
- " return JNI_TRUE;\n"\
- " }\n"\
- " return JNI_FALSE;\n"\
- "}\n" % (ToJNIPackage(self.package, self.jclassname), ToJavaName(self.name, 0),\
- self.jtype, self.structname, self.structname, self.name)
-
-class FieldType_Float(FieldType_BasePOD):
- def __init__(self, name, structname, jclassname, package):
- FieldType_BasePOD.__init__(self, name, structname, jclassname, package, "float", "jfloat", "0.0")
-
-class FieldType_Int(FieldType_BasePOD):
- def __init__(self, name, structname, jclassname, package):
- FieldType_BasePOD.__init__(self, name, structname, jclassname, package, "int", "jint", "0")
-
-class StructSpec:
-
- def parseTextFile(self, filepath):
- # Init
- self.name = None
- self.package = None
- self.fields = []
- self.structname = None
- self.jclassname = None
- self.libname = None
-
- # Open the file
- txtfile = open(filepath)
-
- # Parse it line by line
- lineno = 0
- for line in txtfile:
- # Split line into components
- linecomps = line.split()
- if len(linecomps) == 0:
- continue
-
- # Execute command
- cmd = linecomps[0]
- if cmd == "@name":
- self.commandArgAssert(linecomps, 1, lineno)
- self.name = linecomps[1]
- if not self.structname:
- self.structname = self.name
- if not self.jclassname:
- self.jclassname = self.name
- elif cmd == "@package":
- self.commandArgAssert(linecomps, 1, lineno)
- self.package = linecomps[1]
- elif cmd == "@libname":
- self.commandArgAssert(linecomps, 1, lineno)
- self.libname = linecomps[1]
- elif cmd == "@structname":
- self.commandArgAssert(linecomps, 1, lineno)
- self.structname = linecomps[1]
- elif cmd == "@javaclassname":
- self.commandArgAssert(linecomps, 1, lineno)
- self.jclassname = linecomps[1]
- elif cmd == "@field":
- self.commandArgAssert(linecomps, 2, lineno)
- typestr = linecomps[1]
- if typestr == "int":
- fieldtype = FieldType_Int(linecomps[2], self.structname, self.jclassname, self.package)
- elif typestr == "float":
- fieldtype = FieldType_Float(linecomps[2], self.structname, self.jclassname, self.package)
- else:
- raise ParseError(lineno, "Unknown field type '%s'!" % typestr)
- self.fields.append(fieldtype)
- else:
- raise ParseError(lineno, "Unknown command: '%s'!" % cmd)
-
- lineno = lineno + 1
-
- # Make sure we have all required info
- if not self.name:
- raise ParseError(lineno, "Required field '@name' missing!")
- elif not self.package:
- raise ParseError(lineno, "Required field '@package' missing!")
- elif not self.libname:
- raise ParseError(lineno, "Required field '@libname' missing!")
-
- # Normalize values
- if self.libname[:3] == "lib":
- self.libname = self.libname[3:]
-
- def commandArgAssert(self, linecomps, expectedcount, lineno):
- foundcount = len(linecomps) - 1
- if foundcount < expectedcount:
- raise ParseError(lineno, "Not enough arguments specifed for command '%s'! Expected %d, " \
- "but got only %d!" % (linecomps[0], expectedcount, foundcount))
- elif foundcount > expectedcount + 1:
- raise ParseError(lineno, "Too many arguments specifed for command '%s'! Expected %d, " \
- "but got %d!" % (linecomps[0], expectedcount, foundcount))
-
-
- def cStructString(self):
- cfields = [f.cString() for f in self.fields]
- return "typedef struct Struct%s {\n%s\n} %s;\n" % (self.structname,\
- "\n".join(cfields),\
- self.structname)
-
- def javaClassString(self):
- jgetters = [f.javaGetter() for f in self.fields]
- jsetters = [f.javaSetter() for f in self.fields]
- jnativesetters = [f.javaNativeSetter() for f in self.fields]
- jnativegetters = [f.javaNativeGetter() for f in self.fields]
- return "public class %s extends NativeBuffer {\n\n"\
- " public %s() {\n"\
- " super();\n"\
- " }\n"\
- "\n"\
- " public %s(int count) {\n"\
- " super(count);\n"\
- " }\n"\
- "\n"\
- " public native int getElementSize();\n"\
- "\n"\
- "%s\n\n"\
- "%s\n\n"\
- "%s\n\n"\
- "%s\n\n"\
- " static {\n"\
- " System.loadLibrary(\"%s\");\n"\
- " }\n"\
- "\n"\
- "};\n" % (self.jclassname,\
- self.jclassname,\
- self.jclassname,\
- "\n\n".join(jgetters),\
- "\n\n".join(jsetters),\
- "\n\n".join(jnativegetters),\
- "\n\n".join(jnativesetters),\
- self.libname)
-
- def jniDeclString(self):
- jnigetters = [f.jniGetterDefString() for f in self.fields]
- jnisetters = [f.jniSetterDefString() for f in self.fields]
- return "\n\n".join(jnigetters + jnisetters)
-
- def jniImplString(self):
- jnigetters = [f.jniGetterImplString() for f in self.fields]
- jnisetters = [f.jniSetterImplString() for f in self.fields]
- return "\n\n".join(jnigetters + jnisetters)
-
- def hFileString(self):
- defname = ToMacroDefName(self.structname, self.package)
- return hFileTemplate % (defname, defname, self.cStructString(), defname)
-
- def javaFileString(self):
- return javaFileTemplate % (self.package, self.javaClassString())
-
- def jniFileString(self):
- return jniFileTemplate % (self.structname.lower(),\
- self.structname,\
- self.structname,\
- self.structname,\
- self.structname,\
- ToJNIPackage(self.package, self.jclassname),\
- self.jniDeclString(),\
- ToJNIPackage(self.package, self.jclassname),\
- self.structname,
- self.jniImplString())
-
-def main(argv):
- if len(argv) != 2:
- print("Usage: %s <file.struct>" % argv[0])
- return -1
-
- filepath = argv[1]
-
- structspec = StructSpec()
- structspec.parseTextFile(filepath)
-
- hfilename = "%s.h" % structspec.structname.lower()
- javafilename = "%s.java" % structspec.jclassname
- jnifilename = "jni_%s.c" % structspec.structname.lower()
-
- javapackagepath = structspec.package.replace('.','/')
-
- rootdir = os.path.dirname(filepath)
- hfilepath = "%s/../native/%s" % (rootdir, hfilename)
- javafilepath = "%s/../java/%s/%s" % (rootdir, javapackagepath, javafilename)
- jnifilepath = "%s/../jni/%s" % (rootdir, jnifilename)
-
- hfile = open(hfilepath, 'w')
- hfile.write(structspec.hFileString())
- hfile.close()
-
- javafile = open(javafilepath, 'w')
- javafile.write(structspec.javaFileString())
- javafile.close()
-
- jnifile = open(jnifilepath, 'w')
- jnifile.write(structspec.jniFileString())
- jnifile.close()
-
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv))
diff --git a/mca/tests/Android.mk b/mca/tests/Android.mk
deleted file mode 100644
index 2abd7f6..0000000
--- a/mca/tests/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CameraEffectsTests
-
-LOCAL_INSTRUMENTATION_FOR := CameraEffectsRecordingSample
-
-include $(BUILD_PACKAGE)
-
-
diff --git a/mca/tests/AndroidManifest.xml b/mca/tests/AndroidManifest.xml
deleted file mode 100644
index 5133640..0000000
--- a/mca/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.camera.mediaeffects.tests">
-
- <uses-permission android:name="android.permission.INJECT_EVENTS" />
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="android.media.filterfw.samples"
- android:label="Tests for Camera Effects Recording."/>
-</manifest>
diff --git a/mca/tests/src/android/camera/mediaeffects/tests/functional/EffectsVideoCapture.java b/mca/tests/src/android/camera/mediaeffects/tests/functional/EffectsVideoCapture.java
deleted file mode 100644
index 474b00f..0000000
--- a/mca/tests/src/android/camera/mediaeffects/tests/functional/EffectsVideoCapture.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.camera.mediaeffects.tests.functional;
-
-import android.media.filterfw.samples.CameraEffectsRecordingSample;
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.view.KeyEvent;
-import android.util.Log;
-import android.content.Intent;
-import android.os.Environment;
-import android.media.MediaMetadataRetriever;
-import android.net.Uri;
-import java.io.File;
-
-public class EffectsVideoCapture extends ActivityInstrumentationTestCase2
- <CameraEffectsRecordingSample> {
- private static final String TAG = "EffectsVideoCaptureTest";
- private static final long WAIT_FOR_PREVIEW = 4 * 1000; // 4 seconds
-
- public EffectsVideoCapture() {
- super(CameraEffectsRecordingSample.class);
- }
-
- private void captureVideos(String reportTag, Instrumentation inst) throws Exception{
- int total_num_of_videos = 1;
- int video_duration = 4 * 1000; // 4 seconds
-
- Log.v(TAG, reportTag);
- for (int i = 0; i < total_num_of_videos; i++) {
- Thread.sleep(WAIT_FOR_PREVIEW);
- // record a video
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- Thread.sleep(video_duration);
- inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA);
- }
- }
-
- @LargeTest
- public void testBackEffectsVideoCapture() throws Exception {
- Instrumentation inst = getInstrumentation();
-
- Intent intent = new Intent();
- intent.setClass(getInstrumentation().getTargetContext(),
- CameraEffectsRecordingSample.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra("OUTPUT_FILENAME", Environment.getExternalStorageDirectory().toString()
- + "/CameraEffectsRecordingTest.mp4");
- Activity act = inst.startActivitySync(intent);
- captureVideos("Back Camera Video Capture\n", inst);
- act.finish();
-
- // Verification
- File file = new File(Environment.getExternalStorageDirectory(),
- "CameraEffectsRecordingTest.mp4");
- Uri uri = Uri.fromFile(file);
- verify(getActivity(), uri);
- }
-
- // Verify result code, result data, and the duration.
- private void verify(CameraEffectsRecordingSample activity, Uri uri) throws Exception {
- assertNotNull(uri);
- // Verify the video file
- MediaMetadataRetriever retriever = new MediaMetadataRetriever();
- retriever.setDataSource(activity, uri);
- String duration = retriever.extractMetadata(
- MediaMetadataRetriever.METADATA_KEY_DURATION);
- assertNotNull(duration);
- int durationValue = Integer.parseInt(duration);
- Log.v(TAG, "Video duration is " + durationValue);
- assertTrue(durationValue > 0);
- }
-}
diff --git a/wilhelm/doc/Doxyfile b/wilhelm/doc/Doxyfile
deleted file mode 100644
index 7f6ade7..0000000
--- a/wilhelm/doc/Doxyfile
+++ /dev/null
@@ -1,1630 +0,0 @@
-# Doxyfile 1.7.1
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the
-# iconv built into libc) for the transcoding. See
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
-
-DOXYFILE_ENCODING = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME = Wilhelm
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER = 0.1
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY =
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
-
-CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
-# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
-# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
-# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
-
-OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF =
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like regular Qt-style comments
-# (thus requiring an explicit @brief command for a brief description.)
-
-JAVADOC_AUTOBRIEF = NO
-
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
-# interpret the first line (until the first dot) of a Qt-style
-# comment as the brief description. If set to NO, the comments
-# will behave just like regular Qt-style comments (thus requiring
-# an explicit \brief command for a brief description.)
-
-QT_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
-
-SEPARATE_MEMBER_PAGES = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 8
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = NO
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for
-# Java. For instance, namespaces will be presented as packages, qualified
-# scopes will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources only. Doxygen will then generate output that is more tailored for
-# Fortran.
-
-OPTIMIZE_FOR_FORTRAN = NO
-
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for
-# VHDL.
-
-OPTIMIZE_OUTPUT_VHDL = NO
-
-# Doxygen selects the parser to use depending on the extension of the files it
-# parses. With this tag you can assign which parser to use for a given extension.
-# Doxygen has a built-in mapping, but you can override or extend it using this
-# tag. The format is ext=language, where ext is a file extension, and language
-# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
-# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
-# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
-# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
-# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
-
-EXTENSION_MAPPING =
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-
-CPP_CLI_SUPPORT = NO
-
-# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
-# Doxygen will parse them like normal C++ but will assume all classes use public
-# instead of private inheritance when no explicit protection keyword is present.
-
-SIP_SUPPORT = NO
-
-# For Microsoft's IDL there are propget and propput attributes to indicate getter
-# and setter methods for a property. Setting this option to YES (the default)
-# will make doxygen to replace the get and set methods by a property in the
-# documentation. This will only work if the methods are indeed getting or
-# setting a simple type. If this is not the case, or you want to show the
-# methods anyway, you should set this option to NO.
-
-IDL_PROPERTY_SUPPORT = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = YES
-
-# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
-# is documented as struct, union, or enum with the name of the typedef. So
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
-# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically
-# be useful for C code in case the coding convention dictates that all compound
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-
-TYPEDEF_HIDES_STRUCT = NO
-
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
-# determine which symbols to keep in memory and which to flush to disk.
-# When the cache is full, less often used symbols will be written to disk.
-# For small to medium size projects (<1000 input files) the default value is
-# probably good enough. For larger projects a too small cache size can cause
-# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penality.
-# If the system has enough physical memory increasing the cache will improve the
-# performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will rougly double the
-# memory usage. The cache size is given by this formula:
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols
-
-SYMBOL_CACHE_SIZE = 0
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = YES
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS = NO
-
-# If this flag is set to YES, the members of anonymous namespaces will be
-# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base
-# name of the file that contains the anonymous namespace. By default
-# anonymous namespace are hidden.
-
-EXTRACT_ANON_NSPACES = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = NO
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
-# will list include files with double quotes in the documentation
-# rather than with sharp brackets.
-
-FORCE_LOCAL_INCLUDES = NO
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = NO
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS = NO
-
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
-# will sort the (brief and detailed) documentation of class members so that
-# constructors and destructors are listed first. If set to NO (the default)
-# the constructors will appear in the respective orders defined by
-# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
-# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
-# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
-
-SORT_MEMBERS_CTORS_1ST = NO
-
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
-# hierarchy of group names into alphabetical order. If set to NO (the default)
-# the group names will appear in their defined order.
-
-SORT_GROUP_NAMES = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = YES
-
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES = NO
-
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
-# This will remove the Files entry from the Quick Index and from the
-# Folder Tree View (if specified). The default is YES.
-
-SHOW_FILES = YES
-
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
-# Namespaces page.
-# This will remove the Namespaces entry from the Quick Index
-# and from the Folder Tree View (if specified). The default is YES.
-
-SHOW_NAMESPACES = YES
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from
-# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command <command> <input-file>, where <command> is the value of
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
-
-FILE_VERSION_FILTER =
-
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
-# by doxygen. The layout file controls the global structure of the generated
-# output files in an output format independent way. The create the layout file
-# that represents doxygen's defaults, run doxygen with the -l option.
-# You can optionally specify a file name after the option, if omitted
-# DoxygenLayout.xml will be used as the name of the layout file.
-
-LAYOUT_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = YES
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
-
-WARN_NO_PARAMDOC = NO
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT = ../src
-
-# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-# also the default input encoding. Doxygen uses libiconv (or the iconv built
-# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
-# the list of possible encodings.
-
-INPUT_ENCODING = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-
-FILE_PATTERNS =
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE =
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
-# from the input.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
-
-EXCLUDE_PATTERNS =
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the
-# output. The symbol name can be a fully qualified name, a word, or if the
-# wildcard * is used, a substring. Examples: ANamespace, AClass,
-# AClass::ANamespace, ANamespace::*Test
-
-EXCLUDE_SYMBOLS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output.
-# If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis.
-# Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match.
-# The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = NO
-
-# If the REFERENCED_BY_RELATION tag is set to YES
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = YES
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code.
-# Otherwise they will link to the documentation.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
-
-USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = YES
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET =
-
-# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
-# Doxygen will adjust the colors in the stylesheet and background images
-# according to this color. Hue is specified as an angle on a colorwheel,
-# see http://en.wikipedia.org/wiki/Hue for more information.
-# For instance the value 0 represents red, 60 is yellow, 120 is green,
-# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
-# The allowed range is 0 to 359.
-
-HTML_COLORSTYLE_HUE = 220
-
-# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
-# the colors in the HTML output. For a value of 0 the output will use
-# grayscales only. A value of 255 will produce the most vivid colors.
-
-HTML_COLORSTYLE_SAT = 100
-
-# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
-# the luminance component of the colors in the HTML output. Values below
-# 100 gradually make the output lighter, whereas values above 100 make
-# the output darker. The value divided by 100 is the actual gamma applied,
-# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
-# and 100 does not change the gamma.
-
-HTML_COLORSTYLE_GAMMA = 80
-
-# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
-# page will contain the date and time when the page was generated. Setting
-# this to NO can help when comparing the output of multiple runs.
-
-HTML_TIMESTAMP = YES
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
-# documentation will contain sections that can be hidden and shown after the
-# page has loaded. For this to work a browser that supports
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
-
-HTML_DYNAMIC_SECTIONS = NO
-
-# If the GENERATE_DOCSET tag is set to YES, additional index files
-# will be generated that can be used as input for Apple's Xcode 3
-# integrated development environment, introduced with OSX 10.5 (Leopard).
-# To create a documentation set, doxygen will generate a Makefile in the
-# HTML output directory. Running make will produce the docset in that
-# directory and running "make install" will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
-# it at startup.
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
-# for more information.
-
-GENERATE_DOCSET = NO
-
-# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
-# feed. A documentation feed provides an umbrella under which multiple
-# documentation sets from a single provider (such as a company or product suite)
-# can be grouped.
-
-DOCSET_FEEDNAME = "Doxygen generated docs"
-
-# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
-# should uniquely identify the documentation set bundle. This should be a
-# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
-# will append .docset to the name.
-
-DOCSET_BUNDLE_ID = org.doxygen.Project
-
-# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
-# the documentation publisher. This should be a reverse domain-name style
-# string, e.g. com.mycompany.MyDocSet.documentation.
-
-DOCSET_PUBLISHER_ID = org.doxygen.Publisher
-
-# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
-
-DOCSET_PUBLISHER_NAME = Publisher
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
-# is used to encode HtmlHelp index (hhk), content (hhc) and project file
-# content.
-
-CHM_INDEX_ENCODING =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
-# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
-# that can be used as input for Qt's qhelpgenerator to generate a
-# Qt Compressed Help (.qch) of the generated HTML documentation.
-
-GENERATE_QHP = NO
-
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
-# be used to specify the file name of the resulting .qch file.
-# The path specified is relative to the HTML output folder.
-
-QCH_FILE =
-
-# The QHP_NAMESPACE tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#namespace
-
-QHP_NAMESPACE = org.doxygen.Project
-
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#virtual-folders
-
-QHP_VIRTUAL_FOLDER = doc
-
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
-# add. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#custom-filters
-
-QHP_CUST_FILTER_NAME =
-
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
-# custom filter to add. For more information please see
-# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
-# Qt Help Project / Custom Filters</a>.
-
-QHP_CUST_FILTER_ATTRS =
-
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
-# project's
-# filter section matches.
-# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
-# Qt Help Project / Filter Attributes</a>.
-
-QHP_SECT_FILTER_ATTRS =
-
-# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
-# be used to specify the location of Qt's qhelpgenerator.
-# If non-empty doxygen will try to run qhelpgenerator on the generated
-# .qhp file.
-
-QHG_LOCATION =
-
-# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
-# will be generated, which together with the HTML files, form an Eclipse help
-# plugin. To install this plugin and make it available under the help contents
-# menu in Eclipse, the contents of the directory containing the HTML and XML
-# files needs to be copied into the plugins directory of eclipse. The name of
-# the directory within the plugins directory should be the same as
-# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
-# the help appears.
-
-GENERATE_ECLIPSEHELP = NO
-
-# A unique identifier for the eclipse help plugin. When installing the plugin
-# the directory name containing the HTML and XML files should also have
-# this name.
-
-ECLIPSE_DOC_ID = org.doxygen.Project
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information.
-# If the tag value is set to YES, a side panel will be generated
-# containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
-# Windows users are probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW = NO
-
-# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
-# and Class Hierarchy pages using a tree view instead of an ordered list.
-
-USE_INLINE_TREES = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
-# links to external symbols imported via tag files in a separate window.
-
-EXT_LINKS_IN_WINDOW = NO
-
-# Use this tag to change the font size of Latex formulas included
-# as images in the HTML documentation. The default is 10. Note that
-# when you change the font size after a successful doxygen run you need
-# to manually remove any form_*.png images from the HTML output directory
-# to force them to be regenerated.
-
-FORMULA_FONTSIZE = 10
-
-# Use the FORMULA_TRANPARENT tag to determine whether or not the images
-# generated for formulas are transparent PNGs. Transparent PNGs are
-# not supported properly for IE 6.0, but are supported on all modern browsers.
-# Note that when changing this option you need to delete any form_*.png files
-# in the HTML output before the changes have effect.
-
-FORMULA_TRANSPARENT = YES
-
-# When the SEARCHENGINE tag is enabled doxygen will generate a search box
-# for the HTML output. The underlying search engine uses javascript
-# and DHTML and should work on any modern browser. Note that when using
-# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
-# (GENERATE_DOCSET) there is already a search function so this one should
-# typically be disabled. For large projects the javascript based search engine
-# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
-
-SEARCHENGINE = YES
-
-# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
-# implemented using a PHP enabled web server instead of at the web client
-# using Javascript. Doxygen will generate the search PHP script and index
-# file to put on the web server. The advantage of the server
-# based approach is that it scales better to large projects and allows
-# full text search. The disadvances is that it is more difficult to setup
-# and does not have live searching capabilities.
-
-SERVER_BASED_SEARCH = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-# Note that when enabling USE_PDFLATEX this option is only used for
-# generating bitmaps for formulas in the HTML output, but not in the
-# Makefile that is written to the output directory.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = YES
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-# If LATEX_SOURCE_CODE is set to YES then doxygen will include
-# source code with syntax highlighting in the LaTeX output.
-# Note that which sources are shown also depends on other settings
-# such as SOURCE_BROWSER.
-
-LATEX_SOURCE_CODE = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader.
-# This is useful
-# if you want to understand what is going on.
-# On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-#
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-#
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
-
-CLASS_DIAGRAMS = YES
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see
-# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = NO
-
-# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
-# allowed to run in parallel. When set to 0 (the default) doxygen will
-# base this on the number of processors available in the system. You can set it
-# explicitly to a value larger than 0 to get control over the balance
-# between CPU load and processing speed.
-
-DOT_NUM_THREADS = 0
-
-# By default doxygen will write a font called FreeSans.ttf to the output
-# directory and reference it in all dot files that doxygen generates. This
-# font does not include all possible unicode characters however, so when you need
-# these (or just want a differently looking font) you can specify the font name
-# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
-# which can be done by putting it in a standard location or by setting the
-# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
-# containing the font.
-
-DOT_FONTNAME = FreeSans.ttf
-
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
-# The default size is 10pt.
-
-DOT_FONTSIZE = 10
-
-# By default doxygen will tell dot to use the output directory to look for the
-# FreeSans.ttf font (which doxygen will put there itself). If you specify a
-# different font using DOT_FONTNAME you can set the path where dot
-# can find it using this tag.
-
-DOT_FONTPATH =
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = YES
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
-
-GROUP_GRAPHS = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then
-# doxygen will generate a call dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable call graphs
-# for selected functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
-# doxygen will generate a caller dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable caller
-# graphs for selected functions only using the \callergraph command.
-
-CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
-DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
-# nodes that will be shown in the graph. If the number of nodes in a graph
-# becomes larger than this value, doxygen will truncate the graph, which is
-# visualized by representing a node as a red box. Note that doxygen if the
-# number of direct children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
-# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-
-DOT_GRAPH_MAX_NODES = 50
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes
-# that lay further from the root node will be omitted. Note that setting this
-# option to 1 or 2 may greatly reduce the computation time needed for large
-# code bases. Also note that the size of a graph can be further restricted by
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not
-# seem to support this out of the box. Warning: Depending on the platform used,
-# enabling this option may lead to badly anti-aliased labels on the edges of
-# a graph (i.e. they become hard to read).
-
-DOT_TRANSPARENT = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
-
-DOT_MULTI_TARGETS = NO
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
diff --git a/wilhelm/doc/Makefile b/wilhelm/doc/Makefile
deleted file mode 100644
index 1ab6cee..0000000
--- a/wilhelm/doc/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-html/index.html : Doxyfile clean
- doxygen $<
-
-clean :
- $(RM) -r html
diff --git a/wilhelm/doc/OpenMAX_AL_1_0_1_Specification.pdf b/wilhelm/doc/OpenMAX_AL_1_0_1_Specification.pdf
deleted file mode 100644
index a3380fd..0000000
--- a/wilhelm/doc/OpenMAX_AL_1_0_1_Specification.pdf
+++ /dev/null
Binary files differ
diff --git a/wilhelm/doc/OpenSL_ES_Specification_1.0.1.pdf b/wilhelm/doc/OpenSL_ES_Specification_1.0.1.pdf
deleted file mode 100644
index fe6b266..0000000
--- a/wilhelm/doc/OpenSL_ES_Specification_1.0.1.pdf
+++ /dev/null
Binary files differ
diff --git a/wilhelm/doc/README.txt b/wilhelm/doc/README.txt
deleted file mode 100644
index 7ed9498..0000000
--- a/wilhelm/doc/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-When building applications using the OpenSL-ES API you should compile and link the OpenSLES_IID.c file into your project. This file contains unique interface IDs for all OpenSL-ES API interfaces. These IDs have
-have been automatically generated. Application developers should not edit these interface IDs.
\ No newline at end of file
diff --git a/wilhelm/include/OMXAL/OpenMAXAL.h b/wilhelm/include/OMXAL/OpenMAXAL.h
deleted file mode 100644
index d31283c..0000000
--- a/wilhelm/include/OMXAL/OpenMAXAL.h
+++ /dev/null
@@ -1,3195 +0,0 @@
-/*
- * Copyright (c) 2007-2010 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and/or associated documentation files (the
- * "Materials "), to deal in the Materials without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Materials, and to
- * permit persons to whom the Materials are furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
- *
- * OpenMAXAL.h - OpenMAX AL version 1.0.1
- *
- */
-
-/****************************************************************************/
-/* NOTE: This file is a standard OpenMAX AL header file and should not be */
-/* modified in any way. */
-/****************************************************************************/
-
-#ifndef _OPENMAXAL_H_
-#define _OPENMAXAL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "OpenMAXAL_Platform.h"
-
-
- /*****************************************************************/
- /* TYPES */
- /*****************************************************************/
-
-/* remap common types to XA types for clarity */
-typedef xa_int8_t XAint8; /* 8 bit signed integer */
-typedef xa_uint8_t XAuint8; /* 8 bit unsigned integer */
-typedef xa_int16_t XAint16; /* 16 bit signed integer */
-typedef xa_uint16_t XAuint16; /* 16 bit unsigned integer */
-typedef xa_int32_t XAint32; /* 32 bit signed integer */
-typedef xa_uint32_t XAuint32; /* 32 bit unsigned integer */
-typedef xa_uint64_t XAuint64; /* 64 bit unsigned integer */
-
-typedef XAuint32 XAboolean;
-typedef XAuint8 XAchar;
-typedef XAint16 XAmillibel;
-typedef XAuint32 XAmillisecond;
-typedef XAuint32 XAmilliHertz;
-typedef XAint32 XAmillimeter;
-typedef XAint32 XAmillidegree;
-typedef XAint16 XApermille;
-typedef XAuint32 XAmicrosecond;
-typedef XAuint64 XAtime;
-typedef XAuint32 XAresult;
-
-#define XA_BOOLEAN_FALSE ((XAuint32) 0x00000000)
-#define XA_BOOLEAN_TRUE ((XAuint32) 0x00000001)
-
-#define XA_MILLIBEL_MAX ((XAmillibel) 0x7FFF)
-#define XA_MILLIBEL_MIN ((XAmillibel) (-XA_MILLIBEL_MAX-1))
-
-#define XA_MILLIHERTZ_MAX ((XAmilliHertz) 0xFFFFFFFF)
-
-#define XA_MILLIMETER_MAX ((XAmillimeter) 0x7FFFFFFF)
-
-
-
- /*****************************************************************/
- /* RESULT CODES */
- /*****************************************************************/
-
-#define XA_RESULT_SUCCESS ((XAuint32) 0x00000000)
-#define XA_RESULT_PRECONDITIONS_VIOLATED ((XAuint32) 0x00000001)
-#define XA_RESULT_PARAMETER_INVALID ((XAuint32) 0x00000002)
-#define XA_RESULT_MEMORY_FAILURE ((XAuint32) 0x00000003)
-#define XA_RESULT_RESOURCE_ERROR ((XAuint32) 0x00000004)
-#define XA_RESULT_RESOURCE_LOST ((XAuint32) 0x00000005)
-#define XA_RESULT_IO_ERROR ((XAuint32) 0x00000006)
-#define XA_RESULT_BUFFER_INSUFFICIENT ((XAuint32) 0x00000007)
-#define XA_RESULT_CONTENT_CORRUPTED ((XAuint32) 0x00000008)
-#define XA_RESULT_CONTENT_UNSUPPORTED ((XAuint32) 0x00000009)
-#define XA_RESULT_CONTENT_NOT_FOUND ((XAuint32) 0x0000000A)
-#define XA_RESULT_PERMISSION_DENIED ((XAuint32) 0x0000000B)
-#define XA_RESULT_FEATURE_UNSUPPORTED ((XAuint32) 0x0000000C)
-#define XA_RESULT_INTERNAL_ERROR ((XAuint32) 0x0000000D)
-#define XA_RESULT_UNKNOWN_ERROR ((XAuint32) 0x0000000E)
-#define XA_RESULT_OPERATION_ABORTED ((XAuint32) 0x0000000F)
-#define XA_RESULT_CONTROL_LOST ((XAuint32) 0x00000010)
-
-
-
- /*****************************************************************/
- /* INTERFACE ID DEFINITION */
- /*****************************************************************/
-
-/* Interface ID defined as a UUID */
-typedef const struct XAInterfaceID_ {
- XAuint32 time_low;
- XAuint16 time_mid;
- XAuint16 time_hi_and_version;
- XAuint16 clock_seq;
- XAuint8 node[6];
-} * XAInterfaceID;
-
-/* NULL Interface */
-XA_API extern const XAInterfaceID XA_IID_NULL;
-
-
-
- /*****************************************************************/
- /* GENERAL INTERFACES, STRUCTS AND DEFINES */
- /*****************************************************************/
-
-/* OBJECT */
-
-#define XA_PRIORITY_LOWEST ((XAint32) (-0x7FFFFFFF-1))
-#define XA_PRIORITY_VERYLOW ((XAint32) -0x60000000)
-#define XA_PRIORITY_LOW ((XAint32) -0x40000000)
-#define XA_PRIORITY_BELOWNORMAL ((XAint32) -0x20000000)
-#define XA_PRIORITY_NORMAL ((XAint32) 0x00000000)
-#define XA_PRIORITY_ABOVENORMAL ((XAint32) 0x20000000)
-#define XA_PRIORITY_HIGH ((XAint32) 0x40000000)
-#define XA_PRIORITY_VERYHIGH ((XAint32) 0x60000000)
-#define XA_PRIORITY_HIGHEST ((XAint32) 0x7FFFFFFF)
-
-#define XA_OBJECT_EVENT_RUNTIME_ERROR ((XAuint32) 0x00000001)
-#define XA_OBJECT_EVENT_ASYNC_TERMINATION ((XAuint32) 0x00000002)
-#define XA_OBJECT_EVENT_RESOURCES_LOST ((XAuint32) 0x00000003)
-#define XA_OBJECT_EVENT_RESOURCES_AVAILABLE ((XAuint32) 0x00000004)
-#define XA_OBJECT_EVENT_ITF_CONTROL_TAKEN ((XAuint32) 0x00000005)
-#define XA_OBJECT_EVENT_ITF_CONTROL_RETURNED ((XAuint32) 0x00000006)
-#define XA_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((XAuint32) 0x00000007)
-
-#define XA_OBJECT_STATE_UNREALIZED ((XAuint32) 0x00000001)
-#define XA_OBJECT_STATE_REALIZED ((XAuint32) 0x00000002)
-#define XA_OBJECT_STATE_SUSPENDED ((XAuint32) 0x00000003)
-
-
-XA_API extern const XAInterfaceID XA_IID_OBJECT;
-
-struct XAObjectItf_;
-typedef const struct XAObjectItf_ * const * XAObjectItf;
-
-typedef void (XAAPIENTRY * xaObjectCallback) (
- XAObjectItf caller,
- const void * pContext,
- XAuint32 event,
- XAresult result,
- XAuint32 param,
- void * pInterface
-);
-
-struct XAObjectItf_ {
- XAresult (*Realize) (
- XAObjectItf self,
- XAboolean async
- );
- XAresult (*Resume) (
- XAObjectItf self,
- XAboolean async
- );
- XAresult (*GetState) (
- XAObjectItf self,
- XAuint32 * pState
- );
- XAresult (*GetInterface) (
- XAObjectItf self,
- const XAInterfaceID iid,
- void * pInterface
- );
- XAresult (*RegisterCallback) (
- XAObjectItf self,
- xaObjectCallback callback,
- void * pContext
- );
- void (*AbortAsyncOperation) (
- XAObjectItf self
- );
- void (*Destroy) (
- XAObjectItf self
- );
- XAresult (*SetPriority) (
- XAObjectItf self,
- XAint32 priority,
- XAboolean preemptable
- );
- XAresult (*GetPriority) (
- XAObjectItf self,
- XAint32 * pPriority,
- XAboolean * pPreemptable
- );
- XAresult (*SetLossOfControlInterfaces) (
- XAObjectItf self,
- XAint16 numInterfaces,
- XAInterfaceID * pInterfaceIDs,
- XAboolean enabled
- );
-};
-
-/* CONFIG EXTENSION */
-
-XA_API extern const XAInterfaceID XA_IID_CONFIGEXTENSION;
-
-struct XAConfigExtensionsItf_;
-typedef const struct XAConfigExtensionsItf_
- * const * XAConfigExtensionsItf;
-
-struct XAConfigExtensionsItf_ {
- XAresult (*SetConfiguration) (
- XAConfigExtensionsItf self,
- const XAchar * configKey,
- XAuint32 valueSize,
- const void * pConfigValue
- );
- XAresult (*GetConfiguration) (
- XAConfigExtensionsItf self,
- const XAchar * configKey,
- XAuint32 * pValueSize,
- void * pConfigValue
- );
-};
-
-/* DYNAMIC INTERFACE MANAGEMENT */
-
-#define XA_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((XAuint32) 0x00000001)
-#define XA_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((XAuint32) 0x00000002)
-#define XA_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((XAuint32) 0x00000003)
-#define XA_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((XAuint32) 0x00000004)
-#define XA_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((XAuint32) 0x00000005)
-
-XA_API extern const XAInterfaceID XA_IID_DYNAMICINTERFACEMANAGEMENT;
-
-struct XADynamicInterfaceManagementItf_;
-typedef const struct XADynamicInterfaceManagementItf_
- * const * XADynamicInterfaceManagementItf;
-
-typedef void (XAAPIENTRY * xaDynamicInterfaceManagementCallback) (
- XADynamicInterfaceManagementItf caller,
- void * pContext,
- XAuint32 event,
- XAresult result,
- const XAInterfaceID iid
-);
-
-struct XADynamicInterfaceManagementItf_ {
- XAresult (*AddInterface) (
- XADynamicInterfaceManagementItf self,
- const XAInterfaceID iid,
- XAboolean aysnc
- );
- XAresult (*RemoveInterface) (
- XADynamicInterfaceManagementItf self,
- const XAInterfaceID iid
- );
- XAresult (*ResumeInterface) (
- XADynamicInterfaceManagementItf self,
- const XAInterfaceID iid,
- XAboolean aysnc
- );
- XAresult (*RegisterCallback) (
- XADynamicInterfaceManagementItf self,
- xaDynamicInterfaceManagementCallback callback,
- void * pContext
- );
-};
-
-/* DATA SOURCES/SINKS */
-
-#define XA_DATAFORMAT_MIME ((XAuint32) 0x00000001)
-#define XA_DATAFORMAT_PCM ((XAuint32) 0x00000002)
-#define XA_DATAFORMAT_RAWIMAGE ((XAuint32) 0x00000003)
-
-#define XA_DATALOCATOR_URI ((XAuint32) 0x00000001)
-#define XA_DATALOCATOR_ADDRESS ((XAuint32) 0x00000002)
-#define XA_DATALOCATOR_IODEVICE ((XAuint32) 0x00000003)
-#define XA_DATALOCATOR_OUTPUTMIX ((XAuint32) 0x00000004)
-#define XA_DATALOCATOR_NATIVEDISPLAY ((XAuint32) 0x00000005)
-#define XA_DATALOCATOR_RESERVED6 ((XAuint32) 0x00000006)
-#define XA_DATALOCATOR_RESERVED7 ((XAuint32) 0x00000007)
-
-typedef struct XADataSink_ {
- void * pLocator;
- void * pFormat;
-} XADataSink;
-
-typedef struct XADataSource_ {
- void * pLocator;
- void * pFormat;
-} XADataSource;
-
-#define XA_CONTAINERTYPE_UNSPECIFIED ((XAuint32) 0x00000001)
-#define XA_CONTAINERTYPE_RAW ((XAuint32) 0x00000002)
-#define XA_CONTAINERTYPE_ASF ((XAuint32) 0x00000003)
-#define XA_CONTAINERTYPE_AVI ((XAuint32) 0x00000004)
-#define XA_CONTAINERTYPE_BMP ((XAuint32) 0x00000005)
-#define XA_CONTAINERTYPE_JPG ((XAuint32) 0x00000006)
-#define XA_CONTAINERTYPE_JPG2000 ((XAuint32) 0x00000007)
-#define XA_CONTAINERTYPE_M4A ((XAuint32) 0x00000008)
-#define XA_CONTAINERTYPE_MP3 ((XAuint32) 0x00000009)
-#define XA_CONTAINERTYPE_MP4 ((XAuint32) 0x0000000A)
-#define XA_CONTAINERTYPE_MPEG_ES ((XAuint32) 0x0000000B)
-#define XA_CONTAINERTYPE_MPEG_PS ((XAuint32) 0x0000000C)
-#define XA_CONTAINERTYPE_MPEG_TS ((XAuint32) 0x0000000D)
-#define XA_CONTAINERTYPE_QT ((XAuint32) 0x0000000E)
-#define XA_CONTAINERTYPE_WAV ((XAuint32) 0x0000000F)
-#define XA_CONTAINERTYPE_XMF_0 ((XAuint32) 0x00000010)
-#define XA_CONTAINERTYPE_XMF_1 ((XAuint32) 0x00000011)
-#define XA_CONTAINERTYPE_XMF_2 ((XAuint32) 0x00000012)
-#define XA_CONTAINERTYPE_XMF_3 ((XAuint32) 0x00000013)
-#define XA_CONTAINERTYPE_XMF_GENERIC ((XAuint32) 0x00000014)
-#define XA_CONTAINERTYPE_AMR ((XAuint32) 0x00000015)
-#define XA_CONTAINERTYPE_AAC ((XAuint32) 0x00000016)
-#define XA_CONTAINERTYPE_3GPP ((XAuint32) 0x00000017)
-#define XA_CONTAINERTYPE_3GA ((XAuint32) 0x00000018)
-#define XA_CONTAINERTYPE_RM ((XAuint32) 0x00000019)
-#define XA_CONTAINERTYPE_DMF ((XAuint32) 0x0000001A)
-#define XA_CONTAINERTYPE_SMF ((XAuint32) 0x0000001B)
-#define XA_CONTAINERTYPE_MOBILE_DLS ((XAuint32) 0x0000001C)
-#define XA_CONTAINERTYPE_OGG ((XAuint32) 0x0000001D)
-
-typedef struct XADataFormat_MIME_ {
- XAuint32 formatType;
- XAchar * mimeType;
- XAuint32 containerType;
-} XADataFormat_MIME;
-
-#define XA_BYTEORDER_BIGENDIAN ((XAuint32) 0x00000001)
-#define XA_BYTEORDER_LITTLEENDIAN ((XAuint32) 0x00000002)
-
-#define XA_SAMPLINGRATE_8 ((XAuint32) 8000000)
-#define XA_SAMPLINGRATE_11_025 ((XAuint32) 11025000)
-#define XA_SAMPLINGRATE_12 ((XAuint32) 12000000)
-#define XA_SAMPLINGRATE_16 ((XAuint32) 16000000)
-#define XA_SAMPLINGRATE_22_05 ((XAuint32) 22050000)
-#define XA_SAMPLINGRATE_24 ((XAuint32) 24000000)
-#define XA_SAMPLINGRATE_32 ((XAuint32) 32000000)
-#define XA_SAMPLINGRATE_44_1 ((XAuint32) 44100000)
-#define XA_SAMPLINGRATE_48 ((XAuint32) 48000000)
-#define XA_SAMPLINGRATE_64 ((XAuint32) 64000000)
-#define XA_SAMPLINGRATE_88_2 ((XAuint32) 88200000)
-#define XA_SAMPLINGRATE_96 ((XAuint32) 96000000)
-#define XA_SAMPLINGRATE_192 ((XAuint32) 192000000)
-
-#define XA_SPEAKER_FRONT_LEFT ((XAuint32) 0x00000001)
-#define XA_SPEAKER_FRONT_RIGHT ((XAuint32) 0x00000002)
-#define XA_SPEAKER_FRONT_CENTER ((XAuint32) 0x00000004)
-#define XA_SPEAKER_LOW_FREQUENCY ((XAuint32) 0x00000008)
-#define XA_SPEAKER_BACK_LEFT ((XAuint32) 0x00000010)
-#define XA_SPEAKER_BACK_RIGHT ((XAuint32) 0x00000020)
-#define XA_SPEAKER_FRONT_LEFT_OF_CENTER ((XAuint32) 0x00000040)
-#define XA_SPEAKER_FRONT_RIGHT_OF_CENTER ((XAuint32) 0x00000080)
-#define XA_SPEAKER_BACK_CENTER ((XAuint32) 0x00000100)
-#define XA_SPEAKER_SIDE_LEFT ((XAuint32) 0x00000200)
-#define XA_SPEAKER_SIDE_RIGHT ((XAuint32) 0x00000400)
-#define XA_SPEAKER_TOP_CENTER ((XAuint32) 0x00000800)
-#define XA_SPEAKER_TOP_FRONT_LEFT ((XAuint32) 0x00001000)
-#define XA_SPEAKER_TOP_FRONT_CENTER ((XAuint32) 0x00002000)
-#define XA_SPEAKER_TOP_FRONT_RIGHT ((XAuint32) 0x00004000)
-#define XA_SPEAKER_TOP_BACK_LEFT ((XAuint32) 0x00008000)
-#define XA_SPEAKER_TOP_BACK_CENTER ((XAuint32) 0x00010000)
-#define XA_SPEAKER_TOP_BACK_RIGHT ((XAuint32) 0x00020000)
-
-#define XA_PCMSAMPLEFORMAT_FIXED_8 ((XAuint16) 0x0008)
-#define XA_PCMSAMPLEFORMAT_FIXED_16 ((XAuint16) 0x0010)
-#define XA_PCMSAMPLEFORMAT_FIXED_20 ((XAuint16) 0x0014)
-#define XA_PCMSAMPLEFORMAT_FIXED_24 ((XAuint16) 0x0018)
-#define XA_PCMSAMPLEFORMAT_FIXED_28 ((XAuint16) 0x001C)
-#define XA_PCMSAMPLEFORMAT_FIXED_32 ((XAuint16) 0x0020)
-
-typedef struct XADataFormat_PCM_ {
- XAuint32 formatType;
- XAuint32 numChannels;
- XAuint32 samplesPerSec;
- XAuint32 bitsPerSample;
- XAuint32 containerSize;
- XAuint32 channelMask;
- XAuint32 endianness;
-} XADataFormat_PCM;
-
-#define XA_COLORFORMAT_UNUSED ((XAuint32) 0x00000000)
-#define XA_COLORFORMAT_MONOCHROME ((XAuint32) 0x00000001)
-#define XA_COLORFORMAT_8BITRGB332 ((XAuint32) 0x00000002)
-#define XA_COLORFORMAT_12BITRGB444 ((XAuint32) 0x00000003)
-#define XA_COLORFORMAT_16BITARGB4444 ((XAuint32) 0x00000004)
-#define XA_COLORFORMAT_16BITARGB1555 ((XAuint32) 0x00000005)
-#define XA_COLORFORMAT_16BITRGB565 ((XAuint32) 0x00000006)
-#define XA_COLORFORMAT_16BITBGR565 ((XAuint32) 0x00000007)
-#define XA_COLORFORMAT_18BITRGB666 ((XAuint32) 0x00000008)
-#define XA_COLORFORMAT_18BITARGB1665 ((XAuint32) 0x00000009)
-#define XA_COLORFORMAT_19BITARGB1666 ((XAuint32) 0x0000000A)
-#define XA_COLORFORMAT_24BITRGB888 ((XAuint32) 0x0000000B)
-#define XA_COLORFORMAT_24BITBGR888 ((XAuint32) 0x0000000C)
-#define XA_COLORFORMAT_24BITARGB1887 ((XAuint32) 0x0000000D)
-#define XA_COLORFORMAT_25BITARGB1888 ((XAuint32) 0x0000000E)
-#define XA_COLORFORMAT_32BITBGRA8888 ((XAuint32) 0x0000000F)
-#define XA_COLORFORMAT_32BITARGB8888 ((XAuint32) 0x00000010)
-#define XA_COLORFORMAT_YUV411PLANAR ((XAuint32) 0x00000011)
-#define XA_COLORFORMAT_YUV420PLANAR ((XAuint32) 0x00000013)
-#define XA_COLORFORMAT_YUV420SEMIPLANAR ((XAuint32) 0x00000015)
-#define XA_COLORFORMAT_YUV422PLANAR ((XAuint32) 0x00000016)
-#define XA_COLORFORMAT_YUV422SEMIPLANAR ((XAuint32) 0x00000018)
-#define XA_COLORFORMAT_YCBYCR ((XAuint32) 0x00000019)
-#define XA_COLORFORMAT_YCRYCB ((XAuint32) 0x0000001A)
-#define XA_COLORFORMAT_CBYCRY ((XAuint32) 0x0000001B)
-#define XA_COLORFORMAT_CRYCBY ((XAuint32) 0x0000001C)
-#define XA_COLORFORMAT_YUV444INTERLEAVED ((XAuint32) 0x0000001D)
-#define XA_COLORFORMAT_RAWBAYER8BIT ((XAuint32) 0x0000001E)
-#define XA_COLORFORMAT_RAWBAYER10BIT ((XAuint32) 0x0000001F)
-#define XA_COLORFORMAT_RAWBAYER8BITCOMPRESSED ((XAuint32) 0x00000020)
-#define XA_COLORFORMAT_L2 ((XAuint32) 0x00000021)
-#define XA_COLORFORMAT_L4 ((XAuint32) 0x00000022)
-#define XA_COLORFORMAT_L8 ((XAuint32) 0x00000023)
-#define XA_COLORFORMAT_L16 ((XAuint32) 0x00000024)
-#define XA_COLORFORMAT_L24 ((XAuint32) 0x00000025)
-#define XA_COLORFORMAT_L32 ((XAuint32) 0x00000026)
-#define XA_COLORFORMAT_18BITBGR666 ((XAuint32) 0x00000029)
-#define XA_COLORFORMAT_24BITARGB6666 ((XAuint32) 0x0000002A)
-#define XA_COLORFORMAT_24BITABGR6666 ((XAuint32) 0x0000002B)
-
-typedef struct XADataFormat_RawImage_ {
- XAuint32 formatType;
- XAuint32 colorFormat;
- XAuint32 height;
- XAuint32 width;
- XAuint32 stride;
-} XADataFormat_RawImage;
-
-typedef struct XADataLocator_Address_ {
- XAuint32 locatorType;
- void * pAddress;
- XAuint32 length;
-} XADataLocator_Address;
-
-#define XA_IODEVICE_AUDIOINPUT ((XAuint32) 0x00000001)
-#define XA_IODEVICE_LEDARRAY ((XAuint32) 0x00000002)
-#define XA_IODEVICE_VIBRA ((XAuint32) 0x00000003)
-#define XA_IODEVICE_CAMERA ((XAuint32) 0x00000004)
-#define XA_IODEVICE_RADIO ((XAuint32) 0x00000005)
-
-typedef struct XADataLocator_IODevice_ {
- XAuint32 locatorType;
- XAuint32 deviceType;
- XAuint32 deviceID;
- XAObjectItf device;
-} XADataLocator_IODevice;
-
-typedef void * XANativeHandle;
-
-typedef struct XADataLocator_NativeDisplay_{
- XAuint32 locatorType;
- XANativeHandle hWindow;
- XANativeHandle hDisplay;
-} XADataLocator_NativeDisplay;
-
-typedef struct XADataLocator_OutputMix {
- XAuint32 locatorType;
- XAObjectItf outputMix;
-} XADataLocator_OutputMix;
-
-typedef struct XADataLocator_URI_ {
- XAuint32 locatorType;
- XAchar * URI;
-} XADataLocator_URI;
-
-
-/* ENGINE */
-
-#define XA_DEFAULTDEVICEID_AUDIOINPUT ((XAuint32) 0xFFFFFFFF)
-#define XA_DEFAULTDEVICEID_AUDIOOUTPUT ((XAuint32) 0xFFFFFFFE)
-#define XA_DEFAULTDEVICEID_LED ((XAuint32) 0xFFFFFFFD)
-#define XA_DEFAULTDEVICEID_VIBRA ((XAuint32) 0xFFFFFFFC)
-#define XA_DEFAULTDEVICEID_CAMERA ((XAuint32) 0xFFFFFFFB)
-
-#define XA_ENGINEOPTION_THREADSAFE ((XAuint32) 0x00000001)
-#define XA_ENGINEOPTION_LOSSOFCONTROL ((XAuint32) 0x00000002)
-
-#define XA_OBJECTID_ENGINE ((XAuint32) 0x00000001)
-#define XA_OBJECTID_LEDDEVICE ((XAuint32) 0x00000002)
-#define XA_OBJECTID_VIBRADEVICE ((XAuint32) 0x00000003)
-#define XA_OBJECTID_MEDIAPLAYER ((XAuint32) 0x00000004)
-#define XA_OBJECTID_MEDIARECORDER ((XAuint32) 0x00000005)
-#define XA_OBJECTID_RADIODEVICE ((XAuint32) 0x00000006)
-#define XA_OBJECTID_OUTPUTMIX ((XAuint32) 0x00000007)
-#define XA_OBJECTID_METADATAEXTRACTOR ((XAuint32) 0x00000008)
-#define XA_OBJECTID_CAMERADEVICE ((XAuint32) 0x00000009)
-
-#define XA_PROFILES_MEDIA_PLAYER ((XAint16) 0x0001)
-#define XA_PROFILES_MEDIA_PLAYER_RECORDER ((XAint16) 0x0002)
-#define XA_PROFILES_PLUS_MIDI ((XAint16) 0x0004)
-
-typedef struct XAEngineOption_ {
- XAuint32 feature;
- XAuint32 data;
-} XAEngineOption;
-
-XA_API XAresult XAAPIENTRY xaCreateEngine(
- XAObjectItf * pEngine,
- XAuint32 numOptions,
- const XAEngineOption * pEngineOptions,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
-);
-
-XA_API XAresult XAAPIENTRY xaQueryNumSupportedEngineInterfaces(
- XAuint32 * pNumSupportedInterfaces
-);
-
-XA_API XAresult XAAPIENTRY xaQuerySupportedEngineInterfaces(
- XAuint32 index,
- XAInterfaceID * pInterfaceId
-);
-
-typedef struct XALEDDescriptor_ {
- XAuint8 ledCount;
- XAuint8 primaryLED;
- XAuint32 colorMask;
-} XALEDDescriptor;
-
-typedef struct XAVibraDescriptor_ {
- XAboolean supportsFrequency;
- XAboolean supportsIntensity;
- XAmilliHertz minFrequency;
- XAmilliHertz maxFrequency;
-} XAVibraDescriptor;
-
-
-XA_API extern const XAInterfaceID XA_IID_ENGINE;
-
-struct XAEngineItf_;
-typedef const struct XAEngineItf_ * const * XAEngineItf;
-
-struct XAEngineItf_ {
- XAresult (*CreateCameraDevice) (
- XAEngineItf self,
- XAObjectItf * pDevice,
- XAuint32 deviceID,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateRadioDevice) (
- XAEngineItf self,
- XAObjectItf * pDevice,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateLEDDevice) (
- XAEngineItf self,
- XAObjectItf * pDevice,
- XAuint32 deviceID,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateVibraDevice) (
- XAEngineItf self,
- XAObjectItf * pDevice,
- XAuint32 deviceID,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateMediaPlayer) (
- XAEngineItf self,
- XAObjectItf * pPlayer,
- XADataSource * pDataSrc,
- XADataSource * pBankSrc,
- XADataSink * pAudioSnk,
- XADataSink * pImageVideoSnk,
- XADataSink * pVibra,
- XADataSink * pLEDArray,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateMediaRecorder) (
- XAEngineItf self,
- XAObjectItf * pRecorder,
- XADataSource * pAudioSrc,
- XADataSource * pImageVideoSrc,
- XADataSink * pDataSnk,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateOutputMix) (
- XAEngineItf self,
- XAObjectItf * pMix,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateMetadataExtractor) (
- XAEngineItf self,
- XAObjectItf * pMetadataExtractor,
- XADataSource * pDataSource,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*CreateExtensionObject) (
- XAEngineItf self,
- XAObjectItf * pObject,
- void * pParameters,
- XAuint32 objectID,
- XAuint32 numInterfaces,
- const XAInterfaceID * pInterfaceIds,
- const XAboolean * pInterfaceRequired
- );
- XAresult (*GetImplementationInfo) (
- XAEngineItf self,
- XAuint32 * pMajor,
- XAuint32 * pMinor,
- XAuint32 * pStep,
- const XAchar * pImplementationText
- );
- XAresult (*QuerySupportedProfiles) (
- XAEngineItf self,
- XAint16 * pProfilesSupported
- );
- XAresult (*QueryNumSupportedInterfaces) (
- XAEngineItf self,
- XAuint32 objectID,
- XAuint32 * pNumSupportedInterfaces
- );
- XAresult (*QuerySupportedInterfaces) (
- XAEngineItf self,
- XAuint32 objectID,
- XAuint32 index,
- XAInterfaceID * pInterfaceId
- );
- XAresult (*QueryNumSupportedExtensions) (
- XAEngineItf self,
- XAuint32 * pNumExtensions
- );
- XAresult (*QuerySupportedExtension) (
- XAEngineItf self,
- XAuint32 index,
- XAchar * pExtensionName,
- XAint16 * pNameLength
- );
- XAresult (*IsExtensionSupported) (
- XAEngineItf self,
- const XAchar * pExtensionName,
- XAboolean * pSupported
- );
- XAresult (*QueryLEDCapabilities) (
- XAEngineItf self,
- XAuint32 *pIndex,
- XAuint32 * pLEDDeviceID,
- XALEDDescriptor * pDescriptor
- );
- XAresult (*QueryVibraCapabilities) (
- XAEngineItf self,
- XAuint32 *pIndex,
- XAuint32 * pVibraDeviceID,
- XAVibraDescriptor * pDescriptor
- );
-};
-
-/* THREAD SYNC */
-
-XA_API extern const XAInterfaceID XA_IID_THREADSYNC;
-
-struct XAThreadSyncItf_;
-typedef const struct XAThreadSyncItf_ * const * XAThreadSyncItf;
-
-struct XAThreadSyncItf_ {
- XAresult (*EnterCriticalSection) (
- XAThreadSyncItf self
- );
- XAresult (*ExitCriticalSection) (
- XAThreadSyncItf self
- );
-};
-
-
-
- /*****************************************************************/
- /* PLAYBACK RELATED INTERFACES, STRUCTS AND DEFINES */
- /*****************************************************************/
-
-/* PLAY */
-
-#define XA_TIME_UNKNOWN ((XAuint32) 0xFFFFFFFF)
-
-#define XA_PLAYEVENT_HEADATEND ((XAuint32) 0x00000001)
-#define XA_PLAYEVENT_HEADATMARKER ((XAuint32) 0x00000002)
-#define XA_PLAYEVENT_HEADATNEWPOS ((XAuint32) 0x00000004)
-#define XA_PLAYEVENT_HEADMOVING ((XAuint32) 0x00000008)
-#define XA_PLAYEVENT_HEADSTALLED ((XAuint32) 0x00000010)
-
-#define XA_PLAYSTATE_STOPPED ((XAuint32) 0x00000001)
-#define XA_PLAYSTATE_PAUSED ((XAuint32) 0x00000002)
-#define XA_PLAYSTATE_PLAYING ((XAuint32) 0x00000003)
-
-#define XA_PREFETCHEVENT_STATUSCHANGE ((XAuint32) 0x00000001)
-#define XA_PREFETCHEVENT_FILLLEVELCHANGE ((XAuint32) 0x00000002)
-
-#define XA_PREFETCHSTATUS_UNDERFLOW ((XAuint32) 0x00000001)
-#define XA_PREFETCHSTATUS_SUFFICIENTDATA ((XAuint32) 0x00000002)
-#define XA_PREFETCHSTATUS_OVERFLOW ((XAuint32) 0x00000003)
-
-#define XA_SEEKMODE_FAST ((XAuint32) 0x0001)
-#define XA_SEEKMODE_ACCURATE ((XAuint32) 0x0002)
-
-XA_API extern const XAInterfaceID XA_IID_PLAY;
-
-struct XAPlayItf_;
-typedef const struct XAPlayItf_ * const * XAPlayItf;
-
-typedef void (XAAPIENTRY * xaPlayCallback) (
- XAPlayItf caller,
- void * pContext,
- XAuint32 event
-);
-
-struct XAPlayItf_ {
- XAresult (*SetPlayState) (
- XAPlayItf self,
- XAuint32 state
- );
- XAresult (*GetPlayState) (
- XAPlayItf self,
- XAuint32 * pState
- );
- XAresult (*GetDuration) (
- XAPlayItf self,
- XAmillisecond * pMsec
- );
- XAresult (*GetPosition) (
- XAPlayItf self,
- XAmillisecond * pMsec
- );
- XAresult (*RegisterCallback) (
- XAPlayItf self,
- xaPlayCallback callback,
- void * pContext
- );
- XAresult (*SetCallbackEventsMask) (
- XAPlayItf self,
- XAuint32 eventFlags
- );
- XAresult (*GetCallbackEventsMask) (
- XAPlayItf self,
- XAuint32 * pEventFlags
- );
- XAresult (*SetMarkerPosition) (
- XAPlayItf self,
- XAmillisecond mSec
- );
- XAresult (*ClearMarkerPosition) (
- XAPlayItf self
- );
- XAresult (*GetMarkerPosition) (
- XAPlayItf self,
- XAmillisecond * pMsec
- );
- XAresult (*SetPositionUpdatePeriod) (
- XAPlayItf self,
- XAmillisecond mSec
- );
- XAresult (*GetPositionUpdatePeriod) (
- XAPlayItf self,
- XAmillisecond * pMsec
- );
-};
-
-/* PLAYBACK RATE */
-
-#define XA_RATEPROP_STAGGEREDVIDEO ((XAuint32) 0x00000001)
-#define XA_RATEPROP_SMOOTHVIDEO ((XAuint32) 0x00000002)
-#define XA_RATEPROP_SILENTAUDIO ((XAuint32) 0x00000100)
-#define XA_RATEPROP_STAGGEREDAUDIO ((XAuint32) 0x00000200)
-#define XA_RATEPROP_NOPITCHCORAUDIO ((XAuint32) 0x00000400)
-#define XA_RATEPROP_PITCHCORAUDIO ((XAuint32) 0x00000800)
-
-XA_API extern const XAInterfaceID XA_IID_PLAYBACKRATE;
-
-struct XAPlaybackRateItf_;
-typedef const struct XAPlaybackRateItf_ * const * XAPlaybackRateItf;
-
-struct XAPlaybackRateItf_ {
- XAresult (*SetRate) (
- XAPlaybackRateItf self,
- XApermille rate
- );
- XAresult (*GetRate) (
- XAPlaybackRateItf self,
- XApermille * pRate
- );
- XAresult (*SetPropertyConstraints) (
- XAPlaybackRateItf self,
- XAuint32 constraints
- );
- XAresult (*GetProperties) (
- XAPlaybackRateItf self,
- XAuint32 * pProperties
- );
- XAresult (*GetCapabilitiesOfRate) (
- XAPlaybackRateItf self,
- XApermille rate,
- XAuint32 * pCapabilities
- );
- XAresult (*GetRateRange) (
- XAPlaybackRateItf self,
- XAuint8 index,
- XApermille * pMinRate,
- XApermille * pMaxRate,
- XApermille * pStepSize,
- XAuint32 * pCapabilities
- );
-};
-
-/* PREFETCH STATUS */
-
-XA_API extern const XAInterfaceID XA_IID_PREFETCHSTATUS;
-
-struct XAPrefetchStatusItf_;
-typedef const struct XAPrefetchStatusItf_
- * const * XAPrefetchStatusItf;
-
-typedef void (XAAPIENTRY * xaPrefetchCallback) (
- XAPrefetchStatusItf caller,
- void * pContext,
- XAuint32 event
-);
-
-struct XAPrefetchStatusItf_ {
- XAresult (*GetPrefetchStatus) (
- XAPrefetchStatusItf self,
- XAuint32 * pStatus
- );
- XAresult (*GetFillLevel) (
- XAPrefetchStatusItf self,
- XApermille * pLevel
- );
- XAresult (*RegisterCallback) (
- XAPrefetchStatusItf self,
- xaPrefetchCallback callback,
- void * pContext
- );
- XAresult (*SetCallbackEventsMask) (
- XAPrefetchStatusItf self,
- XAuint32 eventFlags
- );
- XAresult (*GetCallbackEventsMask) (
- XAPrefetchStatusItf self,
- XAuint32 * pEventFlags
- );
- XAresult (*SetFillUpdatePeriod) (
- XAPrefetchStatusItf self,
- XApermille period
- );
- XAresult (*GetFillUpdatePeriod) (
- XAPrefetchStatusItf self,
- XApermille * pPeriod
- );
-};
-
-/* SEEK */
-
-XA_API extern const XAInterfaceID XA_IID_SEEK;
-
-struct XASeekItf_;
-typedef const struct XASeekItf_ * const * XASeekItf;
-
-struct XASeekItf_ {
- XAresult (*SetPosition) (
- XASeekItf self,
- XAmillisecond pos,
- XAuint32 seekMode
- );
- XAresult (*SetLoop) (
- XASeekItf self,
- XAboolean loopEnable,
- XAmillisecond startPos,
- XAmillisecond endPos
- );
- XAresult (*GetLoop) (
- XASeekItf self,
- XAboolean * pLoopEnabled,
- XAmillisecond * pStartPos,
- XAmillisecond * pEndPos
- );
-};
-
-/* VOLUME */
-
-XA_API extern const XAInterfaceID XA_IID_VOLUME;
-
-struct XAVolumeItf_;
-typedef const struct XAVolumeItf_ * const * XAVolumeItf;
-
-struct XAVolumeItf_ {
- XAresult (*SetVolumeLevel) (
- XAVolumeItf self,
- XAmillibel level
- );
- XAresult (*GetVolumeLevel) (
- XAVolumeItf self,
- XAmillibel * pLevel
- );
- XAresult (*GetMaxVolumeLevel) (
- XAVolumeItf self,
- XAmillibel * pMaxLevel
- );
- XAresult (*SetMute) (
- XAVolumeItf self,
- XAboolean mute
- );
- XAresult (*GetMute) (
- XAVolumeItf self,
- XAboolean * pMute
- );
- XAresult (*EnableStereoPosition) (
- XAVolumeItf self,
- XAboolean enable
- );
- XAresult (*IsEnabledStereoPosition) (
- XAVolumeItf self,
- XAboolean * pEnable
- );
- XAresult (*SetStereoPosition) (
- XAVolumeItf self,
- XApermille stereoPosition
- );
- XAresult (*GetStereoPosition) (
- XAVolumeItf self,
- XApermille * pStereoPosition
- );
-};
-
-/* IMAGE CONTROL */
-
-XA_API extern const XAInterfaceID XA_IID_IMAGECONTROLS;
-
-struct XAImageControlsItf_;
-typedef const struct XAImageControlsItf_ * const * XAImageControlsItf;
-
-struct XAImageControlsItf_ {
- XAresult (*SetBrightness) (
- XAImageControlsItf self,
- XAuint32 brightness
- );
- XAresult (*GetBrightness) (
- XAImageControlsItf self,
- XAuint32 * pBrightness
- );
- XAresult (*SetContrast) (
- XAImageControlsItf self,
- XAint32 contrast
- );
- XAresult (*GetContrast) (
- XAImageControlsItf self,
- XAint32 * pContrast
- );
- XAresult (*SetGamma) (
- XAImageControlsItf self,
- XApermille gamma
- );
- XAresult (*GetGamma) (
- XAImageControlsItf self,
- XApermille * pGamma
- );
- XAresult (*GetSupportedGammaSettings) (
- XAImageControlsItf self,
- XApermille * pMinValue,
- XApermille * pMaxValue,
- XAuint32 * pNumSettings,
- XApermille ** ppSettings
- );
-};
-
-/* IMAGE EFFECT */
-
-#define XA_IMAGEEFFECT_MONOCHROME ((XAuint32) 0x00000001)
-#define XA_IMAGEEFFECT_NEGATIVE ((XAuint32) 0x00000002)
-#define XA_IMAGEEFFECT_SEPIA ((XAuint32) 0x00000003)
-#define XA_IMAGEEFFECT_EMBOSS ((XAuint32) 0x00000004)
-#define XA_IMAGEEFFECT_PAINTBRUSH ((XAuint32) 0x00000005)
-#define XA_IMAGEEFFECT_SOLARIZE ((XAuint32) 0x00000006)
-#define XA_IMAGEEFFECT_CARTOON ((XAuint32) 0x00000007)
-
-XA_API extern const XAInterfaceID XA_IID_IMAGEEFFECTS;
-
-struct XAImageEffectsItf_;
-typedef const struct XAImageEffectsItf_ * const * XAImageEffectsItf;
-
-struct XAImageEffectsItf_ {
- XAresult (*QuerySupportedImageEffects) (
- XAImageEffectsItf self,
- XAuint32 index,
- XAuint32 * pImageEffectId
- );
- XAresult (*EnableImageEffect) (
- XAImageEffectsItf self,
- XAuint32 imageEffectID
- );
- XAresult (*DisableImageEffect) (
- XAImageEffectsItf self,
- XAuint32 imageEffectID
- );
- XAresult (*IsImageEffectEnabled) (
- XAImageEffectsItf self,
- XAuint32 imageEffectID,
- XAboolean * pEnabled
- );
-};
-
-/* VIDEO POST PROCESSING */
-
-#define XA_VIDEOMIRROR_NONE ((XAuint32) 0x00000001)
-#define XA_VIDEOMIRROR_VERTICAL ((XAuint32) 0x00000002)
-#define XA_VIDEOMIRROR_HORIZONTAL ((XAuint32) 0x00000003)
-#define XA_VIDEOMIRROR_BOTH ((XAuint32) 0x00000004)
-
-#define XA_VIDEOSCALE_STRETCH ((XAuint32) 0x00000001)
-#define XA_VIDEOSCALE_FIT ((XAuint32) 0x00000002)
-#define XA_VIDEOSCALE_CROP ((XAuint32) 0x00000003)
-
-#define XA_RENDERINGHINT_NONE ((XAuint32) 0x00000000)
-#define XA_RENDERINGHINT_ANTIALIASING ((XAuint32) 0x00000001)
-
-typedef struct XARectangle_ {
- XAuint32 left;
- XAuint32 top;
- XAuint32 width;
- XAuint32 height;
-} XARectangle;
-
-XA_API extern const XAInterfaceID XA_IID_VIDEOPOSTPROCESSING;
-
-struct XAVideoPostProcessingItf_;
-typedef const struct XAVideoPostProcessingItf_ * const * XAVideoPostProcessingItf;
-
-struct XAVideoPostProcessingItf_ {
- XAresult (*SetRotation) (
- XAVideoPostProcessingItf self,
- XAmillidegree rotation
- );
- XAresult (*IsArbitraryRotationSupported) (
- XAVideoPostProcessingItf self,
- XAboolean *pSupported
- );
- XAresult (*SetScaleOptions) (
- XAVideoPostProcessingItf self,
- XAuint32 scaleOptions,
- XAuint32 backgroundColor,
- XAuint32 renderingHints
- );
- XAresult (*SetSourceRectangle) (
- XAVideoPostProcessingItf self,
- const XARectangle *pSrcRect
- );
- XAresult (*SetDestinationRectangle) (
- XAVideoPostProcessingItf self,
- const XARectangle *pDestRect
- );
- XAresult (*SetMirror) (
- XAVideoPostProcessingItf self,
- XAuint32 mirror
- );
- XAresult (*Commit) (
- XAVideoPostProcessingItf self
- );
-};
-
-
-
- /*****************************************************************/
- /* CAPTURING INTERFACES, STRUCTS AND DEFINES */
- /*****************************************************************/
-
-/* RECORD */
-
-#define XA_RECORDEVENT_HEADATLIMIT ((XAuint32) 0x00000001)
-#define XA_RECORDEVENT_HEADATMARKER ((XAuint32) 0x00000002)
-#define XA_RECORDEVENT_HEADATNEWPOS ((XAuint32) 0x00000004)
-#define XA_RECORDEVENT_HEADMOVING ((XAuint32) 0x00000008)
-#define XA_RECORDEVENT_HEADSTALLED ((XAuint32) 0x00000010)
-#define XA_RECORDEVENT_BUFFER_FULL ((XAuint32) 0x00000020)
-
-#define XA_RECORDSTATE_STOPPED ((XAuint32) 0x00000001)
-#define XA_RECORDSTATE_PAUSED ((XAuint32) 0x00000002)
-#define XA_RECORDSTATE_RECORDING ((XAuint32) 0x00000003)
-
-XA_API extern const XAInterfaceID XA_IID_RECORD;
-
-struct XARecordItf_;
-typedef const struct XARecordItf_ * const * XARecordItf;
-
-typedef void (XAAPIENTRY * xaRecordCallback) (
- XARecordItf caller,
- void * pContext,
- XAuint32 event
-);
-
-struct XARecordItf_ {
- XAresult (*SetRecordState) (
- XARecordItf self,
- XAuint32 state
- );
- XAresult (*GetRecordState) (
- XARecordItf self,
- XAuint32 * pState
- );
- XAresult (*SetDurationLimit) (
- XARecordItf self,
- XAmillisecond msec
- );
- XAresult (*GetPosition) (
- XARecordItf self,
- XAmillisecond * pMsec
- );
- XAresult (*RegisterCallback) (
- XARecordItf self,
- xaRecordCallback callback,
- void * pContext
- );
- XAresult (*SetCallbackEventsMask) (
- XARecordItf self,
- XAuint32 eventFlags
- );
- XAresult (*GetCallbackEventsMask) (
- XARecordItf self,
- XAuint32 * pEventFlags
- );
- XAresult (*SetMarkerPosition) (
- XARecordItf self,
- XAmillisecond mSec
- );
- XAresult (*ClearMarkerPosition) (
- XARecordItf self
- );
- XAresult (*GetMarkerPosition) (
- XARecordItf self,
- XAmillisecond * pMsec
- );
- XAresult (*SetPositionUpdatePeriod) (
- XARecordItf self,
- XAmillisecond mSec
- );
- XAresult (*GetPositionUpdatePeriod) (
- XARecordItf self,
- XAmillisecond * pMsec
- );
-};
-
-/* SNAPSHOT */
-
-XA_API extern const XAInterfaceID XA_IID_SNAPSHOT;
-
-struct XASnapshotItf_;
-typedef const struct XASnapshotItf_ * const * XASnapshotItf;
-
-typedef void (XAAPIENTRY * xaSnapshotInitiatedCallback) (
- XASnapshotItf caller,
- void * context
-);
-
-typedef void (XAAPIENTRY * xaSnapshotTakenCallback) (
- XASnapshotItf caller,
- void * context,
- XAuint32 numberOfPicsTaken,
- const XADataSink * image
-);
-
-struct XASnapshotItf_ {
- XAresult (*InitiateSnapshot) (
- XASnapshotItf self,
- XAuint32 numberOfPictures,
- XAuint32 fps,
- XAboolean freezeViewFinder,
- XADataSink sink,
- xaSnapshotInitiatedCallback initiatedCallback,
- xaSnapshotTakenCallback takenCallback,
- void * pContext
- );
- XAresult (*TakeSnapshot) (
- XASnapshotItf self
- );
- XAresult (*CancelSnapshot) (
- XASnapshotItf self
- );
- XAresult (*ReleaseBuffers) (
- XASnapshotItf self,
- XADataSink * image
- );
- XAresult (*GetMaxPicsPerBurst) (
- XASnapshotItf self,
- XAuint32 * maxNumberOfPictures
- );
- XAresult (*GetBurstFPSRange) (
- XASnapshotItf self,
- XAuint32 * minFPS,
- XAuint32 * maxFPS
- );
- XAresult (*SetShutterFeedback) (
- XASnapshotItf self,
- XAboolean enabled
- );
- XAresult (*GetShutterFeedback) (
- XASnapshotItf self,
- XAboolean * enabled
- );
-};
-
-
-
- /*****************************************************************/
- /* METADATA RELATED INTERFACES, STRUCTS AND DEFINES */
- /*****************************************************************/
-
-/* METADATA (EXTRACTION, INSERTION, TRAVERSAL) */
-
-#define XA_NODE_PARENT ((XAuint32) 0xFFFFFFFF)
-
-#define XA_ROOT_NODE_ID ((XAint32) 0x7FFFFFFF)
-
-#define XA_NODETYPE_UNSPECIFIED ((XAuint32) 0x00000001)
-#define XA_NODETYPE_AUDIO ((XAuint32) 0x00000002)
-#define XA_NODETYPE_VIDEO ((XAuint32) 0x00000003)
-#define XA_NODETYPE_IMAGE ((XAuint32) 0x00000004)
-
-#define XA_CHARACTERENCODING_UNKNOWN ((XAuint32) 0x00000000)
-#define XA_CHARACTERENCODING_BINARY ((XAuint32) 0x00000001)
-#define XA_CHARACTERENCODING_ASCII ((XAuint32) 0x00000002)
-#define XA_CHARACTERENCODING_BIG5 ((XAuint32) 0x00000003)
-#define XA_CHARACTERENCODING_CODEPAGE1252 ((XAuint32) 0x00000004)
-#define XA_CHARACTERENCODING_GB2312 ((XAuint32) 0x00000005)
-#define XA_CHARACTERENCODING_HZGB2312 ((XAuint32) 0x00000006)
-#define XA_CHARACTERENCODING_GB12345 ((XAuint32) 0x00000007)
-#define XA_CHARACTERENCODING_GB18030 ((XAuint32) 0x00000008)
-#define XA_CHARACTERENCODING_GBK ((XAuint32) 0x00000009)
-#define XA_CHARACTERENCODING_IMAPUTF7 ((XAuint32) 0x0000000A)
-#define XA_CHARACTERENCODING_ISO2022JP ((XAuint32) 0x0000000B)
-#define XA_CHARACTERENCODING_ISO2022JP1 ((XAuint32) 0x0000000B)
-#define XA_CHARACTERENCODING_ISO88591 ((XAuint32) 0x0000000C)
-#define XA_CHARACTERENCODING_ISO885910 ((XAuint32) 0x0000000D)
-#define XA_CHARACTERENCODING_ISO885913 ((XAuint32) 0x0000000E)
-#define XA_CHARACTERENCODING_ISO885914 ((XAuint32) 0x0000000F)
-#define XA_CHARACTERENCODING_ISO885915 ((XAuint32) 0x00000010)
-#define XA_CHARACTERENCODING_ISO88592 ((XAuint32) 0x00000011)
-#define XA_CHARACTERENCODING_ISO88593 ((XAuint32) 0x00000012)
-#define XA_CHARACTERENCODING_ISO88594 ((XAuint32) 0x00000013)
-#define XA_CHARACTERENCODING_ISO88595 ((XAuint32) 0x00000014)
-#define XA_CHARACTERENCODING_ISO88596 ((XAuint32) 0x00000015)
-#define XA_CHARACTERENCODING_ISO88597 ((XAuint32) 0x00000016)
-#define XA_CHARACTERENCODING_ISO88598 ((XAuint32) 0x00000017)
-#define XA_CHARACTERENCODING_ISO88599 ((XAuint32) 0x00000018)
-#define XA_CHARACTERENCODING_ISOEUCJP ((XAuint32) 0x00000019)
-#define XA_CHARACTERENCODING_SHIFTJIS ((XAuint32) 0x0000001A)
-#define XA_CHARACTERENCODING_SMS7BIT ((XAuint32) 0x0000001B)
-#define XA_CHARACTERENCODING_UTF7 ((XAuint32) 0x0000001C)
-#define XA_CHARACTERENCODING_UTF8 ((XAuint32) 0x0000001D)
-#define XA_CHARACTERENCODING_JAVACONFORMANTUTF8 ((XAuint32) 0x0000001E)
-#define XA_CHARACTERENCODING_UTF16BE ((XAuint32) 0x0000001F)
-#define XA_CHARACTERENCODING_UTF16LE ((XAuint32) 0x00000020)
-
-#define XA_METADATA_FILTER_KEY ((XAuint8) 0x01)
-#define XA_METADATA_FILTER_LANG ((XAuint8) 0x02)
-#define XA_METADATA_FILTER_ENCODING ((XAuint8) 0x04)
-
-#define XA_METADATATRAVERSALMODE_ALL ((XAuint32) 0x00000001)
-#define XA_METADATATRAVERSALMODE_NODE ((XAuint32) 0x00000002)
-
-#ifndef _KHRONOS_KEYS_
-#define _KHRONOS_KEYS_
-#define KHRONOS_TITLE "KhronosTitle"
-#define KHRONOS_ALBUM "KhronosAlbum"
-#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber"
-#define KHRONOS_ARTIST "KhronosArtist"
-#define KHRONOS_GENRE "KhronosGenre"
-#define KHRONOS_YEAR "KhronosYear"
-#define KHRONOS_COMMENT "KhronosComment"
-#define KHRONOS_ARTIST_URL "KhronosArtistURL"
-#define KHRONOS_CONTENT_URL "KhronosContentURL"
-#define KHRONOS_RATING "KhronosRating"
-#define KHRONOS_ALBUM_ART "KhronosAlbumArt"
-#define KHRONOS_COPYRIGHT "KhronosCopyright"
-#endif /* _KHRONOS_KEYS_ */
-
-
-typedef struct XAMetadataInfo_ {
- XAuint32 size;
- XAuint32 encoding;
- const XAchar langCountry[16];
- XAuint8 data[1];
-} XAMetadataInfo;
-
-XA_API extern const XAInterfaceID XA_IID_METADATAEXTRACTION;
-
-struct XAMetadataExtractionItf_;
-typedef const struct XAMetadataExtractionItf_
- * const * XAMetadataExtractionItf;
-
-struct XAMetadataExtractionItf_ {
- XAresult (*GetItemCount) (
- XAMetadataExtractionItf self,
- XAuint32 * pItemCount
- );
- XAresult (*GetKeySize) (
- XAMetadataExtractionItf self,
- XAuint32 index,
- XAuint32 * pKeySize
- );
- XAresult (*GetKey) (
- XAMetadataExtractionItf self,
- XAuint32 index,
- XAuint32 keySize,
- XAMetadataInfo * pKey
- );
- XAresult (*GetValueSize) (
- XAMetadataExtractionItf self,
- XAuint32 index,
- XAuint32 * pValueSize
- );
- XAresult (*GetValue) (
- XAMetadataExtractionItf self,
- XAuint32 index,
- XAuint32 valueSize,
- XAMetadataInfo * pValue
- );
- XAresult (*AddKeyFilter) (
- XAMetadataExtractionItf self,
- XAuint32 keySize,
- const void * pKey,
- XAuint32 keyEncoding,
- const XAchar * pValueLangCountry,
- XAuint32 valueEncoding,
- XAuint8 filterMask
- );
- XAresult (*ClearKeyFilter) (
- XAMetadataExtractionItf self
- );
-};
-
-
-XA_API extern const XAInterfaceID XA_IID_METADATAINSERTION;
-
-struct XAMetadataInsertionItf_;
-typedef const struct XAMetadataInsertionItf_
- * const * XAMetadataInsertionItf;
-
-typedef void (XAAPIENTRY * xaMetadataInsertionCallback) (
- XAMetadataInsertionItf caller,
- void * pContext,
- XAMetadataInfo * pKey,
- XAMetadataInfo * pValue,
- XAint32 nodeID,
- XAboolean result
-);
-
-struct XAMetadataInsertionItf_ {
- XAresult (*CreateChildNode) (
- XAMetadataInsertionItf self,
- XAint32 parentNodeID,
- XAuint32 type,
- XAchar * mimeType,
- XAint32 * pChildNodeID
- );
- XAresult (*GetSupportedKeysCount) (
- XAMetadataInsertionItf self,
- XAint32 nodeID,
- XAboolean * pFreeKeys,
- XAuint32 * pKeyCount,
- XAuint32 * pEncodingCount
- );
- XAresult (*GetKeySize) (
- XAMetadataInsertionItf self,
- XAint32 nodeID,
- XAuint32 keyIndex,
- XAuint32 * pKeySize
- );
- XAresult (*GetKey) (
- XAMetadataInsertionItf self,
- XAint32 nodeID,
- XAuint32 keyIndex,
- XAuint32 keySize,
- XAMetadataInfo * pKey
- );
- XAresult (*GetFreeKeysEncoding) (
- XAMetadataInsertionItf self,
- XAint32 nodeID,
- XAuint32 encodingIndex,
- XAuint32 * pEncoding
- );
- XAresult (*InsertMetadataItem) (
- XAMetadataInsertionItf self,
- XAint32 nodeID,
- XAMetadataInfo * pKey,
- XAMetadataInfo * pValue,
- XAboolean overwrite
- );
- XAresult (*RegisterCallback) (
- XAMetadataInsertionItf self,
- xaMetadataInsertionCallback callback,
- void * pContext
- );
-};
-
-
-XA_API extern const XAInterfaceID XA_IID_METADATATRAVERSAL;
-
-struct XAMetadataTraversalItf_;
-typedef const struct XAMetadataTraversalItf_
- * const * XAMetadataTraversalItf;
-
-struct XAMetadataTraversalItf_ {
- XAresult (*SetMode) (
- XAMetadataTraversalItf self,
- XAuint32 mode
- );
- XAresult (*GetChildCount) (
- XAMetadataTraversalItf self,
- XAuint32 * pCount
- );
- XAresult (*GetChildMIMETypeSize) (
- XAMetadataTraversalItf self,
- XAuint32 index,
- XAuint32 * pSize
- );
- XAresult (*GetChildInfo) (
- XAMetadataTraversalItf self,
- XAuint32 index,
- XAint32 * pNodeID,
- XAuint32 * pType,
- XAuint32 size,
- XAchar * pMimeType
- );
- XAresult (*SetActiveNode) (
- XAMetadataTraversalItf self,
- XAuint32 index
- );
-};
-
-/* DYNAMIC SOURCE */
-
-XA_API extern const XAInterfaceID XA_IID_DYNAMICSOURCE;
-
-struct XADynamicSourceItf_;
-typedef const struct XADynamicSourceItf_ * const * XADynamicSourceItf;
-
-struct XADynamicSourceItf_ {
- XAresult (*SetSource) (
- XADynamicSourceItf self,
- XADataSource * pDataSource
- );
-};
-
-
-
- /*****************************************************************/
- /* I/O DEVICES RELATED INTERFACES, STRUCTS AND DEFINES */
- /*****************************************************************/
-
-/* CAMERA AND CAMERA CAPABILITIES */
-
-#define XA_CAMERA_APERTUREMODE_MANUAL ((XAuint32) 0x00000001)
-#define XA_CAMERA_APERTUREMODE_AUTO ((XAuint32) 0x00000002)
-
-#define XA_CAMERA_AUTOEXPOSURESTATUS_SUCCESS ((XAuint32) 0x00000001)
-#define XA_CAMERA_AUTOEXPOSURESTATUS_UNDEREXPOSURE ((XAuint32) 0x00000002)
-#define XA_CAMERA_AUTOEXPOSURESTATUS_OVEREXPOSURE ((XAuint32) 0x00000003)
-
-#define XA_CAMERACBEVENT_ROTATION ((XAuint32) 0x00000001)
-#define XA_CAMERACBEVENT_FLASHREADY ((XAuint32) 0x00000002)
-#define XA_CAMERACBEVENT_FOCUSSTATUS ((XAuint32) 0x00000003)
-#define XA_CAMERACBEVENT_EXPOSURESTATUS ((XAuint32) 0x00000004)
-#define XA_CAMERACBEVENT_WHITEBALANCELOCKED ((XAuint32) 0x00000005)
-#define XA_CAMERACBEVENT_ZOOMSTATUS ((XAuint32) 0x00000006)
-
-#define XA_CAMERACAP_FLASH ((XAuint32) 0x00000001)
-#define XA_CAMERACAP_AUTOFOCUS ((XAuint32) 0x00000002)
-#define XA_CAMERACAP_CONTINUOUSAUTOFOCUS ((XAuint32) 0x00000004)
-#define XA_CAMERACAP_MANUALFOCUS ((XAuint32) 0x00000008)
-#define XA_CAMERACAP_AUTOEXPOSURE ((XAuint32) 0x00000010)
-#define XA_CAMERACAP_MANUALEXPOSURE ((XAuint32) 0x00000020)
-#define XA_CAMERACAP_AUTOISOSENSITIVITY ((XAuint32) 0x00000040)
-#define XA_CAMERACAP_MANUALISOSENSITIVITY ((XAuint32) 0x00000080)
-#define XA_CAMERACAP_AUTOAPERTURE ((XAuint32) 0x00000100)
-#define XA_CAMERACAP_MANUALAPERTURE ((XAuint32) 0x00000200)
-#define XA_CAMERACAP_AUTOSHUTTERSPEED ((XAuint32) 0x00000400)
-#define XA_CAMERACAP_MANUALSHUTTERSPEED ((XAuint32) 0x00000800)
-#define XA_CAMERACAP_AUTOWHITEBALANCE ((XAuint32) 0x00001000)
-#define XA_CAMERACAP_MANUALWHITEBALANCE ((XAuint32) 0x00002000)
-#define XA_CAMERACAP_OPTICALZOOM ((XAuint32) 0x00004000)
-#define XA_CAMERACAP_DIGITALZOOM ((XAuint32) 0x00008000)
-#define XA_CAMERACAP_METERING ((XAuint32) 0x00010000)
-#define XA_CAMERACAP_BRIGHTNESS ((XAuint32) 0x00020000)
-#define XA_CAMERACAP_CONTRAST ((XAuint32) 0x00040000)
-#define XA_CAMERACAP_GAMMA ((XAuint32) 0x00080000)
-
-
-#define XA_CAMERA_EXPOSUREMODE_MANUAL ((XAuint32) 0x00000001)
-#define XA_CAMERA_EXPOSUREMODE_AUTO ((XAuint32) 0x00000002)
-#define XA_CAMERA_EXPOSUREMODE_NIGHT ((XAuint32) 0x00000004)
-#define XA_CAMERA_EXPOSUREMODE_BACKLIGHT ((XAuint32) 0x00000008)
-#define XA_CAMERA_EXPOSUREMODE_SPOTLIGHT ((XAuint32) 0x00000010)
-#define XA_CAMERA_EXPOSUREMODE_SPORTS ((XAuint32) 0x00000020)
-#define XA_CAMERA_EXPOSUREMODE_SNOW ((XAuint32) 0x00000040)
-#define XA_CAMERA_EXPOSUREMODE_BEACH ((XAuint32) 0x00000080)
-#define XA_CAMERA_EXPOSUREMODE_LARGEAPERTURE ((XAuint32) 0x00000100)
-#define XA_CAMERA_EXPOSUREMODE_SMALLAPERTURE ((XAuint32) 0x00000200)
-#define XA_CAMERA_EXPOSUREMODE_PORTRAIT ((XAuint32) 0x0000400)
-#define XA_CAMERA_EXPOSUREMODE_NIGHTPORTRAIT ((XAuint32) 0x00000800)
-
-#define XA_CAMERA_FLASHMODE_OFF ((XAuint32) 0x00000001)
-#define XA_CAMERA_FLASHMODE_ON ((XAuint32) 0x00000002)
-#define XA_CAMERA_FLASHMODE_AUTO ((XAuint32) 0x00000004)
-#define XA_CAMERA_FLASHMODE_REDEYEREDUCTION ((XAuint32) 0x00000008)
-#define XA_CAMERA_FLASHMODE_REDEYEREDUCTION_AUTO ((XAuint32) 0x00000010)
-#define XA_CAMERA_FLASHMODE_FILLIN ((XAuint32) 0x00000020)
-#define XA_CAMERA_FLASHMODE_TORCH ((XAuint32) 0x00000040)
-
-#define XA_CAMERA_FOCUSMODE_MANUAL ((XAuint32) 0x00000001)
-#define XA_CAMERA_FOCUSMODE_AUTO ((XAuint32) 0x00000002)
-#define XA_CAMERA_FOCUSMODE_CENTROID ((XAuint32) 0x00000004)
-#define XA_CAMERA_FOCUSMODE_CONTINUOUS_AUTO ((XAuint32) 0x00000008)
-#define XA_CAMERA_FOCUSMODE_CONTINUOUS_CENTROID ((XAuint32) 0x00000010)
-
-#define XA_CAMERA_FOCUSMODESTATUS_OFF ((XAuint32) 0x00000001)
-#define XA_CAMERA_FOCUSMODESTATUS_REQUEST ((XAuint32) 0x00000002)
-#define XA_CAMERA_FOCUSMODESTATUS_REACHED ((XAuint32) 0x00000003)
-#define XA_CAMERA_FOCUSMODESTATUS_UNABLETOREACH ((XAuint32) 0x00000004)
-#define XA_CAMERA_FOCUSMODESTATUS_LOST ((XAuint32) 0x00000005)
-
-#define XA_CAMERA_ISOSENSITIVITYMODE_MANUAL ((XAuint32) 0x00000001)
-#define XA_CAMERA_ISOSENSITIVITYMODE_AUTO ((XAuint32) 0x00000002)
-
-#define XA_CAMERA_LOCK_AUTOFOCUS ((XAuint32) 0x00000001)
-#define XA_CAMERA_LOCK_AUTOEXPOSURE ((XAuint32) 0x00000002)
-#define XA_CAMERA_LOCK_AUTOWHITEBALANCE ((XAuint32) 0x00000004)
-
-#define XA_CAMERA_METERINGMODE_AVERAGE ((XAuint32) 0x00000001)
-#define XA_CAMERA_METERINGMODE_SPOT ((XAuint32) 0x00000002)
-#define XA_CAMERA_METERINGMODE_MATRIX ((XAuint32) 0x00000004)
-
-#define XA_CAMERA_SHUTTERSPEEDMODE_MANUAL ((XAuint32) 0x00000001)
-#define XA_CAMERA_SHUTTERSPEEDMODE_AUTO ((XAuint32) 0x00000002)
-
-#define XA_CAMERA_WHITEBALANCEMODE_MANUAL ((XAuint32) 0x00000001)
-#define XA_CAMERA_WHITEBALANCEMODE_AUTO ((XAuint32) 0x00000002)
-#define XA_CAMERA_WHITEBALANCEMODE_SUNLIGHT ((XAuint32) 0x00000004)
-#define XA_CAMERA_WHITEBALANCEMODE_CLOUDY ((XAuint32) 0x00000008)
-#define XA_CAMERA_WHITEBALANCEMODE_SHADE ((XAuint32) 0x00000010)
-#define XA_CAMERA_WHITEBALANCEMODE_TUNGSTEN ((XAuint32) 0x00000020)
-#define XA_CAMERA_WHITEBALANCEMODE_FLUORESCENT ((XAuint32) 0x00000040)
-#define XA_CAMERA_WHITEBALANCEMODE_INCANDESCENT ((XAuint32) 0x00000080)
-#define XA_CAMERA_WHITEBALANCEMODE_FLASH ((XAuint32) 0x00000100)
-#define XA_CAMERA_WHITEBALANCEMODE_SUNSET ((XAuint32) 0x00000200)
-
-#define XA_CAMERA_ZOOM_SLOW ((XAuint32) 50)
-#define XA_CAMERA_ZOOM_NORMAL ((XAuint32) 100)
-#define XA_CAMERA_ZOOM_FAST ((XAuint32) 200)
-#define XA_CAMERA_ZOOM_FASTEST ((XAuint32) 0xFFFFFFFF)
-
-#define XA_FOCUSPOINTS_ONE ((XAuint32) 0x00000001)
-#define XA_FOCUSPOINTS_THREE_3X1 ((XAuint32) 0x00000002)
-#define XA_FOCUSPOINTS_FIVE_CROSS ((XAuint32) 0x00000003)
-#define XA_FOCUSPOINTS_SEVEN_CROSS ((XAuint32) 0x00000004)
-#define XA_FOCUSPOINTS_NINE_SQUARE ((XAuint32) 0x00000005)
-#define XA_FOCUSPOINTS_ELEVEN_CROSS ((XAuint32) 0x00000006)
-#define XA_FOCUSPOINTS_TWELVE_3X4 ((XAuint32) 0x00000007)
-#define XA_FOCUSPOINTS_TWELVE_4X3 ((XAuint32) 0x00000008)
-#define XA_FOCUSPOINTS_SIXTEEN_SQUARE ((XAuint32) 0x00000009)
-#define XA_FOCUSPOINTS_CUSTOM ((XAuint32) 0x0000000A)
-
-typedef struct XAFocusPointPosition_ {
- XAuint32 left;
- XAuint32 top;
- XAuint32 width;
- XAuint32 height;
-} XAFocusPointPosition;
-
-#define XA_ORIENTATION_UNKNOWN ((XAuint32) 0x00000001)
-#define XA_ORIENTATION_OUTWARDS ((XAuint32) 0x00000002)
-#define XA_ORIENTATION_INWARDS ((XAuint32) 0x00000003)
-
-typedef struct XACameraDescriptor_ {
- XAchar * name;
- XAuint32 maxWidth;
- XAuint32 maxHeight;
- XAuint32 orientation;
- XAuint32 featuresSupported;
- XAuint32 exposureModesSupported;
- XAuint32 flashModesSupported;
- XAuint32 focusModesSupported;
- XAuint32 meteringModesSupported;
- XAuint32 whiteBalanceModesSupported;
-} XACameraDescriptor;
-
-XA_API extern const XAInterfaceID XA_IID_CAMERACAPABILITIES;
-
-struct XACameraCapabilitiesItf_;
-typedef const struct XACameraCapabilitiesItf_
- * const * XACameraCapabilitiesItf;
-
-struct XACameraCapabilitiesItf_ {
- XAresult (*GetCameraCapabilities) (
- XACameraCapabilitiesItf self,
- XAuint32 *pIndex,
- XAuint32 * pCameraDeviceID,
- XACameraDescriptor * pDescriptor
- );
- XAresult (*QueryFocusRegionPatterns) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAuint32 * pPatternID,
- XAuint32 * pFocusPattern,
- XAuint32 * pCustomPoints1,
- XAuint32 * pCustomPoints2
- );
- XAresult (*GetSupportedAutoLocks) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAuint32 * pNumCombinations,
- XAuint32 ** ppLocks
- );
- XAresult (*GetSupportedFocusManualSettings) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAboolean macroEnabled,
- XAmillimeter * pMinValue,
- XAmillimeter * pMaxValue,
- XAuint32 * pNumSettings,
- XAmillimeter ** ppSettings
- );
- XAresult (*GetSupportedISOSensitivitySettings) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAuint32 * pMinValue,
- XAuint32 * pMaxValue,
- XAuint32 * pNumSettings,
- XAuint32 ** ppSettings
- );
- XAresult (*GetSupportedApertureManualSettings) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAuint32 * pMinValue,
- XAuint32 * pMaxValue,
- XAuint32 * pNumSettings,
- XAuint32 ** ppSettings
- );
- XAresult (*GetSupportedShutterSpeedManualSettings) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAmicrosecond * pMinValue,
- XAmicrosecond * pMaxValue,
- XAuint32 * pNumSettings,
- XAmicrosecond ** ppSettings
- );
- XAresult (*GetSupportedWhiteBalanceManualSettings) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAuint32 * pMinValue,
- XAuint32 * pMaxValue,
- XAuint32 * pNumSettings,
- XAuint32 ** ppSettings
- );
- XAresult (*GetSupportedZoomSettings) (
- XACameraCapabilitiesItf self,
- XAuint32 cameraDeviceID,
- XAboolean digitalEnabled,
- XAboolean macroEnabled,
- XApermille * pMaxValue,
- XAuint32 * pNumSettings,
- XApermille ** ppSettings,
- XAboolean * pSpeedSupported
-
- );
-};
-
-XA_API extern const XAInterfaceID XA_IID_CAMERA;
-
-struct XACameraItf_;
-typedef const struct XACameraItf_ * const * XACameraItf;
-
-typedef void (XAAPIENTRY * xaCameraCallback) (
- XACameraItf caller,
- void * pContext,
- XAuint32 eventId,
- XAuint32 eventData
-);
-
-struct XACameraItf_ {
- XAresult (*RegisterCallback) (
- XACameraItf self,
- xaCameraCallback callback,
- void * pContext
- );
- XAresult (*SetFlashMode) (
- XACameraItf self,
- XAuint32 flashMode
- );
- XAresult (*GetFlashMode) (
- XACameraItf self,
- XAuint32 * pFlashMode
- );
- XAresult (*IsFlashReady) (
- XACameraItf self,
- XAboolean * pReady
- );
- XAresult (*SetFocusMode) (
- XACameraItf self,
- XAuint32 focusMode,
- XAmillimeter manualSetting,
- XAboolean macroEnabled
- );
- XAresult (*GetFocusMode) (
- XACameraItf self,
- XAuint32 * pFocusMode,
- XAmillimeter * pManualSetting,
- XAboolean * pMacroEnabled
- );
- XAresult (*SetFocusRegionPattern) (
- XACameraItf self,
- XAuint32 focusPattern,
- XAuint32 activePoints1,
- XAuint32 activePoints2
- );
- XAresult (*GetFocusRegionPattern) (
- XACameraItf self,
- XAuint32 * pFocusPattern,
- XAuint32 * pActivePoints1,
- XAuint32 * pActivePoints2
- );
- XAresult (*GetFocusRegionPositions) (
- XACameraItf self,
- XAuint32 * pNumPositionEntries,
- XAFocusPointPosition * pFocusPosition
- );
- XAresult (*GetFocusModeStatus) (
- XACameraItf self,
- XAuint32 * pFocusStatus,
- XAuint32 * pRegionStatus1,
- XAuint32 * pRegionStatus2
- );
- XAresult (*SetMeteringMode) (
- XACameraItf self,
- XAuint32 meteringMode
- );
- XAresult (*GetMeteringMode) (
- XACameraItf self,
- XAuint32 * pMeteringMode
- );
- XAresult (*SetExposureMode) (
- XACameraItf self,
- XAuint32 exposure,
- XAuint32 compensation
- );
- XAresult (*GetExposureMode) (
- XACameraItf self,
- XAuint32 * pExposure,
- XAuint32 * pCompensation
- );
- XAresult (*SetISOSensitivity) (
- XACameraItf self,
- XAuint32 isoSensitivity,
- XAuint32 manualSetting
- );
- XAresult (*GetISOSensitivity) (
- XACameraItf self,
- XAuint32 * pIsoSensitivity,
- XAuint32 * pManualSetting
- );
- XAresult (*SetAperture) (
- XACameraItf self,
- XAuint32 aperture,
- XAuint32 manualSetting
- );
- XAresult (*GetAperture) (
- XACameraItf self,
- XAuint32 * pAperture,
- XAuint32 * pManualSetting
- );
- XAresult (*SetShutterSpeed) (
- XACameraItf self,
- XAuint32 shutterSpeed,
- XAmicrosecond manualSetting
- );
- XAresult (*GetShutterSpeed) (
- XACameraItf self,
- XAuint32 * pShutterSpeed,
- XAmicrosecond * pManualSetting
- );
- XAresult (*SetWhiteBalance) (
- XACameraItf self,
- XAuint32 whiteBalance,
- XAuint32 manualSetting
- );
- XAresult (*GetWhiteBalance) (
- XACameraItf self,
- XAuint32 * pWhiteBalance,
- XAuint32 * pManualSetting
- );
- XAresult (*SetAutoLocks) (
- XACameraItf self,
- XAuint32 locks
- );
- XAresult (*GetAutoLocks) (
- XACameraItf self,
- XAuint32 * locks
- );
- XAresult (*SetZoom) (
- XACameraItf self,
- XApermille zoom,
- XAboolean digitalEnabled,
- XAuint32 speed,
- XAboolean async
- );
- XAresult (*GetZoom) (
- XACameraItf self,
- XApermille * pZoom,
- XAboolean * pDigital
- );
-};
-
-/* AUDIO I/O DEVICE CAPABILITIES */
-
-#define XA_DEVCONNECTION_INTEGRATED ((XAint16) 0x0001)
-#define XA_DEVCONNECTION_ATTACHED_WIRED ((XAint16) 0x0100)
-#define XA_DEVCONNECTION_ATTACHED_WIRELESS ((XAint16) 0x0200)
-#define XA_DEVCONNECTION_NETWORK ((XAint16) 0x0400)
-
-#define XA_DEVLOCATION_HANDSET ((XAint16) 0x0001)
-#define XA_DEVLOCATION_HEADSET ((XAint16) 0x0002)
-#define XA_DEVLOCATION_CARKIT ((XAint16) 0x0003)
-#define XA_DEVLOCATION_DOCK ((XAint16) 0x0004)
-#define XA_DEVLOCATION_REMOTE ((XAint16) 0x0005)
-
-#define XA_DEVSCOPE_UNKNOWN ((XAint16) 0x0001)
-#define XA_DEVSCOPE_ENVIRONMENT ((XAint16) 0x0002)
-#define XA_DEVSCOPE_USER ((XAint16) 0x0003)
-
-typedef struct XAAudioInputDescriptor_ {
- XAchar * deviceName;
- XAint16 deviceConnection;
- XAint16 deviceScope;
- XAint16 deviceLocation;
- XAboolean isForTelephony;
- XAmilliHertz minSampleRate;
- XAmilliHertz maxSampleRate;
- XAboolean isFreqRangeContinuous;
- XAmilliHertz * samplingRatesSupported;
- XAint16 numOfSamplingRatesSupported;
- XAint16 maxChannels;
-} XAAudioInputDescriptor;
-
-typedef struct XAAudioOutputDescriptor_ {
- XAchar *pDeviceName;
- XAint16 deviceConnection;
- XAint16 deviceScope;
- XAint16 deviceLocation;
- XAboolean isForTelephony;
- XAmilliHertz minSampleRate;
- XAmilliHertz maxSampleRate;
- XAboolean isFreqRangeContinuous;
- XAmilliHertz *samplingRatesSupported;
- XAint16 numOfSamplingRatesSupported;
- XAint16 maxChannels;
-} XAAudioOutputDescriptor;
-
-XA_API extern const XAInterfaceID XA_IID_AUDIOIODEVICECAPABILITIES;
-
-struct XAAudioIODeviceCapabilitiesItf_;
-typedef const struct XAAudioIODeviceCapabilitiesItf_
- * const * XAAudioIODeviceCapabilitiesItf;
-
-typedef void (XAAPIENTRY * xaAvailableAudioInputsChangedCallback) (
- XAAudioIODeviceCapabilitiesItf caller,
- void * pContext,
- XAuint32 deviceID,
- XAint32 numInputs,
- XAboolean isNew
-);
-
-typedef void (XAAPIENTRY * xaAvailableAudioOutputsChangedCallback) (
- XAAudioIODeviceCapabilitiesItf caller,
- void * pContext,
- XAuint32 deviceID,
- XAint32 numOutputs,
- XAboolean isNew
-);
-
-typedef void (XAAPIENTRY * xaDefaultDeviceIDMapChangedCallback) (
- XAAudioIODeviceCapabilitiesItf caller,
- void * pContext,
- XAboolean isOutput,
- XAint32 numDevices
-);
-
-struct XAAudioIODeviceCapabilitiesItf_ {
- XAresult (*GetAvailableAudioInputs) (
- XAAudioIODeviceCapabilitiesItf self,
- XAint32 * pNumInputs,
- XAuint32 * pInputDeviceIDs
- );
- XAresult (*QueryAudioInputCapabilities) (
- XAAudioIODeviceCapabilitiesItf self,
- XAuint32 deviceID,
- XAAudioInputDescriptor * pDescriptor
- );
- XAresult (*RegisterAvailableAudioInputsChangedCallback) (
- XAAudioIODeviceCapabilitiesItf self,
- xaAvailableAudioInputsChangedCallback callback,
- void * pContext
- );
- XAresult (*GetAvailableAudioOutputs) (
- XAAudioIODeviceCapabilitiesItf self,
- XAint32 * pNumOutputs,
- XAuint32 * pOutputDeviceIDs
- );
- XAresult (*QueryAudioOutputCapabilities) (
- XAAudioIODeviceCapabilitiesItf self,
- XAuint32 deviceID,
- XAAudioOutputDescriptor * pDescriptor
- );
- XAresult (*RegisterAvailableAudioOutputsChangedCallback) (
- XAAudioIODeviceCapabilitiesItf self,
- xaAvailableAudioOutputsChangedCallback callback,
- void * pContext
- );
- XAresult (*RegisterDefaultDeviceIDMapChangedCallback) (
- XAAudioIODeviceCapabilitiesItf self,
- xaDefaultDeviceIDMapChangedCallback callback,
- void * pContext
- );
- XAresult (*GetAssociatedAudioInputs) (
- XAAudioIODeviceCapabilitiesItf self,
- XAuint32 deviceID,
- XAint32 * pNumAudioInputs,
- XAuint32 * pAudioInputDeviceIDs
- );
- XAresult (*GetAssociatedAudioOutputs) (
- XAAudioIODeviceCapabilitiesItf self,
- XAuint32 deviceID,
- XAint32 * pNumAudioOutputs,
- XAuint32 * pAudioOutputDeviceIDs
- );
- XAresult (*GetDefaultAudioDevices) (
- XAAudioIODeviceCapabilitiesItf self,
- XAuint32 defaultDeviceID,
- XAint32 *pNumAudioDevices,
- XAuint32 *pAudioDeviceIDs
- );
- XAresult (*QuerySampleFormatsSupported) (
- XAAudioIODeviceCapabilitiesItf self,
- XAuint32 deviceID,
- XAmilliHertz samplingRate,
- XAint32 *pSampleFormats,
- XAint32 *pNumOfSampleFormats
- );
-};
-
-/* DEVICE VOLUME */
-
-XA_API extern const XAInterfaceID XA_IID_DEVICEVOLUME;
-
-struct XADeviceVolumeItf_;
-typedef const struct XADeviceVolumeItf_ * const * XADeviceVolumeItf;
-
-struct XADeviceVolumeItf_ {
- XAresult (*GetVolumeScale) (
- XADeviceVolumeItf self,
- XAuint32 deviceID,
- XAint32 * pMinValue,
- XAint32 * pMaxValue,
- XAboolean * pIsMillibelScale
- );
- XAresult (*SetVolume) (
- XADeviceVolumeItf self,
- XAuint32 deviceID,
- XAint32 volume
- );
- XAresult (*GetVolume) (
- XADeviceVolumeItf self,
- XAuint32 deviceID,
- XAint32 * pVolume
- );
-};
-
-/* EQUALIZER */
-
-#define XA_EQUALIZER_UNDEFINED ((XAuint16) 0xFFFF)
-
-XA_API extern const XAInterfaceID XA_IID_EQUALIZER;
-
-struct XAEqualizerItf_;
-typedef const struct XAEqualizerItf_ * const * XAEqualizerItf;
-
-struct XAEqualizerItf_ {
- XAresult (*SetEnabled) (
- XAEqualizerItf self,
- XAboolean enabled
- );
- XAresult (*IsEnabled) (
- XAEqualizerItf self,
- XAboolean * pEnabled
- );
- XAresult (*GetNumberOfBands) (
- XAEqualizerItf self,
- XAuint16 * pNumBands
- );
- XAresult (*GetBandLevelRange) (
- XAEqualizerItf self,
- XAmillibel * pMin,
- XAmillibel * pMax
- );
- XAresult (*SetBandLevel) (
- XAEqualizerItf self,
- XAuint16 band,
- XAmillibel level
- );
- XAresult (*GetBandLevel) (
- XAEqualizerItf self,
- XAuint16 band,
- XAmillibel * pLevel
- );
- XAresult (*GetCenterFreq) (
- XAEqualizerItf self,
- XAuint16 band,
- XAmilliHertz * pCenter
- );
- XAresult (*GetBandFreqRange) (
- XAEqualizerItf self,
- XAuint16 band,
- XAmilliHertz * pMin,
- XAmilliHertz * pMax
- );
- XAresult (*GetBand) (
- XAEqualizerItf self,
- XAmilliHertz frequency,
- XAuint16 * pBand
- );
- XAresult (*GetCurrentPreset) (
- XAEqualizerItf self,
- XAuint16 * pPreset
- );
- XAresult (*UsePreset) (
- XAEqualizerItf self,
- XAuint16 index
- );
- XAresult (*GetNumberOfPresets) (
- XAEqualizerItf self,
- XAuint16 * pNumPresets
- );
- XAresult (*GetPresetName) (
- XAEqualizerItf self,
- XAuint16 index,
- const XAchar ** ppName
- );
-};
-
-/* OUTPUT MIX */
-
-XA_API extern const XAInterfaceID XA_IID_OUTPUTMIX;
-
-struct XAOutputMixItf_;
-typedef const struct XAOutputMixItf_ * const * XAOutputMixItf;
-
-typedef void (XAAPIENTRY * xaMixDeviceChangeCallback) (
- XAOutputMixItf caller,
- void * pContext
-);
-
-struct XAOutputMixItf_ {
- XAresult (*GetDestinationOutputDeviceIDs) (
- XAOutputMixItf self,
- XAint32 * pNumDevices,
- XAuint32 * pDeviceIDs
- );
- XAresult (*RegisterDeviceChangeCallback) (
- XAOutputMixItf self,
- xaMixDeviceChangeCallback callback,
- void * pContext
- );
- XAresult (*ReRoute) (
- XAOutputMixItf self,
- XAint32 numOutputDevices,
- XAuint32 * pOutputDeviceIDs
- );
-};
-
-/* RADIO */
-
-#define XA_FREQRANGE_FMEUROAMERICA ((XAuint8) 0x01)
-#define XA_FREQRANGE_FMJAPAN ((XAuint8) 0x02)
-#define XA_FREQRANGE_AMLW ((XAuint8) 0x03)
-#define XA_FREQRANGE_AMMW ((XAuint8) 0x04)
-#define XA_FREQRANGE_AMSW ((XAuint8) 0x05)
-
-#define XA_RADIO_EVENT_ANTENNA_STATUS_CHANGED ((XAuint32) 0x00000001)
-#define XA_RADIO_EVENT_FREQUENCY_CHANGED ((XAuint32) 0x00000002)
-#define XA_RADIO_EVENT_FREQUENCY_RANGE_CHANGED ((XAuint32) 0x00000003)
-#define XA_RADIO_EVENT_PRESET_CHANGED ((XAuint32) 0x00000004)
-#define XA_RADIO_EVENT_SEEK_COMPLETED ((XAuint32) 0x00000005)
-
-#define XA_STEREOMODE_MONO ((XAuint32) 0x00000000)
-#define XA_STEREOMODE_STEREO ((XAuint32) 0x00000001)
-#define XA_STEREOMODE_AUTO ((XAuint32) 0x00000002)
-
-XA_API extern const XAInterfaceID XA_IID_RADIO;
-
-struct XARadioItf_;
-typedef const struct XARadioItf_ * const * XARadioItf;
-
-typedef void (XAAPIENTRY * xaRadioCallback) (
- XARadioItf caller,
- void * pContext,
- XAuint32 event,
- XAuint32 eventIntData,
- XAboolean eventBooleanData
-);
-
-struct XARadioItf_ {
- XAresult (*SetFreqRange) (
- XARadioItf self,
- XAuint8 range
- );
- XAresult (*GetFreqRange) (
- XARadioItf self,
- XAuint8 * pRange
- );
- XAresult (*IsFreqRangeSupported) (
- XARadioItf self,
- XAuint8 range,
- XAboolean * pSupported
- );
- XAresult (*GetFreqRangeProperties) (
- XARadioItf self,
- XAuint8 range,
- XAuint32 * pMinFreq,
- XAuint32 * pMaxFreq,
- XAuint32 * pFreqInterval
- );
- XAresult (*SetFrequency) (
- XARadioItf self,
- XAuint32 freq
- );
- XAresult (*CancelSetFrequency) (
- XARadioItf self
- );
- XAresult (*GetFrequency) (
- XARadioItf self,
- XAuint32 * pFreq
- );
- XAresult (*SetSquelch) (
- XARadioItf self,
- XAboolean squelch
- );
- XAresult (*GetSquelch) (
- XARadioItf self,
- XAboolean * pSquelch
- );
- XAresult (*SetStereoMode) (
- XARadioItf self,
- XAuint32 mode
- );
- XAresult (*GetStereoMode) (
- XARadioItf self,
- XAuint32 * pMode
- );
- XAresult (*GetSignalStrength) (
- XARadioItf self,
- XAuint32 * pStrength
- );
- XAresult (*Seek) (
- XARadioItf self,
- XAboolean upwards
- );
- XAresult (*StopSeeking) (
- XARadioItf self
- );
- XAresult (*GetNumberOfPresets) (
- XARadioItf self,
- XAuint32 * pNumPresets
- );
- XAresult (*SetPreset) (
- XARadioItf self,
- XAuint32 preset,
- XAuint32 freq,
- XAuint8 range,
- XAuint32 mode,
- const XAchar * pName
- );
- XAresult (*GetPreset) (
- XARadioItf self,
- XAuint32 preset,
- XAuint32 * pFreq,
- XAuint8 * pRange,
- XAuint32 * pMode,
- XAchar * pName,
- XAuint16 * pNameLength
- );
- XAresult (*RegisterRadioCallback) (
- XARadioItf self,
- xaRadioCallback callback,
- void * pContext
- );
-};
-
-/* RDS */
-
-#define XA_RDS_EVENT_NEW_PI ((XAuint16) 0x0001)
-#define XA_RDS_EVENT_NEW_PTY ((XAuint16) 0x0002)
-#define XA_RDS_EVENT_NEW_PS ((XAuint16) 0x0004)
-#define XA_RDS_EVENT_NEW_RT ((XAuint16) 0x0008)
-#define XA_RDS_EVENT_NEW_RT_PLUS ((XAuint16) 0x0010)
-#define XA_RDS_EVENT_NEW_CT ((XAuint16) 0x0020)
-#define XA_RDS_EVENT_NEW_TA ((XAuint16) 0x0040)
-#define XA_RDS_EVENT_NEW_TP ((XAuint16) 0x0080)
-#define XA_RDS_EVENT_NEW_ALARM ((XAuint16) 0x0100)
-
-#define XA_RDSPROGRAMMETYPE_RDSPTY_NONE \
- ((XAuint32) 0x00000000)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_NEWS \
- ((XAuint32) 0x00000001)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_CURRENTAFFAIRS \
- ((XAuint32) 0x00000002)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_INFORMATION \
- ((XAuint32) 0x00000003)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_SPORT \
- ((XAuint32) 0x00000004)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_EDUCATION \
- ((XAuint32) 0x00000005)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_DRAMA \
- ((XAuint32) 0x00000006)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_CULTURE \
- ((XAuint32) 0x00000007)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_SCIENCE \
- ((XAuint32) 0x00000008)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_VARIEDSPEECH \
- ((XAuint32) 0x00000009)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_POPMUSIC \
- ((XAuint32) 0x0000000A)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_ROCKMUSIC \
- ((XAuint32) 0x0000000B)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_EASYLISTENING \
- ((XAuint32) 0x0000000C)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_LIGHTCLASSICAL \
- ((XAuint32) 0x0000000D)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_SERIOUSCLASSICAL \
- ((XAuint32) 0x0000000E)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_OTHERMUSIC \
- ((XAuint32) 0x0000000F)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_WEATHER \
- ((XAuint32) 0x00000010)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_FINANCE \
- ((XAuint32) 0x00000011)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_CHILDRENSPROGRAMMES \
- ((XAuint32) 0x00000012)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_SOCIALAFFAIRS \
- ((XAuint32) 0x00000013)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_RELIGION \
- ((XAuint32) 0x00000014)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_PHONEIN \
- ((XAuint32) 0x00000015)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_TRAVEL \
- ((XAuint32) 0x00000016)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_LEISURE \
- ((XAuint32) 0x00000017)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_JAZZMUSIC \
- ((XAuint32) 0x00000018)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_COUNTRYMUSIC \
- ((XAuint32) 0x00000019)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_NATIONALMUSIC \
- ((XAuint32) 0x0000001A)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_OLDIESMUSIC \
- ((XAuint32) 0x0000001B)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_FOLKMUSIC \
- ((XAuint32) 0x0000001C)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_DOCUMENTARY \
- ((XAuint32) 0x0000001D)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_ALARMTEST \
- ((XAuint32) 0x0000001E)
-#define XA_RDSPROGRAMMETYPE_RDSPTY_ALARM \
- ((XAuint32) 0x0000001F)
-
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_NONE \
- ((XAuint32) 0x00000000)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_NEWS \
- ((XAuint32) 0x00000001)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_INFORMATION \
- ((XAuint32) 0x00000002)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_SPORTS \
- ((XAuint32) 0x00000003)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_TALK \
- ((XAuint32) 0x00000004)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_ROCK \
- ((XAuint32) 0x00000005)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_CLASSICROCK \
- ((XAuint32) 0x00000006)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_ADULTHITS \
- ((XAuint32) 0x00000007)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_SOFTROCK \
- ((XAuint32) 0x00000008)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_TOP40 \
- ((XAuint32) 0x00000009)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_COUNTRY \
- ((XAuint32) 0x0000000A)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_OLDIES \
- ((XAuint32) 0x0000000B)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_SOFT \
- ((XAuint32) 0x0000000C)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_NOSTALGIA \
- ((XAuint32) 0x0000000D)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_JAZZ \
- ((XAuint32) 0x0000000E)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_CLASSICAL \
- ((XAuint32) 0x0000000F)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_RHYTHMANDBLUES \
- ((XAuint32) 0x00000010)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_SOFTRHYTHMANDBLUES \
- ((XAuint32) 0x00000011)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_LANGUAGE \
- ((XAuint32) 0x00000012)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_RELIGIOUSMUSIC \
- ((XAuint32) 0x00000013)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_RELIGIOUSTALK \
- ((XAuint32) 0x00000014)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_PERSONALITY \
- ((XAuint32) 0x00000015)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_PUBLIC \
- ((XAuint32) 0x00000016)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_COLLEGE \
- ((XAuint32) 0x00000017)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_UNASSIGNED1 \
- ((XAuint32) 0x00000018)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_UNASSIGNED2 \
- ((XAuint32) 0x00000019)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_UNASSIGNED3 \
- ((XAuint32) 0x0000001A)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_UNASSIGNED4 \
- ((XAuint32) 0x0000001B)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_UNASSIGNED5 \
- ((XAuint32) 0x0000001C)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_WEATHER \
- ((XAuint32) 0x0000001D)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_EMERGENCYTEST \
- ((XAuint32) 0x0000001E)
-#define XA_RDSPROGRAMMETYPE_RBDSPTY_EMERGENCY \
- ((XAuint32) 0x0000001F)
-
-#define XA_RDSRTPLUS_ITEMTITLE ((XAuint8) 0x01)
-#define XA_RDSRTPLUS_ITEMALBUM ((XAuint8) 0x02)
-#define XA_RDSRTPLUS_ITEMTRACKNUMBER ((XAuint8) 0x03)
-#define XA_RDSRTPLUS_ITEMARTIST ((XAuint8) 0x04)
-#define XA_RDSRTPLUS_ITEMCOMPOSITION ((XAuint8) 0x05)
-#define XA_RDSRTPLUS_ITEMMOVEMENT ((XAuint8) 0x06)
-#define XA_RDSRTPLUS_ITEMCONDUCTOR ((XAuint8) 0x07)
-#define XA_RDSRTPLUS_ITEMCOMPOSER ((XAuint8) 0x08)
-#define XA_RDSRTPLUS_ITEMBAND ((XAuint8) 0x09)
-#define XA_RDSRTPLUS_ITEMCOMMENT ((XAuint8) 0x0A)
-#define XA_RDSRTPLUS_ITEMGENRE ((XAuint8) 0x0B)
-#define XA_RDSRTPLUS_INFONEWS ((XAuint8) 0x0C)
-#define XA_RDSRTPLUS_INFONEWSLOCAL ((XAuint8) 0x0D)
-#define XA_RDSRTPLUS_INFOSTOCKMARKET ((XAuint8) 0x0E)
-#define XA_RDSRTPLUS_INFOSPORT ((XAuint8) 0x0F)
-#define XA_RDSRTPLUS_INFOLOTTERY ((XAuint8) 0x10)
-#define XA_RDSRTPLUS_INFOHOROSCOPE ((XAuint8) 0x11)
-#define XA_RDSRTPLUS_INFODAILYDIVERSION ((XAuint8) 0x12)
-#define XA_RDSRTPLUS_INFOHEALTH ((XAuint8) 0x13)
-#define XA_RDSRTPLUS_INFOEVENT ((XAuint8) 0x14)
-#define XA_RDSRTPLUS_INFOSZENE ((XAuint8) 0x15)
-#define XA_RDSRTPLUS_INFOCINEMA ((XAuint8) 0x16)
-#define XA_RDSRTPLUS_INFOTV ((XAuint8) 0x17)
-#define XA_RDSRTPLUS_INFODATETIME ((XAuint8) 0x18)
-#define XA_RDSRTPLUS_INFOWEATHER ((XAuint8) 0x19)
-#define XA_RDSRTPLUS_INFOTRAFFIC ((XAuint8) 0x1A)
-#define XA_RDSRTPLUS_INFOALARM ((XAuint8) 0x1B)
-#define XA_RDSRTPLUS_INFOADVISERTISEMENT ((XAuint8) 0x1C)
-#define XA_RDSRTPLUS_INFOURL ((XAuint8) 0x1D)
-#define XA_RDSRTPLUS_INFOOTHER ((XAuint8) 0x1E)
-#define XA_RDSRTPLUS_STATIONNAMESHORT ((XAuint8) 0x1F)
-#define XA_RDSRTPLUS_STATIONNAMELONG ((XAuint8) 0x20)
-#define XA_RDSRTPLUS_PROGRAMNOW ((XAuint8) 0x21)
-#define XA_RDSRTPLUS_PROGRAMNEXT ((XAuint8) 0x22)
-#define XA_RDSRTPLUS_PROGRAMPART ((XAuint8) 0x23)
-#define XA_RDSRTPLUS_PROGRAMHOST ((XAuint8) 0x24)
-#define XA_RDSRTPLUS_PROFRAMEDITORIALSTAFF ((XAuint8) 0x25)
-#define XA_RDSRTPLUS_PROGRAMFREQUENCY ((XAuint8) 0x26)
-#define XA_RDSRTPLUS_PROGRAMHOMEPAGE ((XAuint8) 0x27)
-#define XA_RDSRTPLUS_PROGRAMSUBCHANNEL ((XAuint8) 0x28)
-#define XA_RDSRTPLUS_PHONEHOTLINE ((XAuint8) 0x29)
-#define XA_RDSRTPLUS_PHONESTUDIO ((XAuint8) 0x2A)
-#define XA_RDSRTPLUS_PHONEOTHER ((XAuint8) 0x2B)
-#define XA_RDSRTPLUS_SMSSTUDIO ((XAuint8) 0x2C)
-#define XA_RDSRTPLUS_SMSOTHER ((XAuint8) 0x2D)
-#define XA_RDSRTPLUS_EMAILHOTLINE ((XAuint8) 0x2E)
-#define XA_RDSRTPLUS_EMAILSTUDIO ((XAuint8) 0x2F)
-#define XA_RDSRTPLUS_EMAILOTHER ((XAuint8) 0x30)
-#define XA_RDSRTPLUS_MMSOTHER ((XAuint8) 0x31)
-#define XA_RDSRTPLUS_CHAT ((XAuint8) 0x32)
-#define XA_RDSRTPLUS_CHATCENTER ((XAuint8) 0x33)
-#define XA_RDSRTPLUS_VOTEQUESTION ((XAuint8) 0x34)
-#define XA_RDSRTPLUS_VOTECENTER ((XAuint8) 0x35)
-#define XA_RDSRTPLUS_OPENCLASS45 ((XAuint8) 0x36)
-#define XA_RDSRTPLUS_OPENCLASS55 ((XAuint8) 0x37)
-#define XA_RDSRTPLUS_OPENCLASS56 ((XAuint8) 0x38)
-#define XA_RDSRTPLUS_OPENCLASS57 ((XAuint8) 0x39)
-#define XA_RDSRTPLUS_OPENCLASS58 ((XAuint8) 0x3A)
-#define XA_RDSRTPLUS_PLACE ((XAuint8) 0x3B)
-#define XA_RDSRTPLUS_APPOINTMENT ((XAuint8) 0x3C)
-#define XA_RDSRTPLUS_IDENTIFIER ((XAuint8) 0x3D)
-#define XA_RDSRTPLUS_PURCHASE ((XAuint8) 0x3E)
-#define XA_RDSRTPLUS_GETDATA ((XAuint8) 0x3F)
-
-XA_API extern const XAInterfaceID XA_IID_RDS;
-
-struct XARDSItf_;
-typedef const struct XARDSItf_ * const * XARDSItf;
-
-typedef void (XAAPIENTRY * xaGetODAGroupCallback) (
- XARadioItf caller,
- void * pContext,
- XAboolean success,
- XAint16 group,
- XAuint16 message
-);
-
-typedef void (XAAPIENTRY * xaNewODADataCallback) (
- XARDSItf caller,
- void * pContext,
- XAint16 group,
- XAuint64 data
-);
-
-typedef void (XAAPIENTRY * xaRDSCallback) (
- XARDSItf caller,
- void * pContext,
- XAuint16 event,
- XAuint8 eventData
-);
-
-struct XARDSItf_ {
- XAresult (*QueryRDSSignal) (
- XARDSItf self,
- XAboolean * isSignal
- );
- XAresult (*GetProgrammeServiceName) (
- XARDSItf self,
- XAchar * ps
- );
- XAresult (*GetRadioText) (
- XARDSItf self,
- XAchar * rt
- );
- XAresult (*GetRadioTextPlus) (
- XARDSItf self,
- XAuint8 contentType,
- XAchar * informationElement,
- XAchar * descriptor,
- XAuint8 * descriptorContentType
- );
- XAresult (*GetProgrammeType) (
- XARDSItf self,
- XAuint32 * pty
- );
- XAresult (*GetProgrammeTypeString) (
- XARDSItf self,
- XAboolean isLengthMax16,
- XAchar * pty
- );
- XAresult (*GetProgrammeIdentificationCode) (
- XARDSItf self,
- XAint16 * pi
- );
- XAresult (*GetClockTime) (
- XARDSItf self,
- XAtime * dateAndTime
- );
- XAresult (*GetTrafficAnnouncement) (
- XARDSItf self,
- XAboolean * ta
- );
- XAresult (*GetTrafficProgramme) (
- XARDSItf self,
- XAboolean * tp
- );
- XAresult (*SeekByProgrammeType) (
- XARDSItf self,
- XAuint32 pty,
- XAboolean upwards
- );
- XAresult (*SeekTrafficAnnouncement) (
- XARDSItf self,
- XAboolean upwards
- );
- XAresult (*SeekTrafficProgramme) (
- XARDSItf self,
- XAboolean upwards
- );
- XAresult (*SetAutomaticSwitching) (
- XARDSItf self,
- XAboolean automatic
- );
- XAresult (*GetAutomaticSwitching) (
- XARDSItf self,
- XAboolean * automatic
- );
- XAresult (*SetAutomaticTrafficAnnouncement) (
- XARDSItf self,
- XAboolean automatic
- );
- XAresult (*GetAutomaticTrafficAnnouncement) (
- XARDSItf self,
- XAboolean * automatic
- );
- XAresult (*GetODAGroup) (
- XARDSItf self,
- XAuint16 AID,
- xaGetODAGroupCallback callback,
- void * pContext
- );
- XAresult (*SubscribeODAGroup) (
- XARDSItf self,
- XAint16 group,
- XAboolean useErrorCorrection
- );
- XAresult (*UnsubscribeODAGroup) (
- XARDSItf self,
- XAint16 group
- );
- XAresult (*ListODAGroupSubscriptions) (
- XARDSItf self,
- XAint16* pGroups,
- XAuint32* pLength
- );
- XAresult (*RegisterRDSCallback) (
- XARDSItf self,
- xaRDSCallback callback,
- void * pContext
- );
- XAresult (*RegisterODADataCallback) (
- XARDSItf self,
- xaNewODADataCallback callback,
- void * pContext
- );
-};
-
-/* VIBRA */
-
-XA_API extern const XAInterfaceID XA_IID_VIBRA;
-
-struct XAVibraItf_;
-typedef const struct XAVibraItf_ * const * XAVibraItf;
-
-struct XAVibraItf_ {
- XAresult (*Vibrate) (
- XAVibraItf self,
- XAboolean vibrate
- );
- XAresult (*IsVibrating) (
- XAVibraItf self,
- XAboolean * pVibrating
- );
- XAresult (*SetFrequency) (
- XAVibraItf self,
- XAmilliHertz frequency
- );
- XAresult (*GetFrequency) (
- XAVibraItf self,
- XAmilliHertz * pFrequency
- );
- XAresult (*SetIntensity) (
- XAVibraItf self,
- XApermille intensity
- );
- XAresult (*GetIntensity) (
- XAVibraItf self,
- XApermille * pIntensity
- );
-};
-
-/* LED ARRAY */
-
-typedef struct XAHSL_ {
- XAmillidegree hue;
- XApermille saturation;
- XApermille lightness;
-} XAHSL;
-
-XA_API extern const XAInterfaceID XA_IID_LED;
-
-struct XALEDArrayItf_;
-typedef const struct XALEDArrayItf_ * const * XALEDArrayItf;
-
-struct XALEDArrayItf_ {
- XAresult (*ActivateLEDArray) (
- XALEDArrayItf self,
- XAuint32 lightMask
- );
- XAresult (*IsLEDArrayActivated) (
- XALEDArrayItf self,
- XAuint32 * pLightMask
- );
- XAresult (*SetColor) (
- XALEDArrayItf self,
- XAuint8 index,
- const XAHSL * pColor
- );
- XAresult (*GetColor) (
- XALEDArrayItf self,
- XAuint8 index,
- XAHSL * pColor
- );
-};
-
-
-
- /*****************************************************************/
- /* CODEC RELATED INTERFACES, STRUCTS AND DEFINES */
- /*****************************************************************/
-
-/* AUDIO ENCODER AND AUDIO ENCODER/DECODER CAPABILITIES */
-
-#define XA_RATECONTROLMODE_CONSTANTBITRATE ((XAuint32) 0x00000001)
-#define XA_RATECONTROLMODE_VARIABLEBITRATE ((XAuint32) 0x00000002)
-
-#define XA_AUDIOCODEC_PCM ((XAuint32) 0x00000001)
-#define XA_AUDIOCODEC_MP3 ((XAuint32) 0x00000002)
-#define XA_AUDIOCODEC_AMR ((XAuint32) 0x00000003)
-#define XA_AUDIOCODEC_AMRWB ((XAuint32) 0x00000004)
-#define XA_AUDIOCODEC_AMRWBPLUS ((XAuint32) 0x00000005)
-#define XA_AUDIOCODEC_AAC ((XAuint32) 0x00000006)
-#define XA_AUDIOCODEC_WMA ((XAuint32) 0x00000007)
-#define XA_AUDIOCODEC_REAL ((XAuint32) 0x00000008)
-#define XA_AUDIOCODEC_VORBIS ((XAuint32) 0x00000009)
-
-#define XA_AUDIOPROFILE_PCM ((XAuint32) 0x00000001)
-
-#define XA_AUDIOPROFILE_MPEG1_L3 ((XAuint32) 0x00000001)
-#define XA_AUDIOPROFILE_MPEG2_L3 ((XAuint32) 0x00000002)
-#define XA_AUDIOPROFILE_MPEG25_L3 ((XAuint32) 0x00000003)
-
-#define XA_AUDIOCHANMODE_MP3_MONO ((XAuint32) 0x00000001)
-#define XA_AUDIOCHANMODE_MP3_STEREO ((XAuint32) 0x00000002)
-#define XA_AUDIOCHANMODE_MP3_JOINTSTEREO ((XAuint32) 0x00000003)
-#define XA_AUDIOCHANMODE_MP3_DUAL ((XAuint32) 0x00000004)
-
-#define XA_AUDIOPROFILE_AMR ((XAuint32) 0x00000001)
-
-#define XA_AUDIOSTREAMFORMAT_CONFORMANCE ((XAuint32) 0x00000001)
-#define XA_AUDIOSTREAMFORMAT_IF1 ((XAuint32) 0x00000002)
-#define XA_AUDIOSTREAMFORMAT_IF2 ((XAuint32) 0x00000003)
-#define XA_AUDIOSTREAMFORMAT_FSF ((XAuint32) 0x00000004)
-#define XA_AUDIOSTREAMFORMAT_RTPPAYLOAD ((XAuint32) 0x00000005)
-#define XA_AUDIOSTREAMFORMAT_ITU ((XAuint32) 0x00000006)
-
-#define XA_AUDIOPROFILE_AMRWB ((XAuint32) 0x00000001)
-
-#define XA_AUDIOPROFILE_AMRWBPLUS ((XAuint32) 0x00000001)
-
-#define XA_AUDIOPROFILE_AAC_AAC ((XAuint32) 0x00000001)
-
-#define XA_AUDIOMODE_AAC_MAIN ((XAuint32) 0x00000001)
-#define XA_AUDIOMODE_AAC_LC ((XAuint32) 0x00000002)
-#define XA_AUDIOMODE_AAC_SSR ((XAuint32) 0x00000003)
-#define XA_AUDIOMODE_AAC_LTP ((XAuint32) 0x00000004)
-#define XA_AUDIOMODE_AAC_HE ((XAuint32) 0x00000005)
-#define XA_AUDIOMODE_AAC_SCALABLE ((XAuint32) 0x00000006)
-#define XA_AUDIOMODE_AAC_ERLC ((XAuint32) 0x00000007)
-#define XA_AUDIOMODE_AAC_LD ((XAuint32) 0x00000008)
-#define XA_AUDIOMODE_AAC_HE_PS ((XAuint32) 0x00000009)
-#define XA_AUDIOMODE_AAC_HE_MPS ((XAuint32) 0x0000000A)
-
-#define XA_AUDIOSTREAMFORMAT_MP2ADTS ((XAuint32) 0x00000001)
-#define XA_AUDIOSTREAMFORMAT_MP4ADTS ((XAuint32) 0x00000002)
-#define XA_AUDIOSTREAMFORMAT_MP4LOAS ((XAuint32) 0x00000003)
-#define XA_AUDIOSTREAMFORMAT_MP4LATM ((XAuint32) 0x00000004)
-#define XA_AUDIOSTREAMFORMAT_ADIF ((XAuint32) 0x00000005)
-#define XA_AUDIOSTREAMFORMAT_MP4FF ((XAuint32) 0x00000006)
-#define XA_AUDIOSTREAMFORMAT_RAW ((XAuint32) 0x00000007)
-
-#define XA_AUDIOPROFILE_WMA7 ((XAuint32) 0x00000001)
-#define XA_AUDIOPROFILE_WMA8 ((XAuint32) 0x00000002)
-#define XA_AUDIOPROFILE_WMA9 ((XAuint32) 0x00000003)
-#define XA_AUDIOPROFILE_WMA10 ((XAuint32) 0x00000004)
-
-#define XA_AUDIOMODE_WMA_LEVEL1 ((XAuint32) 0x00000001)
-#define XA_AUDIOMODE_WMA_LEVEL2 ((XAuint32) 0x00000002)
-#define XA_AUDIOMODE_WMA_LEVEL3 ((XAuint32) 0x00000003)
-#define XA_AUDIOMODE_WMA_LEVEL4 ((XAuint32) 0x00000004)
-#define XA_AUDIOMODE_WMAPRO_LEVELM0 ((XAuint32) 0x00000005)
-#define XA_AUDIOMODE_WMAPRO_LEVELM1 ((XAuint32) 0x00000006)
-#define XA_AUDIOMODE_WMAPRO_LEVELM2 ((XAuint32) 0x00000007)
-#define XA_AUDIOMODE_WMAPRO_LEVELM3 ((XAuint32) 0x00000008)
-
-#define XA_AUDIOPROFILE_REALAUDIO ((XAuint32) 0x00000001)
-
-#define XA_AUDIOMODE_REALAUDIO_G2 ((XAuint32) 0x00000001)
-#define XA_AUDIOMODE_REALAUDIO_8 ((XAuint32) 0x00000002)
-#define XA_AUDIOMODE_REALAUDIO_10 ((XAuint32) 0x00000003)
-#define XA_AUDIOMODE_REALAUDIO_SURROUND ((XAuint32) 0x00000004)
-
-#define XA_AUDIOPROFILE_VORBIS ((XAuint32) 0x00000001)
-
-#define XA_AUDIOMODE_VORBIS ((XAuint32) 0x00000001)
-
-
-typedef struct XAAudioCodecDescriptor_ {
- XAuint32 maxChannels;
- XAuint32 minBitsPerSample;
- XAuint32 maxBitsPerSample;
- XAmilliHertz minSampleRate;
- XAmilliHertz maxSampleRate;
- XAboolean isFreqRangeContinuous;
- XAmilliHertz * pSampleRatesSupported;
- XAuint32 numSampleRatesSupported;
- XAuint32 minBitRate;
- XAuint32 maxBitRate;
- XAboolean isBitrateRangeContinuous;
- XAuint32 * pBitratesSupported;
- XAuint32 numBitratesSupported;
- XAuint32 profileSetting;
- XAuint32 modeSetting;
-} XAAudioCodecDescriptor;
-
-typedef struct XAAudioEncoderSettings_ {
- XAuint32 encoderId;
- XAuint32 channelsIn;
- XAuint32 channelsOut;
- XAmilliHertz sampleRate;
- XAuint32 bitRate;
- XAuint32 bitsPerSample;
- XAuint32 rateControl;
- XAuint32 profileSetting;
- XAuint32 levelSetting;
- XAuint32 channelMode;
- XAuint32 streamFormat;
- XAuint32 encodeOptions;
- XAuint32 blockAlignment;
-} XAAudioEncoderSettings;
-
-XA_API extern const XAInterfaceID XA_IID_AUDIODECODERCAPABILITIES;
-
-struct XAAudioDecoderCapabilitiesItf_;
-typedef const struct XAAudioDecoderCapabilitiesItf_
- * const * XAAudioDecoderCapabilitiesItf;
-
-struct XAAudioDecoderCapabilitiesItf_ {
- XAresult (*GetAudioDecoders) (
- XAAudioDecoderCapabilitiesItf self,
- XAuint32 * pNumDecoders,
- XAuint32 * pDecoderIds
- );
- XAresult (*GetAudioDecoderCapabilities) (
- XAAudioDecoderCapabilitiesItf self,
- XAuint32 decoderId,
- XAuint32 * pIndex,
- XAAudioCodecDescriptor * pDescriptor
- );
-};
-
-XA_API extern const XAInterfaceID XA_IID_AUDIOENCODER;
-
-struct XAAudioEncoderItf_;
-typedef const struct XAAudioEncoderItf_ * const * XAAudioEncoderItf;
-
-struct XAAudioEncoderItf_ {
- XAresult (*SetEncoderSettings) (
- XAAudioEncoderItf self,
- XAAudioEncoderSettings * pSettings
- );
- XAresult (*GetEncoderSettings) (
- XAAudioEncoderItf self,
- XAAudioEncoderSettings * pSettings
- );
-};
-
-XA_API extern const XAInterfaceID XA_IID_AUDIOENCODERCAPABILITIES;
-
-struct XAAudioEncoderCapabilitiesItf_;
-typedef const struct XAAudioEncoderCapabilitiesItf_
- * const * XAAudioEncoderCapabilitiesItf;
-
-struct XAAudioEncoderCapabilitiesItf_ {
- XAresult (*GetAudioEncoders) (
- XAAudioEncoderCapabilitiesItf self,
- XAuint32 * pNumEncoders,
- XAuint32 * pEncoderIds
- );
- XAresult (*GetAudioEncoderCapabilities) (
- XAAudioEncoderCapabilitiesItf self,
- XAuint32 encoderId,
- XAuint32 * pIndex,
- XAAudioCodecDescriptor * pDescriptor
- );
-};
-
-/* IMAGE ENCODER AND IMAGE ENCODER/DECODER CAPABILITIES */
-
-#define XA_IMAGECODEC_JPEG ((XAuint32) 0x00000001)
-#define XA_IMAGECODEC_GIF ((XAuint32) 0x00000002)
-#define XA_IMAGECODEC_BMP ((XAuint32) 0x00000003)
-#define XA_IMAGECODEC_PNG ((XAuint32) 0x00000004)
-#define XA_IMAGECODEC_TIFF ((XAuint32) 0x00000005)
-#define XA_IMAGECODEC_RAW ((XAuint32) 0x00000006)
-
-typedef struct XAImageCodecDescriptor_ {
- XAuint32 codecId;
- XAuint32 maxWidth;
- XAuint32 maxHeight;
-} XAImageCodecDescriptor;
-
-typedef struct XAImageSettings_ {
- XAuint32 encoderId;
- XAuint32 width;
- XAuint32 height;
- XApermille compressionLevel;
- XAuint32 colorFormat;
-} XAImageSettings;
-
-XA_API extern const XAInterfaceID XA_IID_IMAGEENCODERCAPABILITIES;
-
-struct XAImageEncoderCapabilitiesItf_;
-typedef const struct XAImageEncoderCapabilitiesItf_
- * const * XAImageEncoderCapabilitiesItf;
-
-struct XAImageEncoderCapabilitiesItf_ {
- XAresult (*GetImageEncoderCapabilities) (
- XAImageEncoderCapabilitiesItf self,
- XAuint32 * pEncoderId,
- XAImageCodecDescriptor * pDescriptor
- );
- XAresult (*QueryColorFormats) (
- const XAImageEncoderCapabilitiesItf self,
- XAuint32 * pIndex,
- XAuint32 * pColorFormat
- );
-};
-
-XA_API extern const XAInterfaceID XA_IID_IMAGEDECODERCAPABILITIES;
-
-struct XAImageDecoderCapabilitiesItf_;
-typedef const struct XAImageDecoderCapabilitiesItf_
- * const * XAImageDecoderCapabilitiesItf;
-
-struct XAImageDecoderCapabilitiesItf_ {
- XAresult (*GetImageDecoderCapabilities) (
- XAImageDecoderCapabilitiesItf self,
- XAuint32 * pDecoderId,
- XAImageCodecDescriptor * pDescriptor
- );
- XAresult (*QueryColorFormats) (
- const XAImageDecoderCapabilitiesItf self,
- XAuint32 * pIndex,
- XAuint32 * pColorFormat
- );
-};
-
-XA_API extern const XAInterfaceID XA_IID_IMAGEENCODER;
-
-struct XAImageEncoderItf_;
-typedef const struct XAImageEncoderItf_ * const * XAImageEncoderItf;
-
-struct XAImageEncoderItf_ {
- XAresult (*SetImageSettings) (
- XAImageEncoderItf self,
- const XAImageSettings * pSettings
- );
- XAresult (*GetImageSettings) (
- XAImageEncoderItf self,
- XAImageSettings * pSettings
- );
- XAresult (*GetSizeEstimate) (
- XAImageEncoderItf self,
- XAuint32 * pSize
- );
-};
-
-/* VIDEO ENCODER AND VIDEO ENCODER/DECODER CAPABILITIES */
-
-#define XA_VIDEOCODEC_MPEG2 ((XAuint32) 0x00000001)
-#define XA_VIDEOCODEC_H263 ((XAuint32) 0x00000002)
-#define XA_VIDEOCODEC_MPEG4 ((XAuint32) 0x00000003)
-#define XA_VIDEOCODEC_AVC ((XAuint32) 0x00000004)
-#define XA_VIDEOCODEC_VC1 ((XAuint32) 0x00000005)
-
-#define XA_VIDEOPROFILE_MPEG2_SIMPLE ((XAuint32) 0x00000001)
-#define XA_VIDEOPROFILE_MPEG2_MAIN ((XAuint32) 0x00000002)
-#define XA_VIDEOPROFILE_MPEG2_422 ((XAuint32) 0x00000003)
-#define XA_VIDEOPROFILE_MPEG2_SNR ((XAuint32) 0x00000004)
-#define XA_VIDEOPROFILE_MPEG2_SPATIAL ((XAuint32) 0x00000005)
-#define XA_VIDEOPROFILE_MPEG2_HIGH ((XAuint32) 0x00000006)
-
-#define XA_VIDEOLEVEL_MPEG2_LL ((XAuint32) 0x00000001)
-#define XA_VIDEOLEVEL_MPEG2_ML ((XAuint32) 0x00000002)
-#define XA_VIDEOLEVEL_MPEG2_H14 ((XAuint32) 0x00000003)
-#define XA_VIDEOLEVEL_MPEG2_HL ((XAuint32) 0x00000004)
-
-#define XA_VIDEOPROFILE_H263_BASELINE ((XAuint32) 0x00000001)
-#define XA_VIDEOPROFILE_H263_H320CODING ((XAuint32) 0x00000002)
-#define XA_VIDEOPROFILE_H263_BACKWARDCOMPATIBLE ((XAuint32) 0x00000003)
-#define XA_VIDEOPROFILE_H263_ISWV2 ((XAuint32) 0x00000004)
-#define XA_VIDEOPROFILE_H263_ISWV3 ((XAuint32) 0x00000005)
-#define XA_VIDEOPROFILE_H263_HIGHCOMPRESSION ((XAuint32) 0x00000006)
-#define XA_VIDEOPROFILE_H263_INTERNET ((XAuint32) 0x00000007)
-#define XA_VIDEOPROFILE_H263_INTERLACE ((XAuint32) 0x00000008)
-#define XA_VIDEOPROFILE_H263_HIGHLATENCY ((XAuint32) 0x00000009)
-
-#define XA_VIDEOLEVEL_H263_10 ((XAuint32) 0x00000001)
-#define XA_VIDEOLEVEL_H263_20 ((XAuint32) 0x00000002)
-#define XA_VIDEOLEVEL_H263_30 ((XAuint32) 0x00000003)
-#define XA_VIDEOLEVEL_H263_40 ((XAuint32) 0x00000004)
-#define XA_VIDEOLEVEL_H263_45 ((XAuint32) 0x00000005)
-#define XA_VIDEOLEVEL_H263_50 ((XAuint32) 0x00000006)
-#define XA_VIDEOLEVEL_H263_60 ((XAuint32) 0x00000007)
-#define XA_VIDEOLEVEL_H263_70 ((XAuint32) 0x00000008)
-
-#define XA_VIDEOPROFILE_MPEG4_SIMPLE ((XAuint32) 0x00000001)
-#define XA_VIDEOPROFILE_MPEG4_SIMPLESCALABLE ((XAuint32) 0x00000002)
-#define XA_VIDEOPROFILE_MPEG4_CORE ((XAuint32) 0x00000003)
-#define XA_VIDEOPROFILE_MPEG4_MAIN ((XAuint32) 0x00000004)
-#define XA_VIDEOPROFILE_MPEG4_NBIT ((XAuint32) 0x00000005)
-#define XA_VIDEOPROFILE_MPEG4_SCALABLETEXTURE ((XAuint32) 0x00000006)
-#define XA_VIDEOPROFILE_MPEG4_SIMPLEFACE ((XAuint32) 0x00000007)
-#define XA_VIDEOPROFILE_MPEG4_SIMPLEFBA ((XAuint32) 0x00000008)
-#define XA_VIDEOPROFILE_MPEG4_BASICANIMATED ((XAuint32) 0x00000009)
-#define XA_VIDEOPROFILE_MPEG4_HYBRID ((XAuint32) 0x0000000A)
-#define XA_VIDEOPROFILE_MPEG4_ADVANCEDREALTIME ((XAuint32) 0x0000000B)
-#define XA_VIDEOPROFILE_MPEG4_CORESCALABLE ((XAuint32) 0x0000000C)
-#define XA_VIDEOPROFILE_MPEG4_ADVANCEDCODING ((XAuint32) 0x0000000D)
-#define XA_VIDEOPROFILE_MPEG4_ADVANCEDCORE ((XAuint32) 0x0000000E)
-#define XA_VIDEOPROFILE_MPEG4_ADVANCEDSCALABLE ((XAuint32) 0x0000000F)
-
-#define XA_VIDEOLEVEL_MPEG4_0 ((XAuint32) 0x00000001)
-#define XA_VIDEOLEVEL_MPEG4_0b ((XAuint32) 0x00000002)
-#define XA_VIDEOLEVEL_MPEG4_1 ((XAuint32) 0x00000003)
-#define XA_VIDEOLEVEL_MPEG4_2 ((XAuint32) 0x00000004)
-#define XA_VIDEOLEVEL_MPEG4_3 ((XAuint32) 0x00000005)
-#define XA_VIDEOLEVEL_MPEG4_4 ((XAuint32) 0x00000006)
-#define XA_VIDEOLEVEL_MPEG4_4a ((XAuint32) 0x00000007)
-#define XA_VIDEOLEVEL_MPEG4_5 ((XAuint32) 0x00000008)
-
-#define XA_VIDEOPROFILE_AVC_BASELINE ((XAuint32) 0x00000001)
-#define XA_VIDEOPROFILE_AVC_MAIN ((XAuint32) 0x00000002)
-#define XA_VIDEOPROFILE_AVC_EXTENDED ((XAuint32) 0x00000003)
-#define XA_VIDEOPROFILE_AVC_HIGH ((XAuint32) 0x00000004)
-#define XA_VIDEOPROFILE_AVC_HIGH10 ((XAuint32) 0x00000005)
-#define XA_VIDEOPROFILE_AVC_HIGH422 ((XAuint32) 0x00000006)
-#define XA_VIDEOPROFILE_AVC_HIGH444 ((XAuint32) 0x00000007)
-
-#define XA_VIDEOLEVEL_AVC_1 ((XAuint32) 0x00000001)
-#define XA_VIDEOLEVEL_AVC_1B ((XAuint32) 0x00000002)
-#define XA_VIDEOLEVEL_AVC_11 ((XAuint32) 0x00000003)
-#define XA_VIDEOLEVEL_AVC_12 ((XAuint32) 0x00000004)
-#define XA_VIDEOLEVEL_AVC_13 ((XAuint32) 0x00000005)
-#define XA_VIDEOLEVEL_AVC_2 ((XAuint32) 0x00000006)
-#define XA_VIDEOLEVEL_AVC_21 ((XAuint32) 0x00000007)
-#define XA_VIDEOLEVEL_AVC_22 ((XAuint32) 0x00000008)
-#define XA_VIDEOLEVEL_AVC_3 ((XAuint32) 0x00000009)
-#define XA_VIDEOLEVEL_AVC_31 ((XAuint32) 0x0000000A)
-#define XA_VIDEOLEVEL_AVC_32 ((XAuint32) 0x0000000B)
-#define XA_VIDEOLEVEL_AVC_4 ((XAuint32) 0x0000000C)
-#define XA_VIDEOLEVEL_AVC_41 ((XAuint32) 0x0000000D)
-#define XA_VIDEOLEVEL_AVC_42 ((XAuint32) 0x0000000E)
-#define XA_VIDEOLEVEL_AVC_5 ((XAuint32) 0x0000000F)
-#define XA_VIDEOLEVEL_AVC_51 ((XAuint32) 0x00000010)
-
-#define XA_VIDEOLEVEL_VC1_SIMPLE ((XAuint32) 0x00000001)
-#define XA_VIDEOLEVEL_VC1_MAIN ((XAuint32) 0x00000002)
-#define XA_VIDEOLEVEL_VC1_ADVANCED ((XAuint32) 0x00000003)
-
-#define XA_VIDEOLEVEL_VC1_LOW ((XAuint32) 0x00000001)
-#define XA_VIDEOLEVEL_VC1_MEDIUM ((XAuint32) 0x00000002)
-#define XA_VIDEOLEVEL_VC1_HIGH ((XAuint32) 0x00000003)
-#define XA_VIDEOLEVEL_VC1_L0 ((XAuint32) 0x00000004)
-#define XA_VIDEOLEVEL_VC1_L1 ((XAuint32) 0x00000005)
-#define XA_VIDEOLEVEL_VC1_L2 ((XAuint32) 0x00000006)
-#define XA_VIDEOLEVEL_VC1_L3 ((XAuint32) 0x00000007)
-#define XA_VIDEOLEVEL_VC1_L4 ((XAuint32) 0x00000008)
-
-typedef struct XAVideoCodecDescriptor_ {
- XAuint32 codecId;
- XAuint32 maxWidth;
- XAuint32 maxHeight;
- XAuint32 maxFrameRate;
- XAuint32 maxBitRate;
- XAuint32 rateControlSupported;
- XAuint32 profileSetting;
- XAuint32 levelSetting;
-} XAVideoCodecDescriptor;
-
-typedef struct XAVideoSettings_ {
- XAuint32 encoderId;
- XAuint32 width;
- XAuint32 height;
- XAuint32 frameRate;
- XAuint32 bitRate;
- XAuint32 rateControl;
- XAuint32 profileSetting;
- XAuint32 levelSetting;
- XAuint32 keyFrameInterval;
-} XAVideoSettings;
-
-XA_API extern const XAInterfaceID XA_IID_VIDEODECODERCAPABILITIES;
-
-struct XAVideoDecoderCapabilitiesItf_;
-typedef const struct XAVideoDecoderCapabilitiesItf_
- * const * XAVideoDecoderCapabilitiesItf;
-
-struct XAVideoDecoderCapabilitiesItf_ {
- XAresult (*GetVideoDecoders) (
- XAVideoDecoderCapabilitiesItf self,
- XAuint32 * pNumDecoders,
- XAuint32 * pDecoderIds
- );
- XAresult (*GetVideoDecoderCapabilities) (
- XAVideoDecoderCapabilitiesItf self,
- XAuint32 decoderId,
- XAuint32 * pIndex,
- XAVideoCodecDescriptor * pDescriptor
- );
-};
-
-XA_API extern const XAInterfaceID XA_IID_VIDEOENCODER;
-
-XA_API extern const XAInterfaceID XA_IID_VIDEOENCODERCAPABILITIES;
-
-struct XAVideoEncoderCapabilitiesItf_;
-typedef const struct XAVideoEncoderCapabilitiesItf_
- * const * XAVideoEncoderCapabilitiesItf;
-
-struct XAVideoEncoderCapabilitiesItf_ {
- XAresult (*GetVideoEncoders) (
- XAVideoEncoderCapabilitiesItf self,
- XAuint32 * pNumEncoders,
- XAuint32 * pEncoderIds
- );
- XAresult (*GetVideoEncoderCapabilities) (
- XAVideoEncoderCapabilitiesItf self,
- XAuint32 encoderId,
- XAuint32 * pIndex,
- XAVideoCodecDescriptor * pDescriptor
- );
-};
-
-struct XAVideoEncoderItf_;
-typedef const struct XAVideoEncoderItf_ * const * XAVideoEncoderItf;
-
-struct XAVideoEncoderItf_ {
- XAresult (*SetVideoSettings) (
- XAVideoEncoderItf self,
- XAVideoSettings * pSettings
- );
- XAresult (*GetVideoSettings) (
- XAVideoEncoderItf self,
- XAVideoSettings * pSettings
- );
-};
-
-/* STREAM INFORMATION */
-
-#define XA_DOMAINTYPE_AUDIO 0x00000001
-#define XA_DOMAINTYPE_VIDEO 0x00000002
-#define XA_DOMAINTYPE_IMAGE 0x00000003
-#define XA_DOMAINTYPE_TIMEDTEXT 0x00000004
-#define XA_DOMAINTYPE_MIDI 0x00000005
-#define XA_DOMAINTYPE_VENDOR 0xFFFFFFFE
-#define XA_DOMAINTYPE_UNKNOWN 0xFFFFFFFF
-
-#define XA_MIDIBANK_DEVICE 0x00000001
-#define XA_MIDIBANK_CUSTOM 0x00000002
-
-#define XA_MIDI_UNKNOWN 0xFFFFFFFF
-
-#define XA_STREAMCBEVENT_PROPERTYCHANGE ((XAuint32) 0x00000001)
-
-typedef struct XAMediaContainerInformation_ {
- XAuint32 containerType;
- XAmillisecond mediaDuration;
- XAuint32 numStreams;
-} XAMediaContainerInformation;
-
-typedef struct XAVideoStreamInformation_ {
- XAuint32 codecId;
- XAuint32 width;
- XAuint32 height;
- XAuint32 frameRate;
- XAuint32 bitRate;
- XAmillisecond duration;
-} XAVideoStreamInformation;
-
-typedef struct XAAudioStreamInformation_ {
- XAuint32 codecId;
- XAuint32 channels;
- XAmilliHertz sampleRate;
- XAuint32 bitRate;
- XAchar langCountry[16];
- XAmillisecond duration;
-} XAAudioStreamInformation;
-
-typedef struct XAImageStreamInformation_ {
- XAuint32 codecId;
- XAuint32 width;
- XAuint32 height;
- XAmillisecond presentationDuration;
-} XAImageStreamInformation;
-
-typedef struct XATimedTextStreamInformation_ {
- XAuint16 layer;
- XAuint32 width;
- XAuint32 height;
- XAuint16 tx;
- XAuint16 ty;
- XAuint32 bitrate;
- XAchar langCountry[16];
- XAmillisecond duration;
-} XATimedTextStreamInformation;
-
-typedef struct XAMIDIStreamInformation_ {
- XAuint32 channels;
- XAuint32 tracks;
- XAuint32 bankType;
- XAchar langCountry[16];
- XAmillisecond duration;
-} XAMIDIStreamInformation;
-
-typedef struct XAVendorStreamInformation_ {
- void *VendorStreamInfo;
-} XAVendorStreamInformation;
-
-XA_API extern const XAInterfaceID XA_IID_STREAMINFORMATION;
-
-struct XAStreamInformationItf_;
-typedef const struct XAStreamInformationItf_ * const * XAStreamInformationItf;
-
-typedef void (XAAPIENTRY * xaStreamEventChangeCallback) (
- XAStreamInformationItf caller,
- XAuint32 eventId,
- XAuint32 streamIndex,
- void * pEventData,
- void * pContext
-);
-
-struct XAStreamInformationItf_ {
- XAresult (*QueryMediaContainerInformation) (
- XAStreamInformationItf self,
- XAMediaContainerInformation * info
- );
- XAresult (*QueryStreamType) (
- XAStreamInformationItf self,
- XAuint32 streamIndex,
- XAuint32 *domain
- );
- XAresult (*QueryStreamInformation) (
- XAStreamInformationItf self,
- XAuint32 streamIndex,
- void * info
- );
- XAresult (*QueryStreamName) (
- XAStreamInformationItf self,
- XAuint32 streamIndex,
- XAuint16 * pNameSize,
- XAchar * pName
- );
- XAresult (*RegisterStreamChangeCallback) (
- XAStreamInformationItf self,
- xaStreamEventChangeCallback callback,
- void * pContext
- );
- XAresult (*QueryActiveStreams) (
- XAStreamInformationItf self,
- XAuint32 *numStreams,
- XAboolean *activeStreams
- );
- XAresult (*SetActiveStream) (
- XAStreamInformationItf self,
- XAuint32 streamNum,
- XAboolean active,
- XAboolean commitNow
- );
-};
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* _OPENMAXAL_H_ */
diff --git a/wilhelm/include/OMXAL/OpenMAXAL_Android.h b/wilhelm/include/OMXAL/OpenMAXAL_Android.h
deleted file mode 100644
index 34b9dd9..0000000
--- a/wilhelm/include/OMXAL/OpenMAXAL_Android.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef OPENMAX_AL_ANDROID_H_
-#define OPENMAX_AL_ANDROID_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*---------------------------------------------------------------------------*/
-/* Android common types */
-/*---------------------------------------------------------------------------*/
-
-typedef xa_int64_t XAAint64; /* 64 bit signed integer */
-
-typedef xa_uint64_t XAAuint64; /* 64 bit unsigned integer */
-
-/*---------------------------------------------------------------------------*/
-/* Android common types */
-/*---------------------------------------------------------------------------*/
-
-#define XA_ANDROID_VIDEOCODEC_VP8 ((XAuint32) 0x00000006)
-
-#define XA_ANDROID_VIDEOPROFILE_VP8_MAIN ((XAuint32) 0x00000001)
-
-#define XA_ANDROID_VIDEOLEVEL_VP8_VERSION0 ((XAuint32) 0x00000001)
-#define XA_ANDROID_VIDEOLEVEL_VP8_VERSION1 ((XAuint32) 0x00000002)
-#define XA_ANDROID_VIDEOLEVEL_VP8_VERSION2 ((XAuint32) 0x00000003)
-#define XA_ANDROID_VIDEOLEVEL_VP8_VERSION3 ((XAuint32) 0x00000004)
-
-/*---------------------------------------------------------------------------*/
-/* Android Buffer Queue Interface */
-/*---------------------------------------------------------------------------*/
-
-extern XA_API const XAInterfaceID XA_IID_ANDROIDBUFFERQUEUESOURCE;
-
-struct XAAndroidBufferQueueItf_;
-typedef const struct XAAndroidBufferQueueItf_ * const * XAAndroidBufferQueueItf;
-
-#define XA_ANDROID_ITEMKEY_NONE ((XAuint32) 0x00000000)
-#define XA_ANDROID_ITEMKEY_EOS ((XAuint32) 0x00000001)
-#define XA_ANDROID_ITEMKEY_DISCONTINUITY ((XAuint32) 0x00000002)
-#define XA_ANDROID_ITEMKEY_BUFFERQUEUEEVENT ((XAuint32) 0x00000003)
-#define XA_ANDROID_ITEMKEY_FORMAT_CHANGE ((XAuint32) 0x00000004)
-
-// optional data for XA_ANDROID_ITEMKEY_FORMAT_CHANGE, used when only one stream changes format,
-// and the others remain continuous (i.e. no temporal discontinuity is introduced for them)
-// candidate for being exposed in NDK
-#define XA_ANDROID_FORMATCHANGE_ITEMDATA_VIDEO ((XAuint32) 0x00000001)
-// not supported at this stage, for illustration purposes only
-//#define XA_ANDROID_FORMATCHANGE_ITEMDATA_AUDIO ((XAuint32) 0x00000002)
-
-#define XA_ANDROIDBUFFERQUEUEEVENT_NONE ((XAuint32) 0x00000000)
-#define XA_ANDROIDBUFFERQUEUEEVENT_PROCESSED ((XAuint32) 0x00000001)
-#if 0 // reserved for future use
-#define XA_ANDROIDBUFFERQUEUEEVENT_UNREALIZED ((XAuint32) 0x00000002)
-#define XA_ANDROIDBUFFERQUEUEEVENT_CLEARED ((XAuint32) 0x00000004)
-#define XA_ANDROIDBUFFERQUEUEEVENT_STOPPED ((XAuint32) 0x00000008)
-#define XA_ANDROIDBUFFERQUEUEEVENT_ERROR ((XAuint32) 0x00000010)
-#define XA_ANDROIDBUFFERQUEUEEVENT_CONTENT_END ((XAuint32) 0x00000020)
-#endif
-
-typedef struct XAAndroidBufferItem_ {
- XAuint32 itemKey; // identifies the item
- XAuint32 itemSize;
- XAuint8 itemData[0];
-} XAAndroidBufferItem;
-
-typedef XAresult (XAAPIENTRY *xaAndroidBufferQueueCallback)(
- XAAndroidBufferQueueItf caller,/* input */
- void *pCallbackContext, /* input */
- void *pBufferContext, /* input */
- void *pBufferData, /* input */
- XAuint32 dataSize, /* input */
- XAuint32 dataUsed, /* input */
- const XAAndroidBufferItem *pItems,/* input */
- XAuint32 itemsLength /* input */
-);
-
-typedef struct XAAndroidBufferQueueState_ {
- XAuint32 count;
- XAuint32 index;
-} XAAndroidBufferQueueState;
-
-struct XAAndroidBufferQueueItf_ {
- XAresult (*RegisterCallback) (
- XAAndroidBufferQueueItf self,
- xaAndroidBufferQueueCallback callback,
- void* pCallbackContext
- );
-
- XAresult (*Clear) (
- XAAndroidBufferQueueItf self
- );
-
- XAresult (*Enqueue) (
- XAAndroidBufferQueueItf self,
- void *pBufferContext,
- void *pData,
- XAuint32 dataLength,
- const XAAndroidBufferItem *pItems,
- XAuint32 itemsLength
- );
-
- XAresult (*GetState) (
- XAAndroidBufferQueueItf self,
- XAAndroidBufferQueueState *pState
- );
-
-
- XAresult (*SetCallbackEventsMask) (
- XAAndroidBufferQueueItf self,
- XAuint32 eventFlags
- );
-
- XAresult (*GetCallbackEventsMask) (
- XAAndroidBufferQueueItf self,
- XAuint32 *pEventFlags
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Buffer Queue Data Locator */
-/*---------------------------------------------------------------------------*/
-
-/** Addendum to Data locator macros */
-#define XA_DATALOCATOR_ANDROIDBUFFERQUEUE ((XAuint32) 0x800007BE)
-
-/** Android Buffer Queue-based data locator definition,
- * locatorType must be XA_DATALOCATOR_ANDROIDBUFFERQUEUE */
-typedef struct XADataLocator_AndroidBufferQueue_ {
- XAuint32 locatorType;
- XAuint32 numBuffers;
-} XADataLocator_AndroidBufferQueue;
-
-
-/*---------------------------------------------------------------------------*/
-/* Android File Descriptor Data Locator */
-/*---------------------------------------------------------------------------*/
-
-/** Addendum to Data locator macros */
-#define XA_DATALOCATOR_ANDROIDFD ((XAuint32) 0x800007BC)
-
-#define XA_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((XAAint64) 0xFFFFFFFFFFFFFFFFll)
-
-/** File Descriptor-based data locator definition, locatorType must be XA_DATALOCATOR_ANDROIDFD */
-typedef struct XADataLocator_AndroidFD_ {
- XAuint32 locatorType;
- XAint32 fd;
- XAAint64 offset;
- XAAint64 length;
-} XADataLocator_AndroidFD;
-
-/**
- * MIME types required for data in Android Buffer Queues
- */
-#define XA_ANDROID_MIME_MP2TS ((XAchar *) "video/mp2ts")
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* OPENMAX_AL_ANDROID_H_ */
diff --git a/wilhelm/include/OMXAL/OpenMAXAL_Platform.h b/wilhelm/include/OMXAL/OpenMAXAL_Platform.h
deleted file mode 100644
index 23be77e..0000000
--- a/wilhelm/include/OMXAL/OpenMAXAL_Platform.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2007-2010 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and/or associated documentation files (the
- * "Materials "), to deal in the Materials without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Materials, and to
- * permit persons to whom the Materials are furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
- *
- * OpenMAXAL_Platform.h - OpenMAX AL version 1.0.1
- *
- */
-
-/****************************************************************************/
-/* NOTE: This file contains definitions for the base types and the */
-/* XAAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */
-/* the correct definitions specific to the platform being used. */
-/****************************************************************************/
-
-#ifndef _OPENMAXAL_PLATFORM_H_
-#define _OPENMAXAL_PLATFORM_H_
-
-typedef unsigned char xa_uint8_t;
-typedef signed char xa_int8_t;
-typedef unsigned short xa_uint16_t;
-typedef signed short xa_int16_t;
-typedef unsigned int /*long*/ xa_uint32_t;
-typedef signed int /*long*/ xa_int32_t;
-typedef long long xa_int64_t;
-typedef unsigned long long xa_uint64_t;
-
-#ifndef XAAPIENTRY
-#define XAAPIENTRY /* override per-platform */
-#endif
-
-/** The XA_API is a platform-specific macro used
- * to declare OPENMAX AL function prototypes. It is modified to meet the
- * requirements for a particular platform
- *
- * Example:
- * #ifdef __SYMBIAN32__
- * # define XA_API __declspec(dllimport)
- * #endif
- */
-
-#ifndef XA_API
-#ifdef __GNUC__
-#define XA_API
-#else
-#define XA_API __declspec(dllimport)
-#endif
-#endif
-
-#endif /* _OPENMAXAL_PLATFORM_H_ */
diff --git a/wilhelm/include/SLES/OpenSLES.h b/wilhelm/include/SLES/OpenSLES.h
deleted file mode 100644
index 8686997..0000000
--- a/wilhelm/include/SLES/OpenSLES.h
+++ /dev/null
@@ -1,2774 +0,0 @@
-/*
- * Copyright (c) 2007-2009 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and /or associated documentation files (the "Materials "), to
- * deal in the Materials without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Materials, and to permit persons to whom the Materials are
- * furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE
- * MATERIALS.
- *
- * OpenSLES.h - OpenSL ES version 1.0.1
- *
- */
-
-/****************************************************************************/
-/* NOTE: This file is a standard OpenSL ES header file and should not be */
-/* modified in any way. */
-/****************************************************************************/
-
-#ifndef OPENSL_ES_H_
-#define OPENSL_ES_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "OpenSLES_Platform.h"
-
-
-/*****************************************************************************/
-/* Common types, structures, and defines */
-/*****************************************************************************/
-
-#ifndef _KHRONOS_KEYS_
-#define _KHRONOS_KEYS_
-
-#define KHRONOS_TITLE "KhronosTitle"
-#define KHRONOS_ALBUM "KhronosAlbum"
-#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber"
-#define KHRONOS_ARTIST "KhronosArtist"
-#define KHRONOS_GENRE "KhronosGenre"
-#define KHRONOS_YEAR "KhronosYear"
-#define KHRONOS_COMMENT "KhronosComment"
-#define KHRONOS_ARTIST_URL "KhronosArtistURL"
-#define KHRONOS_CONTENT_URL "KhronosContentURL"
-#define KHRONOS_RATING "KhronosRating"
-#define KHRONOS_ALBUM_ART "KhronosAlbumArt"
-#define KHRONOS_COPYRIGHT "KhronosCopyright"
-
-#endif
-
-
-/* remap common types to SL types for clarity */
-typedef sl_int8_t SLint8; /* 8 bit signed integer */
-typedef sl_uint8_t SLuint8; /* 8 bit unsigned integer */
-typedef sl_int16_t SLint16; /* 16 bit signed integer */
-typedef sl_uint16_t SLuint16; /* 16 bit unsigned integer */
-typedef sl_int32_t SLint32; /* 32 bit signed integer */
-typedef sl_uint32_t SLuint32; /* 32 bit unsigned integer */
-
-typedef SLuint32 SLboolean;
-#define SL_BOOLEAN_FALSE ((SLboolean) 0x00000000)
-#define SL_BOOLEAN_TRUE ((SLboolean) 0x00000001)
-
-typedef SLuint8 SLchar; /* UTF-8 is to be used */
-typedef SLint16 SLmillibel;
-typedef SLuint32 SLmillisecond;
-typedef SLuint32 SLmilliHertz;
-typedef SLint32 SLmillimeter;
-typedef SLint32 SLmillidegree;
-typedef SLint16 SLpermille;
-typedef SLuint32 SLmicrosecond;
-typedef SLuint32 SLresult;
-
-#define SL_MILLIBEL_MAX ((SLmillibel) 0x7FFF)
-#define SL_MILLIBEL_MIN ((SLmillibel) (-SL_MILLIBEL_MAX-1))
-
-#define SL_MILLIHERTZ_MAX ((SLmilliHertz) 0xFFFFFFFF)
-#define SL_MILLIMETER_MAX ((SLmillimeter) 0x7FFFFFFF)
-
-/** Interface ID defined as a UUID */
-typedef const struct SLInterfaceID_ {
- SLuint32 time_low;
- SLuint16 time_mid;
- SLuint16 time_hi_and_version;
- SLuint16 clock_seq;
- SLuint8 node[6];
-} * SLInterfaceID;
-
-/* Forward declaration for the object interface */
-struct SLObjectItf_;
-
-typedef const struct SLObjectItf_ * const * SLObjectItf;
-
-/* Objects ID's */
-
-#define SL_OBJECTID_ENGINE ((SLuint32) 0x00001001)
-#define SL_OBJECTID_LEDDEVICE ((SLuint32) 0x00001002)
-#define SL_OBJECTID_VIBRADEVICE ((SLuint32) 0x00001003)
-#define SL_OBJECTID_AUDIOPLAYER ((SLuint32) 0x00001004)
-#define SL_OBJECTID_AUDIORECORDER ((SLuint32) 0x00001005)
-#define SL_OBJECTID_MIDIPLAYER ((SLuint32) 0x00001006)
-#define SL_OBJECTID_LISTENER ((SLuint32) 0x00001007)
-#define SL_OBJECTID_3DGROUP ((SLuint32) 0x00001008)
-#define SL_OBJECTID_OUTPUTMIX ((SLuint32) 0x00001009)
-#define SL_OBJECTID_METADATAEXTRACTOR ((SLuint32) 0x0000100A)
-
-
-/* SL Profiles */
-
-#define SL_PROFILES_PHONE ((SLuint16) 0x0001)
-#define SL_PROFILES_MUSIC ((SLuint16) 0x0002)
-#define SL_PROFILES_GAME ((SLuint16) 0x0004)
-
-/* Types of voices supported by the system */
-
-#define SL_VOICETYPE_2D_AUDIO ((SLuint16) 0x0001)
-#define SL_VOICETYPE_MIDI ((SLuint16) 0x0002)
-#define SL_VOICETYPE_3D_AUDIO ((SLuint16) 0x0004)
-#define SL_VOICETYPE_3D_MIDIOUTPUT ((SLuint16) 0x0008)
-
-/* Convenient macros representing various different priority levels, for use with the SetPriority method */
-
-#define SL_PRIORITY_LOWEST ((SLint32) (-0x7FFFFFFF-1))
-#define SL_PRIORITY_VERYLOW ((SLint32) -0x60000000)
-#define SL_PRIORITY_LOW ((SLint32) -0x40000000)
-#define SL_PRIORITY_BELOWNORMAL ((SLint32) -0x20000000)
-#define SL_PRIORITY_NORMAL ((SLint32) 0x00000000)
-#define SL_PRIORITY_ABOVENORMAL ((SLint32) 0x20000000)
-#define SL_PRIORITY_HIGH ((SLint32) 0x40000000)
-#define SL_PRIORITY_VERYHIGH ((SLint32) 0x60000000)
-#define SL_PRIORITY_HIGHEST ((SLint32) 0x7FFFFFFF)
-
-
-/** These macros list the various sample formats that are possible on audio input and output devices. */
-
-#define SL_PCMSAMPLEFORMAT_FIXED_8 ((SLuint16) 0x0008)
-#define SL_PCMSAMPLEFORMAT_FIXED_16 ((SLuint16) 0x0010)
-#define SL_PCMSAMPLEFORMAT_FIXED_20 ((SLuint16) 0x0014)
-#define SL_PCMSAMPLEFORMAT_FIXED_24 ((SLuint16) 0x0018)
-#define SL_PCMSAMPLEFORMAT_FIXED_28 ((SLuint16) 0x001C)
-#define SL_PCMSAMPLEFORMAT_FIXED_32 ((SLuint16) 0x0020)
-
-
-/** These macros specify the commonly used sampling rates (in milliHertz) supported by most audio I/O devices. */
-
-#define SL_SAMPLINGRATE_8 ((SLuint32) 8000000)
-#define SL_SAMPLINGRATE_11_025 ((SLuint32) 11025000)
-#define SL_SAMPLINGRATE_12 ((SLuint32) 12000000)
-#define SL_SAMPLINGRATE_16 ((SLuint32) 16000000)
-#define SL_SAMPLINGRATE_22_05 ((SLuint32) 22050000)
-#define SL_SAMPLINGRATE_24 ((SLuint32) 24000000)
-#define SL_SAMPLINGRATE_32 ((SLuint32) 32000000)
-#define SL_SAMPLINGRATE_44_1 ((SLuint32) 44100000)
-#define SL_SAMPLINGRATE_48 ((SLuint32) 48000000)
-#define SL_SAMPLINGRATE_64 ((SLuint32) 64000000)
-#define SL_SAMPLINGRATE_88_2 ((SLuint32) 88200000)
-#define SL_SAMPLINGRATE_96 ((SLuint32) 96000000)
-#define SL_SAMPLINGRATE_192 ((SLuint32) 192000000)
-
-#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001)
-#define SL_SPEAKER_FRONT_RIGHT ((SLuint32) 0x00000002)
-#define SL_SPEAKER_FRONT_CENTER ((SLuint32) 0x00000004)
-#define SL_SPEAKER_LOW_FREQUENCY ((SLuint32) 0x00000008)
-#define SL_SPEAKER_BACK_LEFT ((SLuint32) 0x00000010)
-#define SL_SPEAKER_BACK_RIGHT ((SLuint32) 0x00000020)
-#define SL_SPEAKER_FRONT_LEFT_OF_CENTER ((SLuint32) 0x00000040)
-#define SL_SPEAKER_FRONT_RIGHT_OF_CENTER ((SLuint32) 0x00000080)
-#define SL_SPEAKER_BACK_CENTER ((SLuint32) 0x00000100)
-#define SL_SPEAKER_SIDE_LEFT ((SLuint32) 0x00000200)
-#define SL_SPEAKER_SIDE_RIGHT ((SLuint32) 0x00000400)
-#define SL_SPEAKER_TOP_CENTER ((SLuint32) 0x00000800)
-#define SL_SPEAKER_TOP_FRONT_LEFT ((SLuint32) 0x00001000)
-#define SL_SPEAKER_TOP_FRONT_CENTER ((SLuint32) 0x00002000)
-#define SL_SPEAKER_TOP_FRONT_RIGHT ((SLuint32) 0x00004000)
-#define SL_SPEAKER_TOP_BACK_LEFT ((SLuint32) 0x00008000)
-#define SL_SPEAKER_TOP_BACK_CENTER ((SLuint32) 0x00010000)
-#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000)
-
-
-/*****************************************************************************/
-/* Errors */
-/* */
-/*****************************************************************************/
-
-#define SL_RESULT_SUCCESS ((SLuint32) 0x00000000)
-#define SL_RESULT_PRECONDITIONS_VIOLATED ((SLuint32) 0x00000001)
-#define SL_RESULT_PARAMETER_INVALID ((SLuint32) 0x00000002)
-#define SL_RESULT_MEMORY_FAILURE ((SLuint32) 0x00000003)
-#define SL_RESULT_RESOURCE_ERROR ((SLuint32) 0x00000004)
-#define SL_RESULT_RESOURCE_LOST ((SLuint32) 0x00000005)
-#define SL_RESULT_IO_ERROR ((SLuint32) 0x00000006)
-#define SL_RESULT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000007)
-#define SL_RESULT_CONTENT_CORRUPTED ((SLuint32) 0x00000008)
-#define SL_RESULT_CONTENT_UNSUPPORTED ((SLuint32) 0x00000009)
-#define SL_RESULT_CONTENT_NOT_FOUND ((SLuint32) 0x0000000A)
-#define SL_RESULT_PERMISSION_DENIED ((SLuint32) 0x0000000B)
-#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C)
-#define SL_RESULT_INTERNAL_ERROR ((SLuint32) 0x0000000D)
-#define SL_RESULT_UNKNOWN_ERROR ((SLuint32) 0x0000000E)
-#define SL_RESULT_OPERATION_ABORTED ((SLuint32) 0x0000000F)
-#define SL_RESULT_CONTROL_LOST ((SLuint32) 0x00000010)
-
-
-/* Object state definitions */
-
-#define SL_OBJECT_STATE_UNREALIZED ((SLuint32) 0x00000001)
-#define SL_OBJECT_STATE_REALIZED ((SLuint32) 0x00000002)
-#define SL_OBJECT_STATE_SUSPENDED ((SLuint32) 0x00000003)
-
-/* Object event definitions */
-
-#define SL_OBJECT_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001)
-#define SL_OBJECT_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002)
-#define SL_OBJECT_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003)
-#define SL_OBJECT_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000004)
-#define SL_OBJECT_EVENT_ITF_CONTROL_TAKEN ((SLuint32) 0x00000005)
-#define SL_OBJECT_EVENT_ITF_CONTROL_RETURNED ((SLuint32) 0x00000006)
-#define SL_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((SLuint32) 0x00000007)
-
-
-/*****************************************************************************/
-/* Interface definitions */
-/*****************************************************************************/
-
-/** NULL Interface */
-
-extern SL_API const SLInterfaceID SL_IID_NULL;
-
-/*---------------------------------------------------------------------------*/
-/* Data Source and Data Sink Structures */
-/*---------------------------------------------------------------------------*/
-
-/** Data locator macros */
-#define SL_DATALOCATOR_URI ((SLuint32) 0x00000001)
-#define SL_DATALOCATOR_ADDRESS ((SLuint32) 0x00000002)
-#define SL_DATALOCATOR_IODEVICE ((SLuint32) 0x00000003)
-#define SL_DATALOCATOR_OUTPUTMIX ((SLuint32) 0x00000004)
-#define SL_DATALOCATOR_RESERVED5 ((SLuint32) 0x00000005)
-#define SL_DATALOCATOR_BUFFERQUEUE ((SLuint32) 0x00000006)
-#define SL_DATALOCATOR_MIDIBUFFERQUEUE ((SLuint32) 0x00000007)
-#define SL_DATALOCATOR_RESERVED8 ((SLuint32) 0x00000008)
-
-
-
-/** URI-based data locator definition where locatorType must be SL_DATALOCATOR_URI*/
-typedef struct SLDataLocator_URI_ {
- SLuint32 locatorType;
- SLchar * URI;
-} SLDataLocator_URI;
-
-/** Address-based data locator definition where locatorType must be SL_DATALOCATOR_ADDRESS*/
-typedef struct SLDataLocator_Address_ {
- SLuint32 locatorType;
- void *pAddress;
- SLuint32 length;
-} SLDataLocator_Address;
-
-/** IODevice-types */
-#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001)
-#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002)
-#define SL_IODEVICE_VIBRA ((SLuint32) 0x00000003)
-#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004)
-#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005)
-
-/** IODevice-based data locator definition where locatorType must be SL_DATALOCATOR_IODEVICE*/
-typedef struct SLDataLocator_IODevice_ {
- SLuint32 locatorType;
- SLuint32 deviceType;
- SLuint32 deviceID;
- SLObjectItf device;
-} SLDataLocator_IODevice;
-
-/** OutputMix-based data locator definition where locatorType must be SL_DATALOCATOR_OUTPUTMIX*/
-typedef struct SLDataLocator_OutputMix {
- SLuint32 locatorType;
- SLObjectItf outputMix;
-} SLDataLocator_OutputMix;
-
-
-/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_BUFFERQUEUE*/
-typedef struct SLDataLocator_BufferQueue {
- SLuint32 locatorType;
- SLuint32 numBuffers;
-} SLDataLocator_BufferQueue;
-
-/** MidiBufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_MIDIBUFFERQUEUE*/
-typedef struct SLDataLocator_MIDIBufferQueue {
- SLuint32 locatorType;
- SLuint32 tpqn;
- SLuint32 numBuffers;
-} SLDataLocator_MIDIBufferQueue;
-
-/** Data format defines */
-#define SL_DATAFORMAT_MIME ((SLuint32) 0x00000001)
-#define SL_DATAFORMAT_PCM ((SLuint32) 0x00000002)
-#define SL_DATAFORMAT_RESERVED3 ((SLuint32) 0x00000003)
-
-
-/** MIME-type-based data format definition where formatType must be SL_DATAFORMAT_MIME*/
-typedef struct SLDataFormat_MIME_ {
- SLuint32 formatType;
- SLchar * mimeType;
- SLuint32 containerType;
-} SLDataFormat_MIME;
-
-/* Byte order of a block of 16- or 32-bit data */
-#define SL_BYTEORDER_BIGENDIAN ((SLuint32) 0x00000001)
-#define SL_BYTEORDER_LITTLEENDIAN ((SLuint32) 0x00000002)
-
-/* Container type */
-#define SL_CONTAINERTYPE_UNSPECIFIED ((SLuint32) 0x00000001)
-#define SL_CONTAINERTYPE_RAW ((SLuint32) 0x00000002)
-#define SL_CONTAINERTYPE_ASF ((SLuint32) 0x00000003)
-#define SL_CONTAINERTYPE_AVI ((SLuint32) 0x00000004)
-#define SL_CONTAINERTYPE_BMP ((SLuint32) 0x00000005)
-#define SL_CONTAINERTYPE_JPG ((SLuint32) 0x00000006)
-#define SL_CONTAINERTYPE_JPG2000 ((SLuint32) 0x00000007)
-#define SL_CONTAINERTYPE_M4A ((SLuint32) 0x00000008)
-#define SL_CONTAINERTYPE_MP3 ((SLuint32) 0x00000009)
-#define SL_CONTAINERTYPE_MP4 ((SLuint32) 0x0000000A)
-#define SL_CONTAINERTYPE_MPEG_ES ((SLuint32) 0x0000000B)
-#define SL_CONTAINERTYPE_MPEG_PS ((SLuint32) 0x0000000C)
-#define SL_CONTAINERTYPE_MPEG_TS ((SLuint32) 0x0000000D)
-#define SL_CONTAINERTYPE_QT ((SLuint32) 0x0000000E)
-#define SL_CONTAINERTYPE_WAV ((SLuint32) 0x0000000F)
-#define SL_CONTAINERTYPE_XMF_0 ((SLuint32) 0x00000010)
-#define SL_CONTAINERTYPE_XMF_1 ((SLuint32) 0x00000011)
-#define SL_CONTAINERTYPE_XMF_2 ((SLuint32) 0x00000012)
-#define SL_CONTAINERTYPE_XMF_3 ((SLuint32) 0x00000013)
-#define SL_CONTAINERTYPE_XMF_GENERIC ((SLuint32) 0x00000014)
-#define SL_CONTAINERTYPE_AMR ((SLuint32) 0x00000015)
-#define SL_CONTAINERTYPE_AAC ((SLuint32) 0x00000016)
-#define SL_CONTAINERTYPE_3GPP ((SLuint32) 0x00000017)
-#define SL_CONTAINERTYPE_3GA ((SLuint32) 0x00000018)
-#define SL_CONTAINERTYPE_RM ((SLuint32) 0x00000019)
-#define SL_CONTAINERTYPE_DMF ((SLuint32) 0x0000001A)
-#define SL_CONTAINERTYPE_SMF ((SLuint32) 0x0000001B)
-#define SL_CONTAINERTYPE_MOBILE_DLS ((SLuint32) 0x0000001C)
-#define SL_CONTAINERTYPE_OGG ((SLuint32) 0x0000001D)
-
-
-/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM*/
-typedef struct SLDataFormat_PCM_ {
- SLuint32 formatType;
- SLuint32 numChannels;
- SLuint32 samplesPerSec;
- SLuint32 bitsPerSample;
- SLuint32 containerSize;
- SLuint32 channelMask;
- SLuint32 endianness;
-} SLDataFormat_PCM;
-
-typedef struct SLDataSource_ {
- void *pLocator;
- void *pFormat;
-} SLDataSource;
-
-
-typedef struct SLDataSink_ {
- void *pLocator;
- void *pFormat;
-} SLDataSink;
-
-
-
-
-
-
-/*---------------------------------------------------------------------------*/
-/* Standard Object Interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_OBJECT;
-
-/** Object callback */
-
-
-typedef void (SLAPIENTRY *slObjectCallback) (
- SLObjectItf caller,
- const void * pContext,
- SLuint32 event,
- SLresult result,
- SLuint32 param,
- void *pInterface
-);
-
-
-struct SLObjectItf_ {
- SLresult (*Realize) (
- SLObjectItf self,
- SLboolean async
- );
- SLresult (*Resume) (
- SLObjectItf self,
- SLboolean async
- );
- SLresult (*GetState) (
- SLObjectItf self,
- SLuint32 * pState
- );
- SLresult (*GetInterface) (
- SLObjectItf self,
- const SLInterfaceID iid,
- void * pInterface
- );
- SLresult (*RegisterCallback) (
- SLObjectItf self,
- slObjectCallback callback,
- void * pContext
- );
- void (*AbortAsyncOperation) (
- SLObjectItf self
- );
- void (*Destroy) (
- SLObjectItf self
- );
- SLresult (*SetPriority) (
- SLObjectItf self,
- SLint32 priority,
- SLboolean preemptable
- );
- SLresult (*GetPriority) (
- SLObjectItf self,
- SLint32 *pPriority,
- SLboolean *pPreemptable
- );
- SLresult (*SetLossOfControlInterfaces) (
- SLObjectItf self,
- SLint16 numInterfaces,
- SLInterfaceID * pInterfaceIDs,
- SLboolean enabled
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Audio IO Device capabilities interface */
-/*---------------------------------------------------------------------------*/
-
-#define SL_DEFAULTDEVICEID_AUDIOINPUT ((SLuint32) 0xFFFFFFFF)
-#define SL_DEFAULTDEVICEID_AUDIOOUTPUT ((SLuint32) 0xFFFFFFFE)
-#define SL_DEFAULTDEVICEID_LED ((SLuint32) 0xFFFFFFFD)
-#define SL_DEFAULTDEVICEID_VIBRA ((SLuint32) 0xFFFFFFFC)
-#define SL_DEFAULTDEVICEID_RESERVED1 ((SLuint32) 0xFFFFFFFB)
-
-
-#define SL_DEVCONNECTION_INTEGRATED ((SLint16) 0x0001)
-#define SL_DEVCONNECTION_ATTACHED_WIRED ((SLint16) 0x0100)
-#define SL_DEVCONNECTION_ATTACHED_WIRELESS ((SLint16) 0x0200)
-#define SL_DEVCONNECTION_NETWORK ((SLint16) 0x0400)
-
-
-#define SL_DEVLOCATION_HANDSET ((SLuint16) 0x0001)
-#define SL_DEVLOCATION_HEADSET ((SLuint16) 0x0002)
-#define SL_DEVLOCATION_CARKIT ((SLuint16) 0x0003)
-#define SL_DEVLOCATION_DOCK ((SLuint16) 0x0004)
-#define SL_DEVLOCATION_REMOTE ((SLuint16) 0x0005)
-/* Note: SL_DEVLOCATION_RESLTE is deprecated, use SL_DEVLOCATION_REMOTE instead. */
-#define SL_DEVLOCATION_RESLTE ((SLuint16) 0x0005)
-
-
-#define SL_DEVSCOPE_UNKNOWN ((SLuint16) 0x0001)
-#define SL_DEVSCOPE_ENVIRONMENT ((SLuint16) 0x0002)
-#define SL_DEVSCOPE_USER ((SLuint16) 0x0003)
-
-
-typedef struct SLAudioInputDescriptor_ {
- SLchar *deviceName;
- SLint16 deviceConnection;
- SLint16 deviceScope;
- SLint16 deviceLocation;
- SLboolean isForTelephony;
- SLmilliHertz minSampleRate;
- SLmilliHertz maxSampleRate;
- SLboolean isFreqRangeContinuous;
- SLmilliHertz *samplingRatesSupported;
- SLint16 numOfSamplingRatesSupported;
- SLint16 maxChannels;
-} SLAudioInputDescriptor;
-
-
-typedef struct SLAudioOutputDescriptor_ {
- SLchar *pDeviceName;
- SLint16 deviceConnection;
- SLint16 deviceScope;
- SLint16 deviceLocation;
- SLboolean isForTelephony;
- SLmilliHertz minSampleRate;
- SLmilliHertz maxSampleRate;
- SLboolean isFreqRangeContinuous;
- SLmilliHertz *samplingRatesSupported;
- SLint16 numOfSamplingRatesSupported;
- SLint16 maxChannels;
-} SLAudioOutputDescriptor;
-
-
-
-extern SL_API const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES;
-
-struct SLAudioIODeviceCapabilitiesItf_;
-typedef const struct SLAudioIODeviceCapabilitiesItf_ * const * SLAudioIODeviceCapabilitiesItf;
-
-
-typedef void (SLAPIENTRY *slAvailableAudioInputsChangedCallback) (
- SLAudioIODeviceCapabilitiesItf caller,
- void *pContext,
- SLuint32 deviceID,
- SLint32 numInputs,
- SLboolean isNew
-);
-
-
-typedef void (SLAPIENTRY *slAvailableAudioOutputsChangedCallback) (
- SLAudioIODeviceCapabilitiesItf caller,
- void *pContext,
- SLuint32 deviceID,
- SLint32 numOutputs,
- SLboolean isNew
-);
-
-typedef void (SLAPIENTRY *slDefaultDeviceIDMapChangedCallback) (
- SLAudioIODeviceCapabilitiesItf caller,
- void *pContext,
- SLboolean isOutput,
- SLint32 numDevices
-);
-
-
-struct SLAudioIODeviceCapabilitiesItf_ {
- SLresult (*GetAvailableAudioInputs)(
- SLAudioIODeviceCapabilitiesItf self,
- SLint32 *pNumInputs,
- SLuint32 *pInputDeviceIDs
- );
- SLresult (*QueryAudioInputCapabilities)(
- SLAudioIODeviceCapabilitiesItf self,
- SLuint32 deviceId,
- SLAudioInputDescriptor *pDescriptor
- );
- SLresult (*RegisterAvailableAudioInputsChangedCallback) (
- SLAudioIODeviceCapabilitiesItf self,
- slAvailableAudioInputsChangedCallback callback,
- void *pContext
- );
- SLresult (*GetAvailableAudioOutputs)(
- SLAudioIODeviceCapabilitiesItf self,
- SLint32 *pNumOutputs,
- SLuint32 *pOutputDeviceIDs
- );
- SLresult (*QueryAudioOutputCapabilities)(
- SLAudioIODeviceCapabilitiesItf self,
- SLuint32 deviceId,
- SLAudioOutputDescriptor *pDescriptor
- );
- SLresult (*RegisterAvailableAudioOutputsChangedCallback) (
- SLAudioIODeviceCapabilitiesItf self,
- slAvailableAudioOutputsChangedCallback callback,
- void *pContext
- );
- SLresult (*RegisterDefaultDeviceIDMapChangedCallback) (
- SLAudioIODeviceCapabilitiesItf self,
- slDefaultDeviceIDMapChangedCallback callback,
- void *pContext
- );
- SLresult (*GetAssociatedAudioInputs) (
- SLAudioIODeviceCapabilitiesItf self,
- SLuint32 deviceId,
- SLint32 *pNumAudioInputs,
- SLuint32 *pAudioInputDeviceIDs
- );
- SLresult (*GetAssociatedAudioOutputs) (
- SLAudioIODeviceCapabilitiesItf self,
- SLuint32 deviceId,
- SLint32 *pNumAudioOutputs,
- SLuint32 *pAudioOutputDeviceIDs
- );
- SLresult (*GetDefaultAudioDevices) (
- SLAudioIODeviceCapabilitiesItf self,
- SLuint32 defaultDeviceID,
- SLint32 *pNumAudioDevices,
- SLuint32 *pAudioDeviceIDs
- );
- SLresult (*QuerySampleFormatsSupported)(
- SLAudioIODeviceCapabilitiesItf self,
- SLuint32 deviceId,
- SLmilliHertz samplingRate,
- SLint32 *pSampleFormats,
- SLint32 *pNumOfSampleFormats
- );
-};
-
-
-
-/*---------------------------------------------------------------------------*/
-/* Capabilities of the LED array IODevice */
-/*---------------------------------------------------------------------------*/
-
-typedef struct SLLEDDescriptor_ {
- SLuint8 ledCount;
- SLuint8 primaryLED;
- SLuint32 colorMask;
-} SLLEDDescriptor;
-
-
-/*---------------------------------------------------------------------------*/
-/* LED Array interface */
-/*---------------------------------------------------------------------------*/
-
-typedef struct SLHSL_ {
- SLmillidegree hue;
- SLpermille saturation;
- SLpermille lightness;
-} SLHSL;
-
-
-extern SL_API const SLInterfaceID SL_IID_LED;
-
-struct SLLEDArrayItf_;
-typedef const struct SLLEDArrayItf_ * const * SLLEDArrayItf;
-
-struct SLLEDArrayItf_ {
- SLresult (*ActivateLEDArray) (
- SLLEDArrayItf self,
- SLuint32 lightMask
- );
- SLresult (*IsLEDArrayActivated) (
- SLLEDArrayItf self,
- SLuint32 *lightMask
- );
- SLresult (*SetColor) (
- SLLEDArrayItf self,
- SLuint8 index,
- const SLHSL *color
- );
- SLresult (*GetColor) (
- SLLEDArrayItf self,
- SLuint8 index,
- SLHSL *color
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Capabilities of the Vibra IODevice */
-/*---------------------------------------------------------------------------*/
-
-typedef struct SLVibraDescriptor_ {
- SLboolean supportsFrequency;
- SLboolean supportsIntensity;
- SLmilliHertz minFrequency;
- SLmilliHertz maxFrequency;
-} SLVibraDescriptor;
-
-
-
-/*---------------------------------------------------------------------------*/
-/* Vibra interface */
-/*---------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_VIBRA;
-
-
-struct SLVibraItf_;
-typedef const struct SLVibraItf_ * const * SLVibraItf;
-
-struct SLVibraItf_ {
- SLresult (*Vibrate) (
- SLVibraItf self,
- SLboolean vibrate
- );
- SLresult (*IsVibrating) (
- SLVibraItf self,
- SLboolean *pVibrating
- );
- SLresult (*SetFrequency) (
- SLVibraItf self,
- SLmilliHertz frequency
- );
- SLresult (*GetFrequency) (
- SLVibraItf self,
- SLmilliHertz *pFrequency
- );
- SLresult (*SetIntensity) (
- SLVibraItf self,
- SLpermille intensity
- );
- SLresult (*GetIntensity) (
- SLVibraItf self,
- SLpermille *pIntensity
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Meta data extraction related types and interface */
-/*---------------------------------------------------------------------------*/
-
-#define SL_CHARACTERENCODING_UNKNOWN ((SLuint32) 0x00000000)
-#define SL_CHARACTERENCODING_BINARY ((SLuint32) 0x00000001)
-#define SL_CHARACTERENCODING_ASCII ((SLuint32) 0x00000002)
-#define SL_CHARACTERENCODING_BIG5 ((SLuint32) 0x00000003)
-#define SL_CHARACTERENCODING_CODEPAGE1252 ((SLuint32) 0x00000004)
-#define SL_CHARACTERENCODING_GB2312 ((SLuint32) 0x00000005)
-#define SL_CHARACTERENCODING_HZGB2312 ((SLuint32) 0x00000006)
-#define SL_CHARACTERENCODING_GB12345 ((SLuint32) 0x00000007)
-#define SL_CHARACTERENCODING_GB18030 ((SLuint32) 0x00000008)
-#define SL_CHARACTERENCODING_GBK ((SLuint32) 0x00000009)
-#define SL_CHARACTERENCODING_IMAPUTF7 ((SLuint32) 0x0000000A)
-#define SL_CHARACTERENCODING_ISO2022JP ((SLuint32) 0x0000000B)
-#define SL_CHARACTERENCODING_ISO2022JP1 ((SLuint32) 0x0000000B)
-#define SL_CHARACTERENCODING_ISO88591 ((SLuint32) 0x0000000C)
-#define SL_CHARACTERENCODING_ISO885910 ((SLuint32) 0x0000000D)
-#define SL_CHARACTERENCODING_ISO885913 ((SLuint32) 0x0000000E)
-#define SL_CHARACTERENCODING_ISO885914 ((SLuint32) 0x0000000F)
-#define SL_CHARACTERENCODING_ISO885915 ((SLuint32) 0x00000010)
-#define SL_CHARACTERENCODING_ISO88592 ((SLuint32) 0x00000011)
-#define SL_CHARACTERENCODING_ISO88593 ((SLuint32) 0x00000012)
-#define SL_CHARACTERENCODING_ISO88594 ((SLuint32) 0x00000013)
-#define SL_CHARACTERENCODING_ISO88595 ((SLuint32) 0x00000014)
-#define SL_CHARACTERENCODING_ISO88596 ((SLuint32) 0x00000015)
-#define SL_CHARACTERENCODING_ISO88597 ((SLuint32) 0x00000016)
-#define SL_CHARACTERENCODING_ISO88598 ((SLuint32) 0x00000017)
-#define SL_CHARACTERENCODING_ISO88599 ((SLuint32) 0x00000018)
-#define SL_CHARACTERENCODING_ISOEUCJP ((SLuint32) 0x00000019)
-#define SL_CHARACTERENCODING_SHIFTJIS ((SLuint32) 0x0000001A)
-#define SL_CHARACTERENCODING_SMS7BIT ((SLuint32) 0x0000001B)
-#define SL_CHARACTERENCODING_UTF7 ((SLuint32) 0x0000001C)
-#define SL_CHARACTERENCODING_UTF8 ((SLuint32) 0x0000001D)
-#define SL_CHARACTERENCODING_JAVACONFORMANTUTF8 ((SLuint32) 0x0000001E)
-#define SL_CHARACTERENCODING_UTF16BE ((SLuint32) 0x0000001F)
-#define SL_CHARACTERENCODING_UTF16LE ((SLuint32) 0x00000020)
-
-
-#define SL_METADATA_FILTER_KEY ((SLuint8) 0x01)
-#define SL_METADATA_FILTER_LANG ((SLuint8) 0x02)
-#define SL_METADATA_FILTER_ENCODING ((SLuint8) 0x04)
-
-
-typedef struct SLMetadataInfo_ {
- SLuint32 size;
- SLuint32 encoding;
- SLchar langCountry[16];
- SLuint8 data[1];
-} SLMetadataInfo;
-
-extern SL_API const SLInterfaceID SL_IID_METADATAEXTRACTION;
-
-struct SLMetadataExtractionItf_;
-typedef const struct SLMetadataExtractionItf_ * const * SLMetadataExtractionItf;
-
-
-struct SLMetadataExtractionItf_ {
- SLresult (*GetItemCount) (
- SLMetadataExtractionItf self,
- SLuint32 *pItemCount
- );
- SLresult (*GetKeySize) (
- SLMetadataExtractionItf self,
- SLuint32 index,
- SLuint32 *pKeySize
- );
- SLresult (*GetKey) (
- SLMetadataExtractionItf self,
- SLuint32 index,
- SLuint32 keySize,
- SLMetadataInfo *pKey
- );
- SLresult (*GetValueSize) (
- SLMetadataExtractionItf self,
- SLuint32 index,
- SLuint32 *pValueSize
- );
- SLresult (*GetValue) (
- SLMetadataExtractionItf self,
- SLuint32 index,
- SLuint32 valueSize,
- SLMetadataInfo *pValue
- );
- SLresult (*AddKeyFilter) (
- SLMetadataExtractionItf self,
- SLuint32 keySize,
- const void *pKey,
- SLuint32 keyEncoding,
- const SLchar *pValueLangCountry,
- SLuint32 valueEncoding,
- SLuint8 filterMask
- );
- SLresult (*ClearKeyFilter) (
- SLMetadataExtractionItf self
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Meta data traversal related types and interface */
-/*---------------------------------------------------------------------------*/
-
-#define SL_METADATATRAVERSALMODE_ALL ((SLuint32) 0x00000001)
-#define SL_METADATATRAVERSALMODE_NODE ((SLuint32) 0x00000002)
-
-
-#define SL_NODETYPE_UNSPECIFIED ((SLuint32) 0x00000001)
-#define SL_NODETYPE_AUDIO ((SLuint32) 0x00000002)
-#define SL_NODETYPE_VIDEO ((SLuint32) 0x00000003)
-#define SL_NODETYPE_IMAGE ((SLuint32) 0x00000004)
-
-#define SL_NODE_PARENT 0xFFFFFFFF
-
-extern SL_API const SLInterfaceID SL_IID_METADATATRAVERSAL;
-
-struct SLMetadataTraversalItf_;
-typedef const struct SLMetadataTraversalItf_ * const * SLMetadataTraversalItf;
-
-struct SLMetadataTraversalItf_ {
- SLresult (*SetMode) (
- SLMetadataTraversalItf self,
- SLuint32 mode
- );
- SLresult (*GetChildCount) (
- SLMetadataTraversalItf self,
- SLuint32 *pCount
- );
- SLresult (*GetChildMIMETypeSize) (
- SLMetadataTraversalItf self,
- SLuint32 index,
- SLuint32 *pSize
- );
- SLresult (*GetChildInfo) (
- SLMetadataTraversalItf self,
- SLuint32 index,
- SLint32 *pNodeID,
- SLuint32 *pType,
- SLuint32 size,
- SLchar *pMimeType
- );
- SLresult (*SetActiveNode) (
- SLMetadataTraversalItf self,
- SLuint32 index
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Dynamic Source types and interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_DYNAMICSOURCE;
-
-struct SLDynamicSourceItf_;
-typedef const struct SLDynamicSourceItf_ * const * SLDynamicSourceItf;
-
-struct SLDynamicSourceItf_ {
- SLresult (*SetSource) (
- SLDynamicSourceItf self,
- SLDataSource *pDataSource
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Output Mix interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_OUTPUTMIX;
-
-struct SLOutputMixItf_;
-typedef const struct SLOutputMixItf_ * const * SLOutputMixItf;
-
-typedef void (SLAPIENTRY *slMixDeviceChangeCallback) (
- SLOutputMixItf caller,
- void *pContext
-);
-
-
-struct SLOutputMixItf_ {
- SLresult (*GetDestinationOutputDeviceIDs) (
- SLOutputMixItf self,
- SLint32 *pNumDevices,
- SLuint32 *pDeviceIDs
- );
- SLresult (*RegisterDeviceChangeCallback) (
- SLOutputMixItf self,
- slMixDeviceChangeCallback callback,
- void *pContext
- );
- SLresult (*ReRoute)(
- SLOutputMixItf self,
- SLint32 numOutputDevices,
- SLuint32 *pOutputDeviceIDs
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Playback interface */
-/*---------------------------------------------------------------------------*/
-
-/** Playback states */
-#define SL_PLAYSTATE_STOPPED ((SLuint32) 0x00000001)
-#define SL_PLAYSTATE_PAUSED ((SLuint32) 0x00000002)
-#define SL_PLAYSTATE_PLAYING ((SLuint32) 0x00000003)
-
-/** Play events **/
-#define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001)
-#define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002)
-#define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004)
-#define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008)
-#define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010)
-
-#define SL_TIME_UNKNOWN ((SLuint32) 0xFFFFFFFF)
-
-
-extern SL_API const SLInterfaceID SL_IID_PLAY;
-
-/** Playback interface methods */
-
-struct SLPlayItf_;
-typedef const struct SLPlayItf_ * const * SLPlayItf;
-
-typedef void (SLAPIENTRY *slPlayCallback) (
- SLPlayItf caller,
- void *pContext,
- SLuint32 event
-);
-
-struct SLPlayItf_ {
- SLresult (*SetPlayState) (
- SLPlayItf self,
- SLuint32 state
- );
- SLresult (*GetPlayState) (
- SLPlayItf self,
- SLuint32 *pState
- );
- SLresult (*GetDuration) (
- SLPlayItf self,
- SLmillisecond *pMsec
- );
- SLresult (*GetPosition) (
- SLPlayItf self,
- SLmillisecond *pMsec
- );
- SLresult (*RegisterCallback) (
- SLPlayItf self,
- slPlayCallback callback,
- void *pContext
- );
- SLresult (*SetCallbackEventsMask) (
- SLPlayItf self,
- SLuint32 eventFlags
- );
- SLresult (*GetCallbackEventsMask) (
- SLPlayItf self,
- SLuint32 *pEventFlags
- );
- SLresult (*SetMarkerPosition) (
- SLPlayItf self,
- SLmillisecond mSec
- );
- SLresult (*ClearMarkerPosition) (
- SLPlayItf self
- );
- SLresult (*GetMarkerPosition) (
- SLPlayItf self,
- SLmillisecond *pMsec
- );
- SLresult (*SetPositionUpdatePeriod) (
- SLPlayItf self,
- SLmillisecond mSec
- );
- SLresult (*GetPositionUpdatePeriod) (
- SLPlayItf self,
- SLmillisecond *pMsec
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Prefetch status interface */
-/*---------------------------------------------------------------------------*/
-
-#define SL_PREFETCHEVENT_STATUSCHANGE ((SLuint32) 0x00000001)
-#define SL_PREFETCHEVENT_FILLLEVELCHANGE ((SLuint32) 0x00000002)
-
-#define SL_PREFETCHSTATUS_UNDERFLOW ((SLuint32) 0x00000001)
-#define SL_PREFETCHSTATUS_SUFFICIENTDATA ((SLuint32) 0x00000002)
-#define SL_PREFETCHSTATUS_OVERFLOW ((SLuint32) 0x00000003)
-
-
-extern SL_API const SLInterfaceID SL_IID_PREFETCHSTATUS;
-
-
-/** Prefetch status interface methods */
-
-struct SLPrefetchStatusItf_;
-typedef const struct SLPrefetchStatusItf_ * const * SLPrefetchStatusItf;
-
-typedef void (SLAPIENTRY *slPrefetchCallback) (
- SLPrefetchStatusItf caller,
- void *pContext,
- SLuint32 event
-);
-
-struct SLPrefetchStatusItf_ {
- SLresult (*GetPrefetchStatus) (
- SLPrefetchStatusItf self,
- SLuint32 *pStatus
- );
- SLresult (*GetFillLevel) (
- SLPrefetchStatusItf self,
- SLpermille *pLevel
- );
- SLresult (*RegisterCallback) (
- SLPrefetchStatusItf self,
- slPrefetchCallback callback,
- void *pContext
- );
- SLresult (*SetCallbackEventsMask) (
- SLPrefetchStatusItf self,
- SLuint32 eventFlags
- );
- SLresult (*GetCallbackEventsMask) (
- SLPrefetchStatusItf self,
- SLuint32 *pEventFlags
- );
- SLresult (*SetFillUpdatePeriod) (
- SLPrefetchStatusItf self,
- SLpermille period
- );
- SLresult (*GetFillUpdatePeriod) (
- SLPrefetchStatusItf self,
- SLpermille *pPeriod
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Playback Rate interface */
-/*---------------------------------------------------------------------------*/
-
-#define SL_RATEPROP_RESERVED1 ((SLuint32) 0x00000001)
-#define SL_RATEPROP_RESERVED2 ((SLuint32) 0x00000002)
-#define SL_RATEPROP_SILENTAUDIO ((SLuint32) 0x00000100)
-#define SL_RATEPROP_STAGGEREDAUDIO ((SLuint32) 0x00000200)
-#define SL_RATEPROP_NOPITCHCORAUDIO ((SLuint32) 0x00000400)
-#define SL_RATEPROP_PITCHCORAUDIO ((SLuint32) 0x00000800)
-
-
-extern SL_API const SLInterfaceID SL_IID_PLAYBACKRATE;
-
-struct SLPlaybackRateItf_;
-typedef const struct SLPlaybackRateItf_ * const * SLPlaybackRateItf;
-
-struct SLPlaybackRateItf_ {
- SLresult (*SetRate)(
- SLPlaybackRateItf self,
- SLpermille rate
- );
- SLresult (*GetRate)(
- SLPlaybackRateItf self,
- SLpermille *pRate
- );
- SLresult (*SetPropertyConstraints)(
- SLPlaybackRateItf self,
- SLuint32 constraints
- );
- SLresult (*GetProperties)(
- SLPlaybackRateItf self,
- SLuint32 *pProperties
- );
- SLresult (*GetCapabilitiesOfRate)(
- SLPlaybackRateItf self,
- SLpermille rate,
- SLuint32 *pCapabilities
- );
- SLresult (*GetRateRange) (
- SLPlaybackRateItf self,
- SLuint8 index,
- SLpermille *pMinRate,
- SLpermille *pMaxRate,
- SLpermille *pStepSize,
- SLuint32 *pCapabilities
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Seek Interface */
-/*---------------------------------------------------------------------------*/
-
-#define SL_SEEKMODE_FAST ((SLuint32) 0x0001)
-#define SL_SEEKMODE_ACCURATE ((SLuint32) 0x0002)
-
-extern SL_API const SLInterfaceID SL_IID_SEEK;
-
-struct SLSeekItf_;
-typedef const struct SLSeekItf_ * const * SLSeekItf;
-
-struct SLSeekItf_ {
- SLresult (*SetPosition)(
- SLSeekItf self,
- SLmillisecond pos,
- SLuint32 seekMode
- );
- SLresult (*SetLoop)(
- SLSeekItf self,
- SLboolean loopEnable,
- SLmillisecond startPos,
- SLmillisecond endPos
- );
- SLresult (*GetLoop)(
- SLSeekItf self,
- SLboolean *pLoopEnabled,
- SLmillisecond *pStartPos,
- SLmillisecond *pEndPos
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Standard Recording Interface */
-/*---------------------------------------------------------------------------*/
-
-/** Recording states */
-#define SL_RECORDSTATE_STOPPED ((SLuint32) 0x00000001)
-#define SL_RECORDSTATE_PAUSED ((SLuint32) 0x00000002)
-#define SL_RECORDSTATE_RECORDING ((SLuint32) 0x00000003)
-
-
-/** Record event **/
-#define SL_RECORDEVENT_HEADATLIMIT ((SLuint32) 0x00000001)
-#define SL_RECORDEVENT_HEADATMARKER ((SLuint32) 0x00000002)
-#define SL_RECORDEVENT_HEADATNEWPOS ((SLuint32) 0x00000004)
-#define SL_RECORDEVENT_HEADMOVING ((SLuint32) 0x00000008)
-#define SL_RECORDEVENT_HEADSTALLED ((SLuint32) 0x00000010)
-/* Note: SL_RECORDEVENT_BUFFER_INSUFFICIENT is deprecated, use SL_RECORDEVENT_BUFFER_FULL instead. */
-#define SL_RECORDEVENT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000020)
-#define SL_RECORDEVENT_BUFFER_FULL ((SLuint32) 0x00000020)
-
-
-extern SL_API const SLInterfaceID SL_IID_RECORD;
-
-struct SLRecordItf_;
-typedef const struct SLRecordItf_ * const * SLRecordItf;
-
-typedef void (SLAPIENTRY *slRecordCallback) (
- SLRecordItf caller,
- void *pContext,
- SLuint32 event
-);
-
-/** Recording interface methods */
-struct SLRecordItf_ {
- SLresult (*SetRecordState) (
- SLRecordItf self,
- SLuint32 state
- );
- SLresult (*GetRecordState) (
- SLRecordItf self,
- SLuint32 *pState
- );
- SLresult (*SetDurationLimit) (
- SLRecordItf self,
- SLmillisecond msec
- );
- SLresult (*GetPosition) (
- SLRecordItf self,
- SLmillisecond *pMsec
- );
- SLresult (*RegisterCallback) (
- SLRecordItf self,
- slRecordCallback callback,
- void *pContext
- );
- SLresult (*SetCallbackEventsMask) (
- SLRecordItf self,
- SLuint32 eventFlags
- );
- SLresult (*GetCallbackEventsMask) (
- SLRecordItf self,
- SLuint32 *pEventFlags
- );
- SLresult (*SetMarkerPosition) (
- SLRecordItf self,
- SLmillisecond mSec
- );
- SLresult (*ClearMarkerPosition) (
- SLRecordItf self
- );
- SLresult (*GetMarkerPosition) (
- SLRecordItf self,
- SLmillisecond *pMsec
- );
- SLresult (*SetPositionUpdatePeriod) (
- SLRecordItf self,
- SLmillisecond mSec
- );
- SLresult (*GetPositionUpdatePeriod) (
- SLRecordItf self,
- SLmillisecond *pMsec
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Equalizer interface */
-/*---------------------------------------------------------------------------*/
-
-#define SL_EQUALIZER_UNDEFINED ((SLuint16) 0xFFFF)
-
-extern SL_API const SLInterfaceID SL_IID_EQUALIZER;
-
-struct SLEqualizerItf_;
-typedef const struct SLEqualizerItf_ * const * SLEqualizerItf;
-
-struct SLEqualizerItf_ {
- SLresult (*SetEnabled)(
- SLEqualizerItf self,
- SLboolean enabled
- );
- SLresult (*IsEnabled)(
- SLEqualizerItf self,
- SLboolean *pEnabled
- );
- SLresult (*GetNumberOfBands)(
- SLEqualizerItf self,
- SLuint16 *pAmount
- );
- SLresult (*GetBandLevelRange)(
- SLEqualizerItf self,
- SLmillibel *pMin,
- SLmillibel *pMax
- );
- SLresult (*SetBandLevel)(
- SLEqualizerItf self,
- SLuint16 band,
- SLmillibel level
- );
- SLresult (*GetBandLevel)(
- SLEqualizerItf self,
- SLuint16 band,
- SLmillibel *pLevel
- );
- SLresult (*GetCenterFreq)(
- SLEqualizerItf self,
- SLuint16 band,
- SLmilliHertz *pCenter
- );
- SLresult (*GetBandFreqRange)(
- SLEqualizerItf self,
- SLuint16 band,
- SLmilliHertz *pMin,
- SLmilliHertz *pMax
- );
- SLresult (*GetBand)(
- SLEqualizerItf self,
- SLmilliHertz frequency,
- SLuint16 *pBand
- );
- SLresult (*GetCurrentPreset)(
- SLEqualizerItf self,
- SLuint16 *pPreset
- );
- SLresult (*UsePreset)(
- SLEqualizerItf self,
- SLuint16 index
- );
- SLresult (*GetNumberOfPresets)(
- SLEqualizerItf self,
- SLuint16 *pNumPresets
- );
- SLresult (*GetPresetName)(
- SLEqualizerItf self,
- SLuint16 index,
- const SLchar ** ppName
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Volume Interface */
-/* --------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_VOLUME;
-
-struct SLVolumeItf_;
-typedef const struct SLVolumeItf_ * const * SLVolumeItf;
-
-struct SLVolumeItf_ {
- SLresult (*SetVolumeLevel) (
- SLVolumeItf self,
- SLmillibel level
- );
- SLresult (*GetVolumeLevel) (
- SLVolumeItf self,
- SLmillibel *pLevel
- );
- SLresult (*GetMaxVolumeLevel) (
- SLVolumeItf self,
- SLmillibel *pMaxLevel
- );
- SLresult (*SetMute) (
- SLVolumeItf self,
- SLboolean mute
- );
- SLresult (*GetMute) (
- SLVolumeItf self,
- SLboolean *pMute
- );
- SLresult (*EnableStereoPosition) (
- SLVolumeItf self,
- SLboolean enable
- );
- SLresult (*IsEnabledStereoPosition) (
- SLVolumeItf self,
- SLboolean *pEnable
- );
- SLresult (*SetStereoPosition) (
- SLVolumeItf self,
- SLpermille stereoPosition
- );
- SLresult (*GetStereoPosition) (
- SLVolumeItf self,
- SLpermille *pStereoPosition
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Device Volume Interface */
-/* --------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_DEVICEVOLUME;
-
-struct SLDeviceVolumeItf_;
-typedef const struct SLDeviceVolumeItf_ * const * SLDeviceVolumeItf;
-
-struct SLDeviceVolumeItf_ {
- SLresult (*GetVolumeScale) (
- SLDeviceVolumeItf self,
- SLuint32 deviceID,
- SLint32 *pMinValue,
- SLint32 *pMaxValue,
- SLboolean *pIsMillibelScale
- );
- SLresult (*SetVolume) (
- SLDeviceVolumeItf self,
- SLuint32 deviceID,
- SLint32 volume
- );
- SLresult (*GetVolume) (
- SLDeviceVolumeItf self,
- SLuint32 deviceID,
- SLint32 *pVolume
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Buffer Queue Interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_BUFFERQUEUE;
-
-struct SLBufferQueueItf_;
-typedef const struct SLBufferQueueItf_ * const * SLBufferQueueItf;
-
-typedef void (SLAPIENTRY *slBufferQueueCallback)(
- SLBufferQueueItf caller,
- void *pContext
-);
-
-/** Buffer queue state **/
-
-typedef struct SLBufferQueueState_ {
- SLuint32 count;
- SLuint32 playIndex;
-} SLBufferQueueState;
-
-
-struct SLBufferQueueItf_ {
- SLresult (*Enqueue) (
- SLBufferQueueItf self,
- const void *pBuffer,
- SLuint32 size
- );
- SLresult (*Clear) (
- SLBufferQueueItf self
- );
- SLresult (*GetState) (
- SLBufferQueueItf self,
- SLBufferQueueState *pState
- );
- SLresult (*RegisterCallback) (
- SLBufferQueueItf self,
- slBufferQueueCallback callback,
- void* pContext
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* PresetReverb */
-/*---------------------------------------------------------------------------*/
-
-#define SL_REVERBPRESET_NONE ((SLuint16) 0x0000)
-#define SL_REVERBPRESET_SMALLROOM ((SLuint16) 0x0001)
-#define SL_REVERBPRESET_MEDIUMROOM ((SLuint16) 0x0002)
-#define SL_REVERBPRESET_LARGEROOM ((SLuint16) 0x0003)
-#define SL_REVERBPRESET_MEDIUMHALL ((SLuint16) 0x0004)
-#define SL_REVERBPRESET_LARGEHALL ((SLuint16) 0x0005)
-#define SL_REVERBPRESET_PLATE ((SLuint16) 0x0006)
-
-
-extern SL_API const SLInterfaceID SL_IID_PRESETREVERB;
-
-struct SLPresetReverbItf_;
-typedef const struct SLPresetReverbItf_ * const * SLPresetReverbItf;
-
-struct SLPresetReverbItf_ {
- SLresult (*SetPreset) (
- SLPresetReverbItf self,
- SLuint16 preset
- );
- SLresult (*GetPreset) (
- SLPresetReverbItf self,
- SLuint16 *pPreset
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* EnvironmentalReverb */
-/*---------------------------------------------------------------------------*/
-
-#define SL_I3DL2_ENVIRONMENT_PRESET_DEFAULT \
- { SL_MILLIBEL_MIN, 0, 1000, 500, SL_MILLIBEL_MIN, 20, SL_MILLIBEL_MIN, 40, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_GENERIC \
- { -1000, -100, 1490, 830, -2602, 7, 200, 11, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL \
- { -1000,-6000, 170, 100, -1204, 1, 207, 2, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_ROOM \
- { -1000, -454, 400, 830, -1646, 2, 53, 3, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_BATHROOM \
- { -1000,-1200, 1490, 540, -370, 7, 1030, 11, 1000, 600 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM \
- { -1000,-6000, 500, 100, -1376, 3, -1104, 4, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_STONEROOM \
- { -1000, -300, 2310, 640, -711, 12, 83, 17, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM \
- { -1000, -476, 4320, 590, -789, 20, -289, 30, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL \
- { -1000, -500, 3920, 700, -1230, 20, -2, 29, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_CAVE \
- { -1000, 0, 2910, 1300, -602, 15, -302, 22, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_ARENA \
- { -1000, -698, 7240, 330, -1166, 20, 16, 30, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_HANGAR \
- { -1000,-1000, 10050, 230, -602, 20, 198, 30, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY \
- { -1000,-4000, 300, 100, -1831, 2, -1630, 30, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_HALLWAY \
- { -1000, -300, 1490, 590, -1219, 7, 441, 11, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR \
- { -1000, -237, 2700, 790, -1214, 13, 395, 20, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_ALLEY \
- { -1000, -270, 1490, 860, -1204, 7, -4, 11, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_FOREST \
- { -1000,-3300, 1490, 540, -2560, 162, -613, 88, 790,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_CITY \
- { -1000, -800, 1490, 670, -2273, 7, -2217, 11, 500,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS \
- { -1000,-2500, 1490, 210, -2780, 300, -2014, 100, 270,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_QUARRY \
- { -1000,-1000, 1490, 830, SL_MILLIBEL_MIN, 61, 500, 25, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_PLAIN \
- { -1000,-2000, 1490, 500, -2466, 179, -2514, 100, 210,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT \
- { -1000, 0, 1650, 1500, -1363, 8, -1153, 12, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE \
- { -1000,-1000, 2810, 140, 429, 14, 648, 21, 800, 600 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_UNDERWATER \
- { -1000,-4000, 1490, 100, -449, 7, 1700, 11, 1000,1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_SMALLROOM \
- { -1000,-600, 1100, 830, -400, 5, 500, 10, 1000, 1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM \
- { -1000,-600, 1300, 830, -1000, 20, -200, 20, 1000, 1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEROOM \
- { -1000,-600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL \
- { -1000,-600, 1800, 700, -1300, 15, -800, 30, 1000, 1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEHALL \
- { -1000,-600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000 }
-#define SL_I3DL2_ENVIRONMENT_PRESET_PLATE \
- { -1000,-200, 1300, 900, 0, 2, 0, 10, 1000, 750 }
-
-
-typedef struct SLEnvironmentalReverbSettings_ {
- SLmillibel roomLevel;
- SLmillibel roomHFLevel;
- SLmillisecond decayTime;
- SLpermille decayHFRatio;
- SLmillibel reflectionsLevel;
- SLmillisecond reflectionsDelay;
- SLmillibel reverbLevel;
- SLmillisecond reverbDelay;
- SLpermille diffusion;
- SLpermille density;
-} SLEnvironmentalReverbSettings;
-
-
-
-
-extern SL_API const SLInterfaceID SL_IID_ENVIRONMENTALREVERB;
-
-
-struct SLEnvironmentalReverbItf_;
-typedef const struct SLEnvironmentalReverbItf_ * const * SLEnvironmentalReverbItf;
-
-struct SLEnvironmentalReverbItf_ {
- SLresult (*SetRoomLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel room
- );
- SLresult (*GetRoomLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel *pRoom
- );
- SLresult (*SetRoomHFLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel roomHF
- );
- SLresult (*GetRoomHFLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel *pRoomHF
- );
- SLresult (*SetDecayTime) (
- SLEnvironmentalReverbItf self,
- SLmillisecond decayTime
- );
- SLresult (*GetDecayTime) (
- SLEnvironmentalReverbItf self,
- SLmillisecond *pDecayTime
- );
- SLresult (*SetDecayHFRatio) (
- SLEnvironmentalReverbItf self,
- SLpermille decayHFRatio
- );
- SLresult (*GetDecayHFRatio) (
- SLEnvironmentalReverbItf self,
- SLpermille *pDecayHFRatio
- );
- SLresult (*SetReflectionsLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel reflectionsLevel
- );
- SLresult (*GetReflectionsLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel *pReflectionsLevel
- );
- SLresult (*SetReflectionsDelay) (
- SLEnvironmentalReverbItf self,
- SLmillisecond reflectionsDelay
- );
- SLresult (*GetReflectionsDelay) (
- SLEnvironmentalReverbItf self,
- SLmillisecond *pReflectionsDelay
- );
- SLresult (*SetReverbLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel reverbLevel
- );
- SLresult (*GetReverbLevel) (
- SLEnvironmentalReverbItf self,
- SLmillibel *pReverbLevel
- );
- SLresult (*SetReverbDelay) (
- SLEnvironmentalReverbItf self,
- SLmillisecond reverbDelay
- );
- SLresult (*GetReverbDelay) (
- SLEnvironmentalReverbItf self,
- SLmillisecond *pReverbDelay
- );
- SLresult (*SetDiffusion) (
- SLEnvironmentalReverbItf self,
- SLpermille diffusion
- );
- SLresult (*GetDiffusion) (
- SLEnvironmentalReverbItf self,
- SLpermille *pDiffusion
- );
- SLresult (*SetDensity) (
- SLEnvironmentalReverbItf self,
- SLpermille density
- );
- SLresult (*GetDensity) (
- SLEnvironmentalReverbItf self,
- SLpermille *pDensity
- );
- SLresult (*SetEnvironmentalReverbProperties) (
- SLEnvironmentalReverbItf self,
- const SLEnvironmentalReverbSettings *pProperties
- );
- SLresult (*GetEnvironmentalReverbProperties) (
- SLEnvironmentalReverbItf self,
- SLEnvironmentalReverbSettings *pProperties
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Effects Send Interface */
-/*---------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_EFFECTSEND;
-
-struct SLEffectSendItf_;
-typedef const struct SLEffectSendItf_ * const * SLEffectSendItf;
-
-struct SLEffectSendItf_ {
- SLresult (*EnableEffectSend) (
- SLEffectSendItf self,
- const void *pAuxEffect,
- SLboolean enable,
- SLmillibel initialLevel
- );
- SLresult (*IsEnabled) (
- SLEffectSendItf self,
- const void * pAuxEffect,
- SLboolean *pEnable
- );
- SLresult (*SetDirectLevel) (
- SLEffectSendItf self,
- SLmillibel directLevel
- );
- SLresult (*GetDirectLevel) (
- SLEffectSendItf self,
- SLmillibel *pDirectLevel
- );
- SLresult (*SetSendLevel) (
- SLEffectSendItf self,
- const void *pAuxEffect,
- SLmillibel sendLevel
- );
- SLresult (*GetSendLevel)(
- SLEffectSendItf self,
- const void *pAuxEffect,
- SLmillibel *pSendLevel
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* 3D Grouping Interface */
-/*---------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_3DGROUPING;
-
-
-struct SL3DGroupingItf_ ;
-typedef const struct SL3DGroupingItf_ * const * SL3DGroupingItf;
-
-struct SL3DGroupingItf_ {
- SLresult (*Set3DGroup) (
- SL3DGroupingItf self,
- SLObjectItf group
- );
- SLresult (*Get3DGroup) (
- SL3DGroupingItf self,
- SLObjectItf *pGroup
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* 3D Commit Interface */
-/*---------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_3DCOMMIT;
-
-struct SL3DCommitItf_;
-typedef const struct SL3DCommitItf_* const * SL3DCommitItf;
-
-struct SL3DCommitItf_ {
- SLresult (*Commit) (
- SL3DCommitItf self
- );
- SLresult (*SetDeferred) (
- SL3DCommitItf self,
- SLboolean deferred
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* 3D Location Interface */
-/*---------------------------------------------------------------------------*/
-
-typedef struct SLVec3D_ {
- SLint32 x;
- SLint32 y;
- SLint32 z;
-} SLVec3D;
-
-extern SL_API const SLInterfaceID SL_IID_3DLOCATION;
-
-struct SL3DLocationItf_;
-typedef const struct SL3DLocationItf_ * const * SL3DLocationItf;
-
-struct SL3DLocationItf_ {
- SLresult (*SetLocationCartesian) (
- SL3DLocationItf self,
- const SLVec3D *pLocation
- );
- SLresult (*SetLocationSpherical) (
- SL3DLocationItf self,
- SLmillidegree azimuth,
- SLmillidegree elevation,
- SLmillimeter distance
- );
- SLresult (*Move) (
- SL3DLocationItf self,
- const SLVec3D *pMovement
- );
- SLresult (*GetLocationCartesian) (
- SL3DLocationItf self,
- SLVec3D *pLocation
- );
- SLresult (*SetOrientationVectors) (
- SL3DLocationItf self,
- const SLVec3D *pFront,
- const SLVec3D *pAbove
- );
- SLresult (*SetOrientationAngles) (
- SL3DLocationItf self,
- SLmillidegree heading,
- SLmillidegree pitch,
- SLmillidegree roll
- );
- SLresult (*Rotate) (
- SL3DLocationItf self,
- SLmillidegree theta,
- const SLVec3D *pAxis
- );
- SLresult (*GetOrientationVectors) (
- SL3DLocationItf self,
- SLVec3D *pFront,
- SLVec3D *pUp
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* 3D Doppler Interface */
-/*---------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_3DDOPPLER;
-
-struct SL3DDopplerItf_;
-typedef const struct SL3DDopplerItf_ * const * SL3DDopplerItf;
-
-struct SL3DDopplerItf_ {
- SLresult (*SetVelocityCartesian) (
- SL3DDopplerItf self,
- const SLVec3D *pVelocity
- );
- SLresult (*SetVelocitySpherical) (
- SL3DDopplerItf self,
- SLmillidegree azimuth,
- SLmillidegree elevation,
- SLmillimeter speed
- );
- SLresult (*GetVelocityCartesian) (
- SL3DDopplerItf self,
- SLVec3D *pVelocity
- );
- SLresult (*SetDopplerFactor) (
- SL3DDopplerItf self,
- SLpermille dopplerFactor
- );
- SLresult (*GetDopplerFactor) (
- SL3DDopplerItf self,
- SLpermille *pDopplerFactor
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* 3D Source Interface and associated defines */
-/* --------------------------------------------------------------------------*/
-
-#define SL_ROLLOFFMODEL_EXPONENTIAL ((SLuint32) 0x00000000)
-#define SL_ROLLOFFMODEL_LINEAR ((SLuint32) 0x00000001)
-
-
-extern SL_API const SLInterfaceID SL_IID_3DSOURCE;
-
-struct SL3DSourceItf_;
-typedef const struct SL3DSourceItf_ * const * SL3DSourceItf;
-
-struct SL3DSourceItf_ {
- SLresult (*SetHeadRelative) (
- SL3DSourceItf self,
- SLboolean headRelative
- );
- SLresult (*GetHeadRelative) (
- SL3DSourceItf self,
- SLboolean *pHeadRelative
- );
- SLresult (*SetRolloffDistances) (
- SL3DSourceItf self,
- SLmillimeter minDistance,
- SLmillimeter maxDistance
- );
- SLresult (*GetRolloffDistances) (
- SL3DSourceItf self,
- SLmillimeter *pMinDistance,
- SLmillimeter *pMaxDistance
- );
- SLresult (*SetRolloffMaxDistanceMute) (
- SL3DSourceItf self,
- SLboolean mute
- );
- SLresult (*GetRolloffMaxDistanceMute) (
- SL3DSourceItf self,
- SLboolean *pMute
- );
- SLresult (*SetRolloffFactor) (
- SL3DSourceItf self,
- SLpermille rolloffFactor
- );
- SLresult (*GetRolloffFactor) (
- SL3DSourceItf self,
- SLpermille *pRolloffFactor
- );
- SLresult (*SetRoomRolloffFactor) (
- SL3DSourceItf self,
- SLpermille roomRolloffFactor
- );
- SLresult (*GetRoomRolloffFactor) (
- SL3DSourceItf self,
- SLpermille *pRoomRolloffFactor
- );
- SLresult (*SetRolloffModel) (
- SL3DSourceItf self,
- SLuint8 model
- );
- SLresult (*GetRolloffModel) (
- SL3DSourceItf self,
- SLuint8 *pModel
- );
- SLresult (*SetCone) (
- SL3DSourceItf self,
- SLmillidegree innerAngle,
- SLmillidegree outerAngle,
- SLmillibel outerLevel
- );
- SLresult (*GetCone) (
- SL3DSourceItf self,
- SLmillidegree *pInnerAngle,
- SLmillidegree *pOuterAngle,
- SLmillibel *pOuterLevel
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* 3D Macroscopic Interface */
-/* --------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_3DMACROSCOPIC;
-
-struct SL3DMacroscopicItf_;
-typedef const struct SL3DMacroscopicItf_ * const * SL3DMacroscopicItf;
-
-struct SL3DMacroscopicItf_ {
- SLresult (*SetSize) (
- SL3DMacroscopicItf self,
- SLmillimeter width,
- SLmillimeter height,
- SLmillimeter depth
- );
- SLresult (*GetSize) (
- SL3DMacroscopicItf self,
- SLmillimeter *pWidth,
- SLmillimeter *pHeight,
- SLmillimeter *pDepth
- );
- SLresult (*SetOrientationAngles) (
- SL3DMacroscopicItf self,
- SLmillidegree heading,
- SLmillidegree pitch,
- SLmillidegree roll
- );
- SLresult (*SetOrientationVectors) (
- SL3DMacroscopicItf self,
- const SLVec3D *pFront,
- const SLVec3D *pAbove
- );
- SLresult (*Rotate) (
- SL3DMacroscopicItf self,
- SLmillidegree theta,
- const SLVec3D *pAxis
- );
- SLresult (*GetOrientationVectors) (
- SL3DMacroscopicItf self,
- SLVec3D *pFront,
- SLVec3D *pUp
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Mute Solo Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_MUTESOLO;
-
-struct SLMuteSoloItf_;
-typedef const struct SLMuteSoloItf_ * const * SLMuteSoloItf;
-
-struct SLMuteSoloItf_ {
- SLresult (*SetChannelMute) (
- SLMuteSoloItf self,
- SLuint8 chan,
- SLboolean mute
- );
- SLresult (*GetChannelMute) (
- SLMuteSoloItf self,
- SLuint8 chan,
- SLboolean *pMute
- );
- SLresult (*SetChannelSolo) (
- SLMuteSoloItf self,
- SLuint8 chan,
- SLboolean solo
- );
- SLresult (*GetChannelSolo) (
- SLMuteSoloItf self,
- SLuint8 chan,
- SLboolean *pSolo
- );
- SLresult (*GetNumChannels) (
- SLMuteSoloItf self,
- SLuint8 *pNumChannels
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Dynamic Interface Management Interface and associated types and macros */
-/* --------------------------------------------------------------------------*/
-
-#define SL_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001)
-#define SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002)
-#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003)
-#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((SLuint32) 0x00000004)
-#define SL_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000005)
-
-
-
-
-extern SL_API const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT;
-
-struct SLDynamicInterfaceManagementItf_;
-typedef const struct SLDynamicInterfaceManagementItf_ * const * SLDynamicInterfaceManagementItf;
-
-typedef void (SLAPIENTRY *slDynamicInterfaceManagementCallback) (
- SLDynamicInterfaceManagementItf caller,
- void * pContext,
- SLuint32 event,
- SLresult result,
- const SLInterfaceID iid
-);
-
-
-struct SLDynamicInterfaceManagementItf_ {
- SLresult (*AddInterface) (
- SLDynamicInterfaceManagementItf self,
- const SLInterfaceID iid,
- SLboolean async
- );
- SLresult (*RemoveInterface) (
- SLDynamicInterfaceManagementItf self,
- const SLInterfaceID iid
- );
- SLresult (*ResumeInterface) (
- SLDynamicInterfaceManagementItf self,
- const SLInterfaceID iid,
- SLboolean async
- );
- SLresult (*RegisterCallback) (
- SLDynamicInterfaceManagementItf self,
- slDynamicInterfaceManagementCallback callback,
- void * pContext
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Midi Message Interface and associated types */
-/* --------------------------------------------------------------------------*/
-
-#define SL_MIDIMESSAGETYPE_NOTE_ON_OFF ((SLuint32) 0x00000001)
-#define SL_MIDIMESSAGETYPE_POLY_PRESSURE ((SLuint32) 0x00000002)
-#define SL_MIDIMESSAGETYPE_CONTROL_CHANGE ((SLuint32) 0x00000003)
-#define SL_MIDIMESSAGETYPE_PROGRAM_CHANGE ((SLuint32) 0x00000004)
-#define SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE ((SLuint32) 0x00000005)
-#define SL_MIDIMESSAGETYPE_PITCH_BEND ((SLuint32) 0x00000006)
-#define SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE ((SLuint32) 0x00000007)
-
-
-extern SL_API const SLInterfaceID SL_IID_MIDIMESSAGE;
-
-struct SLMIDIMessageItf_;
-typedef const struct SLMIDIMessageItf_ * const * SLMIDIMessageItf;
-
-typedef void (SLAPIENTRY *slMetaEventCallback) (
- SLMIDIMessageItf caller,
- void *pContext,
- SLuint8 type,
- SLuint32 length,
- const SLuint8 *pData,
- SLuint32 tick,
- SLuint16 track
-);
-
-typedef void (SLAPIENTRY *slMIDIMessageCallback) (
- SLMIDIMessageItf caller,
- void *pContext,
- SLuint8 statusByte,
- SLuint32 length,
- const SLuint8 *pData,
- SLuint32 tick,
- SLuint16 track
-);
-
-struct SLMIDIMessageItf_ {
- SLresult (*SendMessage) (
- SLMIDIMessageItf self,
- const SLuint8 *data,
- SLuint32 length
- );
- SLresult (*RegisterMetaEventCallback) (
- SLMIDIMessageItf self,
- slMetaEventCallback callback,
- void *pContext
- );
- SLresult (*RegisterMIDIMessageCallback) (
- SLMIDIMessageItf self,
- slMIDIMessageCallback callback,
- void *pContext
- );
- SLresult (*AddMIDIMessageCallbackFilter) (
- SLMIDIMessageItf self,
- SLuint32 messageType
- );
- SLresult (*ClearMIDIMessageCallbackFilter) (
- SLMIDIMessageItf self
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Midi Mute Solo interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_MIDIMUTESOLO;
-
-struct SLMIDIMuteSoloItf_;
-typedef const struct SLMIDIMuteSoloItf_ * const * SLMIDIMuteSoloItf;
-
-struct SLMIDIMuteSoloItf_ {
- SLresult (*SetChannelMute) (
- SLMIDIMuteSoloItf self,
- SLuint8 channel,
- SLboolean mute
- );
- SLresult (*GetChannelMute) (
- SLMIDIMuteSoloItf self,
- SLuint8 channel,
- SLboolean *pMute
- );
- SLresult (*SetChannelSolo) (
- SLMIDIMuteSoloItf self,
- SLuint8 channel,
- SLboolean solo
- );
- SLresult (*GetChannelSolo) (
- SLMIDIMuteSoloItf self,
- SLuint8 channel,
- SLboolean *pSolo
- );
- SLresult (*GetTrackCount) (
- SLMIDIMuteSoloItf self,
- SLuint16 *pCount
- );
- SLresult (*SetTrackMute) (
- SLMIDIMuteSoloItf self,
- SLuint16 track,
- SLboolean mute
- );
- SLresult (*GetTrackMute) (
- SLMIDIMuteSoloItf self,
- SLuint16 track,
- SLboolean *pMute
- );
- SLresult (*SetTrackSolo) (
- SLMIDIMuteSoloItf self,
- SLuint16 track,
- SLboolean solo
- );
- SLresult (*GetTrackSolo) (
- SLMIDIMuteSoloItf self,
- SLuint16 track,
- SLboolean *pSolo
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Midi Tempo interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_MIDITEMPO;
-
-struct SLMIDITempoItf_;
-typedef const struct SLMIDITempoItf_ * const * SLMIDITempoItf;
-
-struct SLMIDITempoItf_ {
- SLresult (*SetTicksPerQuarterNote) (
- SLMIDITempoItf self,
- SLuint32 tpqn
- );
- SLresult (*GetTicksPerQuarterNote) (
- SLMIDITempoItf self,
- SLuint32 *pTpqn
- );
- SLresult (*SetMicrosecondsPerQuarterNote) (
- SLMIDITempoItf self,
- SLmicrosecond uspqn
- );
- SLresult (*GetMicrosecondsPerQuarterNote) (
- SLMIDITempoItf self,
- SLmicrosecond *uspqn
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Midi Time interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_MIDITIME;
-
-struct SLMIDITimeItf_;
-typedef const struct SLMIDITimeItf_ * const * SLMIDITimeItf;
-
-struct SLMIDITimeItf_ {
- SLresult (*GetDuration) (
- SLMIDITimeItf self,
- SLuint32 *pDuration
- );
- SLresult (*SetPosition) (
- SLMIDITimeItf self,
- SLuint32 position
- );
- SLresult (*GetPosition) (
- SLMIDITimeItf self,
- SLuint32 *pPosition
- );
- SLresult (*SetLoopPoints) (
- SLMIDITimeItf self,
- SLuint32 startTick,
- SLuint32 numTicks
- );
- SLresult (*GetLoopPoints) (
- SLMIDITimeItf self,
- SLuint32 *pStartTick,
- SLuint32 *pNumTicks
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Audio Decoder Capabilities Interface */
-/* --------------------------------------------------------------------------*/
-
-/*Audio Codec related defines*/
-
-#define SL_RATECONTROLMODE_CONSTANTBITRATE ((SLuint32) 0x00000001)
-#define SL_RATECONTROLMODE_VARIABLEBITRATE ((SLuint32) 0x00000002)
-
-#define SL_AUDIOCODEC_PCM ((SLuint32) 0x00000001)
-#define SL_AUDIOCODEC_MP3 ((SLuint32) 0x00000002)
-#define SL_AUDIOCODEC_AMR ((SLuint32) 0x00000003)
-#define SL_AUDIOCODEC_AMRWB ((SLuint32) 0x00000004)
-#define SL_AUDIOCODEC_AMRWBPLUS ((SLuint32) 0x00000005)
-#define SL_AUDIOCODEC_AAC ((SLuint32) 0x00000006)
-#define SL_AUDIOCODEC_WMA ((SLuint32) 0x00000007)
-#define SL_AUDIOCODEC_REAL ((SLuint32) 0x00000008)
-
-#define SL_AUDIOPROFILE_PCM ((SLuint32) 0x00000001)
-
-#define SL_AUDIOPROFILE_MPEG1_L3 ((SLuint32) 0x00000001)
-#define SL_AUDIOPROFILE_MPEG2_L3 ((SLuint32) 0x00000002)
-#define SL_AUDIOPROFILE_MPEG25_L3 ((SLuint32) 0x00000003)
-
-#define SL_AUDIOCHANMODE_MP3_MONO ((SLuint32) 0x00000001)
-#define SL_AUDIOCHANMODE_MP3_STEREO ((SLuint32) 0x00000002)
-#define SL_AUDIOCHANMODE_MP3_JOINTSTEREO ((SLuint32) 0x00000003)
-#define SL_AUDIOCHANMODE_MP3_DUAL ((SLuint32) 0x00000004)
-
-#define SL_AUDIOPROFILE_AMR ((SLuint32) 0x00000001)
-
-#define SL_AUDIOSTREAMFORMAT_CONFORMANCE ((SLuint32) 0x00000001)
-#define SL_AUDIOSTREAMFORMAT_IF1 ((SLuint32) 0x00000002)
-#define SL_AUDIOSTREAMFORMAT_IF2 ((SLuint32) 0x00000003)
-#define SL_AUDIOSTREAMFORMAT_FSF ((SLuint32) 0x00000004)
-#define SL_AUDIOSTREAMFORMAT_RTPPAYLOAD ((SLuint32) 0x00000005)
-#define SL_AUDIOSTREAMFORMAT_ITU ((SLuint32) 0x00000006)
-
-#define SL_AUDIOPROFILE_AMRWB ((SLuint32) 0x00000001)
-
-#define SL_AUDIOPROFILE_AMRWBPLUS ((SLuint32) 0x00000001)
-
-#define SL_AUDIOPROFILE_AAC_AAC ((SLuint32) 0x00000001)
-
-#define SL_AUDIOMODE_AAC_MAIN ((SLuint32) 0x00000001)
-#define SL_AUDIOMODE_AAC_LC ((SLuint32) 0x00000002)
-#define SL_AUDIOMODE_AAC_SSR ((SLuint32) 0x00000003)
-#define SL_AUDIOMODE_AAC_LTP ((SLuint32) 0x00000004)
-#define SL_AUDIOMODE_AAC_HE ((SLuint32) 0x00000005)
-#define SL_AUDIOMODE_AAC_SCALABLE ((SLuint32) 0x00000006)
-#define SL_AUDIOMODE_AAC_ERLC ((SLuint32) 0x00000007)
-#define SL_AUDIOMODE_AAC_LD ((SLuint32) 0x00000008)
-#define SL_AUDIOMODE_AAC_HE_PS ((SLuint32) 0x00000009)
-#define SL_AUDIOMODE_AAC_HE_MPS ((SLuint32) 0x0000000A)
-
-#define SL_AUDIOSTREAMFORMAT_MP2ADTS ((SLuint32) 0x00000001)
-#define SL_AUDIOSTREAMFORMAT_MP4ADTS ((SLuint32) 0x00000002)
-#define SL_AUDIOSTREAMFORMAT_MP4LOAS ((SLuint32) 0x00000003)
-#define SL_AUDIOSTREAMFORMAT_MP4LATM ((SLuint32) 0x00000004)
-#define SL_AUDIOSTREAMFORMAT_ADIF ((SLuint32) 0x00000005)
-#define SL_AUDIOSTREAMFORMAT_MP4FF ((SLuint32) 0x00000006)
-#define SL_AUDIOSTREAMFORMAT_RAW ((SLuint32) 0x00000007)
-
-#define SL_AUDIOPROFILE_WMA7 ((SLuint32) 0x00000001)
-#define SL_AUDIOPROFILE_WMA8 ((SLuint32) 0x00000002)
-#define SL_AUDIOPROFILE_WMA9 ((SLuint32) 0x00000003)
-#define SL_AUDIOPROFILE_WMA10 ((SLuint32) 0x00000004)
-
-#define SL_AUDIOMODE_WMA_LEVEL1 ((SLuint32) 0x00000001)
-#define SL_AUDIOMODE_WMA_LEVEL2 ((SLuint32) 0x00000002)
-#define SL_AUDIOMODE_WMA_LEVEL3 ((SLuint32) 0x00000003)
-#define SL_AUDIOMODE_WMA_LEVEL4 ((SLuint32) 0x00000004)
-#define SL_AUDIOMODE_WMAPRO_LEVELM0 ((SLuint32) 0x00000005)
-#define SL_AUDIOMODE_WMAPRO_LEVELM1 ((SLuint32) 0x00000006)
-#define SL_AUDIOMODE_WMAPRO_LEVELM2 ((SLuint32) 0x00000007)
-#define SL_AUDIOMODE_WMAPRO_LEVELM3 ((SLuint32) 0x00000008)
-
-#define SL_AUDIOPROFILE_REALAUDIO ((SLuint32) 0x00000001)
-
-#define SL_AUDIOMODE_REALAUDIO_G2 ((SLuint32) 0x00000001)
-#define SL_AUDIOMODE_REALAUDIO_8 ((SLuint32) 0x00000002)
-#define SL_AUDIOMODE_REALAUDIO_10 ((SLuint32) 0x00000003)
-#define SL_AUDIOMODE_REALAUDIO_SURROUND ((SLuint32) 0x00000004)
-
-typedef struct SLAudioCodecDescriptor_ {
- SLuint32 maxChannels;
- SLuint32 minBitsPerSample;
- SLuint32 maxBitsPerSample;
- SLmilliHertz minSampleRate;
- SLmilliHertz maxSampleRate;
- SLboolean isFreqRangeContinuous;
- SLmilliHertz *pSampleRatesSupported;
- SLuint32 numSampleRatesSupported;
- SLuint32 minBitRate;
- SLuint32 maxBitRate;
- SLboolean isBitrateRangeContinuous;
- SLuint32 *pBitratesSupported;
- SLuint32 numBitratesSupported;
- SLuint32 profileSetting;
- SLuint32 modeSetting;
-} SLAudioCodecDescriptor;
-
-/*Structure used to retrieve the profile and level settings supported by an audio encoder */
-
-typedef struct SLAudioCodecProfileMode_ {
- SLuint32 profileSetting;
- SLuint32 modeSetting;
-} SLAudioCodecProfileMode;
-
-extern SL_API const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES;
-
-struct SLAudioDecoderCapabilitiesItf_;
-typedef const struct SLAudioDecoderCapabilitiesItf_ * const * SLAudioDecoderCapabilitiesItf;
-
-struct SLAudioDecoderCapabilitiesItf_ {
- SLresult (*GetAudioDecoders) (
- SLAudioDecoderCapabilitiesItf self,
- SLuint32 * pNumDecoders ,
- SLuint32 *pDecoderIds
- );
- SLresult (*GetAudioDecoderCapabilities) (
- SLAudioDecoderCapabilitiesItf self,
- SLuint32 decoderId,
- SLuint32 *pIndex,
- SLAudioCodecDescriptor *pDescriptor
- );
-};
-
-
-
-
-/*---------------------------------------------------------------------------*/
-/* Audio Encoder Capabilities Interface */
-/* --------------------------------------------------------------------------*/
-
-/* Structure used when setting audio encoding parameters */
-
-typedef struct SLAudioEncoderSettings_ {
- SLuint32 encoderId;
- SLuint32 channelsIn;
- SLuint32 channelsOut;
- SLmilliHertz sampleRate;
- SLuint32 bitRate;
- SLuint32 bitsPerSample;
- SLuint32 rateControl;
- SLuint32 profileSetting;
- SLuint32 levelSetting;
- SLuint32 channelMode;
- SLuint32 streamFormat;
- SLuint32 encodeOptions;
- SLuint32 blockAlignment;
-} SLAudioEncoderSettings;
-
-extern SL_API const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES;
-
-struct SLAudioEncoderCapabilitiesItf_;
-typedef const struct SLAudioEncoderCapabilitiesItf_ * const * SLAudioEncoderCapabilitiesItf;
-
-struct SLAudioEncoderCapabilitiesItf_ {
- SLresult (*GetAudioEncoders) (
- SLAudioEncoderCapabilitiesItf self,
- SLuint32 *pNumEncoders ,
- SLuint32 *pEncoderIds
- );
- SLresult (*GetAudioEncoderCapabilities) (
- SLAudioEncoderCapabilitiesItf self,
- SLuint32 encoderId,
- SLuint32 *pIndex,
- SLAudioCodecDescriptor * pDescriptor
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Audio Encoder Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_AUDIOENCODER;
-
-struct SLAudioEncoderItf_;
-typedef const struct SLAudioEncoderItf_ * const * SLAudioEncoderItf;
-
-struct SLAudioEncoderItf_ {
- SLresult (*SetEncoderSettings) (
- SLAudioEncoderItf self,
- SLAudioEncoderSettings *pSettings
- );
- SLresult (*GetEncoderSettings) (
- SLAudioEncoderItf self,
- SLAudioEncoderSettings *pSettings
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Bass Boost Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_BASSBOOST;
-
-struct SLBassBoostItf_;
-typedef const struct SLBassBoostItf_ * const * SLBassBoostItf;
-
-struct SLBassBoostItf_ {
- SLresult (*SetEnabled)(
- SLBassBoostItf self,
- SLboolean enabled
- );
- SLresult (*IsEnabled)(
- SLBassBoostItf self,
- SLboolean *pEnabled
- );
- SLresult (*SetStrength)(
- SLBassBoostItf self,
- SLpermille strength
- );
- SLresult (*GetRoundedStrength)(
- SLBassBoostItf self,
- SLpermille *pStrength
- );
- SLresult (*IsStrengthSupported)(
- SLBassBoostItf self,
- SLboolean *pSupported
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Pitch Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_PITCH;
-
-struct SLPitchItf_;
-typedef const struct SLPitchItf_ * const * SLPitchItf;
-
-struct SLPitchItf_ {
- SLresult (*SetPitch) (
- SLPitchItf self,
- SLpermille pitch
- );
- SLresult (*GetPitch) (
- SLPitchItf self,
- SLpermille *pPitch
- );
- SLresult (*GetPitchCapabilities) (
- SLPitchItf self,
- SLpermille *pMinPitch,
- SLpermille *pMaxPitch
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Rate Pitch Interface */
-/* RatePitchItf is an interface for controlling the rate a sound is played */
-/* back. A change in rate will cause a change in pitch. */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_RATEPITCH;
-
-struct SLRatePitchItf_;
-typedef const struct SLRatePitchItf_ * const * SLRatePitchItf;
-
-struct SLRatePitchItf_ {
- SLresult (*SetRate) (
- SLRatePitchItf self,
- SLpermille rate
- );
- SLresult (*GetRate) (
- SLRatePitchItf self,
- SLpermille *pRate
- );
- SLresult (*GetRatePitchCapabilities) (
- SLRatePitchItf self,
- SLpermille *pMinRate,
- SLpermille *pMaxRate
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Virtualizer Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_VIRTUALIZER;
-
-struct SLVirtualizerItf_;
-typedef const struct SLVirtualizerItf_ * const * SLVirtualizerItf;
-
-struct SLVirtualizerItf_ {
- SLresult (*SetEnabled)(
- SLVirtualizerItf self,
- SLboolean enabled
- );
- SLresult (*IsEnabled)(
- SLVirtualizerItf self,
- SLboolean *pEnabled
- );
- SLresult (*SetStrength)(
- SLVirtualizerItf self,
- SLpermille strength
- );
- SLresult (*GetRoundedStrength)(
- SLVirtualizerItf self,
- SLpermille *pStrength
- );
- SLresult (*IsStrengthSupported)(
- SLVirtualizerItf self,
- SLboolean *pSupported
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Visualization Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_VISUALIZATION;
-
-struct SLVisualizationItf_;
-typedef const struct SLVisualizationItf_ * const * SLVisualizationItf;
-
-typedef void (SLAPIENTRY *slVisualizationCallback) (
- void *pContext,
- const SLuint8 waveform[],
- const SLuint8 fft[],
- SLmilliHertz samplerate
-);
-
-struct SLVisualizationItf_{
- SLresult (*RegisterVisualizationCallback)(
- SLVisualizationItf self,
- slVisualizationCallback callback,
- void *pContext,
- SLmilliHertz rate
- );
- SLresult (*GetMaxRate)(
- SLVisualizationItf self,
- SLmilliHertz* pRate
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Engine Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_ENGINE;
-
-struct SLEngineItf_;
-typedef const struct SLEngineItf_ * const * SLEngineItf;
-
-
-struct SLEngineItf_ {
-
- SLresult (*CreateLEDDevice) (
- SLEngineItf self,
- SLObjectItf * pDevice,
- SLuint32 deviceID,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateVibraDevice) (
- SLEngineItf self,
- SLObjectItf * pDevice,
- SLuint32 deviceID,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateAudioPlayer) (
- SLEngineItf self,
- SLObjectItf * pPlayer,
- SLDataSource *pAudioSrc,
- SLDataSink *pAudioSnk,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateAudioRecorder) (
- SLEngineItf self,
- SLObjectItf * pRecorder,
- SLDataSource *pAudioSrc,
- SLDataSink *pAudioSnk,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateMidiPlayer) (
- SLEngineItf self,
- SLObjectItf * pPlayer,
- SLDataSource *pMIDISrc,
- SLDataSource *pBankSrc,
- SLDataSink *pAudioOutput,
- SLDataSink *pVibra,
- SLDataSink *pLEDArray,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateListener) (
- SLEngineItf self,
- SLObjectItf * pListener,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*Create3DGroup) (
- SLEngineItf self,
- SLObjectItf * pGroup,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateOutputMix) (
- SLEngineItf self,
- SLObjectItf * pMix,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateMetadataExtractor) (
- SLEngineItf self,
- SLObjectItf * pMetadataExtractor,
- SLDataSource * pDataSource,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*CreateExtensionObject) (
- SLEngineItf self,
- SLObjectItf * pObject,
- void * pParameters,
- SLuint32 objectID,
- SLuint32 numInterfaces,
- const SLInterfaceID * pInterfaceIds,
- const SLboolean * pInterfaceRequired
- );
- SLresult (*QueryNumSupportedInterfaces) (
- SLEngineItf self,
- SLuint32 objectID,
- SLuint32 * pNumSupportedInterfaces
- );
- SLresult (*QuerySupportedInterfaces) (
- SLEngineItf self,
- SLuint32 objectID,
- SLuint32 index,
- SLInterfaceID * pInterfaceId
- );
- SLresult (*QueryNumSupportedExtensions) (
- SLEngineItf self,
- SLuint32 * pNumExtensions
- );
- SLresult (*QuerySupportedExtension) (
- SLEngineItf self,
- SLuint32 index,
- SLchar * pExtensionName,
- SLint16 * pNameLength
- );
- SLresult (*IsExtensionSupported) (
- SLEngineItf self,
- const SLchar * pExtensionName,
- SLboolean * pSupported
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Engine Capabilities Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_ENGINECAPABILITIES;
-
-struct SLEngineCapabilitiesItf_;
-typedef const struct SLEngineCapabilitiesItf_ * const * SLEngineCapabilitiesItf;
-
-struct SLEngineCapabilitiesItf_ {
- SLresult (*QuerySupportedProfiles) (
- SLEngineCapabilitiesItf self,
- SLuint16 *pProfilesSupported
- );
- SLresult (*QueryAvailableVoices) (
- SLEngineCapabilitiesItf self,
- SLuint16 voiceType,
- SLint16 *pNumMaxVoices,
- SLboolean *pIsAbsoluteMax,
- SLint16 *pNumFreeVoices
- );
- SLresult (*QueryNumberOfMIDISynthesizers) (
- SLEngineCapabilitiesItf self,
- SLint16 *pNumMIDIsynthesizers
- );
- SLresult (*QueryAPIVersion) (
- SLEngineCapabilitiesItf self,
- SLint16 *pMajor,
- SLint16 *pMinor,
- SLint16 *pStep
- );
- SLresult (*QueryLEDCapabilities) (
- SLEngineCapabilitiesItf self,
- SLuint32 *pIndex,
- SLuint32 *pLEDDeviceID,
- SLLEDDescriptor *pDescriptor
- );
- SLresult (*QueryVibraCapabilities) (
- SLEngineCapabilitiesItf self,
- SLuint32 *pIndex,
- SLuint32 *pVibraDeviceID,
- SLVibraDescriptor *pDescriptor
- );
- SLresult (*IsThreadSafe) (
- SLEngineCapabilitiesItf self,
- SLboolean *pIsThreadSafe
- );
-};
-
-/*---------------------------------------------------------------------------*/
-/* Thread Sync Interface */
-/* --------------------------------------------------------------------------*/
-
-
-extern SL_API const SLInterfaceID SL_IID_THREADSYNC;
-
-struct SLThreadSyncItf_;
-typedef const struct SLThreadSyncItf_ * const * SLThreadSyncItf;
-
-
-struct SLThreadSyncItf_ {
- SLresult (*EnterCriticalSection) (
- SLThreadSyncItf self
- );
- SLresult (*ExitCriticalSection) (
- SLThreadSyncItf self
- );
-};
-
-
-/*****************************************************************************/
-/* SL engine constructor */
-/*****************************************************************************/
-
-#define SL_ENGINEOPTION_THREADSAFE ((SLuint32) 0x00000001)
-#define SL_ENGINEOPTION_LOSSOFCONTROL ((SLuint32) 0x00000002)
-
-typedef struct SLEngineOption_ {
- SLuint32 feature;
- SLuint32 data;
-} SLEngineOption;
-
-
-SL_API SLresult SLAPIENTRY slCreateEngine(
- SLObjectItf *pEngine,
- SLuint32 numOptions,
- const SLEngineOption *pEngineOptions,
- SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds,
- const SLboolean * pInterfaceRequired
-);
-
-SL_API SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces(
- SLuint32 * pNumSupportedInterfaces
-);
-
-SL_API SLresult SLAPIENTRY slQuerySupportedEngineInterfaces(
- SLuint32 index,
- SLInterfaceID * pInterfaceId
-);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* OPENSL_ES_H_ */
diff --git a/wilhelm/include/SLES/OpenSLES_Android.h b/wilhelm/include/SLES/OpenSLES_Android.h
deleted file mode 100644
index f295518..0000000
--- a/wilhelm/include/SLES/OpenSLES_Android.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef OPENSL_ES_ANDROID_H_
-#define OPENSL_ES_ANDROID_H_
-
-#include "OpenSLES_AndroidConfiguration.h"
-#include "OpenSLES_AndroidMetadata.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*---------------------------------------------------------------------------*/
-/* Android common types */
-/*---------------------------------------------------------------------------*/
-
-typedef sl_int64_t SLAint64; /* 64 bit signed integer */
-
-typedef sl_uint64_t SLAuint64; /* 64 bit unsigned integer */
-
-/*---------------------------------------------------------------------------*/
-/* Android Effect interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECT;
-
-/** Android Effect interface methods */
-
-struct SLAndroidEffectItf_;
-typedef const struct SLAndroidEffectItf_ * const * SLAndroidEffectItf;
-
-struct SLAndroidEffectItf_ {
-
- SLresult (*CreateEffect) (SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId);
-
- SLresult (*ReleaseEffect) (SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId);
-
- SLresult (*SetEnabled) (SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId,
- SLboolean enabled);
-
- SLresult (*IsEnabled) (SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId,
- SLboolean *pEnabled);
-
- SLresult (*SendCommand) (SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId,
- SLuint32 command,
- SLuint32 commandSize,
- void *pCommandData,
- SLuint32 *replySize,
- void *pReplyData);
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Effect Send interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTSEND;
-
-/** Android Effect Send interface methods */
-
-struct SLAndroidEffectSendItf_;
-typedef const struct SLAndroidEffectSendItf_ * const * SLAndroidEffectSendItf;
-
-struct SLAndroidEffectSendItf_ {
- SLresult (*EnableEffectSend) (
- SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId,
- SLboolean enable,
- SLmillibel initialLevel
- );
- SLresult (*IsEnabled) (
- SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId,
- SLboolean *pEnable
- );
- SLresult (*SetDirectLevel) (
- SLAndroidEffectSendItf self,
- SLmillibel directLevel
- );
- SLresult (*GetDirectLevel) (
- SLAndroidEffectSendItf self,
- SLmillibel *pDirectLevel
- );
- SLresult (*SetSendLevel) (
- SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId,
- SLmillibel sendLevel
- );
- SLresult (*GetSendLevel)(
- SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId,
- SLmillibel *pSendLevel
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Effect Capabilities interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES;
-
-/** Android Effect Capabilities interface methods */
-
-struct SLAndroidEffectCapabilitiesItf_;
-typedef const struct SLAndroidEffectCapabilitiesItf_ * const * SLAndroidEffectCapabilitiesItf;
-
-struct SLAndroidEffectCapabilitiesItf_ {
-
- SLresult (*QueryNumEffects) (SLAndroidEffectCapabilitiesItf self,
- SLuint32 *pNumSupportedEffects);
-
-
- SLresult (*QueryEffect) (SLAndroidEffectCapabilitiesItf self,
- SLuint32 index,
- SLInterfaceID *pEffectType,
- SLInterfaceID *pEffectImplementation,
- SLchar *pName,
- SLuint16 *pNameSize);
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Configuration interface */
-/*---------------------------------------------------------------------------*/
-extern SL_API const SLInterfaceID SL_IID_ANDROIDCONFIGURATION;
-
-/** Android Configuration interface methods */
-
-struct SLAndroidConfigurationItf_;
-typedef const struct SLAndroidConfigurationItf_ * const * SLAndroidConfigurationItf;
-
-struct SLAndroidConfigurationItf_ {
-
- SLresult (*SetConfiguration) (SLAndroidConfigurationItf self,
- const SLchar *configKey,
- const void *pConfigValue,
- SLuint32 valueSize);
-
- SLresult (*GetConfiguration) (SLAndroidConfigurationItf self,
- const SLchar *configKey,
- SLuint32 *pValueSize,
- void *pConfigValue
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Simple Buffer Queue Interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
-
-struct SLAndroidSimpleBufferQueueItf_;
-typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf;
-
-typedef void (SLAPIENTRY *slAndroidSimpleBufferQueueCallback)(
- SLAndroidSimpleBufferQueueItf caller,
- void *pContext
-);
-
-/** Android simple buffer queue state **/
-
-typedef struct SLAndroidSimpleBufferQueueState_ {
- SLuint32 count;
- SLuint32 index;
-} SLAndroidSimpleBufferQueueState;
-
-
-struct SLAndroidSimpleBufferQueueItf_ {
- SLresult (*Enqueue) (
- SLAndroidSimpleBufferQueueItf self,
- const void *pBuffer,
- SLuint32 size
- );
- SLresult (*Clear) (
- SLAndroidSimpleBufferQueueItf self
- );
- SLresult (*GetState) (
- SLAndroidSimpleBufferQueueItf self,
- SLAndroidSimpleBufferQueueState *pState
- );
- SLresult (*RegisterCallback) (
- SLAndroidSimpleBufferQueueItf self,
- slAndroidSimpleBufferQueueCallback callback,
- void* pContext
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Buffer Queue Interface */
-/*---------------------------------------------------------------------------*/
-
-extern SL_API const SLInterfaceID SL_IID_ANDROIDBUFFERQUEUESOURCE;
-
-struct SLAndroidBufferQueueItf_;
-typedef const struct SLAndroidBufferQueueItf_ * const * SLAndroidBufferQueueItf;
-
-#define SL_ANDROID_ITEMKEY_NONE ((SLuint32) 0x00000000)
-#define SL_ANDROID_ITEMKEY_EOS ((SLuint32) 0x00000001)
-#define SL_ANDROID_ITEMKEY_DISCONTINUITY ((SLuint32) 0x00000002)
-#define SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT ((SLuint32) 0x00000003)
-#define SL_ANDROID_ITEMKEY_FORMAT_CHANGE ((SLuint32) 0x00000004)
-
-#define SL_ANDROIDBUFFERQUEUEEVENT_NONE ((SLuint32) 0x00000000)
-#define SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED ((SLuint32) 0x00000001)
-#if 0 // reserved for future use
-#define SL_ANDROIDBUFFERQUEUEEVENT_UNREALIZED ((SLuint32) 0x00000002)
-#define SL_ANDROIDBUFFERQUEUEEVENT_CLEARED ((SLuint32) 0x00000004)
-#define SL_ANDROIDBUFFERQUEUEEVENT_STOPPED ((SLuint32) 0x00000008)
-#define SL_ANDROIDBUFFERQUEUEEVENT_ERROR ((SLuint32) 0x00000010)
-#define SL_ANDROIDBUFFERQUEUEEVENT_CONTENT_END ((SLuint32) 0x00000020)
-#endif
-
-typedef struct SLAndroidBufferItem_ {
- SLuint32 itemKey; // identifies the item
- SLuint32 itemSize;
- SLuint8 itemData[0];
-} SLAndroidBufferItem;
-
-typedef SLresult (SLAPIENTRY *slAndroidBufferQueueCallback)(
- SLAndroidBufferQueueItf caller,/* input */
- void *pCallbackContext, /* input */
- void *pBufferContext, /* input */
- void *pBufferData, /* input */
- SLuint32 dataSize, /* input */
- SLuint32 dataUsed, /* input */
- const SLAndroidBufferItem *pItems,/* input */
- SLuint32 itemsLength /* input */
-);
-
-typedef struct SLAndroidBufferQueueState_ {
- SLuint32 count;
- SLuint32 index;
-} SLAndroidBufferQueueState;
-
-struct SLAndroidBufferQueueItf_ {
- SLresult (*RegisterCallback) (
- SLAndroidBufferQueueItf self,
- slAndroidBufferQueueCallback callback,
- void* pCallbackContext
- );
-
- SLresult (*Clear) (
- SLAndroidBufferQueueItf self
- );
-
- SLresult (*Enqueue) (
- SLAndroidBufferQueueItf self,
- void *pBufferContext,
- void *pData,
- SLuint32 dataLength,
- const SLAndroidBufferItem *pItems,
- SLuint32 itemsLength
- );
-
- SLresult (*GetState) (
- SLAndroidBufferQueueItf self,
- SLAndroidBufferQueueState *pState
- );
-
- SLresult (*SetCallbackEventsMask) (
- SLAndroidBufferQueueItf self,
- SLuint32 eventFlags
- );
-
- SLresult (*GetCallbackEventsMask) (
- SLAndroidBufferQueueItf self,
- SLuint32 *pEventFlags
- );
-};
-
-
-/*---------------------------------------------------------------------------*/
-/* Android File Descriptor Data Locator */
-/*---------------------------------------------------------------------------*/
-
-/** Addendum to Data locator macros */
-#define SL_DATALOCATOR_ANDROIDFD ((SLuint32) 0x800007BC)
-
-#define SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ((SLAint64) 0xFFFFFFFFFFFFFFFFll)
-
-/** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */
-typedef struct SLDataLocator_AndroidFD_ {
- SLuint32 locatorType;
- SLint32 fd;
- SLAint64 offset;
- SLAint64 length;
-} SLDataLocator_AndroidFD;
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Android Simple Buffer Queue Data Locator */
-/*---------------------------------------------------------------------------*/
-
-/** Addendum to Data locator macros */
-#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD)
-
-/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE*/
-typedef struct SLDataLocator_AndroidSimpleBufferQueue {
- SLuint32 locatorType;
- SLuint32 numBuffers;
-} SLDataLocator_AndroidSimpleBufferQueue;
-
-
-/*---------------------------------------------------------------------------*/
-/* Android Buffer Queue Data Locator */
-/*---------------------------------------------------------------------------*/
-
-/** Addendum to Data locator macros */
-#define SL_DATALOCATOR_ANDROIDBUFFERQUEUE ((SLuint32) 0x800007BE)
-
-/** Android Buffer Queue-based data locator definition,
- * locatorType must be SL_DATALOCATOR_ANDROIDBUFFERQUEUE */
-typedef struct SLDataLocator_AndroidBufferQueue_ {
- SLuint32 locatorType;
- SLuint32 numBuffers;
-} SLDataLocator_AndroidBufferQueue;
-
-/**
- * MIME types required for data in Android Buffer Queues
- */
-#define SL_ANDROID_MIME_AACADTS ((SLchar *) "audio/vnd.android.aac-adts")
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* OPENSL_ES_ANDROID_H_ */
diff --git a/wilhelm/include/SLES/OpenSLES_AndroidConfiguration.h b/wilhelm/include/SLES/OpenSLES_AndroidConfiguration.h
deleted file mode 100644
index 01f460d..0000000
--- a/wilhelm/include/SLES/OpenSLES_AndroidConfiguration.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef OPENSL_ES_ANDROIDCONFIGURATION_H_
-#define OPENSL_ES_ANDROIDCONFIGURATION_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*---------------------------------------------------------------------------*/
-/* Android AudioRecorder configuration */
-/*---------------------------------------------------------------------------*/
-
-/** Audio recording preset */
-/** Audio recording preset key */
-#define SL_ANDROID_KEY_RECORDING_PRESET ((const SLchar*) "androidRecordingPreset")
-/** Audio recording preset values */
-/** preset "none" cannot be set, it is used to indicate the current settings
- * do not match any of the presets. */
-#define SL_ANDROID_RECORDING_PRESET_NONE ((SLuint32) 0x00000000)
-/** generic recording configuration on the platform */
-#define SL_ANDROID_RECORDING_PRESET_GENERIC ((SLuint32) 0x00000001)
-/** uses the microphone audio source with the same orientation as the camera
- * if available, the main device microphone otherwise */
-#define SL_ANDROID_RECORDING_PRESET_CAMCORDER ((SLuint32) 0x00000002)
-/** uses the main microphone tuned for voice recognition */
-#define SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION ((SLuint32) 0x00000003)
-/** uses the main microphone tuned for audio communications */
-#define SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION ((SLuint32) 0x00000004)
-
-/*---------------------------------------------------------------------------*/
-/* Android AudioPlayer configuration */
-/*---------------------------------------------------------------------------*/
-
-/** Audio playback stream type */
-/** Audio playback stream type key */
-#define SL_ANDROID_KEY_STREAM_TYPE ((const SLchar*) "androidPlaybackStreamType")
-
-/** Audio playback stream type values */
-/* same as android.media.AudioManager.STREAM_VOICE_CALL */
-#define SL_ANDROID_STREAM_VOICE ((SLint32) 0x00000000)
-/* same as android.media.AudioManager.STREAM_SYSTEM */
-#define SL_ANDROID_STREAM_SYSTEM ((SLint32) 0x00000001)
-/* same as android.media.AudioManager.STREAM_RING */
-#define SL_ANDROID_STREAM_RING ((SLint32) 0x00000002)
-/* same as android.media.AudioManager.STREAM_MUSIC */
-#define SL_ANDROID_STREAM_MEDIA ((SLint32) 0x00000003)
-/* same as android.media.AudioManager.STREAM_ALARM */
-#define SL_ANDROID_STREAM_ALARM ((SLint32) 0x00000004)
-/* same as android.media.AudioManager.STREAM_NOTIFICATION */
-#define SL_ANDROID_STREAM_NOTIFICATION ((SLint32) 0x00000005)
-
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* OPENSL_ES_ANDROIDCONFIGURATION_H_ */
diff --git a/wilhelm/include/SLES/OpenSLES_AndroidMetadata.h b/wilhelm/include/SLES/OpenSLES_AndroidMetadata.h
deleted file mode 100644
index 01e33b8..0000000
--- a/wilhelm/include/SLES/OpenSLES_AndroidMetadata.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef OPENSL_ES_ANDROIDMETADATA_H_
-#define OPENSL_ES_ANDROIDMETADATA_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*---------------------------------------------------------------------------*/
-/* Android metadata keys */
-/*---------------------------------------------------------------------------*/
-
-/**
- * Additional metadata keys to be used in SLMetadataExtractionItf:
- * the ANDROID_KEY_PCMFORMAT_* keys follow the fields of the SLDataFormat_PCM struct, and as such
- * all values corresponding to these keys are of SLuint32 type, and are defined as the fields
- * of the same name in SLDataFormat_PCM. The exception is that sample rate is expressed here
- * in Hz units, rather than in milliHz units.
- */
-#define ANDROID_KEY_PCMFORMAT_NUMCHANNELS "AndroidPcmFormatNumChannels"
-#define ANDROID_KEY_PCMFORMAT_SAMPLERATE "AndroidPcmFormatSampleRate"
-#define ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE "AndroidPcmFormatBitsPerSample"
-#define ANDROID_KEY_PCMFORMAT_CONTAINERSIZE "AndroidPcmFormatContainerSize"
-#define ANDROID_KEY_PCMFORMAT_CHANNELMASK "AndroidPcmFormatChannelMask"
-#define ANDROID_KEY_PCMFORMAT_ENDIANNESS "AndroidPcmFormatEndianness"
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* OPENSL_ES_ANDROIDMETADATA_H_ */
diff --git a/wilhelm/include/SLES/OpenSLES_Platform.h b/wilhelm/include/SLES/OpenSLES_Platform.h
deleted file mode 100644
index 527693d..0000000
--- a/wilhelm/include/SLES/OpenSLES_Platform.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2007-2009 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and /or associated documentation files (the "Materials "), to
- * deal in the Materials without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Materials, and to permit persons to whom the Materials are
- * furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE
- * MATERIALS.
- *
- * OpenSLES_Platform.h - OpenSL ES version 1.0
- *
- */
-
-/****************************************************************************/
-/* NOTE: This file contains definitions for the base types and the */
-/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */
-/* the correct definitions specific to the platform being used. */
-/****************************************************************************/
-
-#ifndef _OPENSLES_PLATFORM_H_
-#define _OPENSLES_PLATFORM_H_
-
-typedef unsigned char sl_uint8_t;
-typedef signed char sl_int8_t;
-typedef unsigned short sl_uint16_t;
-typedef signed short sl_int16_t;
-typedef unsigned int /*long*/ sl_uint32_t;
-typedef signed int /*long*/ sl_int32_t;
-typedef long long sl_int64_t;
-typedef unsigned long long sl_uint64_t;
-
-#ifndef SL_API
-#ifdef __GNUC__
-#define SL_API /* override per-platform */
-#else
-#define SL_API __declspec(dllimport)
-#endif
-#endif
-
-#ifndef SLAPIENTRY
-#define SLAPIENTRY
-#endif
-
-#endif /* _OPENSLES_PLATFORM_H_ */
diff --git a/wilhelm/src/Android.mk b/wilhelm/src/Android.mk
deleted file mode 100644
index 94c99a5..0000000
--- a/wilhelm/src/Android.mk
+++ /dev/null
@@ -1,226 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- assert.c \
- ut/OpenSLESUT.c \
- ut/slesutResult.c
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_CFLAGS += -fvisibility=hidden -UNDEBUG
-
-LOCAL_MODULE := libOpenSLESUT
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_CFLAGS += -Wno-override-init
-# -Wno-missing-field-initializers
-# optional, see comments in MPH_to.c: -DUSE_DESIGNATED_INITIALIZERS -S
-LOCAL_CFLAGS += -DUSE_DESIGNATED_INITIALIZERS -UNDEBUG
-
-LOCAL_SRC_FILES:= \
- assert.c \
- MPH_to.c \
- handlers.c
-
-LOCAL_MODULE:= libopensles_helper
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-# do not claim support for any OpenSL ES or OpenMAX AL profiles
-LOCAL_CFLAGS += -DUSE_PROFILES=0
-
-# enable API logging; details are set separately by SL_TRACE_DEFAULT below
-LOCAL_CFLAGS += -DUSE_TRACE
-# or -UUSE_TRACE to disable API logging
-
-# enable mutex deadlock detection
-LOCAL_CFLAGS += -DUSE_DEBUG
-# or -UUSE_DEBUG for no mutex deadlock detection
-
-# enable assert() to do runtime checking
-LOCAL_CFLAGS += -UNDEBUG
-# or -DNDEBUG for no runtime checking
-
-# select the level of log messages
-LOCAL_CFLAGS += -DUSE_LOG=SLAndroidLogLevel_Info
-# or -DUSE_LOG=SLAndroidLogLevel_Verbose for verbose logging
-
-# log all API entries and exits
-# LOCAL_CFLAGS += -DSL_TRACE_DEFAULT=SL_TRACE_ALL
-# (otherwise a warning log on error results only)
-
-# API level
-LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
-
-# Reduce size of .so and hide internal global symbols
-LOCAL_CFLAGS += -fvisibility=hidden -DLI_API='__attribute__((visibility("default")))'
-
-LOCAL_SRC_FILES:= \
- OpenSLES_IID.c \
- assert.c \
- classes.c \
- data.c \
- devices.c \
- entry.c \
- handler_bodies.c \
- trace.c \
- locks.c \
- sles.c \
- sl_iid.c \
- sllog.c \
- ThreadPool.c \
- android/AudioPlayer_to_android.cpp \
- android/AudioRecorder_to_android.cpp \
- android/MediaPlayer_to_android.cpp \
- android/OutputMix_to_android.cpp \
- android/VideoCodec_to_android.cpp \
- android/BufferQueueSource.cpp \
- android/CallbackProtector.cpp \
- android/AacBqToPcmCbRenderer.cpp \
- android/android_AudioSfDecoder.cpp \
- android/android_AudioToCbRenderer.cpp \
- android/android_GenericMediaPlayer.cpp\
- android/android_GenericPlayer.cpp \
- android/android_LocAVPlayer.cpp \
- android/android_StreamPlayer.cpp \
- android/android_Effect.cpp \
- android/util/AacAdtsExtractor.cpp \
- autogen/IID_to_MPH.c \
- objects/C3DGroup.c \
- objects/CAudioPlayer.c \
- objects/CAudioRecorder.c \
- objects/CEngine.c \
- objects/COutputMix.c \
- objects/CMediaPlayer.c \
- itf/IAndroidBufferQueue.c \
- itf/IAndroidConfiguration.c \
- itf/IAndroidEffect.cpp \
- itf/IAndroidEffectCapabilities.c \
- itf/IAndroidEffectSend.c \
- itf/IBassBoost.c \
- itf/IBufferQueue.c \
- itf/IDynamicInterfaceManagement.c \
- itf/IEffectSend.c \
- itf/IEngine.c \
- itf/IEngineCapabilities.c \
- itf/IEnvironmentalReverb.c \
- itf/IEqualizer.c \
- itf/IMetadataExtraction.c \
- itf/IMuteSolo.c \
- itf/IObject.c \
- itf/IOutputMix.c \
- itf/IPlay.c \
- itf/IPlaybackRate.c \
- itf/IPrefetchStatus.c \
- itf/IPresetReverb.c \
- itf/IRecord.c \
- itf/ISeek.c \
- itf/IStreamInformation.cpp \
- itf/IVideoDecoderCapabilities.cpp \
- itf/IVirtualizer.c \
- itf/IVolume.c
-
-EXCLUDE_SRC := \
- sync.c \
- itf/I3DCommit.c \
- itf/I3DDoppler.c \
- itf/I3DGrouping.c \
- itf/I3DLocation.c \
- itf/I3DMacroscopic.c \
- itf/I3DSource.c \
- itf/IAudioDecoderCapabilities.c \
- itf/IAudioEncoder.c \
- itf/IAudioEncoderCapabilities.c \
- itf/IAudioIODeviceCapabilities.c \
- itf/IDeviceVolume.c \
- itf/IDynamicSource.c \
- itf/ILEDArray.c \
- itf/IMIDIMessage.c \
- itf/IMIDIMuteSolo.c \
- itf/IMIDITempo.c \
- itf/IMIDITime.c \
- itf/IMetadataTraversal.c \
- itf/IPitch.c \
- itf/IRatePitch.c \
- itf/IThreadSync.c \
- itf/IVibra.c \
- itf/IVisualization.c
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include \
- frameworks/base/media/libstagefright \
- frameworks/base/media/libstagefright/include \
- frameworks/base/include/media/stagefright/openmax \
- system/media/audio_effects/include
-
-# __pthread_gettid
-LOCAL_C_INCLUDES += bionic/libc/private
-
-LOCAL_CFLAGS += -x c++ -Wno-multichar -Wno-invalid-offsetof
-
-LOCAL_STATIC_LIBRARIES += \
- libopensles_helper \
- libOpenSLESUT
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libmedia \
- libbinder \
- libstagefright \
- libstagefright_foundation \
- libcutils \
- libgui \
- libdl
-
-
-
-LOCAL_MODULE := libwilhelm
-LOCAL_MODULE_TAGS := optional
-
-ifeq ($(TARGET_BUILD_VARIANT),userdebug)
- LOCAL_CFLAGS += -DUSERDEBUG_BUILD=1
-endif
-
-LOCAL_PRELINK_MODULE := false
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := sl_entry.c sl_iid.c assert.c
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include \
- frameworks/base/media/libstagefright \
- frameworks/base/media/libstagefright/include \
- frameworks/base/include/media/stagefright/openmax
-LOCAL_MODULE := libOpenSLES
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS += -x c++ -DLI_API= -fvisibility=hidden -UNDEBUG \
- -DSL_API='__attribute__((visibility("default")))'
-LOCAL_SHARED_LIBRARIES := libwilhelm liblog
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := xa_entry.c xa_iid.c assert.c
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include \
- frameworks/base/media/libstagefright \
- frameworks/base/media/libstagefright/include \
- frameworks/base/include/media/stagefright/openmax
-LOCAL_MODULE := libOpenMAXAL
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS += -x c++ -DLI_API= -fvisibility=hidden -UNDEBUG \
- -DXA_API='__attribute__((visibility("default")))'
-LOCAL_SHARED_LIBRARIES := libwilhelm liblog
-include $(BUILD_SHARED_LIBRARY)
diff --git a/wilhelm/src/MPH.h b/wilhelm/src/MPH.h
deleted file mode 100644
index f822390..0000000
--- a/wilhelm/src/MPH.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MPH_H
-#define __MPH_H
-
-// Minimal perfect hash for each interface ID
-
-#define MPH_NONE (-1)
-#define MPH_MIN 0
-
-// OpenSL ES 1.0.1 interfaces
-#define MPH_3DCOMMIT 0
-#define MPH_3DDOPPLER 1
-#define MPH_3DGROUPING 2
-#define MPH_3DLOCATION 3
-#define MPH_3DMACROSCOPIC 4
-#define MPH_3DSOURCE 5
-#define MPH_AUDIODECODERCAPABILITIES 6
-#define MPH_AUDIOENCODER 7
-#define MPH_AUDIOENCODERCAPABILITIES 8
-#define MPH_AUDIOIODEVICECAPABILITIES 9
-#define MPH_BASSBOOST 10
-#define MPH_BUFFERQUEUE 11
-#define MPH_DEVICEVOLUME 12
-#define MPH_DYNAMICINTERFACEMANAGEMENT 13
-#define MPH_DYNAMICSOURCE 14
-#define MPH_EFFECTSEND 15
-#define MPH_ENGINE 16
-#define MPH_ENGINECAPABILITIES 17
-#define MPH_ENVIRONMENTALREVERB 18
-#define MPH_EQUALIZER 19
-#define MPH_LED 20
-#define MPH_METADATAEXTRACTION 21
-#define MPH_METADATATRAVERSAL 22
-#define MPH_MIDIMESSAGE 23
-#define MPH_MIDIMUTESOLO 24
-#define MPH_MIDITEMPO 25
-#define MPH_MIDITIME 26
-#define MPH_MUTESOLO 27
-#define MPH_NULL 28 // shared by SL and XA
-#define MPH_OBJECT 29
-#define MPH_OUTPUTMIX 30
-#define MPH_PITCH 31
-#define MPH_PLAY 32
-#define MPH_PLAYBACKRATE 33
-#define MPH_PREFETCHSTATUS 34
-#define MPH_PRESETREVERB 35
-#define MPH_RATEPITCH 36
-#define MPH_RECORD 37
-#define MPH_SEEK 38
-#define MPH_THREADSYNC 39
-#define MPH_VIBRA 40
-#define MPH_VIRTUALIZER 41
-#define MPH_VISUALIZATION 42
-#define MPH_VOLUME 43
-
-// Wilhelm desktop extended interfaces
-#define MPH_OUTPUTMIXEXT 44
-
-// Android API level 9 extended interfaces
-// GUID and MPH are shared by SL and XA, but currently documented for SL only
-#define MPH_ANDROIDEFFECT 45
-#define MPH_ANDROIDEFFECTCAPABILITIES 46
-#define MPH_ANDROIDEFFECTSEND 47
-#define MPH_ANDROIDCONFIGURATION 48
-#define MPH_ANDROIDSIMPLEBUFFERQUEUE 49
-
-// Android API level 12 extended interfaces
-// GUID and MPH are shared by SL and XA, but currently documented for XA only
-#define MPH_ANDROIDBUFFERQUEUESOURCE 50
-
-// OpenMAX AL 1.0.1 interfaces
-#define MPH_XAAUDIODECODERCAPABILITIES 51
-#define MPH_XAAUDIOENCODER 52
-#define MPH_XAAUDIOENCODERCAPABILITIES 53
-#define MPH_XAAUDIOIODEVICECAPABILITIES 54
-#define MPH_XACAMERA 55
-#define MPH_XACAMERACAPABILITIES 56
-#define MPH_XACONFIGEXTENSION 57
-#define MPH_XADEVICEVOLUME 58
-#define MPH_XADYNAMICINTERFACEMANAGEMENT 59
-#define MPH_XADYNAMICSOURCE 60
-#define MPH_XAENGINE 61
-#define MPH_XAEQUALIZER 62
-#define MPH_XAIMAGECONTROLS 63
-#define MPH_XAIMAGEDECODERCAPABILITIES 64
-#define MPH_XAIMAGEEFFECTS 65
-#define MPH_XAIMAGEENCODER 66
-#define MPH_XAIMAGEENCODERCAPABILITIES 67
-#define MPH_XALED 68
-#define MPH_XAMETADATAEXTRACTION 69
-#define MPH_XAMETADATAINSERTION 70
-#define MPH_XAMETADATATRAVERSAL 71
-#define MPH_XANULL MPH_NULL
-#define MPH_XAOBJECT 72
-#define MPH_XAOUTPUTMIX 73
-#define MPH_XAPLAY 74
-#define MPH_XAPLAYBACKRATE 75
-#define MPH_XAPREFETCHSTATUS 76
-#define MPH_XARADIO 77
-#define MPH_XARDS 78
-#define MPH_XARECORD 79
-#define MPH_XASEEK 80
-#define MPH_XASNAPSHOT 81
-#define MPH_XASTREAMINFORMATION 82
-#define MPH_XATHREADSYNC 83
-#define MPH_XAVIBRA 84
-#define MPH_XAVIDEODECODERCAPABILITIES 85
-#define MPH_XAVIDEOENCODER 86
-#define MPH_XAVIDEOENCODERCAPABILITIES 87
-#define MPH_XAVIDEOPOSTPROCESSING 88
-#define MPH_XAVOLUME 89
-
-// total number of interface IDs
-#define MPH_MAX 90
-
-#endif // !defined(__MPH_H)
diff --git a/wilhelm/src/MPH_to.c b/wilhelm/src/MPH_to.c
deleted file mode 100644
index 638117a..0000000
--- a/wilhelm/src/MPH_to.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Map minimal perfect hash of an interface ID to its class index.
-
-#include "MPH.h"
-
-// If defined, then compile with C99 such as GNU C, not GNU C++ or non-GNU C.
-//#define USE_DESIGNATED_INITIALIZERS
-
-// It is critical that all entries are populated with either a specific index
-// or -1. Do not let the compiler use a default initializer of zero, because
-// that actually maps to the IObject index. For non-USE_DESIGNATED_INITIALIZERS
-// builds, we use the automagically-generated MPH_to_*.h files for this reason.
-
-// A good test is to use the GNU C compiler with -S option (for assembler output),
-// and compile both with and without USE_DESIGNATED_INITIALIZERS. The resulting .s
-// files should be identical for both compilations.
-
-// Important note: if you add any interfaces here, be sure to also
-// update the #define for the corresponding INTERFACES_<Class>.
-
-// IObject is the first interface in a class, so the index for MPH_OBJECT must be zero.
-// Don't cross streams, otherwise bad things happen.
-
-
-const signed char MPH_to_3DGroup[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_3DLOCATION] = 2,
- [MPH_3DDOPPLER] = 3,
- [MPH_3DSOURCE] = 4,
- [MPH_3DMACROSCOPIC] = 5
-#else
-#include "MPH_to_3DGroup.h"
-#endif
-};
-
-const signed char MPH_to_AudioPlayer[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_PLAY] = 2,
- [MPH_3DDOPPLER] = 3,
- [MPH_3DGROUPING] = 4,
- [MPH_3DLOCATION] = 5,
- [MPH_3DSOURCE] = 6,
- [MPH_BUFFERQUEUE] = 7,
- [MPH_EFFECTSEND] = 8,
- [MPH_MUTESOLO] = 9,
- [MPH_METADATAEXTRACTION] = 10,
- [MPH_METADATATRAVERSAL] = 11,
- [MPH_PREFETCHSTATUS] = 12,
- [MPH_RATEPITCH] = 13,
- [MPH_SEEK] = 14,
- [MPH_VOLUME] = 15,
- [MPH_3DMACROSCOPIC] = 16,
- [MPH_BASSBOOST] = 17,
- [MPH_DYNAMICSOURCE] = 18,
- [MPH_ENVIRONMENTALREVERB] = 19,
- [MPH_EQUALIZER] = 20,
- [MPH_PITCH] = 21,
- [MPH_PRESETREVERB] = 22,
- [MPH_PLAYBACKRATE] = 23,
- [MPH_VIRTUALIZER] = 24,
- [MPH_VISUALIZATION] = 25,
-#ifdef ANDROID
- [MPH_ANDROIDEFFECT] = 26,
- [MPH_ANDROIDEFFECTSEND] = 27,
- [MPH_ANDROIDCONFIGURATION] = 28,
- [MPH_ANDROIDSIMPLEBUFFERQUEUE] = 7, // alias for [MPH_BUFFERQUEUE]
- [MPH_ANDROIDBUFFERQUEUESOURCE] = 29
-#endif
-#else
-#include "MPH_to_AudioPlayer.h"
-#endif
-};
-
-const signed char MPH_to_AudioRecorder[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_RECORD] = 2,
- [MPH_AUDIOENCODER] = 3,
- [MPH_BASSBOOST] = 4,
- [MPH_DYNAMICSOURCE] = 5,
- [MPH_EQUALIZER] = 6,
- [MPH_VISUALIZATION] = 7,
- [MPH_VOLUME] = 8,
-#ifdef ANDROID
- [MPH_ANDROIDSIMPLEBUFFERQUEUE] = 9, // this is not an alias
- [MPH_ANDROIDCONFIGURATION] = 10
-#endif
-#else
-#include "MPH_to_AudioRecorder.h"
-#endif
-};
-
-const signed char MPH_to_Engine[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_ENGINE] = 2,
- [MPH_ENGINECAPABILITIES] = 3,
- [MPH_THREADSYNC] = 4,
- [MPH_AUDIOIODEVICECAPABILITIES] = 5,
- [MPH_AUDIODECODERCAPABILITIES] = 6,
- [MPH_AUDIOENCODERCAPABILITIES] = 7,
- [MPH_3DCOMMIT] = 8,
- [MPH_DEVICEVOLUME] = 9,
- [MPH_XAENGINE] = 10,
-#ifdef ANDROID
- [MPH_ANDROIDEFFECTCAPABILITIES] = 11,
-#endif
- [MPH_XAVIDEODECODERCAPABILITIES] = 12
-#else
-#include "MPH_to_Engine.h"
-#endif
-};
-
-const signed char MPH_to_LEDDevice[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_LED] = 2
-#else
-#include "MPH_to_LEDDevice.h"
-#endif
-};
-
-const signed char MPH_to_Listener[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_3DDOPPLER] = 2,
- [MPH_3DLOCATION] = 3
-#else
-#include "MPH_to_Listener.h"
-#endif
-};
-
-const signed char MPH_to_MetadataExtractor[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_DYNAMICSOURCE] = 2,
- [MPH_METADATAEXTRACTION] = 3,
- [MPH_METADATATRAVERSAL] = 4
-#else
-#include "MPH_to_MetadataExtractor.h"
-#endif
-};
-
-const signed char MPH_to_MidiPlayer[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_PLAY] = 2,
- [MPH_3DDOPPLER] = 3,
- [MPH_3DGROUPING] = 4,
- [MPH_3DLOCATION] = 5,
- [MPH_3DSOURCE] = 6,
- [MPH_BUFFERQUEUE] = 7,
- [MPH_EFFECTSEND] = 8,
- [MPH_MUTESOLO] = 9,
- [MPH_METADATAEXTRACTION] = 10,
- [MPH_METADATATRAVERSAL] = 11,
- [MPH_MIDIMESSAGE] = 12,
- [MPH_MIDITIME] = 13,
- [MPH_MIDITEMPO] = 14,
- [MPH_MIDIMUTESOLO] = 15,
- [MPH_PREFETCHSTATUS] = 16,
- [MPH_SEEK] = 17,
- [MPH_VOLUME] = 18,
- [MPH_3DMACROSCOPIC] = 19,
- [MPH_BASSBOOST] = 20,
- [MPH_DYNAMICSOURCE] = 21,
- [MPH_ENVIRONMENTALREVERB] = 22,
- [MPH_EQUALIZER] = 23,
- [MPH_PITCH] = 24,
- [MPH_PRESETREVERB] = 25,
- [MPH_PLAYBACKRATE] = 26,
- [MPH_VIRTUALIZER] = 27,
- [MPH_VISUALIZATION] = 28,
-#else
-#include "MPH_to_MidiPlayer.h"
-#endif
-};
-
-const signed char MPH_to_OutputMix[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_OUTPUTMIX] = 2,
-#ifdef USE_OUTPUTMIXEXT
- [MPH_OUTPUTMIXEXT] = 3,
-#endif
- [MPH_ENVIRONMENTALREVERB] = 4,
- [MPH_EQUALIZER] = 5,
- [MPH_PRESETREVERB] = 6,
- [MPH_VIRTUALIZER] = 7,
- [MPH_VOLUME] = 8,
- [MPH_BASSBOOST] = 9,
- [MPH_VISUALIZATION] = 10,
-#ifdef ANDROID
- [MPH_ANDROIDEFFECT] = 11
-#endif
-#else
-#include "MPH_to_OutputMix.h"
-#endif
-};
-
-const signed char MPH_to_Vibra[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_OBJECT] = 0,
- [MPH_DYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_VIBRA] = 2
-#else
-#include "MPH_to_Vibra.h"
-#endif
-};
-
-const signed char MPH_to_MediaPlayer[MPH_MAX] = {
-#ifdef USE_DESIGNATED_INITIALIZERS
- [0 ... MPH_MAX-1] = -1,
- [MPH_XAOBJECT] = 0,
- [MPH_XADYNAMICINTERFACEMANAGEMENT] = 1,
- [MPH_XAPLAY] = 2,
- [MPH_XASTREAMINFORMATION] = 3,
- [MPH_XAVOLUME] = 4,
- [MPH_XASEEK] = 5,
- [MPH_XAPREFETCHSTATUS] = 6,
-#ifdef ANDROID
- [MPH_ANDROIDBUFFERQUEUESOURCE] = 7,
-#endif
-#else
-#include "MPH_to_MediaPlayer.h"
-#endif
-};
diff --git a/wilhelm/src/MPH_to.h b/wilhelm/src/MPH_to.h
deleted file mode 100644
index 1dc83c4..0000000
--- a/wilhelm/src/MPH_to.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MPH_to_H
-#define __MPH_to_H
-
-/** \brief Map minimal perfect hash of an interface ID to its class index. */
-
-extern const signed char
- MPH_to_3DGroup[MPH_MAX],
- MPH_to_AudioPlayer[MPH_MAX],
- MPH_to_AudioRecorder[MPH_MAX],
- MPH_to_Engine[MPH_MAX],
- MPH_to_LEDDevice[MPH_MAX],
- MPH_to_Listener[MPH_MAX],
- MPH_to_MetadataExtractor[MPH_MAX],
- MPH_to_MidiPlayer[MPH_MAX],
- MPH_to_OutputMix[MPH_MAX],
- MPH_to_Vibra[MPH_MAX],
- MPH_to_MediaPlayer[MPH_MAX];
-
-/** \brief Maximum number of interfaces on a single object. */
-#define MAX_INDEX 32
-
-#endif // !defined(__MPH_to_H)
diff --git a/wilhelm/src/OpenSLES_IID.c b/wilhelm/src/OpenSLES_IID.c
deleted file mode 100644
index 95f0599..0000000
--- a/wilhelm/src/OpenSLES_IID.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (c) 2007-2009 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and /or associated documentation files (the "Materials "), to
- * deal in the Materials without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Materials, and to permit persons to whom the Materials are
- * furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE
- * MATERIALS.
- *
- * OpenSLES_IID.c - OpenSL ES version 1.0
- *
- */
-
-/****************************************************************************/
-/* NOTE: This file is a standard OpenSL ES file and should not be */
-/* modified in any way. */
-/****************************************************************************/
-
-
-#include <SLES/OpenSLES.h> /* SL Header */
-#include <OMXAL/OpenMAXAL.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h> /* Android-specific SL Header */
-#include <OMXAL/OpenMAXAL_Android.h>/* Android-specific MAX AL Header */
-#endif
-#include "MPH.h"
-
-#ifdef __cplusplus
-LI_API extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];
-#endif
-
-/*****************************************************************************/
-/* Interface IDs */
-/*****************************************************************************/
-
-// Note that the lack of an ifdef on each section is intentional. The entries in this table map
-// to an interface GUID from an MPH (a short-hand representation of the full interface GUID).
-// The presence of an entry does not represent a commitment to support that particular interface.
-
-const struct SLInterfaceID_ SL_IID_array[MPH_MAX] = {
-
-// OpenSL ES 1.0.1 interfaces
-
- // SL_IID_3DCOMMIT
- { 0x3564ad80, 0xdd0f, 0x11db, 0x9e19, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_3DDOPPLER
- { 0xb45c9a80, 0xddd2, 0x11db, 0xb028, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_3DGROUPING
- { 0xebe844e0, 0xddd2, 0x11db, 0xb510, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_3DLOCATION
- { 0x2b878020, 0xddd3, 0x11db, 0x8a01, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_3DMACROSCOPIC
- { 0x5089aec0, 0xddd3, 0x11db, 0x9ad3, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_3DSOURCE
- { 0x70bc7b00, 0xddd3, 0x11db, 0xa873, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_AUDIODECODERCAPABILITIES
- { 0x3fe5a3a0, 0xfcc6, 0x11db, 0x94ac, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_AUDIOENCODER
- { 0xd7d5af7a, 0x351c, 0x41a6, 0x94ec, { 0x1a, 0xc9, 0x5c, 0x71, 0x82, 0x2c } },
- // SL_IID_AUDIOENCODERCAPABILITIES
- { 0x0f52a340, 0xfcd1, 0x11db, 0xa993, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_AUDIOIODEVICECAPABILITIES
- { 0xb2564dc0, 0xddd3, 0x11db, 0xbd62, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_BASSBOOST
- { 0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_BUFFERQUEUE
- { 0x2bc99cc0, 0xddd4, 0x11db, 0x8d99, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_DEVICEVOLUME
- { 0xe1634760, 0xf3e2, 0x11db, 0x9ca9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_DYNAMICINTERFACEMANAGEMENT
- { 0x63936540, 0xf775, 0x11db, 0x9cc4, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_DYNAMICSOURCE
- { 0xc55cc100, 0x038b, 0x11dc, 0xbb45, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_EFFECTSEND
- { 0x56e7d200, 0xddd4, 0x11db, 0xaefb, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_ENGINE
- { 0x8d97c260, 0xddd4, 0x11db, 0x958f, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_ENGINECAPABILITIES
- { 0x8320d0a0, 0xddd5, 0x11db, 0xa1b1, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_ENVIRONMENTALREVERB
- { 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x6, 0x83, 0x9e } },
- // SL_IID_EQUALIZER
- { 0x0bed4300, 0xddd6, 0x11db, 0x8f34, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_LED
- { 0x2cc1cd80, 0xddd6, 0x11db, 0x807e, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_METADATAEXTRACTION
- { 0xaa5b1f80, 0xddd6, 0x11db, 0xac8e, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_METADATATRAVERSAL
- { 0xc43662c0, 0xddd6, 0x11db, 0xa7ab, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_MIDIMESSAGE
- { 0xddf4a820, 0xddd6, 0x11db, 0xb174, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_MIDIMUTESOLO
- { 0x039eaf80, 0xddd7, 0x11db, 0x9a02, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_MIDITEMPO
- { 0x1f347400, 0xddd7, 0x11db, 0xa7ce, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_MIDITIME
- { 0x3da51de0, 0xddd7, 0x11db, 0xaf70, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_MUTESOLO
- { 0x5a28ebe0, 0xddd7, 0x11db, 0x8220, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_NULL
- { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } },
- // SL_IID_OBJECT
- { 0x79216360, 0xddd7, 0x11db, 0xac16, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_OUTPUTMIX
- { 0x97750f60, 0xddd7, 0x11db, 0x92b1, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_PITCH
- { 0xc7e8ee00, 0xddd7, 0x11db, 0xa42c, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_PLAY
- { 0xef0bd9c0, 0xddd7, 0x11db, 0xbf49, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_PLAYBACKRATE
- { 0x2e3b2a40, 0xddda, 0x11db, 0xa349, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_PREFETCHSTATUS
- { 0x2a41ee80, 0xddd8, 0x11db, 0xa41f, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_PRESETREVERB
- { 0x47382d60, 0xddd8, 0x11db, 0xbf3a, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_RATEPITCH
- { 0x61b62e60, 0xddda, 0x11db, 0x9eb8, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_RECORD
- { 0xc5657aa0, 0xdddb, 0x11db, 0x82f7, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_SEEK
- { 0xd43135a0, 0xdddc, 0x11db, 0xb458, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_THREADSYNC
- { 0xf6ac6b40, 0xdddc, 0x11db, 0xa62e, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_VIBRA
- { 0x169a8d60, 0xdddd, 0x11db, 0x923d, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_VIRTUALIZER
- { 0x37cc2c00, 0xdddd, 0x11db, 0x8577, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_VISUALIZATION
- { 0xe46b26a0, 0xdddd, 0x11db, 0x8afd, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_VOLUME
- { 0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
-
-// Wilhelm desktop extended interfaces
-
- // SL_IID_OUTPUTMIXEXT
- { 0xfe5cce00, 0x57bb, 0x11df, 0x951c, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
-
-// Android API level 9 extended interfaces
-// GUID and MPH shared by SL and XA, but currently documented for SL only
-
- // SL_IID_ANDROIDEFFECT
- { 0xae12da60, 0x99ac, 0x11df, 0xb456, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_ANDROIDEFFECTCAPABILITIES
- { 0x6a4f6d60, 0xb5e6, 0x11df, 0xbb3b, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_ANDROIDEFFECTSEND
- { 0x7be462c0, 0xbc43, 0x11df, 0x8670, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_ANDROIDCONFIGURATION
- { 0x89f6a7e0, 0xbeac, 0x11df, 0x8b5c, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // SL_IID_ANDROIDSIMPLEBUFERQUEUE
- { 0x198e4940, 0xc5d7, 0x11df, 0xa2a6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
-
-// Android API level 12 extended interfaces
-// GUID and MPH shared by SL and XA, but currently documented for XA only
-
- // SL_IID_ANDROIDBUFFERQUEUESOURCE
- { 0x7fc1a460, 0xeec1, 0x11df, 0xa306, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
-
-// OpenMAX AL 1.0.1 interfaces
-
- // XA_IID_AUDIODECODERCAPABILITIES
- { 0xdeac0cc0, 0x3995, 0x11dc, 0x8872, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_AUDIOENCODER
- { 0xebbab900, 0x3997, 0x11dc, 0x891f, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_AUDIOENCODERCAPABILITIES
- { 0x83fbc600, 0x3998, 0x11dc, 0x8f6d, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_AUDIOIODEVICECAPABILITIES
- { 0x2b276d00, 0xf775, 0x11db, 0xa963, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_CAMERA
- { 0xc7b84d20, 0xdf00, 0x11db, 0xba87, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_CAMERACAPABILITIES
- { 0x01cab1c0, 0xe86a, 0x11db, 0xa5b9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_CONFIGEXTENSION
- { 0x6dc22ea0, 0xdf03, 0x11db, 0xbed7, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_DEVICEVOLUME
- { 0x4bb44020, 0xf775, 0x11db, 0xad03, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_DYNAMICINTERFACEMANAGEMENT
- { 0x6e2340c0, 0xf775, 0x11db, 0x85da, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_DYNAMICSOURCE
- { 0xc88d5480, 0x3a12, 0x11dc, 0x80a2, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_ENGINE
- { 0x45c58f40, 0xdf04, 0x11db, 0x9e76, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_EQUALIZER
- { 0x7ad86d40, 0xf775, 0x11db, 0xbc77, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_IMAGECONTROLS
- { 0xf46de3e0, 0xdf03, 0x11db, 0x92f1, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_IMAGEDECODERCAPABILITIES
- { 0xc333e7a0, 0xe616, 0x11dc, 0xa93e, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_IMAGEEFFECTS
- { 0xb865bca0, 0xdf04, 0x11db, 0xbab9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_IMAGEENCODER
- { 0xcd49f140, 0xdf04, 0x11db, 0x8888, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_IMAGEENCODERCAPABILITIES
- { 0xc19f0640, 0xe86f, 0x11db, 0xb2d2, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_LED
- { 0xa534d920, 0xf775, 0x11db, 0x8b70, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_METADATAEXTRACTION
- { 0x5df4fda0, 0xf776, 0x11db, 0xabc5, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_METADATAINSERTION
- { 0x49a14d60, 0xdf05, 0x11db, 0x9191, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_METADATATRAVERSAL
- { 0x73ffb0e0, 0xf776, 0x11db, 0xa00e, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_OBJECT
- { 0x82f5a5a0, 0xf776, 0x11db, 0x9700, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_OUTPUTMIX
- { 0xb25b6fa0, 0xf776, 0x11db, 0xb86b, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_NULL
- // shared with OpenSL ES
- // XA_IID_PLAY
- { 0xb9c293e0, 0xf776, 0x11db, 0x80df, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_PLAYBACKRATE
- { 0xc36f1440, 0xf776, 0x11db, 0xac48, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_PREFETCHSTATUS
- { 0xcceac0a0, 0xf776, 0x11db, 0xbb9c, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_RADIO
- { 0xb316ad80, 0xdf05, 0x11db, 0xb5b6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_RDS
- { 0xb80f42c0, 0xdf05, 0x11db, 0x92a5, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_RECORD
- { 0xd7948cc0, 0xf776, 0x11db, 0x8a3b, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_SEEK
- { 0xee6a3120, 0xf776, 0x11db, 0xb518, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_SNAPSHOT
- { 0xdb1b6dc0, 0xdf05, 0x11db, 0x8c01, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_STREAMINFORMATION
- { 0x3a628fe0, 0x1238, 0x11de, 0xad9f, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_THREADSYNC
- { 0xf3599ea0, 0xf776, 0x11db, 0xb3ea, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_VIBRA
- { 0xfe374c00, 0xf776, 0x11db, 0xa8f0, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_VIDEODECODERCAPABILITIES
- { 0xd18cb200, 0xe616, 0x11dc, 0xab01, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_VIDEOENCODER
- { 0x9444db60, 0xdf06, 0x11db, 0xb311, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_VIDEOENCODERCAPABILITIES
- { 0x5aef2760, 0xe872, 0x11db, 0x849f, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_VIDEOPOSTPROCESSING
- { 0x898b6820, 0x7e6e, 0x11dd, 0x8caf, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
- // XA_IID_VOLUME
- { 0x088ba520, 0xf777, 0x11db, 0xa5e3, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
-};
diff --git a/wilhelm/src/README.txt b/wilhelm/src/README.txt
deleted file mode 100644
index 8230d1b..0000000
--- a/wilhelm/src/README.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-This is the source code for the Wilhelm project, an implementation of native audio
-and multimedia for Android based on Khronos Group OpenSL ES and OpenMAX AL 1.0.1.
-
-Top-level:
- * Makefile
- * Initial entry points
- * Common glue code
-
-Subdirectories:
-android/ Android platform-specific code, other than interfaces
-autogen/ Automagically generated files, do not edit by hand
-desktop/ Experimental desktop PC platform-specific code
-itf/ OpenSL ES and OpenMAX AL interfaces, including Android-specific extensions
-objects/ OpenSL ES and OpenMAX AL objects aka classes
-ut/ Private utility toolkit
diff --git a/wilhelm/src/ThreadPool.c b/wilhelm/src/ThreadPool.c
deleted file mode 100644
index 20130cf..0000000
--- a/wilhelm/src/ThreadPool.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* ThreadPool */
-
-#include "sles_allinclusive.h"
-
-// Entry point for each worker thread
-
-static void *ThreadPool_start(void *context)
-{
- ThreadPool *tp = (ThreadPool *) context;
- assert(NULL != tp);
- for (;;) {
- Closure *pClosure = ThreadPool_remove(tp);
- // closure is NULL when thread pool is being destroyed
- if (NULL == pClosure) {
- break;
- }
- // make a copy of parameters, then free the parameters
- const Closure closure = *pClosure;
- free(pClosure);
- // extract parameters and call the right method depending on kind
- ClosureKind kind = closure.mKind;
- void *context1 = closure.mContext1;
- void *context2 = closure.mContext2;
- int parameter1 = closure.mParameter1;
- switch (kind) {
- case CLOSURE_KIND_PPI:
- {
- ClosureHandler_ppi handler_ppi = closure.mHandler.mHandler_ppi;
- assert(NULL != handler_ppi);
- (*handler_ppi)(context1, context2, parameter1);
- }
- break;
- case CLOSURE_KIND_PPII:
- {
- ClosureHandler_ppii handler_ppii = closure.mHandler.mHandler_ppii;
- assert(NULL != handler_ppii);
- int parameter2 = closure.mParameter2;
- (*handler_ppii)(context1, context2, parameter1, parameter2);
- }
- break;
- case CLOSURE_KIND_PIIPP:
- {
- ClosureHandler_piipp handler_piipp = closure.mHandler.mHandler_piipp;
- assert(NULL != handler_piipp);
- int parameter2 = closure.mParameter2;
- void *context3 = closure.mContext3;
- (*handler_piipp)(context1, parameter1, parameter2, context2, context3);
- }
- break;
- default:
- SL_LOGE("Unexpected callback kind %d", kind);
- assert(false);
- break;
- }
- }
- return NULL;
-}
-
-#define INITIALIZED_NONE 0
-#define INITIALIZED_MUTEX 1
-#define INITIALIZED_CONDNOTFULL 2
-#define INITIALIZED_CONDNOTEMPTY 4
-#define INITIALIZED_ALL 7
-
-static void ThreadPool_deinit_internal(ThreadPool *tp, unsigned initialized, unsigned nThreads);
-
-// Initialize a ThreadPool
-// maxClosures defaults to CLOSURE_TYPICAL if 0
-// maxThreads defaults to THREAD_TYPICAL if 0
-
-SLresult ThreadPool_init(ThreadPool *tp, unsigned maxClosures, unsigned maxThreads)
-{
- assert(NULL != tp);
- memset(tp, 0, sizeof(ThreadPool));
- tp->mShutdown = SL_BOOLEAN_FALSE;
- unsigned initialized = INITIALIZED_NONE; // which objects were successfully initialized
- unsigned nThreads = 0; // number of threads successfully created
- int err;
- SLresult result;
-
- // initialize mutex and condition variables
- err = pthread_mutex_init(&tp->mMutex, (const pthread_mutexattr_t *) NULL);
- result = err_to_result(err);
- if (SL_RESULT_SUCCESS != result)
- goto fail;
- initialized |= INITIALIZED_MUTEX;
- err = pthread_cond_init(&tp->mCondNotFull, (const pthread_condattr_t *) NULL);
- result = err_to_result(err);
- if (SL_RESULT_SUCCESS != result)
- goto fail;
- initialized |= INITIALIZED_CONDNOTFULL;
- err = pthread_cond_init(&tp->mCondNotEmpty, (const pthread_condattr_t *) NULL);
- result = err_to_result(err);
- if (SL_RESULT_SUCCESS != result)
- goto fail;
- initialized |= INITIALIZED_CONDNOTEMPTY;
-
- // use default values for parameters, if not specified explicitly
- tp->mWaitingNotFull = 0;
- tp->mWaitingNotEmpty = 0;
- if (0 == maxClosures)
- maxClosures = CLOSURE_TYPICAL;
- tp->mMaxClosures = maxClosures;
- if (0 == maxThreads)
- maxThreads = THREAD_TYPICAL;
- tp->mMaxThreads = maxThreads;
-
- // initialize circular buffer for closures
- if (CLOSURE_TYPICAL >= maxClosures) {
- tp->mClosureArray = tp->mClosureTypical;
- } else {
- tp->mClosureArray = (Closure **) malloc((maxClosures + 1) * sizeof(Closure *));
- if (NULL == tp->mClosureArray) {
- result = SL_RESULT_RESOURCE_ERROR;
- goto fail;
- }
- }
- tp->mClosureFront = tp->mClosureArray;
- tp->mClosureRear = tp->mClosureArray;
-
- // initialize thread pool
- if (THREAD_TYPICAL >= maxThreads) {
- tp->mThreadArray = tp->mThreadTypical;
- } else {
- tp->mThreadArray = (pthread_t *) malloc(maxThreads * sizeof(pthread_t));
- if (NULL == tp->mThreadArray) {
- result = SL_RESULT_RESOURCE_ERROR;
- goto fail;
- }
- }
- unsigned i;
- for (i = 0; i < maxThreads; ++i) {
- int err = pthread_create(&tp->mThreadArray[i], (const pthread_attr_t *) NULL,
- ThreadPool_start, tp);
- result = err_to_result(err);
- if (SL_RESULT_SUCCESS != result)
- goto fail;
- ++nThreads;
- }
- tp->mInitialized = initialized;
-
- // done
- return SL_RESULT_SUCCESS;
-
- // here on any kind of error
-fail:
- ThreadPool_deinit_internal(tp, initialized, nThreads);
- return result;
-}
-
-static void ThreadPool_deinit_internal(ThreadPool *tp, unsigned initialized, unsigned nThreads)
-{
- int ok;
-
- assert(NULL != tp);
- // Destroy all threads
- if (0 < nThreads) {
- assert(INITIALIZED_ALL == initialized);
- ok = pthread_mutex_lock(&tp->mMutex);
- assert(0 == ok);
- tp->mShutdown = SL_BOOLEAN_TRUE;
- ok = pthread_cond_broadcast(&tp->mCondNotEmpty);
- assert(0 == ok);
- ok = pthread_cond_broadcast(&tp->mCondNotFull);
- assert(0 == ok);
- ok = pthread_mutex_unlock(&tp->mMutex);
- assert(0 == ok);
- unsigned i;
- for (i = 0; i < nThreads; ++i) {
- ok = pthread_join(tp->mThreadArray[i], (void **) NULL);
- assert(ok == 0);
- }
-
- // Empty out the circular buffer of closures
- ok = pthread_mutex_lock(&tp->mMutex);
- assert(0 == ok);
- Closure **oldFront = tp->mClosureFront;
- while (oldFront != tp->mClosureRear) {
- Closure **newFront = oldFront;
- if (++newFront == &tp->mClosureArray[tp->mMaxClosures + 1])
- newFront = tp->mClosureArray;
- Closure *pClosure = *oldFront;
- assert(NULL != pClosure);
- *oldFront = NULL;
- tp->mClosureFront = newFront;
- ok = pthread_mutex_unlock(&tp->mMutex);
- assert(0 == ok);
- free(pClosure);
- ok = pthread_mutex_lock(&tp->mMutex);
- assert(0 == ok);
- }
- ok = pthread_mutex_unlock(&tp->mMutex);
- assert(0 == ok);
- // Note that we can't be sure when mWaitingNotFull will drop to zero
- }
-
- // destroy the mutex and condition variables
- if (initialized & INITIALIZED_CONDNOTEMPTY) {
- ok = pthread_cond_destroy(&tp->mCondNotEmpty);
- assert(0 == ok);
- }
- if (initialized & INITIALIZED_CONDNOTFULL) {
- ok = pthread_cond_destroy(&tp->mCondNotFull);
- assert(0 == ok);
- }
- if (initialized & INITIALIZED_MUTEX) {
- ok = pthread_mutex_destroy(&tp->mMutex);
- assert(0 == ok);
- }
- tp->mInitialized = INITIALIZED_NONE;
-
- // release the closure circular buffer
- if (tp->mClosureTypical != tp->mClosureArray && NULL != tp->mClosureArray) {
- free(tp->mClosureArray);
- tp->mClosureArray = NULL;
- }
-
- // release the thread pool
- if (tp->mThreadTypical != tp->mThreadArray && NULL != tp->mThreadArray) {
- free(tp->mThreadArray);
- tp->mThreadArray = NULL;
- }
-
-}
-
-void ThreadPool_deinit(ThreadPool *tp)
-{
- ThreadPool_deinit_internal(tp, tp->mInitialized, tp->mMaxThreads);
-}
-
-// Enqueue a closure to be executed later by a worker thread.
-// Note that this raw interface requires an explicit "kind" and full parameter list.
-// There are convenience methods below that make this easier to use.
-SLresult ThreadPool_add(ThreadPool *tp, ClosureKind kind, ClosureHandler_generic handler,
- void *context1, void *context2, void *context3, int parameter1, int parameter2)
-{
- assert(NULL != tp);
- assert(NULL != handler);
- Closure *closure = (Closure *) malloc(sizeof(Closure));
- if (NULL == closure) {
- return SL_RESULT_RESOURCE_ERROR;
- }
- closure->mKind = kind;
- switch(kind) {
- case CLOSURE_KIND_PPI:
- closure->mHandler.mHandler_ppi = (ClosureHandler_ppi)handler;
- break;
- case CLOSURE_KIND_PPII:
- closure->mHandler.mHandler_ppii = (ClosureHandler_ppii)handler;
- break;
- case CLOSURE_KIND_PIIPP:
- closure->mHandler.mHandler_piipp = (ClosureHandler_piipp)handler;
- break;
- default:
- SL_LOGE("ThreadPool_add() invalid closure kind %d", kind);
- assert(false);
- }
- closure->mContext1 = context1;
- closure->mContext2 = context2;
- closure->mContext3 = context3;
- closure->mParameter1 = parameter1;
- closure->mParameter2 = parameter2;
- int ok;
- ok = pthread_mutex_lock(&tp->mMutex);
- assert(0 == ok);
- // can't enqueue while thread pool shutting down
- if (tp->mShutdown) {
- ok = pthread_mutex_unlock(&tp->mMutex);
- assert(0 == ok);
- free(closure);
- return SL_RESULT_PRECONDITIONS_VIOLATED;
- }
- for (;;) {
- Closure **oldRear = tp->mClosureRear;
- Closure **newRear = oldRear;
- if (++newRear == &tp->mClosureArray[tp->mMaxClosures + 1])
- newRear = tp->mClosureArray;
- // if closure circular buffer is full, then wait for it to become non-full
- if (newRear == tp->mClosureFront) {
- ++tp->mWaitingNotFull;
- ok = pthread_cond_wait(&tp->mCondNotFull, &tp->mMutex);
- assert(0 == ok);
- // can't enqueue while thread pool shutting down
- if (tp->mShutdown) {
- assert(0 < tp->mWaitingNotFull);
- --tp->mWaitingNotFull;
- ok = pthread_mutex_unlock(&tp->mMutex);
- assert(0 == ok);
- free(closure);
- return SL_RESULT_PRECONDITIONS_VIOLATED;
- }
- continue;
- }
- assert(NULL == *oldRear);
- *oldRear = closure;
- tp->mClosureRear = newRear;
- // if a worker thread was waiting to dequeue, then suggest that it try again
- if (0 < tp->mWaitingNotEmpty) {
- --tp->mWaitingNotEmpty;
- ok = pthread_cond_signal(&tp->mCondNotEmpty);
- assert(0 == ok);
- }
- break;
- }
- ok = pthread_mutex_unlock(&tp->mMutex);
- assert(0 == ok);
- return SL_RESULT_SUCCESS;
-}
-
-// Called by a worker thread when it is ready to accept the next closure to execute
-Closure *ThreadPool_remove(ThreadPool *tp)
-{
- Closure *pClosure;
- int ok;
- ok = pthread_mutex_lock(&tp->mMutex);
- assert(0 == ok);
- for (;;) {
- // fail if thread pool is shutting down
- if (tp->mShutdown) {
- pClosure = NULL;
- break;
- }
- Closure **oldFront = tp->mClosureFront;
- // if closure circular buffer is empty, then wait for it to become non-empty
- if (oldFront == tp->mClosureRear) {
- ++tp->mWaitingNotEmpty;
- ok = pthread_cond_wait(&tp->mCondNotEmpty, &tp->mMutex);
- assert(0 == ok);
- // try again
- continue;
- }
- // dequeue the closure at front of circular buffer
- Closure **newFront = oldFront;
- if (++newFront == &tp->mClosureArray[tp->mMaxClosures + 1]) {
- newFront = tp->mClosureArray;
- }
- pClosure = *oldFront;
- assert(NULL != pClosure);
- *oldFront = NULL;
- tp->mClosureFront = newFront;
- // if a client thread was waiting to enqueue, then suggest that it try again
- if (0 < tp->mWaitingNotFull) {
- --tp->mWaitingNotFull;
- ok = pthread_cond_signal(&tp->mCondNotFull);
- assert(0 == ok);
- }
- break;
- }
- ok = pthread_mutex_unlock(&tp->mMutex);
- assert(0 == ok);
- return pClosure;
-}
-
-// Convenience methods for applications
-SLresult ThreadPool_add_ppi(ThreadPool *tp, ClosureHandler_ppi handler,
- void *context1, void *context2, int parameter1)
-{
- // function pointers are the same size so this is a safe cast
- return ThreadPool_add(tp, CLOSURE_KIND_PPI, (ClosureHandler_generic) handler,
- context1, context2, NULL, parameter1, 0);
-}
-
-SLresult ThreadPool_add_ppii(ThreadPool *tp, ClosureHandler_ppii handler,
- void *context1, void *context2, int parameter1, int parameter2)
-{
- // function pointers are the same size so this is a safe cast
- return ThreadPool_add(tp, CLOSURE_KIND_PPII, (ClosureHandler_generic) handler,
- context1, context2, NULL, parameter1, parameter2);
-}
-
-SLresult ThreadPool_add_piipp(ThreadPool *tp, ClosureHandler_piipp handler,
- void *cntxt1, int param1, int param2, void *cntxt2, void *cntxt3)
-{
- // function pointers are the same size so this is a safe cast
- return ThreadPool_add(tp, CLOSURE_KIND_PIIPP, (ClosureHandler_generic) handler,
- cntxt1, cntxt2, cntxt3, param1, param2);
-}
diff --git a/wilhelm/src/ThreadPool.h b/wilhelm/src/ThreadPool.h
deleted file mode 100644
index 0e4ae94..0000000
--- a/wilhelm/src/ThreadPool.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file ThreadPool.h ThreadPool interface */
-
-/** Kind of closure */
-
-typedef enum {
- CLOSURE_KIND_PPI, // void *, void *, int
- CLOSURE_KIND_PPII, // void *, void *, int, int
- CLOSURE_KIND_PIIPP // void *, int, int, void *, void *
-} ClosureKind;
-
-/** Closure handlers */
-
-typedef void (*ClosureHandler_generic)(void *p1, void *p2, void *p3, int i1, int i2);
-typedef void (*ClosureHandler_ppi) (void *p1, void *p2, int i1);
-typedef void (*ClosureHandler_ppii) (void *p1, void *p2, int i1, int i2);
-typedef void (*ClosureHandler_piipp) (void *p1, int i1, int i2, void *p2, void *p3);
-
-/** \brief Closure represents a deferred computation */
-
-typedef struct {
- union {
- ClosureHandler_ppi mHandler_ppi;
- ClosureHandler_ppii mHandler_ppii;
- ClosureHandler_piipp mHandler_piipp;
- } mHandler;
- ClosureKind mKind;
- void *mContext1;
- void *mContext2;
- void *mContext3;
- int mParameter1;
- int mParameter2;
-} Closure;
-
-/** \brief ThreadPool manages a pool of worker threads that execute Closures */
-
-typedef struct {
- unsigned mInitialized; ///< Indicates which of the following 3 fields are initialized
- pthread_mutex_t mMutex;
- pthread_cond_t mCondNotFull; ///< Signalled when a client thread could be unblocked
- pthread_cond_t mCondNotEmpty; ///< Signalled when a worker thread could be unblocked
- SLboolean mShutdown; ///< Whether shutdown of thread pool has been requested
- unsigned mWaitingNotFull; ///< Number of client threads waiting to enqueue
- unsigned mWaitingNotEmpty; ///< Number of worker threads waiting to dequeue
- unsigned mMaxClosures; ///< Number of slots in circular buffer for closures, not counting spare
- unsigned mMaxThreads; ///< Number of worker threads
- Closure **mClosureArray; ///< The circular buffer of closures
- Closure **mClosureFront, **mClosureRear;
- /// Saves a malloc in the typical case
-#define CLOSURE_TYPICAL 15
- Closure *mClosureTypical[CLOSURE_TYPICAL+1];
- pthread_t *mThreadArray; ///< The worker threads
-#ifdef ANDROID
-// Note: if you set THREAD_TYPICAL to a non-zero value because you
-// want to use asynchronous callbacks, be aware that any value greater
-// than 1 can result in out-of-order callbacks on a given player, in the
-// current implementation. Thus you should probably configure 1 total or
-// change the implementation so that it uses at most 1 thread per player.
-#if defined(USE_ASYNCHRONOUS_PLAY_CALLBACK) || \
- defined(USE_ASYNCHRONOUS_STREAMCBEVENT_PROPERTYCHANGE_CALLBACK)
-#define THREAD_TYPICAL 1
-#else
-#define THREAD_TYPICAL 0
-#endif
-#else // !ANDROID
-#define THREAD_TYPICAL 4
-#endif
- pthread_t mThreadTypical[THREAD_TYPICAL];
-} ThreadPool;
-
-extern SLresult ThreadPool_init(ThreadPool *tp, unsigned maxClosures, unsigned maxThreads);
-extern void ThreadPool_deinit(ThreadPool *tp);
-extern SLresult ThreadPool_add(ThreadPool *tp, ClosureKind kind,
- ClosureHandler_generic,
- void *cntxt1, void *cntxt2, int param1, int param2);
-extern Closure *ThreadPool_remove(ThreadPool *tp);
-extern SLresult ThreadPool_add_ppi(ThreadPool *tp, ClosureHandler_ppi handler,
- void *cntxt1, void *cntxt2, int param1);
-extern SLresult ThreadPool_add_ppii(ThreadPool *tp, ClosureHandler_ppii handler,
- void *cntxt1, void *cntxt2, int param1, int param2);
-extern SLresult ThreadPool_add_piipp(ThreadPool *tp, ClosureHandler_piipp handler,
- void *cntxt1, int param1, int param2, void *cntxt2, void *cntxt3);
diff --git a/wilhelm/src/android/AacBqToPcmCbRenderer.cpp b/wilhelm/src/android/AacBqToPcmCbRenderer.cpp
deleted file mode 100644
index 41879e8..0000000
--- a/wilhelm/src/android/AacBqToPcmCbRenderer.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Debug
-
-#include "sles_allinclusive.h"
-#include "android/include/AacBqToPcmCbRenderer.h"
-#include <media/stagefright/foundation/ADebug.h>
-
-namespace android {
-
-// ADTS header size is 7, but frame size information ends on byte 6 (when counting from byte 1)
-#define ADTS_HEADER_SIZE_UP_TO_FRAMESIZE 6
-
-/**
- * Returns the size of an AAC ADTS frame.
- * Note that if the returned value + offset > size, it means that a partial frame starts at that
- * offset, but this function will still return the size of the full frame.
- * @param data pointer to the compressed audio data
- * @param offset offset in bytes relative to data of where the frame is supposed to start
- * @param size the size in bytes of the data block starting at data
- * @return the size in bytes of the AAC ADTS frame starting at the given offset of the given
- * memory address, 0 if the frame couldn't be parsed.
- */
-static size_t getAdtsFrameSize(const uint8_t *data, off64_t offset, size_t size) {
- size_t frameSize = 0;
-
- if (!(offset + ADTS_HEADER_SIZE_UP_TO_FRAMESIZE < size)) {
- SL_LOGE("AacBqToPcmCbRenderer::getAdtsFrameSize() returns 0 (can't read syncword or header)"
- );
- return 0;
- }
-
- const uint8_t *syncword = data + offset;
- if ((syncword[0] != 0xff) || ((syncword[1] & 0xf6) != 0xf0)) {
- SL_LOGE("AacBqToPcmCbRenderer::getAdtsFrameSize() returns 0 (wrong syncword)");
- return 0;
- }
-
- const uint8_t protectionAbsent = data[offset+1] & 0x1;
-
- const uint8_t* header = data + offset + 3;
- frameSize = (header[0] & 0x3) << 11 | header[1] << 3 | header[2] >> 5;
- // the frame size read already contains the size of the header, so no need to add it here
-
- // protectionAbsent is 0 if there is CRC
- static const size_t kAdtsHeaderLengthNoCrc = 7;
- static const size_t kAdtsHeaderLengthWithCrc = 9;
- size_t headSize = protectionAbsent ? kAdtsHeaderLengthNoCrc : kAdtsHeaderLengthWithCrc;
- if (headSize > frameSize) {
- SL_LOGE("AacBqToPcmCbRenderer::getAdtsFrameSize() returns 0 (frameSize %u < headSize %u)",
- frameSize, headSize);
- return 0;
- }
-
- SL_LOGV("AacBqToPcmCbRenderer::getAdtsFrameSize() returns %u", frameSize);
-
- return frameSize;
-}
-
-/**
- * Returns whether a block of memory starts and ends on AAC ADTS frame boundaries
- * @param data pointer to the compressed audio data
- * @param size the size in bytes of the data block to validate
- * @return SL_RESULT_SUCCESS if there is AAC ADTS data, and it starts and ends on frame boundaries,
- * or an appropriate error code otherwise:
- * SL_RESULT_PARAMETER_INVALID if not possible to attempt validation of even one frame
- * SL_RESULT_CONTENT_CORRUPTED if the frame contents are otherwise invalid
- */
-SLresult AacBqToPcmCbRenderer::validateBufferStartEndOnFrameBoundaries(void* data, size_t size)
-{
- off64_t offset = 0;
- size_t frameSize = 0;
-
- if ((NULL == data) || (size == 0)) {
- SL_LOGE("No ADTS to validate");
- return SL_RESULT_PARAMETER_INVALID;
- }
-
- while (offset < size) {
- if ((frameSize = getAdtsFrameSize((uint8_t *)data, offset, size)) == 0) {
- SL_LOGE("found ADTS frame of size 0 at offset %llu", offset);
- return SL_RESULT_CONTENT_CORRUPTED;
- }
- //SL_LOGV("last good offset %llu", offset);
- offset += frameSize;
- if (offset > size) {
- SL_LOGE("found incomplete ADTS frame at end of data");
- return SL_RESULT_CONTENT_CORRUPTED;
- }
- }
- if (offset != size) { SL_LOGE("ADTS parsing error: reached end of incomplete frame"); }
- assert(offset == size);
- return SL_RESULT_SUCCESS;
-}
-
-//--------------------------------------------------------------------------------------------------
-AacBqToPcmCbRenderer::AacBqToPcmCbRenderer(AudioPlayback_Parameters* params) :
- AudioToCbRenderer(params),
- mBqSource(0)
-{
- SL_LOGD("AacBqToPcmCbRenderer::AacBqToPcmCbRenderer()");
-
-}
-
-
-AacBqToPcmCbRenderer::~AacBqToPcmCbRenderer() {
- SL_LOGD("AacBqToPcmCbRenderer::~AacBqToPcmCbRenderer()");
-
-}
-
-
-//--------------------------------------------------
-void AacBqToPcmCbRenderer::registerSourceQueueCallback(
- const void* user, void *context, const void *caller) {
- SL_LOGD("AacBqToPcmCbRenderer::registerQueueCallback");
-
- Mutex::Autolock _l(mBqSourceLock);
-
- mBqSource = new BufferQueueSource(user, context, caller);
-
- CHECK(mBqSource != 0);
- SL_LOGD("AacBqToPcmCbRenderer::registerSourceQueueCallback end");
-}
-
-
-//--------------------------------------------------
-// Event handlers
-void AacBqToPcmCbRenderer::onPrepare() {
- SL_LOGD("AacBqToPcmCbRenderer::onPrepare()");
- Mutex::Autolock _l(mBufferSourceLock);
-
- // Initialize the PCM format info with the known parameters before the start of the decode
- {
- android::Mutex::Autolock autoLock(mPcmFormatLock);
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_BITSPERSAMPLE] = SL_PCMSAMPLEFORMAT_FIXED_16;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CONTAINERSIZE] = 16;
- //FIXME not true on all platforms
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_ENDIANNESS] = SL_BYTEORDER_LITTLEENDIAN;
- // initialization with the default values: they will be replaced by the actual values
- // once the decoder has figured them out
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = UNKNOWN_NUMCHANNELS;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = UNKNOWN_SAMPLERATE;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] = UNKNOWN_CHANNELMASK;
- }
-
- sp<DataSource> dataSource;
- {
- Mutex::Autolock _l(mBqSourceLock);
- dataSource = mBqSource;
- }
- if (dataSource == 0) {
- SL_LOGE("AacBqToPcmCbRenderer::onPrepare(): Error no data source");
- notifyPrepared(MEDIA_ERROR_BASE);
- return;
- }
-
- sp<MediaExtractor> extractor = new AacAdtsExtractor(dataSource);
- if (extractor == 0) {
- SL_LOGE("AacBqToPcmCbRenderer::onPrepare: Could not instantiate AAC extractor.");
- notifyPrepared(ERROR_UNSUPPORTED);
- return;
- }
-
- // only decoding a single track of data
- const size_t kTrackToDecode = 0;
-
- sp<MediaSource> source = extractor->getTrack(kTrackToDecode);
- if (source == 0) {
- SL_LOGE("AacBqToPcmCbRenderer::onPrepare: error getting source from extractor");
- notifyPrepared(ERROR_UNSUPPORTED);
- return;
- }
- sp<MetaData> meta = extractor->getTrackMetaData(kTrackToDecode);
-
- // the audio content is not raw PCM, so we need a decoder
- OMXClient client;
- CHECK_EQ(client.connect(), (status_t)OK);
-
- source = OMXCodec::Create(
- client.interface(), meta, false /* createEncoder */,
- source);
-
- if (source == NULL) {
- SL_LOGE("AacBqToPcmCbRenderer::onPrepare: Could not instantiate decoder.");
- notifyPrepared(ERROR_UNSUPPORTED);
- return;
- }
-
- meta = source->getFormat();
-
- SL_LOGD("AacBqToPcmCbRenderer::onPrepare() after instantiating decoder");
-
- if (source->start() != OK) {
- SL_LOGE("AacBqToPcmCbRenderer::onPrepare() Failed to start source/decoder.");
- notifyPrepared(MEDIA_ERROR_BASE);
- return;
- }
-
- //---------------------------------
- int32_t channelCount;
- CHECK(meta->findInt32(kKeyChannelCount, &channelCount));
- int32_t sr;
- CHECK(meta->findInt32(kKeySampleRate, &sr));
- // FIXME similar to AudioSfDecoder::onPrepare()
-
- // already "good to go" (compare to AudioSfDecoder::onPrepare)
- mCacheStatus = kStatusHigh;
- mCacheFill = 1000;
- notifyStatus();
- notifyCacheFill();
-
- {
- android::Mutex::Autolock autoLock(mPcmFormatLock);
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = sr;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = channelCount;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] =
- channelCountToMask(channelCount);
- }
- SL_LOGV("AacBqToPcmCbRenderer::onPrepare() channel count=%d SR=%d",
- channelCount, sr);
-
- //---------------------------------
- // The data source, and audio source (a decoder) are ready to be used
- mDataSource = dataSource;
- mAudioSource = source;
- mAudioSourceStarted = true;
-
- //-------------------------------------
- // signal successful completion of prepare
- mStateFlags |= kFlagPrepared;
-
- GenericPlayer::onPrepare();
-
- SL_LOGD("AacBqToPcmCbRenderer::onPrepare() done, mStateFlags=0x%x", mStateFlags);
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/AudioPlayer_to_android.cpp b/wilhelm/src/android/AudioPlayer_to_android.cpp
deleted file mode 100644
index 8f60ead..0000000
--- a/wilhelm/src/android/AudioPlayer_to_android.cpp
+++ /dev/null
@@ -1,2200 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-#include "android_prompts.h"
-#include "android/android_AudioToCbRenderer.h"
-#include "android/android_StreamPlayer.h"
-#include "android/android_LocAVPlayer.h"
-#include "android/include/AacBqToPcmCbRenderer.h"
-
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#include <system/audio.h>
-
-template class android::KeyedVector<SLuint32, android::AudioEffect* > ;
-
-#define KEY_STREAM_TYPE_PARAMSIZE sizeof(SLint32)
-
-#define AUDIOTRACK_MIN_PLAYBACKRATE_PERMILLE 500
-#define AUDIOTRACK_MAX_PLAYBACKRATE_PERMILLE 2000
-
-//-----------------------------------------------------------------------------
-// FIXME this method will be absorbed into android_audioPlayer_setPlayState() once
-// bufferqueue and uri/fd playback are moved under the GenericPlayer C++ object
-SLresult aplayer_setPlayState(const android::sp<android::GenericPlayer> &ap, SLuint32 playState,
- AndroidObjectState* pObjState) {
- SLresult result = SL_RESULT_SUCCESS;
- AndroidObjectState objState = *pObjState;
-
- switch (playState) {
- case SL_PLAYSTATE_STOPPED:
- SL_LOGV("setting GenericPlayer to SL_PLAYSTATE_STOPPED");
- ap->stop();
- break;
- case SL_PLAYSTATE_PAUSED:
- SL_LOGV("setting GenericPlayer to SL_PLAYSTATE_PAUSED");
- switch(objState) {
- case ANDROID_UNINITIALIZED:
- *pObjState = ANDROID_PREPARING;
- ap->prepare();
- break;
- case ANDROID_PREPARING:
- break;
- case ANDROID_READY:
- ap->pause();
- break;
- default:
- SL_LOGE(ERROR_PLAYERSETPLAYSTATE_INVALID_OBJECT_STATE_D, playState);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
- break;
- case SL_PLAYSTATE_PLAYING: {
- SL_LOGV("setting GenericPlayer to SL_PLAYSTATE_PLAYING");
- switch(objState) {
- case ANDROID_UNINITIALIZED:
- *pObjState = ANDROID_PREPARING;
- ap->prepare();
- // intended fall through
- case ANDROID_PREPARING:
- // intended fall through
- case ANDROID_READY:
- ap->play();
- break;
- default:
- SL_LOGE(ERROR_PLAYERSETPLAYSTATE_INVALID_OBJECT_STATE_D, playState);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
- }
- break;
- default:
- // checked by caller, should not happen
- SL_LOGE(ERROR_SHOULDNT_BE_HERE_S, "aplayer_setPlayState");
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-// Callback associated with a AudioToCbRenderer of an SL ES AudioPlayer that gets its data
-// from a URI or FD, to write the decoded audio data to a buffer queue
-static size_t adecoder_writeToBufferQueue(const uint8_t *data, size_t size, CAudioPlayer* ap) {
- if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
- // it is not safe to enter the callback (the player is about to go away)
- return 0;
- }
- size_t sizeConsumed = 0;
- SL_LOGD("received %d bytes from decoder", size);
- slBufferQueueCallback callback = NULL;
- void * callbackPContext = NULL;
-
- // push decoded data to the buffer queue
- object_lock_exclusive(&ap->mObject);
-
- if (ap->mBufferQueue.mState.count != 0) {
- assert(ap->mBufferQueue.mFront != ap->mBufferQueue.mRear);
-
- BufferHeader *oldFront = ap->mBufferQueue.mFront;
- BufferHeader *newFront = &oldFront[1];
-
- uint8_t *pDest = (uint8_t *)oldFront->mBuffer + ap->mBufferQueue.mSizeConsumed;
- if (ap->mBufferQueue.mSizeConsumed + size < oldFront->mSize) {
- // room to consume the whole or rest of the decoded data in one shot
- ap->mBufferQueue.mSizeConsumed += size;
- // consume data but no callback to the BufferQueue interface here
- memcpy (pDest, data, size);
- sizeConsumed = size;
- } else {
- // push as much as possible of the decoded data into the buffer queue
- sizeConsumed = oldFront->mSize - ap->mBufferQueue.mSizeConsumed;
-
- // the buffer at the head of the buffer queue is full, update the state
- ap->mBufferQueue.mSizeConsumed = 0;
- if (newFront == &ap->mBufferQueue.mArray[ap->mBufferQueue.mNumBuffers + 1]) {
- newFront = ap->mBufferQueue.mArray;
- }
- ap->mBufferQueue.mFront = newFront;
-
- ap->mBufferQueue.mState.count--;
- ap->mBufferQueue.mState.playIndex++;
- // consume data
- memcpy (pDest, data, sizeConsumed);
- // data has been copied to the buffer, and the buffer queue state has been updated
- // we will notify the client if applicable
- callback = ap->mBufferQueue.mCallback;
- // save callback data
- callbackPContext = ap->mBufferQueue.mContext;
- }
-
- } else {
- // no available buffers in the queue to write the decoded data
- sizeConsumed = 0;
- }
-
- object_unlock_exclusive(&ap->mObject);
- // notify client
- if (NULL != callback) {
- (*callback)(&ap->mBufferQueue.mItf, callbackPContext);
- }
-
- ap->mCallbackProtector->exitCb();
- return sizeConsumed;
-}
-
-//-----------------------------------------------------------------------------
-int android_getMinFrameCount(uint32_t sampleRate) {
- int afSampleRate;
- if (android::AudioSystem::getOutputSamplingRate(&afSampleRate,
- ANDROID_DEFAULT_OUTPUT_STREAM_TYPE) != android::NO_ERROR) {
- return ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE;
- }
- int afFrameCount;
- if (android::AudioSystem::getOutputFrameCount(&afFrameCount,
- ANDROID_DEFAULT_OUTPUT_STREAM_TYPE) != android::NO_ERROR) {
- return ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE;
- }
- uint32_t afLatency;
- if (android::AudioSystem::getOutputLatency(&afLatency,
- ANDROID_DEFAULT_OUTPUT_STREAM_TYPE) != android::NO_ERROR) {
- return ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE;
- }
- // minimum nb of buffers to cover output latency, given the size of each hardware audio buffer
- uint32_t minBufCount = afLatency / ((1000 * afFrameCount)/afSampleRate);
- if (minBufCount < 2) minBufCount = 2;
- // minimum number of frames to cover output latency at the sample rate of the content
- return (afFrameCount*sampleRate*minBufCount)/afSampleRate;
-}
-
-
-//-----------------------------------------------------------------------------
-#define LEFT_CHANNEL_MASK 0x1 << 0
-#define RIGHT_CHANNEL_MASK 0x1 << 1
-
-void android_audioPlayer_volumeUpdate(CAudioPlayer* ap)
-{
- assert(ap != NULL);
-
- // the source's channel count, where zero means unknown
- SLuint8 channelCount = ap->mNumChannels;
-
- // whether each channel is audible
- bool leftAudibilityFactor, rightAudibilityFactor;
-
- // mute has priority over solo
- if (channelCount >= STEREO_CHANNELS) {
- if (ap->mMuteMask & LEFT_CHANNEL_MASK) {
- // left muted
- leftAudibilityFactor = false;
- } else {
- // left not muted
- if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
- // left soloed
- leftAudibilityFactor = true;
- } else {
- // left not soloed
- if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
- // right solo silences left
- leftAudibilityFactor = false;
- } else {
- // left and right are not soloed, and left is not muted
- leftAudibilityFactor = true;
- }
- }
- }
-
- if (ap->mMuteMask & RIGHT_CHANNEL_MASK) {
- // right muted
- rightAudibilityFactor = false;
- } else {
- // right not muted
- if (ap->mSoloMask & RIGHT_CHANNEL_MASK) {
- // right soloed
- rightAudibilityFactor = true;
- } else {
- // right not soloed
- if (ap->mSoloMask & LEFT_CHANNEL_MASK) {
- // left solo silences right
- rightAudibilityFactor = false;
- } else {
- // left and right are not soloed, and right is not muted
- rightAudibilityFactor = true;
- }
- }
- }
-
- // channel mute and solo are ignored for mono and unknown channel count sources
- } else {
- leftAudibilityFactor = true;
- rightAudibilityFactor = true;
- }
-
- // compute volumes without setting
- const bool audibilityFactors[2] = {leftAudibilityFactor, rightAudibilityFactor};
- float volumes[2];
- android_player_volumeUpdate(volumes, &ap->mVolume, channelCount, ap->mAmplFromDirectLevel,
- audibilityFactors);
- float leftVol = volumes[0], rightVol = volumes[1];
-
- // set volume on the underlying media player or audio track
- if (ap->mAPlayer != 0) {
- ap->mAPlayer->setVolume(leftVol, rightVol);
- } else if (ap->mAudioTrack != 0) {
- ap->mAudioTrack->setVolume(leftVol, rightVol);
- }
-
- // changes in the AudioPlayer volume must be reflected in the send level:
- // in SLEffectSendItf or in SLAndroidEffectSendItf?
- // FIXME replace interface test by an internal API once we have one.
- if (NULL != ap->mEffectSend.mItf) {
- for (unsigned int i=0 ; i<AUX_MAX ; i++) {
- if (ap->mEffectSend.mEnableLevels[i].mEnable) {
- android_fxSend_setSendLevel(ap,
- ap->mEffectSend.mEnableLevels[i].mSendLevel + ap->mVolume.mLevel);
- // there's a single aux bus on Android, so we can stop looking once the first
- // aux effect is found.
- break;
- }
- }
- } else if (NULL != ap->mAndroidEffectSend.mItf) {
- android_fxSend_setSendLevel(ap, ap->mAndroidEffectSend.mSendLevel + ap->mVolume.mLevel);
- }
-}
-
-// Called by android_audioPlayer_volumeUpdate and android_mediaPlayer_volumeUpdate to compute
-// volumes, but setting volumes is handled by the caller.
-
-void android_player_volumeUpdate(float *pVolumes /*[2]*/, const IVolume *volumeItf, unsigned
-channelCount, float amplFromDirectLevel, const bool *audibilityFactors /*[2]*/)
-{
- assert(pVolumes != NULL);
- assert(volumeItf != NULL);
- // OK for audibilityFactors to be NULL
-
- bool leftAudibilityFactor, rightAudibilityFactor;
-
- // apply player mute factor
- // note that AudioTrack has mute() but not MediaPlayer, so it's easier to use volume
- // to mute for both rather than calling mute() for AudioTrack
-
- // player is muted
- if (volumeItf->mMute) {
- leftAudibilityFactor = false;
- rightAudibilityFactor = false;
- // player isn't muted, and channel mute/solo audibility factors are available (AudioPlayer)
- } else if (audibilityFactors != NULL) {
- leftAudibilityFactor = audibilityFactors[0];
- rightAudibilityFactor = audibilityFactors[1];
- // player isn't muted, and channel mute/solo audibility factors aren't available (MediaPlayer)
- } else {
- leftAudibilityFactor = true;
- rightAudibilityFactor = true;
- }
-
- // compute amplification as the combination of volume level and stereo position
- // amplification (or attenuation) from volume level
- float amplFromVolLevel = sles_to_android_amplification(volumeItf->mLevel);
- // amplification from direct level (changed in SLEffectSendtItf and SLAndroidEffectSendItf)
- float leftVol = amplFromVolLevel * amplFromDirectLevel;
- float rightVol = leftVol;
-
- // amplification from stereo position
- if (volumeItf->mEnableStereoPosition) {
- // Left/right amplification (can be attenuations) factors derived for the StereoPosition
- float amplFromStereoPos[STEREO_CHANNELS];
- // panning law depends on content channel count: mono to stereo panning vs stereo balance
- if (1 == channelCount) {
- // mono to stereo panning
- double theta = (1000+volumeItf->mStereoPosition)*M_PI_4/1000.0f; // 0 <= theta <= Pi/2
- amplFromStereoPos[0] = cos(theta);
- amplFromStereoPos[1] = sin(theta);
- // channel count is 0 (unknown), 2 (stereo), or > 2 (multi-channel)
- } else {
- // stereo balance
- if (volumeItf->mStereoPosition > 0) {
- amplFromStereoPos[0] = (1000-volumeItf->mStereoPosition)/1000.0f;
- amplFromStereoPos[1] = 1.0f;
- } else {
- amplFromStereoPos[0] = 1.0f;
- amplFromStereoPos[1] = (1000+volumeItf->mStereoPosition)/1000.0f;
- }
- }
- leftVol *= amplFromStereoPos[0];
- rightVol *= amplFromStereoPos[1];
- }
-
- // apply audibility factors
- if (!leftAudibilityFactor) {
- leftVol = 0.0;
- }
- if (!rightAudibilityFactor) {
- rightVol = 0.0;
- }
-
- // return the computed volumes
- pVolumes[0] = leftVol;
- pVolumes[1] = rightVol;
-}
-
-//-----------------------------------------------------------------------------
-void audioTrack_handleMarker_lockPlay(CAudioPlayer* ap) {
- //SL_LOGV("received event EVENT_MARKER from AudioTrack");
- slPlayCallback callback = NULL;
- void* callbackPContext = NULL;
-
- interface_lock_shared(&ap->mPlay);
- callback = ap->mPlay.mCallback;
- callbackPContext = ap->mPlay.mContext;
- interface_unlock_shared(&ap->mPlay);
-
- if (NULL != callback) {
- // getting this event implies SL_PLAYEVENT_HEADATMARKER was set in the event mask
- (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATMARKER);
- }
-}
-
-//-----------------------------------------------------------------------------
-void audioTrack_handleNewPos_lockPlay(CAudioPlayer* ap) {
- //SL_LOGV("received event EVENT_NEW_POS from AudioTrack");
- slPlayCallback callback = NULL;
- void* callbackPContext = NULL;
-
- interface_lock_shared(&ap->mPlay);
- callback = ap->mPlay.mCallback;
- callbackPContext = ap->mPlay.mContext;
- interface_unlock_shared(&ap->mPlay);
-
- if (NULL != callback) {
- // getting this event implies SL_PLAYEVENT_HEADATNEWPOS was set in the event mask
- (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADATNEWPOS);
- }
-}
-
-
-//-----------------------------------------------------------------------------
-void audioTrack_handleUnderrun_lockPlay(CAudioPlayer* ap) {
- slPlayCallback callback = NULL;
- void* callbackPContext = NULL;
-
- interface_lock_shared(&ap->mPlay);
- callback = ap->mPlay.mCallback;
- callbackPContext = ap->mPlay.mContext;
- bool headStalled = (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADSTALLED) != 0;
- interface_unlock_shared(&ap->mPlay);
-
- if ((NULL != callback) && headStalled) {
- (*callback)(&ap->mPlay.mItf, callbackPContext, SL_PLAYEVENT_HEADSTALLED);
- }
-}
-
-
-//-----------------------------------------------------------------------------
-/**
- * post-condition: play state of AudioPlayer is SL_PLAYSTATE_PAUSED if setPlayStateToPaused is true
- *
- * note: a conditional flag, setPlayStateToPaused, is used here to specify whether the play state
- * needs to be changed when the player reaches the end of the content to play. This is
- * relative to what the specification describes for buffer queues vs the
- * SL_PLAYEVENT_HEADATEND event. In the OpenSL ES specification 1.0.1:
- * - section 8.12 SLBufferQueueItf states "In the case of starvation due to insufficient
- * buffers in the queue, the playing of audio data stops. The player remains in the
- * SL_PLAYSTATE_PLAYING state."
- * - section 9.2.31 SL_PLAYEVENT states "SL_PLAYEVENT_HEADATEND Playback head is at the end
- * of the current content and the player has paused."
- */
-void audioPlayer_dispatch_headAtEnd_lockPlay(CAudioPlayer *ap, bool setPlayStateToPaused,
- bool needToLock) {
- //SL_LOGV("ap=%p, setPlayStateToPaused=%d, needToLock=%d", ap, setPlayStateToPaused,
- // needToLock);
- slPlayCallback playCallback = NULL;
- void * playContext = NULL;
- // SLPlayItf callback or no callback?
- if (needToLock) {
- interface_lock_exclusive(&ap->mPlay);
- }
- if (ap->mPlay.mEventFlags & SL_PLAYEVENT_HEADATEND) {
- playCallback = ap->mPlay.mCallback;
- playContext = ap->mPlay.mContext;
- }
- if (setPlayStateToPaused) {
- ap->mPlay.mState = SL_PLAYSTATE_PAUSED;
- }
- if (needToLock) {
- interface_unlock_exclusive(&ap->mPlay);
- }
- // enqueue callback with no lock held
- if (NULL != playCallback) {
-#ifndef USE_ASYNCHRONOUS_PLAY_CALLBACK
- (*playCallback)(&ap->mPlay.mItf, playContext, SL_PLAYEVENT_HEADATEND);
-#else
- SLresult result = EnqueueAsyncCallback_ppi(ap, playCallback, &ap->mPlay.mItf, playContext,
- SL_PLAYEVENT_HEADATEND);
- if (SL_RESULT_SUCCESS != result) {
- LOGW("Callback %p(%p, %p, SL_PLAYEVENT_HEADATEND) dropped", playCallback,
- &ap->mPlay.mItf, playContext);
- }
-#endif
- }
-
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult audioPlayer_setStreamType(CAudioPlayer* ap, SLint32 type) {
- SLresult result = SL_RESULT_SUCCESS;
- SL_LOGV("type %d", type);
-
- int newStreamType = ANDROID_DEFAULT_OUTPUT_STREAM_TYPE;
- switch(type) {
- case SL_ANDROID_STREAM_VOICE:
- newStreamType = AUDIO_STREAM_VOICE_CALL;
- break;
- case SL_ANDROID_STREAM_SYSTEM:
- newStreamType = AUDIO_STREAM_SYSTEM;
- break;
- case SL_ANDROID_STREAM_RING:
- newStreamType = AUDIO_STREAM_RING;
- break;
- case SL_ANDROID_STREAM_MEDIA:
- newStreamType = AUDIO_STREAM_MUSIC;
- break;
- case SL_ANDROID_STREAM_ALARM:
- newStreamType = AUDIO_STREAM_ALARM;
- break;
- case SL_ANDROID_STREAM_NOTIFICATION:
- newStreamType = AUDIO_STREAM_NOTIFICATION;
- break;
- default:
- SL_LOGE(ERROR_PLAYERSTREAMTYPE_SET_UNKNOWN_TYPE);
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- // stream type needs to be set before the object is realized
- // (ap->mAudioTrack is supposed to be NULL until then)
- if (SL_OBJECT_STATE_UNREALIZED != ap->mObject.mState) {
- SL_LOGE(ERROR_PLAYERSTREAMTYPE_REALIZED);
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- ap->mStreamType = newStreamType;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult audioPlayer_getStreamType(CAudioPlayer* ap, SLint32 *pType) {
- SLresult result = SL_RESULT_SUCCESS;
-
- switch(ap->mStreamType) {
- case AUDIO_STREAM_VOICE_CALL:
- *pType = SL_ANDROID_STREAM_VOICE;
- break;
- case AUDIO_STREAM_SYSTEM:
- *pType = SL_ANDROID_STREAM_SYSTEM;
- break;
- case AUDIO_STREAM_RING:
- *pType = SL_ANDROID_STREAM_RING;
- break;
- case AUDIO_STREAM_DEFAULT:
- case AUDIO_STREAM_MUSIC:
- *pType = SL_ANDROID_STREAM_MEDIA;
- break;
- case AUDIO_STREAM_ALARM:
- *pType = SL_ANDROID_STREAM_ALARM;
- break;
- case AUDIO_STREAM_NOTIFICATION:
- *pType = SL_ANDROID_STREAM_NOTIFICATION;
- break;
- default:
- result = SL_RESULT_INTERNAL_ERROR;
- *pType = SL_ANDROID_STREAM_MEDIA;
- break;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-void audioPlayer_auxEffectUpdate(CAudioPlayer* ap) {
- if ((ap->mAudioTrack != 0) && (ap->mAuxEffect != 0)) {
- android_fxSend_attach(ap, true, ap->mAuxEffect, ap->mVolume.mLevel + ap->mAuxSendLevel);
- }
-}
-
-
-//-----------------------------------------------------------------------------
-void audioPlayer_setInvalid(CAudioPlayer* ap) {
- ap->mAndroidObjType = INVALID_TYPE;
-}
-
-
-//-----------------------------------------------------------------------------
-/*
- * returns true if the given data sink is supported by AudioPlayer that doesn't
- * play to an OutputMix object, false otherwise
- *
- * pre-condition: the locator of the audio sink is not SL_DATALOCATOR_OUTPUTMIX
- */
-bool audioPlayer_isSupportedNonOutputMixSink(const SLDataSink* pAudioSink) {
- bool result = true;
- const SLuint32 sinkLocatorType = *(SLuint32 *)pAudioSink->pLocator;
- const SLuint32 sinkFormatType = *(SLuint32 *)pAudioSink->pFormat;
-
- switch (sinkLocatorType) {
-
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- if (SL_DATAFORMAT_PCM != sinkFormatType) {
- SL_LOGE("Unsupported sink format 0x%x, expected SL_DATAFORMAT_PCM",
- (unsigned)sinkFormatType);
- result = false;
- }
- // it's no use checking the PCM format fields because additional characteristics
- // such as the number of channels, or sample size are unknown to the player at this stage
- break;
-
- default:
- SL_LOGE("Unsupported sink locator type 0x%x", (unsigned)sinkLocatorType);
- result = false;
- break;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-/*
- * returns the Android object type if the locator type combinations for the source and sinks
- * are supported by this implementation, INVALID_TYPE otherwise
- */
-AndroidObjectType audioPlayer_getAndroidObjectTypeForSourceSink(CAudioPlayer *ap) {
-
- const SLDataSource *pAudioSrc = &ap->mDataSource.u.mSource;
- const SLDataSink *pAudioSnk = &ap->mDataSink.u.mSink;
- const SLuint32 sourceLocatorType = *(SLuint32 *)pAudioSrc->pLocator;
- const SLuint32 sinkLocatorType = *(SLuint32 *)pAudioSnk->pLocator;
- AndroidObjectType type = INVALID_TYPE;
-
- //--------------------------------------
- // Sink / source matching check:
- // the following source / sink combinations are supported
- // SL_DATALOCATOR_BUFFERQUEUE / SL_DATALOCATOR_OUTPUTMIX
- // SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE / SL_DATALOCATOR_OUTPUTMIX
- // SL_DATALOCATOR_URI / SL_DATALOCATOR_OUTPUTMIX
- // SL_DATALOCATOR_ANDROIDFD / SL_DATALOCATOR_OUTPUTMIX
- // SL_DATALOCATOR_ANDROIDBUFFERQUEUE / SL_DATALOCATOR_OUTPUTMIX
- // SL_DATALOCATOR_ANDROIDBUFFERQUEUE / SL_DATALOCATOR_BUFFERQUEUE
- // SL_DATALOCATOR_URI / SL_DATALOCATOR_BUFFERQUEUE
- // SL_DATALOCATOR_ANDROIDFD / SL_DATALOCATOR_BUFFERQUEUE
- // SL_DATALOCATOR_URI / SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE
- // SL_DATALOCATOR_ANDROIDFD / SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE
- switch (sinkLocatorType) {
-
- case SL_DATALOCATOR_OUTPUTMIX: {
- switch (sourceLocatorType) {
-
- // Buffer Queue to AudioTrack
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- type = AUDIOPLAYER_FROM_PCM_BUFFERQUEUE;
- break;
-
- // URI or FD to MediaPlayer
- case SL_DATALOCATOR_URI:
- case SL_DATALOCATOR_ANDROIDFD:
- type = AUDIOPLAYER_FROM_URIFD;
- break;
-
- // Android BufferQueue to MediaPlayer (shared memory streaming)
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- type = AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE;
- break;
-
- default:
- SL_LOGE("Source data locator 0x%x not supported with SL_DATALOCATOR_OUTPUTMIX sink",
- (unsigned)sourceLocatorType);
- break;
- }
- }
- break;
-
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- switch (sourceLocatorType) {
-
- // URI or FD decoded to PCM in a buffer queue
- case SL_DATALOCATOR_URI:
- case SL_DATALOCATOR_ANDROIDFD:
- type = AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE;
- break;
-
- // AAC ADTS Android buffer queue decoded to PCM in a buffer queue
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- type = AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE;
- break;
-
- default:
- SL_LOGE("Source data locator 0x%x not supported with SL_DATALOCATOR_BUFFERQUEUE sink",
- (unsigned)sourceLocatorType);
- break;
- }
- break;
-
- default:
- SL_LOGE("Sink data locator 0x%x not supported", (unsigned)sinkLocatorType);
- break;
- }
-
- return type;
-}
-
-
-//-----------------------------------------------------------------------------
-/*
- * Callback associated with an SfPlayer of an SL ES AudioPlayer that gets its data
- * from a URI or FD, for prepare, prefetch, and play events
- */
-static void sfplayer_handlePrefetchEvent(int event, int data1, int data2, void* user) {
-
- // FIXME see similar code and comment in player_handleMediaPlayerEventNotifications
-
- if (NULL == user) {
- return;
- }
-
- CAudioPlayer *ap = (CAudioPlayer *)user;
- if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
- // it is not safe to enter the callback (the track is about to go away)
- return;
- }
- union {
- char c[sizeof(int)];
- int i;
- } u;
- u.i = event;
- SL_LOGV("sfplayer_handlePrefetchEvent(event='%c%c%c%c' (%d), data1=%d, data2=%d, user=%p) from "
- "SfAudioPlayer", u.c[3], u.c[2], u.c[1], u.c[0], event, data1, data2, user);
- switch(event) {
-
- case android::GenericPlayer::kEventPrepared: {
- SL_LOGV("Received GenericPlayer::kEventPrepared for CAudioPlayer %p", ap);
-
- // assume no callback
- slPrefetchCallback callback = NULL;
- void* callbackPContext;
- SLuint32 events;
-
- object_lock_exclusive(&ap->mObject);
-
- // mark object as prepared; same state is used for successful or unsuccessful prepare
- assert(ap->mAndroidObjState == ANDROID_PREPARING);
- ap->mAndroidObjState = ANDROID_READY;
-
- if (PLAYER_SUCCESS == data1) {
- // Most of successful prepare completion is handled by a subclass.
- } else {
- // SfPlayer prepare() failed prefetching, there is no event in SLPrefetchStatus to
- // indicate a prefetch error, so we signal it by sending simultaneously two events:
- // - SL_PREFETCHEVENT_FILLLEVELCHANGE with a level of 0
- // - SL_PREFETCHEVENT_STATUSCHANGE with a status of SL_PREFETCHSTATUS_UNDERFLOW
- SL_LOGE(ERROR_PLAYER_PREFETCH_d, data1);
- if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
- ap->mPrefetchStatus.mLevel = 0;
- ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
- (SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE))) {
- callback = ap->mPrefetchStatus.mCallback;
- callbackPContext = ap->mPrefetchStatus.mContext;
- events = SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE;
- }
- }
- }
-
- object_unlock_exclusive(&ap->mObject);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, events);
- }
-
- }
- break;
-
- case android::GenericPlayer::kEventPrefetchFillLevelUpdate : {
- if (!IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
- break;
- }
- slPrefetchCallback callback = NULL;
- void* callbackPContext = NULL;
-
- // SLPrefetchStatusItf callback or no callback?
- interface_lock_exclusive(&ap->mPrefetchStatus);
- if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- callback = ap->mPrefetchStatus.mCallback;
- callbackPContext = ap->mPrefetchStatus.mContext;
- }
- ap->mPrefetchStatus.mLevel = (SLpermille)data1;
- interface_unlock_exclusive(&ap->mPrefetchStatus);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
- SL_PREFETCHEVENT_FILLLEVELCHANGE);
- }
- }
- break;
-
- case android::GenericPlayer::kEventPrefetchStatusChange: {
- if (!IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
- break;
- }
- slPrefetchCallback callback = NULL;
- void* callbackPContext = NULL;
-
- // SLPrefetchStatusItf callback or no callback?
- object_lock_exclusive(&ap->mObject);
- if (ap->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_STATUSCHANGE) {
- callback = ap->mPrefetchStatus.mCallback;
- callbackPContext = ap->mPrefetchStatus.mContext;
- }
- if (data1 >= android::kStatusIntermediate) {
- ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
- } else if (data1 < android::kStatusIntermediate) {
- ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- }
- object_unlock_exclusive(&ap->mObject);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext, SL_PREFETCHEVENT_STATUSCHANGE);
- }
- }
- break;
-
- case android::GenericPlayer::kEventEndOfStream: {
- audioPlayer_dispatch_headAtEnd_lockPlay(ap, true /*set state to paused?*/, true);
- if ((ap->mAudioTrack != 0) && (!ap->mSeek.mLoopEnabled)) {
- ap->mAudioTrack->stop();
- }
- }
- break;
-
- case android::GenericPlayer::kEventChannelCount: {
- object_lock_exclusive(&ap->mObject);
- if (UNKNOWN_NUMCHANNELS == ap->mNumChannels && UNKNOWN_NUMCHANNELS != data1) {
- ap->mNumChannels = data1;
- android_audioPlayer_volumeUpdate(ap);
- }
- object_unlock_exclusive(&ap->mObject);
- }
- break;
-
- case android::GenericPlayer::kEventPlay: {
- slPlayCallback callback = NULL;
- void* callbackPContext = NULL;
-
- interface_lock_shared(&ap->mPlay);
- callback = ap->mPlay.mCallback;
- callbackPContext = ap->mPlay.mContext;
- interface_unlock_shared(&ap->mPlay);
-
- if (NULL != callback) {
- SLuint32 event = (SLuint32) data1; // SL_PLAYEVENT_HEAD*
-#ifndef USE_ASYNCHRONOUS_PLAY_CALLBACK
- // synchronous callback requires a synchronous GetPosition implementation
- (*callback)(&ap->mPlay.mItf, callbackPContext, event);
-#else
- // asynchronous callback works with any GetPosition implementation
- SLresult result = EnqueueAsyncCallback_ppi(ap, callback, &ap->mPlay.mItf,
- callbackPContext, event);
- if (SL_RESULT_SUCCESS != result) {
- LOGW("Callback %p(%p, %p, 0x%x) dropped", callback,
- &ap->mPlay.mItf, callbackPContext, event);
- }
-#endif
- }
- }
- break;
-
- case android::GenericPlayer::kEventErrorAfterPrepare: {
- SL_LOGV("kEventErrorAfterPrepare");
-
- // assume no callback
- slPrefetchCallback callback = NULL;
- void* callbackPContext = NULL;
-
- object_lock_exclusive(&ap->mObject);
- if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
- ap->mPrefetchStatus.mLevel = 0;
- ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
- (SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE))) {
- callback = ap->mPrefetchStatus.mCallback;
- callbackPContext = ap->mPrefetchStatus.mContext;
- }
- }
- object_unlock_exclusive(&ap->mObject);
-
- // FIXME there's interesting information in data1, but no API to convey it to client
- SL_LOGE("Error after prepare: %d", data1);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
- }
-
- }
- break;
-
-
- default:
- break;
- }
-
- ap->mCallbackProtector->exitCb();
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_checkSourceSink(CAudioPlayer *pAudioPlayer)
-{
- // verify that the locator types for the source / sink combination is supported
- pAudioPlayer->mAndroidObjType = audioPlayer_getAndroidObjectTypeForSourceSink(pAudioPlayer);
- if (INVALID_TYPE == pAudioPlayer->mAndroidObjType) {
- return SL_RESULT_PARAMETER_INVALID;
- }
-
- const SLDataSource *pAudioSrc = &pAudioPlayer->mDataSource.u.mSource;
- const SLDataSink *pAudioSnk = &pAudioPlayer->mDataSink.u.mSink;
-
- // format check:
- const SLuint32 sourceLocatorType = *(SLuint32 *)pAudioSrc->pLocator;
- const SLuint32 sinkLocatorType = *(SLuint32 *)pAudioSnk->pLocator;
- const SLuint32 sourceFormatType = *(SLuint32 *)pAudioSrc->pFormat;
- const SLuint32 sinkFormatType = *(SLuint32 *)pAudioSnk->pFormat;
-
- switch (sourceLocatorType) {
- //------------------
- // Buffer Queues
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- {
- SLDataLocator_BufferQueue *dl_bq = (SLDataLocator_BufferQueue *) pAudioSrc->pLocator;
-
- // Buffer format
- switch (sourceFormatType) {
- // currently only PCM buffer queues are supported,
- case SL_DATAFORMAT_PCM: {
- SLDataFormat_PCM *df_pcm = (SLDataFormat_PCM *) pAudioSrc->pFormat;
- switch (df_pcm->numChannels) {
- case 1:
- case 2:
- break;
- default:
- // this should have already been rejected by checkDataFormat
- SL_LOGE("Cannot create audio player: unsupported " \
- "PCM data source with %u channels", (unsigned) df_pcm->numChannels);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- switch (df_pcm->samplesPerSec) {
- case SL_SAMPLINGRATE_8:
- case SL_SAMPLINGRATE_11_025:
- case SL_SAMPLINGRATE_12:
- case SL_SAMPLINGRATE_16:
- case SL_SAMPLINGRATE_22_05:
- case SL_SAMPLINGRATE_24:
- case SL_SAMPLINGRATE_32:
- case SL_SAMPLINGRATE_44_1:
- case SL_SAMPLINGRATE_48:
- break;
- case SL_SAMPLINGRATE_64:
- case SL_SAMPLINGRATE_88_2:
- case SL_SAMPLINGRATE_96:
- case SL_SAMPLINGRATE_192:
- default:
- SL_LOGE("Cannot create audio player: unsupported sample rate %u milliHz",
- (unsigned) df_pcm->samplesPerSec);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- switch (df_pcm->bitsPerSample) {
- case SL_PCMSAMPLEFORMAT_FIXED_8:
- case SL_PCMSAMPLEFORMAT_FIXED_16:
- break;
- // others
- default:
- // this should have already been rejected by checkDataFormat
- SL_LOGE("Cannot create audio player: unsupported sample bit depth %u",
- (SLuint32)df_pcm->bitsPerSample);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- switch (df_pcm->containerSize) {
- case 8:
- case 16:
- break;
- // others
- default:
- SL_LOGE("Cannot create audio player: unsupported container size %u",
- (unsigned) df_pcm->containerSize);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- // df_pcm->channelMask: the earlier platform-independent check and the
- // upcoming check by sles_to_android_channelMaskOut are sufficient
- switch (df_pcm->endianness) {
- case SL_BYTEORDER_LITTLEENDIAN:
- break;
- case SL_BYTEORDER_BIGENDIAN:
- SL_LOGE("Cannot create audio player: unsupported big-endian byte order");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- // native is proposed but not yet in spec
- default:
- SL_LOGE("Cannot create audio player: unsupported byte order %u",
- (unsigned) df_pcm->endianness);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- } //case SL_DATAFORMAT_PCM
- break;
- case SL_DATAFORMAT_MIME:
- case XA_DATAFORMAT_RAWIMAGE:
- SL_LOGE("Cannot create audio player with buffer queue data source "
- "without SL_DATAFORMAT_PCM format");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- default:
- // invalid data format is detected earlier
- assert(false);
- return SL_RESULT_INTERNAL_ERROR;
- } // switch (sourceFormatType)
- } // case SL_DATALOCATOR_BUFFERQUEUE or SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE
- break;
- //------------------
- // URI
- case SL_DATALOCATOR_URI:
- {
- SLDataLocator_URI *dl_uri = (SLDataLocator_URI *) pAudioSrc->pLocator;
- if (NULL == dl_uri->URI) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- // URI format
- switch (sourceFormatType) {
- case SL_DATAFORMAT_MIME:
- break;
- case SL_DATAFORMAT_PCM:
- case XA_DATAFORMAT_RAWIMAGE:
- SL_LOGE("Cannot create audio player with SL_DATALOCATOR_URI data source without "
- "SL_DATAFORMAT_MIME format");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- } // switch (sourceFormatType)
- // decoding format check
- if ((sinkLocatorType != SL_DATALOCATOR_OUTPUTMIX) &&
- !audioPlayer_isSupportedNonOutputMixSink(pAudioSnk)) {
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- } // case SL_DATALOCATOR_URI
- break;
- //------------------
- // File Descriptor
- case SL_DATALOCATOR_ANDROIDFD:
- {
- // fd is already non null
- switch (sourceFormatType) {
- case SL_DATAFORMAT_MIME:
- break;
- case SL_DATAFORMAT_PCM:
- // FIXME implement
- SL_LOGD("[ FIXME implement PCM FD data sources ]");
- break;
- case XA_DATAFORMAT_RAWIMAGE:
- SL_LOGE("Cannot create audio player with SL_DATALOCATOR_ANDROIDFD data source "
- "without SL_DATAFORMAT_MIME or SL_DATAFORMAT_PCM format");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- default:
- // invalid data format is detected earlier
- assert(false);
- return SL_RESULT_INTERNAL_ERROR;
- } // switch (sourceFormatType)
- if ((sinkLocatorType != SL_DATALOCATOR_OUTPUTMIX) &&
- !audioPlayer_isSupportedNonOutputMixSink(pAudioSnk)) {
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- } // case SL_DATALOCATOR_ANDROIDFD
- break;
- //------------------
- // Stream
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- {
- switch (sourceFormatType) {
- case SL_DATAFORMAT_MIME:
- {
- SLDataFormat_MIME *df_mime = (SLDataFormat_MIME *) pAudioSrc->pFormat;
- if (NULL == df_mime) {
- SL_LOGE("MIME type null invalid");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- SL_LOGD("source MIME is %s", (char*)df_mime->mimeType);
- switch(df_mime->containerType) {
- case SL_CONTAINERTYPE_MPEG_TS:
- if (strcasecmp((char*)df_mime->mimeType, (const char *)XA_ANDROID_MIME_MP2TS)) {
- SL_LOGE("Invalid MIME (%s) for container SL_CONTAINERTYPE_MPEG_TS, expects %s",
- (char*)df_mime->mimeType, XA_ANDROID_MIME_MP2TS);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- break;
- case SL_CONTAINERTYPE_RAW:
- case SL_CONTAINERTYPE_AAC:
- if (strcasecmp((char*)df_mime->mimeType, (const char *)SL_ANDROID_MIME_AACADTS) &&
- strcasecmp((char*)df_mime->mimeType,
- ANDROID_MIME_AACADTS_ANDROID_FRAMEWORK)) {
- SL_LOGE("Invalid MIME (%s) for container type %d, expects %s",
- (char*)df_mime->mimeType, df_mime->containerType,
- SL_ANDROID_MIME_AACADTS);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- break;
- default:
- SL_LOGE("Cannot create player with SL_DATALOCATOR_ANDROIDBUFFERQUEUE data source "
- "that is not fed MPEG-2 TS data or AAC ADTS data");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- }
- break;
- default:
- SL_LOGE("Cannot create player with SL_DATALOCATOR_ANDROIDBUFFERQUEUE data source "
- "without SL_DATAFORMAT_MIME format");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- }
- break; // case SL_DATALOCATOR_ANDROIDBUFFERQUEUE
- //------------------
- // Address
- case SL_DATALOCATOR_ADDRESS:
- case SL_DATALOCATOR_IODEVICE:
- case SL_DATALOCATOR_OUTPUTMIX:
- case XA_DATALOCATOR_NATIVEDISPLAY:
- case SL_DATALOCATOR_MIDIBUFFERQUEUE:
- SL_LOGE("Cannot create audio player with data locator type 0x%x",
- (unsigned) sourceLocatorType);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- default:
- SL_LOGE("Cannot create audio player with invalid data locator type 0x%x",
- (unsigned) sourceLocatorType);
- return SL_RESULT_PARAMETER_INVALID;
- }// switch (locatorType)
-
- return SL_RESULT_SUCCESS;
-}
-
-
-//-----------------------------------------------------------------------------
-// Callback associated with an AudioTrack of an SL ES AudioPlayer that gets its data
-// from a buffer queue. This will not be called once the AudioTrack has been destroyed.
-static void audioTrack_callBack_pullFromBuffQueue(int event, void* user, void *info) {
- CAudioPlayer *ap = (CAudioPlayer *)user;
-
- if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
- // it is not safe to enter the callback (the track is about to go away)
- return;
- }
-
- void * callbackPContext = NULL;
- switch(event) {
-
- case android::AudioTrack::EVENT_MORE_DATA: {
- //SL_LOGV("received event EVENT_MORE_DATA from AudioTrack TID=%d", gettid());
- slBufferQueueCallback callback = NULL;
- slPrefetchCallback prefetchCallback = NULL;
- void *prefetchContext = NULL;
- SLuint32 prefetchEvents = SL_PREFETCHEVENT_NONE;
- android::AudioTrack::Buffer* pBuff = (android::AudioTrack::Buffer*)info;
-
- // retrieve data from the buffer queue
- interface_lock_exclusive(&ap->mBufferQueue);
-
- if (ap->mBufferQueue.mState.count != 0) {
- //SL_LOGV("nbBuffers in queue = %u",ap->mBufferQueue.mState.count);
- assert(ap->mBufferQueue.mFront != ap->mBufferQueue.mRear);
-
- BufferHeader *oldFront = ap->mBufferQueue.mFront;
- BufferHeader *newFront = &oldFront[1];
-
- // declared as void * because this code supports both 8-bit and 16-bit PCM data
- void *pSrc = (char *)oldFront->mBuffer + ap->mBufferQueue.mSizeConsumed;
- if (ap->mBufferQueue.mSizeConsumed + pBuff->size < oldFront->mSize) {
- // can't consume the whole or rest of the buffer in one shot
- ap->mBufferQueue.mSizeConsumed += pBuff->size;
- // leave pBuff->size untouched
- // consume data
- // FIXME can we avoid holding the lock during the copy?
- memcpy (pBuff->raw, pSrc, pBuff->size);
- } else {
- // finish consuming the buffer or consume the buffer in one shot
- pBuff->size = oldFront->mSize - ap->mBufferQueue.mSizeConsumed;
- ap->mBufferQueue.mSizeConsumed = 0;
-
- if (newFront ==
- &ap->mBufferQueue.mArray
- [ap->mBufferQueue.mNumBuffers + 1])
- {
- newFront = ap->mBufferQueue.mArray;
- }
- ap->mBufferQueue.mFront = newFront;
-
- ap->mBufferQueue.mState.count--;
- ap->mBufferQueue.mState.playIndex++;
-
- // consume data
- // FIXME can we avoid holding the lock during the copy?
- memcpy (pBuff->raw, pSrc, pBuff->size);
-
- // data has been consumed, and the buffer queue state has been updated
- // we will notify the client if applicable
- callback = ap->mBufferQueue.mCallback;
- // save callback data
- callbackPContext = ap->mBufferQueue.mContext;
- }
- } else { // empty queue
- // signal no data available
- pBuff->size = 0;
-
- // signal we're at the end of the content, but don't pause (see note in function)
- audioPlayer_dispatch_headAtEnd_lockPlay(ap, false /*set state to paused?*/, false);
-
- // signal underflow to prefetch status itf
- if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
- ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- ap->mPrefetchStatus.mLevel = 0;
- // callback or no callback?
- prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE);
- if (SL_PREFETCHEVENT_NONE != prefetchEvents) {
- prefetchCallback = ap->mPrefetchStatus.mCallback;
- prefetchContext = ap->mPrefetchStatus.mContext;
- }
- }
-
- // stop the track so it restarts playing faster when new data is enqueued
- ap->mAudioTrack->stop();
- }
- interface_unlock_exclusive(&ap->mBufferQueue);
-
- // notify client
- if (NULL != prefetchCallback) {
- assert(SL_PREFETCHEVENT_NONE != prefetchEvents);
- // spec requires separate callbacks for each event
- if (prefetchEvents & SL_PREFETCHEVENT_STATUSCHANGE) {
- (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
- SL_PREFETCHEVENT_STATUSCHANGE);
- }
- if (prefetchEvents & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
- SL_PREFETCHEVENT_FILLLEVELCHANGE);
- }
- }
- if (NULL != callback) {
- (*callback)(&ap->mBufferQueue.mItf, callbackPContext);
- }
- }
- break;
-
- case android::AudioTrack::EVENT_MARKER:
- //SL_LOGI("received event EVENT_MARKER from AudioTrack");
- audioTrack_handleMarker_lockPlay(ap);
- break;
-
- case android::AudioTrack::EVENT_NEW_POS:
- //SL_LOGI("received event EVENT_NEW_POS from AudioTrack");
- audioTrack_handleNewPos_lockPlay(ap);
- break;
-
- case android::AudioTrack::EVENT_UNDERRUN:
- //SL_LOGI("received event EVENT_UNDERRUN from AudioTrack");
- audioTrack_handleUnderrun_lockPlay(ap);
- break;
-
- default:
- // FIXME where does the notification of SL_PLAYEVENT_HEADMOVING fit?
- SL_LOGE("Encountered unknown AudioTrack event %d for CAudioPlayer %p", event,
- (CAudioPlayer *)user);
- break;
- }
-
- ap->mCallbackProtector->exitCb();
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_create(CAudioPlayer *pAudioPlayer) {
-
- SLresult result = SL_RESULT_SUCCESS;
- // pAudioPlayer->mAndroidObjType has been set in audioPlayer_getAndroidObjectTypeForSourceSink()
- if (INVALID_TYPE == pAudioPlayer->mAndroidObjType) {
- audioPlayer_setInvalid(pAudioPlayer);
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
-
- // These initializations are in the same order as the field declarations in classes.h
-
- // FIXME Consolidate initializations (many of these already in IEngine_CreateAudioPlayer)
- // mAndroidObjType: see above comment
- pAudioPlayer->mAndroidObjState = ANDROID_UNINITIALIZED;
- pAudioPlayer->mSessionId = android::AudioSystem::newAudioSessionId();
- pAudioPlayer->mStreamType = ANDROID_DEFAULT_OUTPUT_STREAM_TYPE;
-
- // mAudioTrack
- pAudioPlayer->mCallbackProtector = new android::CallbackProtector();
- // mAPLayer
- // mAuxEffect
-
- pAudioPlayer->mAuxSendLevel = 0;
- pAudioPlayer->mAmplFromDirectLevel = 1.0f; // matches initial mDirectLevel value
- pAudioPlayer->mDeferredStart = false;
-
- // Already initialized in IEngine_CreateAudioPlayer, to be consolidated
- pAudioPlayer->mDirectLevel = 0; // no attenuation
-
- // This section re-initializes interface-specific fields that
- // can be set or used regardless of whether the interface is
- // exposed on the AudioPlayer or not
-
- // Only AudioTrack supports a non-trivial playback rate
- switch (pAudioPlayer->mAndroidObjType) {
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
- pAudioPlayer->mPlaybackRate.mMinRate = AUDIOTRACK_MIN_PLAYBACKRATE_PERMILLE;
- pAudioPlayer->mPlaybackRate.mMaxRate = AUDIOTRACK_MAX_PLAYBACKRATE_PERMILLE;
- break;
- default:
- // use the default range
- break;
- }
-
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_setConfig(CAudioPlayer *ap, const SLchar *configKey,
- const void *pConfigValue, SLuint32 valueSize) {
-
- SLresult result;
-
- assert(NULL != ap && NULL != configKey && NULL != pConfigValue);
- if(strcmp((const char*)configKey, (const char*)SL_ANDROID_KEY_STREAM_TYPE) == 0) {
-
- // stream type
- if (KEY_STREAM_TYPE_PARAMSIZE > valueSize) {
- SL_LOGE(ERROR_CONFIG_VALUESIZE_TOO_LOW);
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- result = audioPlayer_setStreamType(ap, *(SLuint32*)pConfigValue);
- }
-
- } else {
- SL_LOGE(ERROR_CONFIG_UNKNOWN_KEY);
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_getConfig(CAudioPlayer* ap, const SLchar *configKey,
- SLuint32* pValueSize, void *pConfigValue) {
-
- SLresult result;
-
- assert(NULL != ap && NULL != configKey && NULL != pValueSize);
- if(strcmp((const char*)configKey, (const char*)SL_ANDROID_KEY_STREAM_TYPE) == 0) {
-
- // stream type
- if (NULL == pConfigValue) {
- result = SL_RESULT_SUCCESS;
- } else if (KEY_STREAM_TYPE_PARAMSIZE > *pValueSize) {
- SL_LOGE(ERROR_CONFIG_VALUESIZE_TOO_LOW);
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- result = audioPlayer_getStreamType(ap, (SLint32*)pConfigValue);
- }
- *pValueSize = KEY_STREAM_TYPE_PARAMSIZE;
-
- } else {
- SL_LOGE(ERROR_CONFIG_UNKNOWN_KEY);
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-// FIXME abstract out the diff between CMediaPlayer and CAudioPlayer
-SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async) {
-
- SLresult result = SL_RESULT_SUCCESS;
- SL_LOGV("Realize pAudioPlayer=%p", pAudioPlayer);
-
- switch (pAudioPlayer->mAndroidObjType) {
- //-----------------------------------
- // AudioTrack
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
- {
- // initialize platform-specific CAudioPlayer fields
-
- SLDataLocator_BufferQueue *dl_bq = (SLDataLocator_BufferQueue *)
- pAudioPlayer->mDynamicSource.mDataSource;
- SLDataFormat_PCM *df_pcm = (SLDataFormat_PCM *)
- pAudioPlayer->mDynamicSource.mDataSource->pFormat;
-
- uint32_t sampleRate = sles_to_android_sampleRate(df_pcm->samplesPerSec);
-
- pAudioPlayer->mAudioTrack = new android::AudioTrackProxy(new android::AudioTrack(
- pAudioPlayer->mStreamType, // streamType
- sampleRate, // sampleRate
- sles_to_android_sampleFormat(df_pcm->bitsPerSample), // format
- sles_to_android_channelMaskOut(df_pcm->numChannels, df_pcm->channelMask),
- //channel mask
- 0, // frameCount (here min)
- 0, // flags
- audioTrack_callBack_pullFromBuffQueue, // callback
- (void *) pAudioPlayer, // user
- 0 // FIXME find appropriate frame count // notificationFrame
- , pAudioPlayer->mSessionId
- ));
- android::status_t status = pAudioPlayer->mAudioTrack->initCheck();
- if (status != android::NO_ERROR) {
- SL_LOGE("AudioTrack::initCheck status %u", status);
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- pAudioPlayer->mAudioTrack.clear();
- return result;
- }
-
- // initialize platform-independent CAudioPlayer fields
-
- pAudioPlayer->mNumChannels = df_pcm->numChannels;
- pAudioPlayer->mSampleRateMilliHz = df_pcm->samplesPerSec; // Note: bad field name in SL ES
-
- // This use case does not have a separate "prepare" step
- pAudioPlayer->mAndroidObjState = ANDROID_READY;
- }
- break;
- //-----------------------------------
- // MediaPlayer
- case AUDIOPLAYER_FROM_URIFD: {
- assert(pAudioPlayer->mAndroidObjState == ANDROID_UNINITIALIZED);
- assert(pAudioPlayer->mNumChannels == UNKNOWN_NUMCHANNELS);
- assert(pAudioPlayer->mSampleRateMilliHz == UNKNOWN_SAMPLERATE);
- assert(pAudioPlayer->mAudioTrack == 0);
-
- AudioPlayback_Parameters app;
- app.sessionId = pAudioPlayer->mSessionId;
- app.streamType = pAudioPlayer->mStreamType;
-
- pAudioPlayer->mAPlayer = new android::LocAVPlayer(&app, false /*hasVideo*/);
- pAudioPlayer->mAPlayer->init(sfplayer_handlePrefetchEvent,
- (void*)pAudioPlayer /*notifUSer*/);
-
- switch (pAudioPlayer->mDataSource.mLocator.mLocatorType) {
- case SL_DATALOCATOR_URI: {
- // The legacy implementation ran Stagefright within the application process, and
- // so allowed local pathnames specified by URI that were openable by
- // the application but were not openable by mediaserver.
- // The current implementation runs Stagefright (mostly) within mediaserver,
- // which runs as a different UID and likely a different current working directory.
- // For backwards compatibility with any applications which may have relied on the
- // previous behavior, we convert an openable file URI into an FD.
- // Note that unlike SL_DATALOCATOR_ANDROIDFD, this FD is owned by us
- // and so we close it as soon as we've passed it (via Binder dup) to mediaserver.
- const char *uri = (const char *)pAudioPlayer->mDataSource.mLocator.mURI.URI;
- if (!isDistantProtocol(uri)) {
- // don't touch the original uri, we may need it later
- const char *pathname = uri;
- // skip over an optional leading file:// prefix
- if (!strncasecmp(pathname, "file://", 7)) {
- pathname += 7;
- }
- // attempt to open it as a file using the application's credentials
- int fd = ::open(pathname, O_RDONLY);
- if (fd >= 0) {
- // if open is successful, then check to see if it's a regular file
- struct stat statbuf;
- if (!::fstat(fd, &statbuf) && S_ISREG(statbuf.st_mode)) {
- // treat similarly to an FD data locator, but
- // let setDataSource take responsibility for closing fd
- pAudioPlayer->mAPlayer->setDataSource(fd, 0, statbuf.st_size, true);
- break;
- }
- // we were able to open it, but it's not a file, so let mediaserver try
- (void) ::close(fd);
- }
- }
- // if either the URI didn't look like a file, or open failed, or not a file
- pAudioPlayer->mAPlayer->setDataSource(uri);
- } break;
- case SL_DATALOCATOR_ANDROIDFD: {
- int64_t offset = (int64_t)pAudioPlayer->mDataSource.mLocator.mFD.offset;
- pAudioPlayer->mAPlayer->setDataSource(
- (int)pAudioPlayer->mDataSource.mLocator.mFD.fd,
- offset == SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ?
- (int64_t)PLAYER_FD_FIND_FILE_SIZE : offset,
- (int64_t)pAudioPlayer->mDataSource.mLocator.mFD.length);
- }
- break;
- default:
- SL_LOGE(ERROR_PLAYERREALIZE_UNKNOWN_DATASOURCE_LOCATOR);
- break;
- }
-
- }
- break;
- //-----------------------------------
- // StreamPlayer
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: {
- AudioPlayback_Parameters ap_params;
- ap_params.sessionId = pAudioPlayer->mSessionId;
- ap_params.streamType = pAudioPlayer->mStreamType;
- android::StreamPlayer* splr = new android::StreamPlayer(&ap_params, false /*hasVideo*/,
- &pAudioPlayer->mAndroidBufferQueue, pAudioPlayer->mCallbackProtector);
- pAudioPlayer->mAPlayer = splr;
- splr->init(sfplayer_handlePrefetchEvent, (void*)pAudioPlayer);
- }
- break;
- //-----------------------------------
- // AudioToCbRenderer
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE: {
- AudioPlayback_Parameters app;
- app.sessionId = pAudioPlayer->mSessionId;
- app.streamType = pAudioPlayer->mStreamType;
-
- android::AudioToCbRenderer* decoder = new android::AudioToCbRenderer(&app);
- pAudioPlayer->mAPlayer = decoder;
- // configures the callback for the sink buffer queue
- decoder->setDataPushListener(adecoder_writeToBufferQueue, pAudioPlayer);
- // configures the callback for the notifications coming from the SF code
- decoder->init(sfplayer_handlePrefetchEvent, (void*)pAudioPlayer);
-
- switch (pAudioPlayer->mDataSource.mLocator.mLocatorType) {
- case SL_DATALOCATOR_URI:
- decoder->setDataSource(
- (const char*)pAudioPlayer->mDataSource.mLocator.mURI.URI);
- break;
- case SL_DATALOCATOR_ANDROIDFD: {
- int64_t offset = (int64_t)pAudioPlayer->mDataSource.mLocator.mFD.offset;
- decoder->setDataSource(
- (int)pAudioPlayer->mDataSource.mLocator.mFD.fd,
- offset == SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ?
- (int64_t)PLAYER_FD_FIND_FILE_SIZE : offset,
- (int64_t)pAudioPlayer->mDataSource.mLocator.mFD.length);
- }
- break;
- default:
- SL_LOGE(ERROR_PLAYERREALIZE_UNKNOWN_DATASOURCE_LOCATOR);
- break;
- }
-
- }
- break;
- //-----------------------------------
- // AacBqToPcmCbRenderer
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE: {
- AudioPlayback_Parameters app;
- app.sessionId = pAudioPlayer->mSessionId;
- app.streamType = pAudioPlayer->mStreamType;
- android::AacBqToPcmCbRenderer* bqtobq = new android::AacBqToPcmCbRenderer(&app);
- // configures the callback for the sink buffer queue
- bqtobq->setDataPushListener(adecoder_writeToBufferQueue, pAudioPlayer);
- pAudioPlayer->mAPlayer = bqtobq;
- // configures the callback for the notifications coming from the SF code,
- // but also implicitly configures the AndroidBufferQueue from which ADTS data is read
- pAudioPlayer->mAPlayer->init(sfplayer_handlePrefetchEvent, (void*)pAudioPlayer);
- }
- break;
- //-----------------------------------
- default:
- SL_LOGE(ERROR_PLAYERREALIZE_UNEXPECTED_OBJECT_TYPE_D, pAudioPlayer->mAndroidObjType);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
-
-
- // proceed with effect initialization
- // initialize EQ
- // FIXME use a table of effect descriptors when adding support for more effects
- if (memcmp(SL_IID_EQUALIZER, &pAudioPlayer->mEqualizer.mEqDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- SL_LOGV("Need to initialize EQ for AudioPlayer=%p", pAudioPlayer);
- android_eq_init(pAudioPlayer->mSessionId, &pAudioPlayer->mEqualizer);
- }
- // initialize BassBoost
- if (memcmp(SL_IID_BASSBOOST, &pAudioPlayer->mBassBoost.mBassBoostDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- SL_LOGV("Need to initialize BassBoost for AudioPlayer=%p", pAudioPlayer);
- android_bb_init(pAudioPlayer->mSessionId, &pAudioPlayer->mBassBoost);
- }
- // initialize Virtualizer
- if (memcmp(SL_IID_VIRTUALIZER, &pAudioPlayer->mVirtualizer.mVirtualizerDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- SL_LOGV("Need to initialize Virtualizer for AudioPlayer=%p", pAudioPlayer);
- android_virt_init(pAudioPlayer->mSessionId, &pAudioPlayer->mVirtualizer);
- }
-
- // initialize EffectSend
- // FIXME initialize EffectSend
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-/**
- * Called with a lock on AudioPlayer, and blocks until safe to destroy
- */
-SLresult android_audioPlayer_preDestroy(CAudioPlayer *pAudioPlayer) {
- SL_LOGD("android_audioPlayer_preDestroy(%p)", pAudioPlayer);
- SLresult result = SL_RESULT_SUCCESS;
-
- bool disableCallbacksBeforePreDestroy;
- switch (pAudioPlayer->mAndroidObjType) {
- // Not yet clear why this order is important, but it reduces detected deadlocks
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- disableCallbacksBeforePreDestroy = true;
- break;
- // Use the old behavior for all other use cases until proven
- // case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- default:
- disableCallbacksBeforePreDestroy = false;
- break;
- }
-
- if (disableCallbacksBeforePreDestroy) {
- object_unlock_exclusive(&pAudioPlayer->mObject);
- if (pAudioPlayer->mCallbackProtector != 0) {
- pAudioPlayer->mCallbackProtector->requestCbExitAndWait();
- }
- object_lock_exclusive(&pAudioPlayer->mObject);
- }
-
- if (pAudioPlayer->mAPlayer != 0) {
- pAudioPlayer->mAPlayer->preDestroy();
- }
- SL_LOGD("android_audioPlayer_preDestroy(%p) after mAPlayer->preDestroy()", pAudioPlayer);
-
- if (!disableCallbacksBeforePreDestroy) {
- object_unlock_exclusive(&pAudioPlayer->mObject);
- if (pAudioPlayer->mCallbackProtector != 0) {
- pAudioPlayer->mCallbackProtector->requestCbExitAndWait();
- }
- object_lock_exclusive(&pAudioPlayer->mObject);
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_destroy(CAudioPlayer *pAudioPlayer) {
- SLresult result = SL_RESULT_SUCCESS;
- SL_LOGV("android_audioPlayer_destroy(%p)", pAudioPlayer);
- switch (pAudioPlayer->mAndroidObjType) {
-
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
- // We own the audio track for PCM buffer queue players
- if (pAudioPlayer->mAudioTrack != 0) {
- pAudioPlayer->mAudioTrack->stop();
- // Note that there may still be another reference in post-unlock phase of SetPlayState
- pAudioPlayer->mAudioTrack.clear();
- }
- break;
-
- case AUDIOPLAYER_FROM_URIFD: // intended fall-through
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE: // intended fall-through
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- pAudioPlayer->mAPlayer.clear();
- break;
- //-----------------------------------
- default:
- SL_LOGE(ERROR_PLAYERDESTROY_UNEXPECTED_OBJECT_TYPE_D, pAudioPlayer->mAndroidObjType);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
-
- pAudioPlayer->mCallbackProtector.clear();
-
- // FIXME might not be needed
- pAudioPlayer->mAndroidObjType = INVALID_TYPE;
-
- // explicit destructor
- pAudioPlayer->mAudioTrack.~sp();
- // note that SetPlayState(PLAYING) may still hold a reference
- pAudioPlayer->mCallbackProtector.~sp();
- pAudioPlayer->mAuxEffect.~sp();
- pAudioPlayer->mAPlayer.~sp();
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_setPlaybackRateAndConstraints(CAudioPlayer *ap, SLpermille rate,
- SLuint32 constraints) {
- SLresult result = SL_RESULT_SUCCESS;
- switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE: {
- // these asserts were already checked by the platform-independent layer
- assert((AUDIOTRACK_MIN_PLAYBACKRATE_PERMILLE <= rate) &&
- (rate <= AUDIOTRACK_MAX_PLAYBACKRATE_PERMILLE));
- assert(constraints & SL_RATEPROP_NOPITCHCORAUDIO);
- // get the content sample rate
- uint32_t contentRate = sles_to_android_sampleRate(ap->mSampleRateMilliHz);
- // apply the SL ES playback rate on the AudioTrack as a factor of its content sample rate
- if (ap->mAudioTrack != 0) {
- ap->mAudioTrack->setSampleRate(contentRate * (rate/1000.0f));
- }
- }
- break;
- case AUDIOPLAYER_FROM_URIFD:
- assert(rate == 1000);
- assert(constraints & SL_RATEPROP_NOPITCHCORAUDIO);
- // that was easy
- break;
-
- default:
- SL_LOGE("Unexpected object type %d", ap->mAndroidObjType);
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- break;
- }
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-// precondition
-// called with no lock held
-// ap != NULL
-// pItemCount != NULL
-SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *ap, SLuint32 *pItemCount) {
- if (ap->mAPlayer == 0) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- {
- android::AudioSfDecoder* decoder =
- static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
- *pItemCount = decoder->getPcmFormatKeyCount();
- }
- break;
- default:
- *pItemCount = 0;
- break;
- }
- return SL_RESULT_SUCCESS;
-}
-
-
-//-----------------------------------------------------------------------------
-// precondition
-// called with no lock held
-// ap != NULL
-// pKeySize != NULL
-SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *ap,
- SLuint32 index, SLuint32 *pKeySize) {
- if (ap->mAPlayer == 0) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLresult res = SL_RESULT_SUCCESS;
- switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- {
- android::AudioSfDecoder* decoder =
- static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
- SLuint32 keyNameSize = 0;
- if (!decoder->getPcmFormatKeySize(index, &keyNameSize)) {
- res = SL_RESULT_PARAMETER_INVALID;
- } else {
- // *pKeySize is the size of the region used to store the key name AND
- // the information about the key (size, lang, encoding)
- *pKeySize = keyNameSize + sizeof(SLMetadataInfo);
- }
- }
- break;
- default:
- *pKeySize = 0;
- res = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- return res;
-}
-
-
-//-----------------------------------------------------------------------------
-// precondition
-// called with no lock held
-// ap != NULL
-// pKey != NULL
-SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *ap,
- SLuint32 index, SLuint32 size, SLMetadataInfo *pKey) {
- if (ap->mAPlayer == 0) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLresult res = SL_RESULT_SUCCESS;
- switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- {
- android::AudioSfDecoder* decoder =
- static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
- if ((size < sizeof(SLMetadataInfo) ||
- (!decoder->getPcmFormatKeyName(index, size - sizeof(SLMetadataInfo),
- (char*)pKey->data)))) {
- res = SL_RESULT_PARAMETER_INVALID;
- } else {
- // successfully retrieved the key value, update the other fields
- pKey->encoding = SL_CHARACTERENCODING_UTF8;
- memcpy((char *) pKey->langCountry, "en", 3);
- pKey->size = strlen((char*)pKey->data) + 1;
- }
- }
- break;
- default:
- res = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- return res;
-}
-
-
-//-----------------------------------------------------------------------------
-// precondition
-// called with no lock held
-// ap != NULL
-// pValueSize != NULL
-SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *ap,
- SLuint32 index, SLuint32 *pValueSize) {
- if (ap->mAPlayer == 0) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLresult res = SL_RESULT_SUCCESS;
- switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- {
- android::AudioSfDecoder* decoder =
- static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
- SLuint32 valueSize = 0;
- if (!decoder->getPcmFormatValueSize(index, &valueSize)) {
- res = SL_RESULT_PARAMETER_INVALID;
- } else {
- // *pValueSize is the size of the region used to store the key value AND
- // the information about the value (size, lang, encoding)
- *pValueSize = valueSize + sizeof(SLMetadataInfo);
- }
- }
- break;
- default:
- *pValueSize = 0;
- res = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- return res;
-}
-
-
-//-----------------------------------------------------------------------------
-// precondition
-// called with no lock held
-// ap != NULL
-// pValue != NULL
-SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *ap,
- SLuint32 index, SLuint32 size, SLMetadataInfo *pValue) {
- if (ap->mAPlayer == 0) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLresult res = SL_RESULT_SUCCESS;
- switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- {
- android::AudioSfDecoder* decoder =
- static_cast<android::AudioSfDecoder*>(ap->mAPlayer.get());
- pValue->encoding = SL_CHARACTERENCODING_BINARY;
- memcpy((char *) pValue->langCountry, "en", 3); // applicable here?
- SLuint32 valueSize = 0;
- if ((size < sizeof(SLMetadataInfo)
- || (!decoder->getPcmFormatValueSize(index, &valueSize))
- || (!decoder->getPcmFormatKeyValue(index, size - sizeof(SLMetadataInfo),
- (SLuint32*)pValue->data)))) {
- res = SL_RESULT_PARAMETER_INVALID;
- } else {
- pValue->size = valueSize;
- }
- }
- break;
- default:
- res = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- return res;
-}
-
-//-----------------------------------------------------------------------------
-// preconditions
-// ap != NULL
-// mutex is locked
-// play state has changed
-void android_audioPlayer_setPlayState(CAudioPlayer *ap) {
-
- SLuint32 playState = ap->mPlay.mState;
- AndroidObjectState objState = ap->mAndroidObjState;
-
- switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
- switch (playState) {
- case SL_PLAYSTATE_STOPPED:
- SL_LOGV("setting AudioPlayer to SL_PLAYSTATE_STOPPED");
- if (ap->mAudioTrack != 0) {
- ap->mAudioTrack->stop();
- }
- break;
- case SL_PLAYSTATE_PAUSED:
- SL_LOGV("setting AudioPlayer to SL_PLAYSTATE_PAUSED");
- if (ap->mAudioTrack != 0) {
- ap->mAudioTrack->pause();
- }
- break;
- case SL_PLAYSTATE_PLAYING:
- SL_LOGV("setting AudioPlayer to SL_PLAYSTATE_PLAYING");
- if (ap->mAudioTrack != 0) {
- // instead of ap->mAudioTrack->start();
- ap->mDeferredStart = true;
- }
- break;
- default:
- // checked by caller, should not happen
- break;
- }
- break;
-
- case AUDIOPLAYER_FROM_URIFD: // intended fall-through
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE: // intended fall-through
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- // FIXME report and use the return code to the lock mechanism, which is where play state
- // changes are updated (see object_unlock_exclusive_attributes())
- aplayer_setPlayState(ap->mAPlayer, playState, &(ap->mAndroidObjState));
- break;
- default:
- SL_LOGE(ERROR_PLAYERSETPLAYSTATE_UNEXPECTED_OBJECT_TYPE_D, ap->mAndroidObjType);
- break;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// call when either player event flags, marker position, or position update period changes
-void android_audioPlayer_usePlayEventMask(CAudioPlayer *ap) {
- IPlay *pPlayItf = &ap->mPlay;
- SLuint32 eventFlags = pPlayItf->mEventFlags;
- /*switch(ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:*/
-
- if (ap->mAPlayer != 0) {
- assert(ap->mAudioTrack == 0);
- ap->mAPlayer->setPlayEvents((int32_t) eventFlags, (int32_t) pPlayItf->mMarkerPosition,
- (int32_t) pPlayItf->mPositionUpdatePeriod);
- return;
- }
-
- if (ap->mAudioTrack == 0) {
- return;
- }
-
- if (eventFlags & SL_PLAYEVENT_HEADATMARKER) {
- ap->mAudioTrack->setMarkerPosition((uint32_t)((((int64_t)pPlayItf->mMarkerPosition
- * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
- } else {
- // clear marker
- ap->mAudioTrack->setMarkerPosition(0);
- }
-
- if (eventFlags & SL_PLAYEVENT_HEADATNEWPOS) {
- ap->mAudioTrack->setPositionUpdatePeriod(
- (uint32_t)((((int64_t)pPlayItf->mPositionUpdatePeriod
- * sles_to_android_sampleRate(ap->mSampleRateMilliHz)))/1000));
- } else {
- // clear periodic update
- ap->mAudioTrack->setPositionUpdatePeriod(0);
- }
-
- if (eventFlags & SL_PLAYEVENT_HEADATEND) {
- // nothing to do for SL_PLAYEVENT_HEADATEND, callback event will be checked against mask
- }
-
- if (eventFlags & SL_PLAYEVENT_HEADMOVING) {
- // FIXME support SL_PLAYEVENT_HEADMOVING
- SL_LOGD("[ FIXME: IPlay_SetCallbackEventsMask(SL_PLAYEVENT_HEADMOVING) on an "
- "SL_OBJECTID_AUDIOPLAYER to be implemented ]");
- }
- if (eventFlags & SL_PLAYEVENT_HEADSTALLED) {
- // nothing to do for SL_PLAYEVENT_HEADSTALLED, callback event will be checked against mask
- }
-
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_getDuration(IPlay *pPlayItf, SLmillisecond *pDurMsec) {
- CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
- switch(ap->mAndroidObjType) {
-
- case AUDIOPLAYER_FROM_URIFD: // intended fall-through
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE: {
- int32_t durationMsec = ANDROID_UNKNOWN_TIME;
- if (ap->mAPlayer != 0) {
- ap->mAPlayer->getDurationMsec(&durationMsec);
- }
- *pDurMsec = durationMsec == ANDROID_UNKNOWN_TIME ? SL_TIME_UNKNOWN : durationMsec;
- break;
- }
-
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- default: {
- *pDurMsec = SL_TIME_UNKNOWN;
- }
- }
- return SL_RESULT_SUCCESS;
-}
-
-
-//-----------------------------------------------------------------------------
-void android_audioPlayer_getPosition(IPlay *pPlayItf, SLmillisecond *pPosMsec) {
- CAudioPlayer *ap = (CAudioPlayer *)pPlayItf->mThis;
- switch(ap->mAndroidObjType) {
-
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
- if ((ap->mSampleRateMilliHz == UNKNOWN_SAMPLERATE) || (ap->mAudioTrack == 0)) {
- *pPosMsec = 0;
- } else {
- uint32_t positionInFrames;
- ap->mAudioTrack->getPosition(&positionInFrames);
- *pPosMsec = ((int64_t)positionInFrames * 1000) /
- sles_to_android_sampleRate(ap->mSampleRateMilliHz);
- }
- break;
-
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- case AUDIOPLAYER_FROM_URIFD:
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE: {
- int32_t posMsec = ANDROID_UNKNOWN_TIME;
- if (ap->mAPlayer != 0) {
- ap->mAPlayer->getPositionMsec(&posMsec);
- }
- *pPosMsec = posMsec == ANDROID_UNKNOWN_TIME ? 0 : posMsec;
- break;
- }
-
- default:
- *pPosMsec = 0;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_seek(CAudioPlayer *ap, SLmillisecond posMsec) {
- SLresult result = SL_RESULT_SUCCESS;
-
- switch(ap->mAndroidObjType) {
-
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE: // intended fall-through
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE:
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- break;
-
- case AUDIOPLAYER_FROM_URIFD: // intended fall-through
- case AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- if (ap->mAPlayer != 0) {
- ap->mAPlayer->seek(posMsec);
- }
- break;
-
- default:
- break;
- }
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_loop(CAudioPlayer *ap, SLboolean loopEnable) {
- SLresult result = SL_RESULT_SUCCESS;
-
- switch (ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_URIFD:
- // case AUDIOPLAY_FROM_URIFD_TO_PCM_BUFFERQUEUE:
- // would actually work, but what's the point?
- if (ap->mAPlayer != 0) {
- ap->mAPlayer->loop((bool)loopEnable);
- }
- break;
- default:
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- break;
- }
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *ap,
- SLpermille threshold) {
- SLresult result = SL_RESULT_SUCCESS;
-
- switch (ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_URIFD:
- if (ap->mAPlayer != 0) {
- ap->mAPlayer->setBufferingUpdateThreshold(threshold / 10);
- }
- break;
-
- default: {}
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *ap) {
- // the AudioTrack associated with the AudioPlayer receiving audio from a PCM buffer
- // queue was stopped when the queue become empty, we restart as soon as a new buffer
- // has been enqueued since we're in playing state
- if (ap->mAudioTrack != 0) {
- // instead of ap->mAudioTrack->start();
- ap->mDeferredStart = true;
- }
-
- // when the queue became empty, an underflow on the prefetch status itf was sent. Now the queue
- // has received new data, signal it has sufficient data
- if (IsInterfaceInitialized(&(ap->mObject), MPH_PREFETCHSTATUS)) {
- // we wouldn't have been called unless we were previously in the underflow state
- assert(SL_PREFETCHSTATUS_UNDERFLOW == ap->mPrefetchStatus.mStatus);
- assert(0 == ap->mPrefetchStatus.mLevel);
- ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
- ap->mPrefetchStatus.mLevel = 1000;
- // callback or no callback?
- SLuint32 prefetchEvents = ap->mPrefetchStatus.mCallbackEventsMask &
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE);
- if (SL_PREFETCHEVENT_NONE != prefetchEvents) {
- ap->mPrefetchStatus.mDeferredPrefetchCallback = ap->mPrefetchStatus.mCallback;
- ap->mPrefetchStatus.mDeferredPrefetchContext = ap->mPrefetchStatus.mContext;
- ap->mPrefetchStatus.mDeferredPrefetchEvents = prefetchEvents;
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------
-/*
- * BufferQueue::Clear
- */
-SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *ap) {
- SLresult result = SL_RESULT_SUCCESS;
-
- switch (ap->mAndroidObjType) {
- //-----------------------------------
- // AudioTrack
- case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE:
- if (ap->mAudioTrack != 0) {
- ap->mAudioTrack->flush();
- }
- break;
- default:
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioPlayer_androidBufferQueue_registerCallback_l(CAudioPlayer *ap) {
- SLresult result = SL_RESULT_SUCCESS;
- assert(ap->mAPlayer != 0);
- // FIXME investigate why these two cases are not handled symmetrically any more
- switch (ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: {
- } break;
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE: {
- android::AacBqToPcmCbRenderer* dec =
- static_cast<android::AacBqToPcmCbRenderer*>(ap->mAPlayer.get());
- dec->registerSourceQueueCallback((const void*)ap /*user*/,
- ap->mAndroidBufferQueue.mContext /*context*/,
- (const void*)&(ap->mAndroidBufferQueue.mItf) /*caller*/);
- } break;
- default:
- SL_LOGE("Error registering AndroidBufferQueue callback: unexpected object type %d",
- ap->mAndroidObjType);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
- return result;
-}
-
-//-----------------------------------------------------------------------------
-void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *ap) {
- switch (ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE:
- if (ap->mAPlayer != 0) {
- android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());
- splr->appClear_l();
- } break;
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- // nothing to do here, fall through
- default:
- break;
- }
-}
-
-void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *ap) {
- switch (ap->mAndroidObjType) {
- case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE:
- if (ap->mAPlayer != 0) {
- android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());
- splr->queueRefilled();
- } break;
- case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE:
- // FIXME this may require waking up the decoder if it is currently starved and isn't polling
- default:
- break;
- }
-}
diff --git a/wilhelm/src/android/AudioPlayer_to_android.h b/wilhelm/src/android/AudioPlayer_to_android.h
deleted file mode 100644
index 96855e6..0000000
--- a/wilhelm/src/android/AudioPlayer_to_android.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define ANDROID_DEFAULT_AUDIOTRACK_BUFFER_SIZE 4096
-
-/**************************************************************************************************
- * AudioPlayer lifecycle
- ****************************/
-/*
- * Checks that the combination of source and sink parameters is supported in this implementation.
- * Return
- * SL_RESULT_SUCCESS
- * SL_PARAMETER_INVALID
- */
-extern SLresult android_audioPlayer_checkSourceSink(CAudioPlayer *pAudioPlayer);
-
-/*
- * Determines the Android media framework object that maps to the given audio source and sink.
- * Return
- * SL_RESULT_SUCCESS if the Android resources were successfully created
- * SL_PARAMETER_INVALID if the Android resources couldn't be created due to an invalid or
- * unsupported parameter or value
- * SL_RESULT_CONTENT_UNSUPPORTED if a format is not supported (e.g. sample rate too high)
- */
-extern SLresult android_audioPlayer_create(CAudioPlayer *pAudioPlayer);
-
-/*
- * Allocates and initializes the Android media framework objects intended to be used with the
- * given CAudioPlayer data
- * Return
- * SL_RESULT_SUCCESS
- * SL_RESULT_CONTENT_UNSUPPORTED if an error occurred during the allocation and initialization
- * of the Android resources
- */
-extern SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async);
-
-/*
- * Return
- * SL_RESULT_SUCCESS
- * SL_RESULT_PARAMETER_INVALID
- * SL_RESULT_INTERNAL_ERROR
- * SL_RESULT_PRECONDITIONS_VIOLATED
- */
-extern SLresult android_audioPlayer_setConfig(CAudioPlayer *pAudioPlayer, const SLchar *configKey,
- const void *pConfigValue, SLuint32 valueSize);
-
-/*
- * if pConfigValue is NULL, pValueSize contains the size required for the given key
- *
- * Return
- * SL_RESULT_SUCCESS
- * SL_RESULT_PARAMETER_INVALID
- * SL_RESULT_INTERNAL_ERROR
- * SL_RESULT_PRECONDITIONS_VIOLATED
- */
-extern SLresult android_audioPlayer_getConfig(CAudioPlayer *pAudioPlayer, const SLchar *configKey,
- SLuint32* pValueSize, void *pConfigValue);
-
-extern SLresult android_audioPlayer_preDestroy(CAudioPlayer *pAudioPlayer);
-
-extern SLresult android_audioPlayer_destroy(CAudioPlayer *pAudioPlayer);
-
-/**************************************************************************************************
- * Configuration
- ****************************/
-extern SLresult android_audioPlayer_setPlaybackRateAndConstraints(CAudioPlayer *pAudioPlayer,
- SLpermille rate, SLuint32 constraints);
-
-extern SLresult android_audioPlayer_getDuration(IPlay *pPlayItf, SLmillisecond *pDurMsec);
-
-extern void android_audioPlayer_volumeUpdate(CAudioPlayer *pAudioPlayer);
-
-extern SLresult android_audioPlayer_setBufferingUpdateThresholdPerMille(CAudioPlayer *pAudioPlayer,
- SLpermille threshold);
-
-/**************************************************************************************************
- * Metadata Extraction
- ****************************/
-/*
- * For all metadata extraction functions:
- * Precondition:
- * no lock held
- * pAudioPlayer != NULL
- * input pointers != NULL (pItemCount, pKeySize, pKey, pValueSize, pValue)
- * Return:
- * SL_RESULT_SUCCESS
- * SL_RESULT_PARAMETER_INVALID
- */
-extern SLresult android_audioPlayer_metadata_getItemCount(CAudioPlayer *pAudioPlayer,
- SLuint32 *pItemCount);
-
-extern SLresult android_audioPlayer_metadata_getKeySize(CAudioPlayer *pAudioPlayer,
- SLuint32 index, SLuint32 *pKeySize);
-
-extern SLresult android_audioPlayer_metadata_getKey(CAudioPlayer *pAudioPlayer,
- SLuint32 index, SLuint32 size, SLMetadataInfo *pKey);
-
-extern SLresult android_audioPlayer_metadata_getValueSize(CAudioPlayer *pAudioPlayer,
- SLuint32 index, SLuint32 *pValueSize);
-
-extern SLresult android_audioPlayer_metadata_getValue(CAudioPlayer *pAudioPlayer,
- SLuint32 index, SLuint32 size, SLMetadataInfo *pValue);
-
-/**************************************************************************************************
- * Playback control and events
- ****************************/
-extern void android_audioPlayer_setPlayState(CAudioPlayer *pAudioPlayer);
-
-extern void android_audioPlayer_usePlayEventMask(CAudioPlayer *pAudioPlayer);
-
-extern SLresult android_audioPlayer_seek(CAudioPlayer *pAudioPlayer, SLmillisecond posMsec);
-
-extern SLresult android_audioPlayer_loop(CAudioPlayer *pAudioPlayer, SLboolean loopEnable);
-
-extern void android_audioPlayer_getPosition(IPlay *pPlayItf, SLmillisecond *pPosMsec);
-
-/**************************************************************************************************
- * Buffer Queue events
- ****************************/
-extern void android_audioPlayer_bufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer);
-
-extern SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *pAudioPlayer);
-
-/**************************************************************************************************
- * Android Buffer Queue
- ****************************/
-/* must be called with a lock on pAudioPlayer->mThis */
-extern SLresult android_audioPlayer_androidBufferQueue_registerCallback_l(
- CAudioPlayer *pAudioPlayer);
-/* must be called with a lock on pAudioPlayer->mThis */
-extern void android_audioPlayer_androidBufferQueue_clear_l(CAudioPlayer *pAudioPlayer);
-/* must be called with a lock on pAudioPlayer->mThis */
-extern void android_audioPlayer_androidBufferQueue_onRefilled_l(CAudioPlayer *pAudioPlayer);
diff --git a/wilhelm/src/android/AudioRecorder_to_android.cpp b/wilhelm/src/android/AudioRecorder_to_android.cpp
deleted file mode 100644
index 497bed2..0000000
--- a/wilhelm/src/android/AudioRecorder_to_android.cpp
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "sles_allinclusive.h"
-#include "android_prompts.h"
-
-#include <system/audio.h>
-
-// use this flag to dump all recorded audio into a file
-//#define MONITOR_RECORDING
-#ifdef MONITOR_RECORDING
-#define MONITOR_TARGET "/sdcard/monitor.raw"
-#include <stdio.h>
-static FILE* gMonitorFp = NULL;
-#endif
-
-
-#define KEY_RECORDING_SOURCE_PARAMSIZE sizeof(SLuint32)
-#define KEY_RECORDING_PRESET_PARAMSIZE sizeof(SLuint32)
-
-//-----------------------------------------------------------------------------
-// Internal utility functions
-//----------------------------
-
-SLresult audioRecorder_setPreset(CAudioRecorder* ar, SLuint32 recordPreset) {
- SLresult result = SL_RESULT_SUCCESS;
-
- int newRecordSource = AUDIO_SOURCE_DEFAULT;
- switch (recordPreset) {
- case SL_ANDROID_RECORDING_PRESET_GENERIC:
- newRecordSource = AUDIO_SOURCE_DEFAULT;
- break;
- case SL_ANDROID_RECORDING_PRESET_CAMCORDER:
- newRecordSource = AUDIO_SOURCE_CAMCORDER;
- break;
- case SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION:
- newRecordSource = AUDIO_SOURCE_VOICE_RECOGNITION;
- break;
- case SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION:
- newRecordSource = AUDIO_SOURCE_VOICE_COMMUNICATION;
- break;
- case SL_ANDROID_RECORDING_PRESET_NONE:
- // it is an error to set preset "none"
- default:
- SL_LOGE(ERROR_RECORDERPRESET_SET_UNKNOWN_PRESET);
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- // recording preset needs to be set before the object is realized
- // (ap->mAudioRecord is supposed to be NULL until then)
- if (SL_OBJECT_STATE_UNREALIZED != ar->mObject.mState) {
- SL_LOGE(ERROR_RECORDERPRESET_REALIZED);
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- ar->mRecordSource = newRecordSource;
- }
-
- return result;
-}
-
-
-SLresult audioRecorder_getPreset(CAudioRecorder* ar, SLuint32* pPreset) {
- SLresult result = SL_RESULT_SUCCESS;
-
- switch (ar->mRecordSource) {
- case AUDIO_SOURCE_DEFAULT:
- case AUDIO_SOURCE_MIC:
- *pPreset = SL_ANDROID_RECORDING_PRESET_GENERIC;
- break;
- case AUDIO_SOURCE_VOICE_UPLINK:
- case AUDIO_SOURCE_VOICE_DOWNLINK:
- case AUDIO_SOURCE_VOICE_CALL:
- *pPreset = SL_ANDROID_RECORDING_PRESET_NONE;
- break;
- case AUDIO_SOURCE_VOICE_RECOGNITION:
- *pPreset = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION;
- break;
- case AUDIO_SOURCE_CAMCORDER:
- *pPreset = SL_ANDROID_RECORDING_PRESET_CAMCORDER;
- break;
- case AUDIO_SOURCE_VOICE_COMMUNICATION:
- *pPreset = SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
- break;
- default:
- *pPreset = SL_ANDROID_RECORDING_PRESET_NONE;
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
-
- return result;
-}
-
-
-void audioRecorder_handleNewPos_lockRecord(CAudioRecorder* ar) {
- //SL_LOGV("received event EVENT_NEW_POS from AudioRecord");
- slRecordCallback callback = NULL;
- void* callbackPContext = NULL;
-
- interface_lock_shared(&ar->mRecord);
- callback = ar->mRecord.mCallback;
- callbackPContext = ar->mRecord.mContext;
- interface_unlock_shared(&ar->mRecord);
-
- if (NULL != callback) {
- // getting this event implies SL_RECORDEVENT_HEADATNEWPOS was set in the event mask
- (*callback)(&ar->mRecord.mItf, callbackPContext, SL_RECORDEVENT_HEADATNEWPOS);
- }
-}
-
-
-void audioRecorder_handleMarker_lockRecord(CAudioRecorder* ar) {
- //SL_LOGV("received event EVENT_MARKER from AudioRecord");
- slRecordCallback callback = NULL;
- void* callbackPContext = NULL;
-
- interface_lock_shared(&ar->mRecord);
- callback = ar->mRecord.mCallback;
- callbackPContext = ar->mRecord.mContext;
- interface_unlock_shared(&ar->mRecord);
-
- if (NULL != callback) {
- // getting this event implies SL_RECORDEVENT_HEADATMARKER was set in the event mask
- (*callback)(&ar->mRecord.mItf, callbackPContext, SL_RECORDEVENT_HEADATMARKER);
- }
-}
-
-
-void audioRecorder_handleOverrun_lockRecord(CAudioRecorder* ar) {
- //SL_LOGV("received event EVENT_OVERRUN from AudioRecord");
- slRecordCallback callback = NULL;
- void* callbackPContext = NULL;
-
- interface_lock_shared(&ar->mRecord);
- if (ar->mRecord.mCallbackEventsMask & SL_RECORDEVENT_HEADSTALLED) {
- callback = ar->mRecord.mCallback;
- callbackPContext = ar->mRecord.mContext;
- }
- interface_unlock_shared(&ar->mRecord);
-
- if (NULL != callback) {
- (*callback)(&ar->mRecord.mItf, callbackPContext, SL_RECORDEVENT_HEADSTALLED);
- }
-}
-
-//-----------------------------------------------------------------------------
-SLresult android_audioRecorder_checkSourceSinkSupport(CAudioRecorder* ar) {
-
- const SLDataSource *pAudioSrc = &ar->mDataSource.u.mSource;
- const SLDataSink *pAudioSnk = &ar->mDataSink.u.mSink;
-
- // Sink check:
- // only buffer queue sinks are supported, regardless of the data source
- if (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE != *(SLuint32 *)pAudioSnk->pLocator) {
- SL_LOGE(ERROR_RECORDER_SINK_MUST_BE_ANDROIDSIMPLEBUFFERQUEUE);
- return SL_RESULT_PARAMETER_INVALID;
- } else {
- // only PCM buffer queues are supported
- SLuint32 formatType = *(SLuint32 *)pAudioSnk->pFormat;
- if (SL_DATAFORMAT_PCM == formatType) {
- SLDataFormat_PCM *df_pcm = (SLDataFormat_PCM *)ar->mDataSink.u.mSink.pFormat;
- ar->mSampleRateMilliHz = df_pcm->samplesPerSec;
- ar->mNumChannels = df_pcm->numChannels;
- SL_LOGV("AudioRecorder requested sample rate = %u mHz, %u channel(s)",
- ar->mSampleRateMilliHz, ar->mNumChannels);
- }
- else {
- SL_LOGE(ERROR_RECORDER_SINK_FORMAT_MUST_BE_PCM);
- return SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- // Source check:
- // only input device sources are supported
- // check it's an IO device
- if (SL_DATALOCATOR_IODEVICE != *(SLuint32 *)pAudioSrc->pLocator) {
- SL_LOGE(ERROR_RECORDER_SOURCE_MUST_BE_IODEVICE);
- return SL_RESULT_PARAMETER_INVALID;
- } else {
-
- // check it's an input device
- SLDataLocator_IODevice *dl_iod = (SLDataLocator_IODevice *) pAudioSrc->pLocator;
- if (SL_IODEVICE_AUDIOINPUT != dl_iod->deviceType) {
- SL_LOGE(ERROR_RECORDER_IODEVICE_MUST_BE_AUDIOINPUT);
- return SL_RESULT_PARAMETER_INVALID;
- }
-
- // check it's the default input device, others aren't supported here
- if (SL_DEFAULTDEVICEID_AUDIOINPUT != dl_iod->deviceID) {
- SL_LOGE(ERROR_RECORDER_INPUT_ID_MUST_BE_DEFAULT);
- return SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- return SL_RESULT_SUCCESS;
-}
-//-----------------------------------------------------------------------------
-static void audioRecorder_callback(int event, void* user, void *info) {
- //SL_LOGV("audioRecorder_callback(%d, %p, %p) entering", event, user, info);
-
- CAudioRecorder *ar = (CAudioRecorder *)user;
- void * callbackPContext = NULL;
-
- switch(event) {
- case android::AudioRecord::EVENT_MORE_DATA: {
- slBufferQueueCallback callback = NULL;
- android::AudioRecord::Buffer* pBuff = (android::AudioRecord::Buffer*)info;
-
- // push data to the buffer queue
- interface_lock_exclusive(&ar->mBufferQueue);
-
- if (ar->mBufferQueue.mState.count != 0) {
- assert(ar->mBufferQueue.mFront != ar->mBufferQueue.mRear);
-
- BufferHeader *oldFront = ar->mBufferQueue.mFront;
- BufferHeader *newFront = &oldFront[1];
-
- // FIXME handle 8bit based on buffer format
- short *pDest = (short*)((char *)oldFront->mBuffer + ar->mBufferQueue.mSizeConsumed);
- if (ar->mBufferQueue.mSizeConsumed + pBuff->size < oldFront->mSize) {
- // can't consume the whole or rest of the buffer in one shot
- ar->mBufferQueue.mSizeConsumed += pBuff->size;
- // leave pBuff->size untouched
- // consume data
- // FIXME can we avoid holding the lock during the copy?
- memcpy (pDest, pBuff->i16, pBuff->size);
-#ifdef MONITOR_RECORDING
- if (NULL != gMonitorFp) { fwrite(pBuff->i16, pBuff->size, 1, gMonitorFp); }
-#endif
- } else {
- // finish pushing the buffer or push the buffer in one shot
- pBuff->size = oldFront->mSize - ar->mBufferQueue.mSizeConsumed;
- ar->mBufferQueue.mSizeConsumed = 0;
- if (newFront == &ar->mBufferQueue.mArray[ar->mBufferQueue.mNumBuffers + 1]) {
- newFront = ar->mBufferQueue.mArray;
- }
- ar->mBufferQueue.mFront = newFront;
-
- ar->mBufferQueue.mState.count--;
- ar->mBufferQueue.mState.playIndex++;
- // consume data
- // FIXME can we avoid holding the lock during the copy?
- memcpy (pDest, pBuff->i16, pBuff->size);
-#ifdef MONITOR_RECORDING
- if (NULL != gMonitorFp) { fwrite(pBuff->i16, pBuff->size, 1, gMonitorFp); }
-#endif
- // data has been copied to the buffer, and the buffer queue state has been updated
- // we will notify the client if applicable
- callback = ar->mBufferQueue.mCallback;
- // save callback data
- callbackPContext = ar->mBufferQueue.mContext;
- }
- } else {
- // no destination to push the data
- pBuff->size = 0;
- }
-
- interface_unlock_exclusive(&ar->mBufferQueue);
- // notify client
- if (NULL != callback) {
- (*callback)(&ar->mBufferQueue.mItf, callbackPContext);
- }
- }
- break;
-
- case android::AudioRecord::EVENT_OVERRUN:
- audioRecorder_handleOverrun_lockRecord(ar);
- break;
-
- case android::AudioRecord::EVENT_MARKER:
- audioRecorder_handleMarker_lockRecord(ar);
- break;
-
- case android::AudioRecord::EVENT_NEW_POS:
- audioRecorder_handleNewPos_lockRecord(ar);
- break;
-
- }
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioRecorder_create(CAudioRecorder* ar) {
- SL_LOGV("android_audioRecorder_create(%p) entering", ar);
-
- const SLDataSource *pAudioSrc = &ar->mDataSource.u.mSource;
- const SLDataSink *pAudioSnk = &ar->mDataSink.u.mSink;
- SLresult result = SL_RESULT_SUCCESS;
-
- const SLuint32 sourceLocatorType = *(SLuint32 *)pAudioSrc->pLocator;
- const SLuint32 sinkLocatorType = *(SLuint32 *)pAudioSnk->pLocator;
-
- // the following platform-independent fields have been initialized in CreateAudioRecorder()
- // ar->mNumChannels
- // ar->mSampleRateMilliHz
-
- if ((SL_DATALOCATOR_IODEVICE == sourceLocatorType) &&
- (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE == sinkLocatorType)) {
- // microphone to simple buffer queue
- ar->mAndroidObjType = AUDIORECORDER_FROM_MIC_TO_PCM_BUFFERQUEUE;
- ar->mAudioRecord = NULL;
- ar->mRecordSource = AUDIO_SOURCE_DEFAULT;
- } else {
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioRecorder_setConfig(CAudioRecorder* ar, const SLchar *configKey,
- const void *pConfigValue, SLuint32 valueSize) {
-
- SLresult result;
-
- assert(NULL != ar && NULL != configKey && NULL != pConfigValue);
- if(strcmp((const char*)configKey, (const char*)SL_ANDROID_KEY_RECORDING_PRESET) == 0) {
-
- // recording preset
- if (KEY_RECORDING_PRESET_PARAMSIZE > valueSize) {
- SL_LOGE(ERROR_CONFIG_VALUESIZE_TOO_LOW);
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- result = audioRecorder_setPreset(ar, *(SLuint32*)pConfigValue);
- }
-
- } else {
- SL_LOGE(ERROR_CONFIG_UNKNOWN_KEY);
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioRecorder_getConfig(CAudioRecorder* ar, const SLchar *configKey,
- SLuint32* pValueSize, void *pConfigValue) {
-
- SLresult result;
-
- assert(NULL != ar && NULL != configKey && NULL != pValueSize);
- if(strcmp((const char*)configKey, (const char*)SL_ANDROID_KEY_RECORDING_PRESET) == 0) {
-
- // recording preset
- if (NULL == pConfigValue) {
- result = SL_RESULT_SUCCESS;
- } else if (KEY_RECORDING_PRESET_PARAMSIZE > *pValueSize) {
- SL_LOGE(ERROR_CONFIG_VALUESIZE_TOO_LOW);
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- result = audioRecorder_getPreset(ar, (SLuint32*)pConfigValue);
- }
- *pValueSize = KEY_RECORDING_PRESET_PARAMSIZE;
-
- } else {
- SL_LOGE(ERROR_CONFIG_UNKNOWN_KEY);
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async) {
- SL_LOGV("android_audioRecorder_realize(%p) entering", ar);
-
- SLresult result = SL_RESULT_SUCCESS;
-
- // initialize platform-independent CAudioRecorder fields
- if (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE != ar->mDataSink.mLocator.mLocatorType) {
- SL_LOGE(ERROR_RECORDER_SINK_MUST_BE_ANDROIDSIMPLEBUFFERQUEUE);
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- // the following platform-independent fields have been initialized in CreateAudioRecorder()
- // ar->mNumChannels
- // ar->mSampleRateMilliHz
-
- SL_LOGV("new AudioRecord %u channels, %u mHz", ar->mNumChannels, ar->mSampleRateMilliHz);
-
- // initialize platform-specific CAudioRecorder fields
- ar->mAudioRecord = new android::AudioRecord();
- ar->mAudioRecord->set(ar->mRecordSource, // source
- sles_to_android_sampleRate(ar->mSampleRateMilliHz), // sample rate in Hertz
- AUDIO_FORMAT_PCM_16_BIT, //FIXME use format from buffer queue sink
- sles_to_android_channelMaskIn(ar->mNumChannels, 0 /*no channel mask*/),
- // channel config
- 0, //frameCount min
- 0, // flags
- audioRecorder_callback,// callback_t
- (void*)ar, // user, callback data, here the AudioRecorder
- 0, // notificationFrames
- false); // threadCanCallJava, note: this will prevent direct Java
- // callbacks, but we don't want them in the recording loop
-
- if (android::NO_ERROR != ar->mAudioRecord->initCheck()) {
- SL_LOGE("android_audioRecorder_realize(%p) error creating AudioRecord object", ar);
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- }
-
-#ifdef MONITOR_RECORDING
- gMonitorFp = fopen(MONITOR_TARGET, "w");
- if (NULL == gMonitorFp) { SL_LOGE("error opening %s", MONITOR_TARGET); }
- else { SL_LOGE("recording to %s", MONITOR_TARGET); } // SL_LOGE so it's always displayed
-#endif
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-void android_audioRecorder_destroy(CAudioRecorder* ar) {
- SL_LOGV("android_audioRecorder_destroy(%p) entering", ar);
-
- if (NULL != ar->mAudioRecord) {
- ar->mAudioRecord->stop();
- delete ar->mAudioRecord;
- ar->mAudioRecord = NULL;
- }
-
-#ifdef MONITOR_RECORDING
- if (NULL != gMonitorFp) {
- fclose(gMonitorFp);
- gMonitorFp = NULL;
- }
-#endif
-}
-
-
-//-----------------------------------------------------------------------------
-void android_audioRecorder_setRecordState(CAudioRecorder* ar, SLuint32 state) {
- SL_LOGV("android_audioRecorder_setRecordState(%p, %u) entering", ar, state);
-
- if (NULL == ar->mAudioRecord) {
- return;
- }
-
- switch (state) {
- case SL_RECORDSTATE_STOPPED:
- ar->mAudioRecord->stop();
- break;
- case SL_RECORDSTATE_PAUSED:
- // Note that pausing is treated like stop as this implementation only records to a buffer
- // queue, so there is no notion of destination being "opened" or "closed" (See description
- // of SL_RECORDSTATE in specification)
- ar->mAudioRecord->stop();
- break;
- case SL_RECORDSTATE_RECORDING:
- ar->mAudioRecord->start();
- break;
- default:
- break;
- }
-
-}
-
-
-//-----------------------------------------------------------------------------
-void android_audioRecorder_useRecordEventMask(CAudioRecorder *ar) {
- IRecord *pRecordItf = &ar->mRecord;
- SLuint32 eventFlags = pRecordItf->mCallbackEventsMask;
-
- if (NULL == ar->mAudioRecord) {
- return;
- }
-
- if ((eventFlags & SL_RECORDEVENT_HEADATMARKER) && (pRecordItf->mMarkerPosition != 0)) {
- ar->mAudioRecord->setMarkerPosition((uint32_t)((((int64_t)pRecordItf->mMarkerPosition
- * sles_to_android_sampleRate(ar->mSampleRateMilliHz)))/1000));
- } else {
- // clear marker
- ar->mAudioRecord->setMarkerPosition(0);
- }
-
- if (eventFlags & SL_RECORDEVENT_HEADATNEWPOS) {
- SL_LOGV("pos update period %d", pRecordItf->mPositionUpdatePeriod);
- ar->mAudioRecord->setPositionUpdatePeriod(
- (uint32_t)((((int64_t)pRecordItf->mPositionUpdatePeriod
- * sles_to_android_sampleRate(ar->mSampleRateMilliHz)))/1000));
- } else {
- // clear periodic update
- ar->mAudioRecord->setPositionUpdatePeriod(0);
- }
-
- if (eventFlags & SL_RECORDEVENT_HEADATLIMIT) {
- // FIXME support SL_RECORDEVENT_HEADATLIMIT
- SL_LOGD("[ FIXME: IRecord_SetCallbackEventsMask(SL_RECORDEVENT_HEADATLIMIT) on an "
- "SL_OBJECTID_AUDIORECORDER to be implemented ]");
- }
-
- if (eventFlags & SL_RECORDEVENT_HEADMOVING) {
- // FIXME support SL_RECORDEVENT_HEADMOVING
- SL_LOGD("[ FIXME: IRecord_SetCallbackEventsMask(SL_RECORDEVENT_HEADMOVING) on an "
- "SL_OBJECTID_AUDIORECORDER to be implemented ]");
- }
-
- if (eventFlags & SL_RECORDEVENT_BUFFER_FULL) {
- // nothing to do for SL_RECORDEVENT_BUFFER_FULL since this will not be encountered on
- // recording to buffer queues
- }
-
- if (eventFlags & SL_RECORDEVENT_HEADSTALLED) {
- // nothing to do for SL_RECORDEVENT_HEADSTALLED, callback event will be checked against mask
- // when AudioRecord::EVENT_OVERRUN is encountered
-
- }
-
-}
-
-
-//-----------------------------------------------------------------------------
-void android_audioRecorder_getPosition(CAudioRecorder *ar, SLmillisecond *pPosMsec) {
- if ((NULL == ar) || (NULL == ar->mAudioRecord)) {
- *pPosMsec = 0;
- } else {
- uint32_t positionInFrames;
- ar->mAudioRecord->getPosition(&positionInFrames);
- if (ar->mSampleRateMilliHz == UNKNOWN_SAMPLERATE) {
- *pPosMsec = 0;
- } else {
- *pPosMsec = ((int64_t)positionInFrames * 1000) /
- sles_to_android_sampleRate(ar->mSampleRateMilliHz);
- }
- }
-}
diff --git a/wilhelm/src/android/AudioRecorder_to_android.h b/wilhelm/src/android/AudioRecorder_to_android.h
deleted file mode 100644
index b8d4dd2..0000000
--- a/wilhelm/src/android/AudioRecorder_to_android.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**************************************************************************************************
- * AudioRecorder lifecycle
- ****************************/
-extern SLresult android_audioRecorder_checkSourceSinkSupport(CAudioRecorder* ar);
-
-extern SLresult android_audioRecorder_create(CAudioRecorder* ar);
-
-/*
- * Return
- * SL_RESULT_SUCCESS
- * SL_RESULT_PARAMETER_INVALID
- * SL_RESULT_INTERNAL_ERROR
- * SL_RESULT_PRECONDITIONS_VIOLATED
- */
-extern SLresult android_audioRecorder_setConfig(CAudioRecorder* ar, const SLchar *configKey,
- const void *pConfigValue, SLuint32 valueSize);
-
-/*
- * if pConfigValue is NULL, pValueSize contains the size required for the given key
- *
- * Return
- * SL_RESULT_SUCCESS
- * SL_RESULT_PARAMETER_INVALID
- * SL_RESULT_INTERNAL_ERROR
- * SL_RESULT_PRECONDITIONS_VIOLATED
- */
-extern SLresult android_audioRecorder_getConfig(CAudioRecorder* ar, const SLchar *configKey,
- SLuint32* pValueSize, void *pConfigValue);
-
-extern SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async);
-
-extern void android_audioRecorder_destroy(CAudioRecorder* ar);
-
-/**************************************************************************************************
- * AudioRecorder control
- ****************************/
-
-extern void android_audioRecorder_setRecordState(CAudioRecorder* ar, SLuint32 state);
-
-extern void android_audioRecorder_useRecordEventMask(CAudioRecorder *ar);
-
-extern void android_audioRecorder_getPosition(CAudioRecorder *ar, SLmillisecond *pPosMsec);
diff --git a/wilhelm/src/android/AudioTrackProxy.h b/wilhelm/src/android/AudioTrackProxy.h
deleted file mode 100644
index 6b711b8..0000000
--- a/wilhelm/src/android/AudioTrackProxy.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// sp<> capable proxy for AudioTrack
-
-#include <media/AudioTrack.h>
-
-namespace android {
-
-class AudioTrackProxy : public RefBase {
-
-public:
-
- AudioTrackProxy(AudioTrack *raw) : mRaw(raw) { assert(raw != NULL); }
-
- // don't define all methods, just the ones needed
-
- void setVolume(float left, float right)
- { mRaw->setVolume(left, right); }
- void stop()
- { mRaw->stop(); }
- void start()
- { mRaw->start(); }
- status_t initCheck()
- { return mRaw->initCheck(); }
- status_t setSampleRate(int sampleRate)
- { return mRaw->setSampleRate(sampleRate); }
- void pause()
- { mRaw->pause(); }
- void getPosition(uint32_t *p)
- { mRaw->getPosition(p); }
- void mute(bool muted)
- { mRaw->mute(muted); }
- void flush()
- { mRaw->flush(); }
- void setMarkerPosition(uint32_t marker)
- { mRaw->setMarkerPosition(marker); }
- void setPositionUpdatePeriod(uint32_t updatePeriod)
- { mRaw->setPositionUpdatePeriod(updatePeriod); }
- status_t attachAuxEffect(int effectId)
- { return mRaw->attachAuxEffect(effectId); }
- status_t setAuxEffectSendLevel(float level)
- { return mRaw->setAuxEffectSendLevel(level); }
-
-protected:
-
- virtual ~AudioTrackProxy()
- { }
- virtual void onLastStrongRef(const void* id)
- {
- assert(mRaw != NULL);
- delete mRaw;
- mRaw = NULL;
- }
-
-private:
- android::AudioTrack *mRaw;
-
- AudioTrackProxy(const AudioTrackProxy &);
- AudioTrackProxy &operator=(const AudioTrackProxy &);
-};
-
-}
diff --git a/wilhelm/src/android/BufferQueueSource.cpp b/wilhelm/src/android/BufferQueueSource.cpp
deleted file mode 100644
index 323a3a0..0000000
--- a/wilhelm/src/android/BufferQueueSource.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-#include "android/BufferQueueSource.h"
-
-#include <media/stagefright/MediaDebug.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-namespace android {
-
-
-const SLuint32 BufferQueueSource::kItemProcessed[NB_BUFFEREVENT_ITEM_FIELDS] = {
- SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT, // item key
- sizeof(SLuint32), // item size
- SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED // item data
-};
-
-
-BufferQueueSource::BufferQueueSource(const void* user, void *context, const void *caller) :
- mAndroidBufferQueueSource(NULL),
- mStreamToBqOffset(0),
- mEosReached(false)
-{
- if (NULL != user) {
- mAndroidBufferQueueSource = &((CAudioPlayer*)user)->mAndroidBufferQueue;
- } else {
- SL_LOGE("Can't create BufferQueueSource with NULL user");
- }
-
-}
-
-
-BufferQueueSource::~BufferQueueSource() {
- SL_LOGD("BufferQueueSource::~BufferQueueSource");
-}
-
-
-//--------------------------------------------------------------------------
-status_t BufferQueueSource::initCheck() const {
- return mAndroidBufferQueueSource != NULL ? OK : NO_INIT;
-}
-
-ssize_t BufferQueueSource::readAt(off64_t offset, void *data, size_t size) {
- SL_LOGD("BufferQueueSource::readAt(offset=%lld, data=%p, size=%d)", offset, data, size);
-
- if (mEosReached) {
- // once EOS has been received from the buffer queue, you can't read anymore
- return 0;
- }
-
- ssize_t readSize;
- slAndroidBufferQueueCallback callback = NULL;
- void* pBufferContext, *pBufferData, *callbackPContext;
- uint32_t dataSize, dataUsed;
-
- interface_lock_exclusive(mAndroidBufferQueueSource);
-
- if (mAndroidBufferQueueSource->mState.count == 0) {
- readSize = 0;
- } else {
- assert(mAndroidBufferQueueSource->mFront != mAndroidBufferQueueSource->mRear);
-
- AdvancedBufferHeader *oldFront = mAndroidBufferQueueSource->mFront;
- AdvancedBufferHeader *newFront = &oldFront[1];
-
- // where to read from
- char *pSrc = NULL;
- // can this read operation cause us to call the buffer queue callback
- // (either because there was a command with no data, or all the data has been consumed)
- bool queueCallbackCandidate = false;
-
- // consume events when starting to read data from a buffer for the first time
- if (oldFront->mDataSizeConsumed == 0) {
- if (oldFront->mItems.mAdtsCmdData.mAdtsCmdCode & ANDROID_ADTSEVENT_EOS) {
- mEosReached = true;
- // EOS has no associated data
- queueCallbackCandidate = true;
- }
- oldFront->mItems.mAdtsCmdData.mAdtsCmdCode = ANDROID_ADTSEVENT_NONE;
- }
-
- //assert(mStreamToBqOffset <= offset);
- CHECK(mStreamToBqOffset <= offset);
-
- if (offset + size <= mStreamToBqOffset + oldFront->mDataSize) {
- pSrc = ((char*)oldFront->mDataBuffer) + (offset - mStreamToBqOffset);
-
- if (offset - mStreamToBqOffset + size == oldFront->mDataSize) {
- // consumed buffer entirely
- oldFront->mDataSizeConsumed = oldFront->mDataSize;
- mStreamToBqOffset += oldFront->mDataSize;
- queueCallbackCandidate = true;
-
- // move queue to next buffer
- if (newFront == &mAndroidBufferQueueSource->
- mBufferArray[mAndroidBufferQueueSource->mNumBuffers + 1]) {
- // reached the end, circle back
- newFront = mAndroidBufferQueueSource->mBufferArray;
- }
- mAndroidBufferQueueSource->mFront = newFront;
- // update the queue state
- mAndroidBufferQueueSource->mState.count--;
- mAndroidBufferQueueSource->mState.index++;
- SL_LOGV("BufferQueueSource moving to next buffer");
- }
- }
-
- // consume data: copy to given destination
- if (NULL != pSrc) {
- memcpy(data, pSrc, size);
- readSize = size;
- } else {
- readSize = 0;
- }
-
- if (queueCallbackCandidate) {
- // data has been consumed, and the buffer queue state has been updated
- // we will notify the client if applicable
- if (mAndroidBufferQueueSource->mCallbackEventsMask &
- SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED) {
- callback = mAndroidBufferQueueSource->mCallback;
- // save callback data while under lock
- callbackPContext = mAndroidBufferQueueSource->mContext;
- pBufferContext = (void *)oldFront->mBufferContext;
- pBufferData = (void *)oldFront->mDataBuffer;
- dataSize = oldFront->mDataSize;
- dataUsed = oldFront->mDataSizeConsumed;
- }
- }
- }
-
- interface_unlock_exclusive(mAndroidBufferQueueSource);
-
- // notify client
- if (NULL != callback) {
- SLresult result = (*callback)(&mAndroidBufferQueueSource->mItf, callbackPContext,
- pBufferContext, pBufferData, dataSize, dataUsed,
- // no messages during playback other than marking the buffer as processed
- (const SLAndroidBufferItem*)(&kItemProcessed) /* pItems */,
- NB_BUFFEREVENT_ITEM_FIELDS * sizeof(SLuint32) /* itemsLength */ );
- if (SL_RESULT_SUCCESS != result) {
- // Reserved for future use
- SL_LOGW("Unsuccessful result %d returned from AndroidBufferQueueCallback", result);
- }
- }
-
- return readSize;
-}
-
-
-status_t BufferQueueSource::getSize(off64_t *size) {
- SL_LOGD("BufferQueueSource::getSize()");
- // we're streaming, we don't know how much there is
- *size = 0;
- return OK;
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/BufferQueueSource.h b/wilhelm/src/android/BufferQueueSource.h
deleted file mode 100644
index c91b7b1..0000000
--- a/wilhelm/src/android/BufferQueueSource.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef BUFFERQUEUE_SOURCE_H_
-#define BUFFERQUEUE_SOURCE_H_
-
-#include <media/stagefright/DataSource.h>
-
-// number of SLuint32 fields to store a buffer event message in an item, by mapping each
-// to the item key (SLuint32), the item size (SLuint32), and the item data (mask on SLuint32)
-#define NB_BUFFEREVENT_ITEM_FIELDS 3
-
-namespace android {
-
-// a Stagefright DataSource that pulls data from an AndroidBufferQueue
-
-class BufferQueueSource : public DataSource {
-public:
-
- // store an item structure to indicate a processed buffer
- static const SLuint32 kItemProcessed[NB_BUFFEREVENT_ITEM_FIELDS];
-
- BufferQueueSource(const void* user, void *context, const void *caller);
-
- virtual status_t initCheck() const;
-
- virtual ssize_t readAt(off64_t offset, void *data, size_t size);
-
- virtual status_t getSize(off64_t *size);
-
- virtual ~BufferQueueSource();
-
-private:
- // the Android Buffer Queue from which data is consumed
- IAndroidBufferQueue* mAndroidBufferQueueSource;
-
- // a monotonically increasing offset used to translate an offset from the beginning
- // of the stream, to an offset in each buffer from the buffer queue source
- off64_t mStreamToBqOffset;
-
- // indicates whether an EOS command has been reached when consuming the buffers in the queue
- bool mEosReached;
-
- BufferQueueSource(const BufferQueueSource &);
- BufferQueueSource &operator=(const BufferQueueSource &);
-};
-
-} // namespace android
-
-#endif // BUFFERQUEUE_SOURCE_H_
-
diff --git a/wilhelm/src/android/CallbackProtector.cpp b/wilhelm/src/android/CallbackProtector.cpp
deleted file mode 100644
index 85eceac..0000000
--- a/wilhelm/src/android/CallbackProtector.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "CallbackProtector.h"
-#include "sllog.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-
-CallbackProtector::CallbackProtector() : RefBase(),
- mSafeToEnterCb(true),
- mCbCount(0)
-#ifdef USE_DEBUG
- , mCallbackThread(NULL),
- mCallbackTid(0),
- mRequesterThread(NULL),
- mRequesterTid(0)
-#endif
-{
-}
-
-
-CallbackProtector::~CallbackProtector() {
- Mutex::Autolock _l(mLock);
- if (mCbCount) {
- SL_LOGE("Callback protector detected an active callback after destroy");
- }
-
-}
-
-
-// static
-bool CallbackProtector::enterCbIfOk(const sp<CallbackProtector> &protector) {
- if (protector != 0) {
- return protector->enterCb();
- } else {
- SL_LOGE("Callback protector is missing");
- return false;
- }
-}
-
-
-bool CallbackProtector::enterCb() {
- Mutex::Autolock _l(mLock);
- if (mSafeToEnterCb) {
- mCbCount++;
-#ifdef USE_DEBUG
- if (mCbCount > 1) {
- SL_LOGV("Callback protector allowed multiple or nested callback entry: %u", mCbCount);
- } else {
- mCallbackThread = pthread_self();
- mCallbackTid = gettid();
- }
-#endif
- } else {
-#ifdef USE_DEBUG
- SL_LOGV("Callback protector denied callback entry by thread %p tid %d during destroy"
- " requested by thread %p tid %d",
- (void *) pthread_self(), gettid(),
- (void *) mRequesterThread, mRequesterTid);
-#else
- SL_LOGV("Callback protector denied callback entry during destroy");
-#endif
- }
- return mSafeToEnterCb;
-}
-
-
-void CallbackProtector::exitCb() {
- Mutex::Autolock _l(mLock);
-
- CHECK(mCbCount > 0);
- mCbCount--;
-
- if (mCbCount == 0) {
- if (!mSafeToEnterCb) {
-#ifdef USE_DEBUG
- SL_LOGV("Callback protector detected return from callback by thread %p tid %d during"
- " destroy requested by thread %p tid %d",
- (void *) mCallbackThread, mCallbackTid,
- (void *) mRequesterThread, mRequesterTid);
-#else
- SL_LOGV("Callback protector detected return from callback during destroy");
-#endif
- mCbExitedCondition.broadcast();
- }
-#ifdef USE_DEBUG
- mCallbackThread = NULL;
- mCallbackTid = 0;
-#endif
- }
-}
-
-
-void CallbackProtector::requestCbExitAndWait() {
- Mutex::Autolock _l(mLock);
- mSafeToEnterCb = false;
-#ifdef USE_DEBUG
- mRequesterThread = pthread_self();
- mRequesterTid = gettid();
-#endif
- while (mCbCount) {
-#ifdef USE_DEBUG
- SL_LOGV("Callback protector detected in-progress callback by thread %p tid %d during"
- " blocking destroy requested by thread %p tid %d",
- (void *) mCallbackThread, mCallbackTid,
- (void *) pthread_self(), gettid());
-#else
- SL_LOGV("Callback protector detected in-progress callback during blocking destroy");
-#endif
- mCbExitedCondition.wait(mLock);
- }
-}
-
-
-void CallbackProtector::requestCbExit() {
- Mutex::Autolock _l(mLock);
- mSafeToEnterCb = false;
-#ifdef USE_DEBUG
- mRequesterThread = pthread_self();
- mRequesterTid = gettid();
-#endif
- if (mCbCount) {
-#ifdef USE_DEBUG
- SL_LOGV("Callback protector detected in-progress callback by thread %p tid %d during"
- " non-blocking destroy requested by thread %p tid %d",
- (void *) mCallbackThread, mCallbackTid,
- (void *) pthread_self(), gettid());
-#else
- SL_LOGV("Callback protector detected in-progress callback during non-blocking destroy");
-#endif
- }
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/CallbackProtector.h b/wilhelm/src/android/CallbackProtector.h
deleted file mode 100644
index 8b7d2cd..0000000
--- a/wilhelm/src/android/CallbackProtector.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "utils/threads.h"
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-class CallbackProtector : public RefBase {
-
-public:
- CallbackProtector();
- virtual ~CallbackProtector();
-
- /**
- * Indicates whether the CallbackProtector is non-NULL and it's safe to enter the callback.
- */
- static bool enterCbIfOk(const sp<CallbackProtector> &protector);
-
- /**
- * Indicates whether it's safe to enter the callback. It would typically return false
- * if the associated object (AudioTrack, AudioPlayer, MediaPlayer) is about to be destroyed.
- */
- bool enterCb();
-
- /**
- * This method must be paired to each call to enterCb() or enterCbIfOk(),
- * only it returned that it is safe enter the callback;
- */
- void exitCb();
-
- /**
- * Called to signal the associated object is about to be destroyed, so whenever a callback is
- * entered (see enterCb) it will be notified it is pointless to process the callback. This will
- * return immediately if there are no callbacks, and will block until current callbacks exit.
- */
- void requestCbExitAndWait();
-
- /**
- * Similar to requestCbExitAndWait, but does not wait for current callbacks to exit.
- */
- void requestCbExit();
-
-private:
- Mutex mLock;
- Condition mCbExitedCondition;
-
- bool mSafeToEnterCb;
-
- /** Counts the number of callbacks actively locking the associated AudioPlayer */
- unsigned int mCbCount;
-
-#ifdef USE_DEBUG
- pthread_t mCallbackThread;
- pid_t mCallbackTid;
- pthread_t mRequesterThread;
- pid_t mRequesterTid;
-#endif
-
- // disallow "evil" constructors
- CallbackProtector(const CallbackProtector &);
- CallbackProtector &operator=(const CallbackProtector &);
-};
-
-} // namespace android
diff --git a/wilhelm/src/android/MediaPlayer_to_android.cpp b/wilhelm/src/android/MediaPlayer_to_android.cpp
deleted file mode 100644
index 083738d..0000000
--- a/wilhelm/src/android/MediaPlayer_to_android.cpp
+++ /dev/null
@@ -1,748 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-#include "utils/RefBase.h"
-#include "android_prompts.h"
-// LocAVPlayer and StreamPlayer derive from GenericMediaPlayer,
-// so no need to #include "android_GenericMediaPlayer.h"
-#include "android_LocAVPlayer.h"
-#include "android_StreamPlayer.h"
-
-
-//-----------------------------------------------------------------------------
-static void player_handleMediaPlayerEventNotifications(int event, int data1, int data2, void* user)
-{
-
- // FIXME This code is derived from similar code in sfplayer_handlePrefetchEvent. The two
- // versions are quite similar, but still different enough that they need to be separate.
- // At some point they should be re-factored and merged if feasible.
- // As with other OpenMAX AL implementation code, this copy mostly uses SL_ symbols
- // rather than XA_ unless the difference is significant.
-
- if (NULL == user) {
- return;
- }
-
- CMediaPlayer* mp = (CMediaPlayer*) user;
- if (!android::CallbackProtector::enterCbIfOk(mp->mCallbackProtector)) {
- // it is not safe to enter the callback (the media player is about to go away)
- return;
- }
- union {
- char c[sizeof(int)];
- int i;
- } u;
- u.i = event;
- SL_LOGV("player_handleMediaPlayerEventNotifications(event='%c%c%c%c' (%d), data1=%d, data2=%d, "
- "user=%p) from AVPlayer", u.c[3], u.c[2], u.c[1], u.c[0], event, data1, data2, user);
- switch(event) {
-
- case android::GenericPlayer::kEventPrepared: {
-
- SL_LOGV("Received AVPlayer::kEventPrepared for CMediaPlayer %p", mp);
-
- // assume no callback
- slPrefetchCallback callback = NULL;
- void* callbackPContext = NULL;
-
- object_lock_exclusive(&mp->mObject);
- // mark object as prepared; same state is used for successfully or unsuccessful prepare
- mp->mAndroidObjState = ANDROID_READY;
-
- // AVPlayer prepare() failed prefetching, there is no event in XAPrefetchStatus to
- // indicate a prefetch error, so we signal it by sending simulataneously two events:
- // - SL_PREFETCHEVENT_FILLLEVELCHANGE with a level of 0
- // - SL_PREFETCHEVENT_STATUSCHANGE with a status of SL_PREFETCHSTATUS_UNDERFLOW
- if (PLAYER_SUCCESS != data1 && IsInterfaceInitialized(&mp->mObject, MPH_XAPREFETCHSTATUS)) {
- mp->mPrefetchStatus.mLevel = 0;
- mp->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- if (!(~mp->mPrefetchStatus.mCallbackEventsMask &
- (SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE))) {
- callback = mp->mPrefetchStatus.mCallback;
- callbackPContext = mp->mPrefetchStatus.mContext;
- }
- }
- object_unlock_exclusive(&mp->mObject);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&mp->mPrefetchStatus.mItf, callbackPContext,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
- }
-
- break;
- }
-
- case android::GenericPlayer::kEventHasVideoSize: {
- SL_LOGV("Received AVPlayer::kEventHasVideoSize (%d,%d) for CMediaPlayer %p",
- data1, data2, mp);
-
- object_lock_exclusive(&mp->mObject);
-
- // remove an existing video info entry (here we only have one video stream)
- for(size_t i=0 ; i < mp->mStreamInfo.mStreamInfoTable.size() ; i++) {
- if (XA_DOMAINTYPE_VIDEO == mp->mStreamInfo.mStreamInfoTable.itemAt(i).domain) {
- mp->mStreamInfo.mStreamInfoTable.removeAt(i);
- break;
- }
- }
- // update the stream information with a new video info entry
- StreamInfo streamInfo;
- streamInfo.domain = XA_DOMAINTYPE_VIDEO;
- streamInfo.videoInfo.codecId = 0;// unknown, we don't have that info FIXME
- streamInfo.videoInfo.width = (XAuint32)data1;
- streamInfo.videoInfo.height = (XAuint32)data2;
- streamInfo.videoInfo.bitRate = 0;// unknown, we don't have that info FIXME
- streamInfo.videoInfo.frameRate = 0;
- streamInfo.videoInfo.duration = XA_TIME_UNKNOWN;
- StreamInfo &contInfo = mp->mStreamInfo.mStreamInfoTable.editItemAt(0);
- contInfo.containerInfo.numStreams = 1;
- ssize_t index = mp->mStreamInfo.mStreamInfoTable.add(streamInfo);
-
- xaStreamEventChangeCallback callback = mp->mStreamInfo.mCallback;
- void* callbackPContext = mp->mStreamInfo.mContext;
-
- object_unlock_exclusive(&mp->mObject);
-
- // enqueue notification (outside of lock) that the stream information has been updated
- if ((NULL != callback) && (index >= 0)) {
-#ifndef USE_ASYNCHRONOUS_STREAMCBEVENT_PROPERTYCHANGE_CALLBACK
- (*callback)(&mp->mStreamInfo.mItf, XA_STREAMCBEVENT_PROPERTYCHANGE /*eventId*/,
- 1 /*streamIndex, only one stream supported here, 0 is reserved*/,
- NULL /*pEventData, always NULL in OpenMAX AL 1.0.1*/,
- callbackPContext /*pContext*/);
-#else
- SLresult res = EnqueueAsyncCallback_piipp(mp, callback,
- /*p1*/ &mp->mStreamInfo.mItf,
- /*i1*/ XA_STREAMCBEVENT_PROPERTYCHANGE /*eventId*/,
- /*i2*/ 1 /*streamIndex, only one stream supported here, 0 is reserved*/,
- /*p2*/ NULL /*pEventData, always NULL in OpenMAX AL 1.0.1*/,
- /*p3*/ callbackPContext /*pContext*/);
- LOGW_IF(SL_RESULT_SUCCESS != res,
- "Callback %p(%p, XA_STREAMCBEVENT_PROPERTYCHANGE, 1, NULL, %p) dropped",
- callback, &mp->mStreamInfo.mItf, callbackPContext);
-#endif
- }
- break;
- }
-
- case android::GenericPlayer::kEventEndOfStream: {
- SL_LOGV("Received AVPlayer::kEventEndOfStream for CMediaPlayer %p", mp);
-
- object_lock_exclusive(&mp->mObject);
- // should be xaPlayCallback but we're sharing the itf between SL and AL
- slPlayCallback playCallback = NULL;
- void * playContext = NULL;
- // XAPlayItf callback or no callback?
- if (mp->mPlay.mEventFlags & XA_PLAYEVENT_HEADATEND) {
- playCallback = mp->mPlay.mCallback;
- playContext = mp->mPlay.mContext;
- }
- mp->mPlay.mState = XA_PLAYSTATE_PAUSED;
- object_unlock_exclusive(&mp->mObject);
-
- // enqueue callback with no lock held
- if (NULL != playCallback) {
-#ifndef USE_ASYNCHRONOUS_PLAY_CALLBACK
- (*playCallback)(&mp->mPlay.mItf, playContext, XA_PLAYEVENT_HEADATEND);
-#else
- SLresult res = EnqueueAsyncCallback_ppi(mp, playCallback, &mp->mPlay.mItf, playContext,
- XA_PLAYEVENT_HEADATEND);
- LOGW_IF(SL_RESULT_SUCCESS != res,
- "Callback %p(%p, %p, SL_PLAYEVENT_HEADATEND) dropped", playCallback,
- &mp->mPlay.mItf, playContext);
-#endif
- }
- break;
- }
-
- case android::GenericPlayer::kEventChannelCount: {
- SL_LOGV("kEventChannelCount channels = %d", data1);
- object_lock_exclusive(&mp->mObject);
- if (UNKNOWN_NUMCHANNELS == mp->mNumChannels && UNKNOWN_NUMCHANNELS != data1) {
- mp->mNumChannels = data1;
- android_Player_volumeUpdate(mp);
- }
- object_unlock_exclusive(&mp->mObject);
- }
- break;
-
- case android::GenericPlayer::kEventPrefetchFillLevelUpdate: {
- SL_LOGV("kEventPrefetchFillLevelUpdate");
- if (!IsInterfaceInitialized(&mp->mObject, MPH_XAPREFETCHSTATUS)) {
- break;
- }
- slPrefetchCallback callback = NULL;
- void* callbackPContext = NULL;
-
- // SLPrefetchStatusItf callback or no callback?
- interface_lock_exclusive(&mp->mPrefetchStatus);
- if (mp->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- callback = mp->mPrefetchStatus.mCallback;
- callbackPContext = mp->mPrefetchStatus.mContext;
- }
- mp->mPrefetchStatus.mLevel = (SLpermille)data1;
- interface_unlock_exclusive(&mp->mPrefetchStatus);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&mp->mPrefetchStatus.mItf, callbackPContext,
- SL_PREFETCHEVENT_FILLLEVELCHANGE);
- }
- }
- break;
-
- case android::GenericPlayer::kEventPrefetchStatusChange: {
- SL_LOGV("kEventPrefetchStatusChange");
- if (!IsInterfaceInitialized(&mp->mObject, MPH_XAPREFETCHSTATUS)) {
- break;
- }
- slPrefetchCallback callback = NULL;
- void* callbackPContext = NULL;
-
- // SLPrefetchStatusItf callback or no callback?
- object_lock_exclusive(&mp->mObject);
- if (mp->mPrefetchStatus.mCallbackEventsMask & SL_PREFETCHEVENT_STATUSCHANGE) {
- callback = mp->mPrefetchStatus.mCallback;
- callbackPContext = mp->mPrefetchStatus.mContext;
- }
- if (data1 >= android::kStatusIntermediate) {
- mp->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
- } else if (data1 < android::kStatusIntermediate) {
- mp->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- }
- object_unlock_exclusive(&mp->mObject);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&mp->mPrefetchStatus.mItf, callbackPContext, SL_PREFETCHEVENT_STATUSCHANGE);
- }
- }
- break;
-
- case android::GenericPlayer::kEventPlay: {
- SL_LOGV("kEventPlay");
-
- interface_lock_shared(&mp->mPlay);
- slPlayCallback callback = mp->mPlay.mCallback;
- void* callbackPContext = mp->mPlay.mContext;
- interface_unlock_shared(&mp->mPlay);
-
- if (NULL != callback) {
- (*callback)(&mp->mPlay.mItf, callbackPContext, (SLuint32) data1); // SL_PLAYEVENT_HEAD*
- }
- }
- break;
-
- case android::GenericPlayer::kEventErrorAfterPrepare: {
- SL_LOGV("kEventErrorAfterPrepare");
-
- // assume no callback
- slPrefetchCallback callback = NULL;
- void* callbackPContext = NULL;
-
- object_lock_exclusive(&mp->mObject);
- if (IsInterfaceInitialized(&mp->mObject, MPH_XAPREFETCHSTATUS)) {
- mp->mPrefetchStatus.mLevel = 0;
- mp->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- if (!(~mp->mPrefetchStatus.mCallbackEventsMask &
- (SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE))) {
- callback = mp->mPrefetchStatus.mCallback;
- callbackPContext = mp->mPrefetchStatus.mContext;
- }
- }
- object_unlock_exclusive(&mp->mObject);
-
- // FIXME there's interesting information in data1, but no API to convey it to client
- SL_LOGE("Error after prepare: %d", data1);
-
- // callback with no lock held
- if (NULL != callback) {
- (*callback)(&mp->mPrefetchStatus.mItf, callbackPContext,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
- }
-
- }
- break;
-
- default: {
- SL_LOGE("Received unknown event %d, data %d from AVPlayer", event, data1);
- }
- }
-
- mp->mCallbackProtector->exitCb();
-}
-
-
-//-----------------------------------------------------------------------------
-XAresult android_Player_checkSourceSink(CMediaPlayer *mp) {
-
- XAresult result = XA_RESULT_SUCCESS;
-
- const SLDataSource *pSrc = &mp->mDataSource.u.mSource;
- const SLDataSink *pAudioSnk = &mp->mAudioSink.u.mSink;
-
- // format check:
- const SLuint32 sourceLocatorType = *(SLuint32 *)pSrc->pLocator;
- const SLuint32 sourceFormatType = *(SLuint32 *)pSrc->pFormat;
- const SLuint32 audioSinkLocatorType = *(SLuint32 *)pAudioSnk->pLocator;
- //const SLuint32 sinkFormatType = *(SLuint32 *)pAudioSnk->pFormat;
-
- // Source check
- switch(sourceLocatorType) {
-
- case XA_DATALOCATOR_ANDROIDBUFFERQUEUE: {
- switch (sourceFormatType) {
- case XA_DATAFORMAT_MIME: {
- SLDataFormat_MIME *df_mime = (SLDataFormat_MIME *) pSrc->pFormat;
- if (SL_CONTAINERTYPE_MPEG_TS != df_mime->containerType) {
- SL_LOGE("Cannot create player with XA_DATALOCATOR_ANDROIDBUFFERQUEUE data source "
- "that is not fed MPEG-2 TS data");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- } break;
- default:
- SL_LOGE("Cannot create player with XA_DATALOCATOR_ANDROIDBUFFERQUEUE data source "
- "without SL_DATAFORMAT_MIME format");
- return XA_RESULT_CONTENT_UNSUPPORTED;
- }
- } break;
-
- case XA_DATALOCATOR_URI: // intended fall-through
- case XA_DATALOCATOR_ANDROIDFD:
- break;
-
- default:
- SL_LOGE("Cannot create media player with data locator type 0x%x",
- (unsigned) sourceLocatorType);
- return SL_RESULT_PARAMETER_INVALID;
- }// switch (locatorType)
-
- // Audio sink check: only playback is supported here
- switch(audioSinkLocatorType) {
-
- case XA_DATALOCATOR_OUTPUTMIX:
- break;
-
- default:
- SL_LOGE("Cannot create media player with audio sink data locator of type 0x%x",
- (unsigned) audioSinkLocatorType);
- return XA_RESULT_PARAMETER_INVALID;
- }// switch (locaaudioSinkLocatorTypeorType)
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-XAresult android_Player_create(CMediaPlayer *mp) {
-
- XAresult result = XA_RESULT_SUCCESS;
-
- // FIXME verify data source
- const SLDataSource *pDataSrc = &mp->mDataSource.u.mSource;
- // FIXME verify audio data sink
- const SLDataSink *pAudioSnk = &mp->mAudioSink.u.mSink;
- // FIXME verify image data sink
- const SLDataSink *pVideoSnk = &mp->mImageVideoSink.u.mSink;
-
- XAuint32 sourceLocator = *(XAuint32 *)pDataSrc->pLocator;
- switch(sourceLocator) {
- // FIXME support Android simple buffer queue as well
- case XA_DATALOCATOR_ANDROIDBUFFERQUEUE:
- mp->mAndroidObjType = AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE;
- break;
- case XA_DATALOCATOR_URI: // intended fall-through
- case SL_DATALOCATOR_ANDROIDFD:
- mp->mAndroidObjType = AUDIOVIDEOPLAYER_FROM_URIFD;
- break;
- case XA_DATALOCATOR_ADDRESS: // intended fall-through
- default:
- SL_LOGE("Unable to create MediaPlayer for data source locator 0x%x", sourceLocator);
- result = XA_RESULT_PARAMETER_INVALID;
- break;
- }
-
- // FIXME duplicates an initialization also done by higher level
- mp->mAndroidObjState = ANDROID_UNINITIALIZED;
- mp->mStreamType = ANDROID_DEFAULT_OUTPUT_STREAM_TYPE;
- mp->mSessionId = android::AudioSystem::newAudioSessionId();
-
- mp->mCallbackProtector = new android::CallbackProtector();
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-// FIXME abstract out the diff between CMediaPlayer and CAudioPlayer
-XAresult android_Player_realize(CMediaPlayer *mp, SLboolean async) {
- SL_LOGV("android_Player_realize_l(%p)", mp);
- XAresult result = XA_RESULT_SUCCESS;
-
- const SLDataSource *pDataSrc = &mp->mDataSource.u.mSource;
- const SLuint32 sourceLocator = *(SLuint32 *)pDataSrc->pLocator;
-
- AudioPlayback_Parameters ap_params;
- ap_params.sessionId = mp->mSessionId;
- ap_params.streamType = mp->mStreamType;
-
- switch(mp->mAndroidObjType) {
- case AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: {
- mp->mAVPlayer = new android::StreamPlayer(&ap_params, true /*hasVideo*/,
- &mp->mAndroidBufferQueue, mp->mCallbackProtector);
- mp->mAVPlayer->init(player_handleMediaPlayerEventNotifications, (void*)mp);
- }
- break;
- case AUDIOVIDEOPLAYER_FROM_URIFD: {
- mp->mAVPlayer = new android::LocAVPlayer(&ap_params, true /*hasVideo*/);
- mp->mAVPlayer->init(player_handleMediaPlayerEventNotifications, (void*)mp);
- switch (mp->mDataSource.mLocator.mLocatorType) {
- case XA_DATALOCATOR_URI:
- ((android::LocAVPlayer*)mp->mAVPlayer.get())->setDataSource(
- (const char*)mp->mDataSource.mLocator.mURI.URI);
- break;
- case XA_DATALOCATOR_ANDROIDFD: {
- int64_t offset = (int64_t)mp->mDataSource.mLocator.mFD.offset;
- ((android::LocAVPlayer*)mp->mAVPlayer.get())->setDataSource(
- (int)mp->mDataSource.mLocator.mFD.fd,
- offset == SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE ?
- (int64_t)PLAYER_FD_FIND_FILE_SIZE : offset,
- (int64_t)mp->mDataSource.mLocator.mFD.length);
- }
- break;
- default:
- SL_LOGE("Invalid or unsupported data locator type %u for data source",
- mp->mDataSource.mLocator.mLocatorType);
- result = XA_RESULT_PARAMETER_INVALID;
- }
- }
- break;
- case INVALID_TYPE: // intended fall-through
- default:
- SL_LOGE("Unable to realize MediaPlayer, invalid internal Android object type");
- result = XA_RESULT_PARAMETER_INVALID;
- break;
- }
-
- if (XA_RESULT_SUCCESS == result) {
-
- // if there is a video sink
- if (XA_DATALOCATOR_NATIVEDISPLAY ==
- mp->mImageVideoSink.mLocator.mLocatorType) {
- ANativeWindow *nativeWindow = (ANativeWindow *)
- mp->mImageVideoSink.mLocator.mNativeDisplay.hWindow;
- // we already verified earlier that hWindow is non-NULL
- assert(nativeWindow != NULL);
- result = android_Player_setNativeWindow(mp, nativeWindow);
- }
-
- }
-
- return result;
-}
-
-// Called with a lock on MediaPlayer, and blocks until safe to destroy
-XAresult android_Player_preDestroy(CMediaPlayer *mp) {
- SL_LOGV("android_Player_preDestroy(%p)", mp);
-
- // Not yet clear why this order is important, but it reduces detected deadlocks
- object_unlock_exclusive(&mp->mObject);
- if (mp->mCallbackProtector != 0) {
- mp->mCallbackProtector->requestCbExitAndWait();
- }
- object_lock_exclusive(&mp->mObject);
-
- if (mp->mAVPlayer != 0) {
- mp->mAVPlayer->preDestroy();
- }
- SL_LOGV("android_Player_preDestroy(%p) after mAVPlayer->preDestroy()", mp);
-
- return XA_RESULT_SUCCESS;
-}
-
-//-----------------------------------------------------------------------------
-XAresult android_Player_destroy(CMediaPlayer *mp) {
- SL_LOGV("android_Player_destroy(%p)", mp);
-
- mp->mAVPlayer.clear();
- mp->mCallbackProtector.clear();
-
- // explicit destructor
- mp->mAVPlayer.~sp();
- mp->mCallbackProtector.~sp();
-
- return XA_RESULT_SUCCESS;
-}
-
-
-void android_Player_usePlayEventMask(CMediaPlayer *mp) {
- if (mp->mAVPlayer != 0) {
- IPlay *pPlayItf = &mp->mPlay;
- mp->mAVPlayer->setPlayEvents((int32_t) pPlayItf->mEventFlags,
- (int32_t) pPlayItf->mMarkerPosition, (int32_t) pPlayItf->mPositionUpdatePeriod);
- }
-}
-
-
-XAresult android_Player_getDuration(IPlay *pPlayItf, XAmillisecond *pDurMsec) {
- CMediaPlayer *avp = (CMediaPlayer *)pPlayItf->mThis;
-
- switch (avp->mAndroidObjType) {
-
- case AUDIOVIDEOPLAYER_FROM_URIFD: {
- int dur = ANDROID_UNKNOWN_TIME;
- if (avp->mAVPlayer != 0) {
- avp->mAVPlayer->getDurationMsec(&dur);
- }
- if (dur == ANDROID_UNKNOWN_TIME) {
- *pDurMsec = XA_TIME_UNKNOWN;
- } else {
- *pDurMsec = (XAmillisecond)dur;
- }
- } break;
-
- case AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- default:
- *pDurMsec = XA_TIME_UNKNOWN;
- break;
- }
-
- return XA_RESULT_SUCCESS;
-}
-
-
-XAresult android_Player_getPosition(IPlay *pPlayItf, XAmillisecond *pPosMsec) {
- SL_LOGD("android_Player_getPosition()");
- XAresult result = XA_RESULT_SUCCESS;
- CMediaPlayer *avp = (CMediaPlayer *)pPlayItf->mThis;
-
- switch (avp->mAndroidObjType) {
-
- case AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- case AUDIOVIDEOPLAYER_FROM_URIFD: {
- int pos = ANDROID_UNKNOWN_TIME;
- if (avp->mAVPlayer != 0) {
- avp->mAVPlayer->getPositionMsec(&pos);
- }
- if (pos == ANDROID_UNKNOWN_TIME) {
- *pPosMsec = 0;
- } else {
- *pPosMsec = (XAmillisecond)pos;
- }
- } break;
-
- default:
- // we shouldn't be here
- assert(false);
- break;
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-/**
- * pre-condition: mp != NULL
- */
-void android_Player_volumeUpdate(CMediaPlayer* mp)
-{
- android::GenericPlayer* avp = mp->mAVPlayer.get();
- if (avp != NULL) {
- float volumes[2];
- // MediaPlayer does not currently support EffectSend or MuteSolo
- android_player_volumeUpdate(volumes, &mp->mVolume, mp->mNumChannels, 1.0f, NULL);
- float leftVol = volumes[0], rightVol = volumes[1];
- avp->setVolume(leftVol, rightVol);
- }
-}
-
-//-----------------------------------------------------------------------------
-/**
- * pre-condition: gp != 0
- */
-XAresult android_Player_setPlayState(const android::sp<android::GenericPlayer> &gp,
- SLuint32 playState,
- AndroidObjectState* pObjState)
-{
- XAresult result = XA_RESULT_SUCCESS;
- AndroidObjectState objState = *pObjState;
-
- switch (playState) {
- case SL_PLAYSTATE_STOPPED: {
- SL_LOGV("setting AVPlayer to SL_PLAYSTATE_STOPPED");
- gp->stop();
- }
- break;
- case SL_PLAYSTATE_PAUSED: {
- SL_LOGV("setting AVPlayer to SL_PLAYSTATE_PAUSED");
- switch(objState) {
- case ANDROID_UNINITIALIZED:
- *pObjState = ANDROID_PREPARING;
- gp->prepare();
- break;
- case ANDROID_PREPARING:
- break;
- case ANDROID_READY:
- gp->pause();
- break;
- default:
- SL_LOGE("Android object in invalid state");
- break;
- }
- }
- break;
- case SL_PLAYSTATE_PLAYING: {
- SL_LOGV("setting AVPlayer to SL_PLAYSTATE_PLAYING");
- switch(objState) {
- case ANDROID_UNINITIALIZED:
- *pObjState = ANDROID_PREPARING;
- gp->prepare();
- // intended fall through
- case ANDROID_PREPARING:
- // intended fall through
- case ANDROID_READY:
- gp->play();
- break;
- default:
- SL_LOGE("Android object in invalid state");
- break;
- }
- }
- break;
- default:
- // checked by caller, should not happen
- break;
- }
-
- return result;
-}
-
-
-/**
- * pre-condition: mp != NULL
- */
-XAresult android_Player_seek(CMediaPlayer *mp, SLmillisecond posMsec) {
- XAresult result = XA_RESULT_SUCCESS;
- switch (mp->mAndroidObjType) {
- case AUDIOVIDEOPLAYER_FROM_URIFD:
- if (mp->mAVPlayer !=0) {
- mp->mAVPlayer->seek(posMsec);
- }
- break;
- case AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- default: {
- result = XA_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- return result;
-}
-
-
-/**
- * pre-condition: mp != NULL
- */
-XAresult android_Player_loop(CMediaPlayer *mp, SLboolean loopEnable) {
- XAresult result = XA_RESULT_SUCCESS;
- switch (mp->mAndroidObjType) {
- case AUDIOVIDEOPLAYER_FROM_URIFD:
- if (mp->mAVPlayer !=0) {
- mp->mAVPlayer->loop(loopEnable);
- }
- break;
- case AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: // intended fall-through
- default: {
- result = XA_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-void android_Player_androidBufferQueue_clear_l(CMediaPlayer *mp) {
- if ((mp->mAndroidObjType == AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE)
- && (mp->mAVPlayer != 0)) {
- android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(mp->mAVPlayer.get());
- splr->appClear_l();
- }
-}
-
-
-void android_Player_androidBufferQueue_onRefilled_l(CMediaPlayer *mp) {
- if ((mp->mAndroidObjType == AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE)
- && (mp->mAVPlayer != 0)) {
- android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(mp->mAVPlayer.get());
- splr->queueRefilled();
- }
-}
-
-
-/*
- * pre-conditions:
- * mp != NULL
- * mp->mAVPlayer != 0 (player is realized)
- * nativeWindow can be NULL, but if NULL it is treated as an error
- */
-SLresult android_Player_setNativeWindow(CMediaPlayer *mp, ANativeWindow *nativeWindow)
-{
- assert(mp != NULL);
- assert(mp->mAVPlayer != 0);
- if (nativeWindow == NULL) {
- SL_LOGE("ANativeWindow is NULL");
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLresult result;
- int err;
- int value;
- // this could crash if app passes in a bad parameter, but that's OK
- err = (*nativeWindow->query)(nativeWindow, NATIVE_WINDOW_CONCRETE_TYPE, &value);
- if (0 != err) {
- SL_LOGE("Query NATIVE_WINDOW_CONCRETE_TYPE on ANativeWindow * %p failed; "
- "errno %d", nativeWindow, err);
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- switch (value) {
- case NATIVE_WINDOW_SURFACE: { // Surface
- SL_LOGV("Displaying on ANativeWindow of type NATIVE_WINDOW_SURFACE");
- android::sp<android::Surface> nativeSurface(
- static_cast<android::Surface *>(nativeWindow));
- mp->mAVPlayer->setVideoSurfaceTexture(
- nativeSurface->getSurfaceTexture());
- result = SL_RESULT_SUCCESS;
- } break;
- case NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT: { // SurfaceTextureClient
- SL_LOGV("Displaying on ANativeWindow of type NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT");
- android::sp<android::SurfaceTextureClient> surfaceTextureClient(
- static_cast<android::SurfaceTextureClient *>(nativeWindow));
- android::sp<android::ISurfaceTexture> nativeSurfaceTexture(
- surfaceTextureClient->getISurfaceTexture());
- mp->mAVPlayer->setVideoSurfaceTexture(nativeSurfaceTexture);
- result = SL_RESULT_SUCCESS;
- } break;
- case NATIVE_WINDOW_FRAMEBUFFER: // FramebufferNativeWindow
- // fall through
- default:
- SL_LOGE("ANativeWindow * %p has unknown or unsupported concrete type %d",
- nativeWindow, value);
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- }
- return result;
-}
diff --git a/wilhelm/src/android/MediaPlayer_to_android.h b/wilhelm/src/android/MediaPlayer_to_android.h
deleted file mode 100644
index e83439d..0000000
--- a/wilhelm/src/android/MediaPlayer_to_android.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <surfaceflinger/Surface.h>
-#include <gui/ISurfaceTexture.h>
-
-
-/**************************************************************************************************
- * Player lifecycle
- ****************************/
-extern XAresult android_Player_checkSourceSink(CMediaPlayer *mp);
-
-extern XAresult android_Player_create(CMediaPlayer *mp);
-
-extern XAresult android_Player_realize(CMediaPlayer *mp, SLboolean async);
-
-extern XAresult android_Player_destroy(CMediaPlayer *mp);
-
-extern XAresult android_Player_preDestroy(CMediaPlayer *mp);
-
-
-/**************************************************************************************************
- * Configuration
- ****************************/
-
-/**
- * pre-conditions:
- * pMediaPlayer != NULL
- * pMediaPlayer->mAVPlayer != 0 (player is realized)
- * nativeWindow can be NULL, but if NULL it is treated as an error
- */
-extern SLresult android_Player_setNativeWindow(CMediaPlayer *pMediaPlayer,
- ANativeWindow *nativeWindow);
-
-/**
- * pre-conditions:
- * pPlayItf != NULL
- * pDurMsec, pPosMsec ! = NULL
- * IObjectToObjectID( ((IPlay *) self)->mThis ) == XA_OBJECTID_MEDIAPLAYER
- */
-extern XAresult android_Player_getDuration(IPlay *pPlayItf, SLmillisecond *pDurMsec);
-extern XAresult android_Player_getPosition(IPlay *pPlayItf, SLmillisecond *pPosMsec);
-
-/**
- * pre-condition: mp != NULL
- */
-extern void android_Player_volumeUpdate(CMediaPlayer *mp);
-extern void android_Player_usePlayEventMask(CMediaPlayer *mp);
-
-/**************************************************************************************************
- * Playback control and events
- ****************************/
-/**
- * pre-condition: gp != 0
- */
-extern XAresult android_Player_setPlayState(const android::sp<android::GenericPlayer> &gp,
- SLuint32 playState,
- AndroidObjectState* pObjState);
-
-/**
- * for all functions below: pre-condition: mp != NULL
- */
-extern XAresult android_Player_seek(CMediaPlayer *mp, SLmillisecond posMsec);
-extern XAresult android_Player_loop(CMediaPlayer *mp, SLboolean loopEnable);
-
-
-
-/**************************************************************************************************
- * Buffer Queue events
- ****************************/
-
-/**************************************************************************************************
- * Android Buffer Queue
- ****************************/
-
-/* must be called with a lock on mp->mThis */
-extern void android_Player_androidBufferQueue_clear_l(CMediaPlayer *mp);
-/* must be called with a lock on mp->mThis */
-extern void android_Player_androidBufferQueue_onRefilled_l(CMediaPlayer *mp);
diff --git a/wilhelm/src/android/OutputMix_to_android.cpp b/wilhelm/src/android/OutputMix_to_android.cpp
deleted file mode 100644
index a7d11ef..0000000
--- a/wilhelm/src/android/OutputMix_to_android.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-//#include "math.h"
-//#include "utils/RefBase.h"
-
-#include <system/audio.h>
-
-SLresult android_outputMix_create(COutputMix *om) {
- SL_LOGV("Create outputMix=%p", om);
- return SL_RESULT_SUCCESS;
-}
-
-
-SLresult android_outputMix_realize(COutputMix *om, SLboolean async) {
- SLresult result = SL_RESULT_SUCCESS;
- SL_LOGV("Realize outputMix=%p", om);
-
- // initialize effects
- // initialize EQ
- if (memcmp(SL_IID_EQUALIZER, &om->mEqualizer.mEqDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- android_eq_init(AUDIO_SESSION_OUTPUT_MIX /*sessionId*/, &om->mEqualizer);
- }
- // initialize BassBoost
- if (memcmp(SL_IID_BASSBOOST, &om->mBassBoost.mBassBoostDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- android_bb_init(AUDIO_SESSION_OUTPUT_MIX /*sessionId*/, &om->mBassBoost);
- }
- // initialize PresetReverb
- if (memcmp(SL_IID_PRESETREVERB, &om->mPresetReverb.mPresetReverbDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- android_prev_init(&om->mPresetReverb);
- }
- // initialize EnvironmentalReverb
- if (memcmp(SL_IID_ENVIRONMENTALREVERB,
- &om->mEnvironmentalReverb.mEnvironmentalReverbDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- android_erev_init(&om->mEnvironmentalReverb);
- }
- // initialize Virtualizer
- if (memcmp(SL_IID_VIRTUALIZER, &om->mVirtualizer.mVirtualizerDescriptor.type,
- sizeof(effect_uuid_t)) == 0) {
- android_virt_init(AUDIO_SESSION_OUTPUT_MIX /*sessionId*/,
- &om->mVirtualizer);
- }
-
- return result;
-}
-
-
-SLresult android_outputMix_destroy(COutputMix *om) {
- SL_LOGV("Destroy outputMix=%p", om);
- return SL_RESULT_SUCCESS;
-}
diff --git a/wilhelm/src/android/OutputMix_to_android.h b/wilhelm/src/android/OutputMix_to_android.h
deleted file mode 100644
index d15fd57..0000000
--- a/wilhelm/src/android/OutputMix_to_android.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-extern SLresult android_outputMix_create(COutputMix *om);
-
-extern SLresult android_outputMix_realize(COutputMix *om, SLboolean async);
-
-extern SLresult android_outputMix_destroy(COutputMix *om);
diff --git a/wilhelm/src/android/VideoCodec_to_android.cpp b/wilhelm/src/android/VideoCodec_to_android.cpp
deleted file mode 100644
index e2d8295..0000000
--- a/wilhelm/src/android/VideoCodec_to_android.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-#include <media/IMediaPlayerService.h>
-#include <media/stagefright/OMXClient.h>
-#include <media/stagefright/OMXCodec.h>
-#include <media/IOMX.h>
-#include <media/stagefright/MediaDefs.h>
-
-
-namespace android {
-
-static sp<IOMX> omx;
-
-// listed in same order as VideoCodecIds[] in file "../devices.c" with ANDROID defined
-static const char *kVideoMimeTypes[] = {
- MEDIA_MIMETYPE_VIDEO_MPEG2,
- MEDIA_MIMETYPE_VIDEO_H263,
- MEDIA_MIMETYPE_VIDEO_MPEG4,
- MEDIA_MIMETYPE_VIDEO_AVC,
- MEDIA_MIMETYPE_VIDEO_VPX
-};
-static const size_t kNbVideoMimeTypes = sizeof(kVideoMimeTypes) / sizeof(kVideoMimeTypes[0]);
-
-// codec capabilities in the following arrays maps to the mime types defined in kVideoMimeTypes
-static Vector<CodecCapabilities> VideoDecoderCapabilities[kNbVideoMimeTypes];
-static XAuint32 VideoDecoderNbProfLevel[kNbVideoMimeTypes];
-
-static XAuint32 NbSupportedDecoderTypes = 0;
-
-
-XAuint32 convertOpenMaxIlToAl(OMX_U32 ilVideoProfileOrLevel) {
- // For video codec profiles and levels, the number of trailing zeroes in OpenMAX IL
- // are equal to the matching OpenMAX AL constant value plus 1, for example:
- // XA_VIDEOPROFILE_H263_BACKWARDCOMPATIBLE ((XAuint32) 0x00000003)
- // matches
- // OMX_VIDEO_H263ProfileBackwardCompatible = 0x04
- return (XAuint32) (__builtin_ctz(ilVideoProfileOrLevel) + 1);
-}
-
-
-bool android_videoCodec_expose() {
- SL_LOGV("android_videoCodec_expose()");
-
- sp<IMediaPlayerService> service(IMediaDeathNotifier::getMediaPlayerService());
- if (service == NULL) {
- // no need to SL_LOGE; getMediaPlayerService already will have done so
- return false;
- }
-
- omx = service->getOMX();
- if (omx.get() == NULL) {
- LOGE("android_videoCodec_expose() couldn't access OMX interface");
- return false;
- }
-
- // used to check whether no codecs were found, which is a sign of failure
- NbSupportedDecoderTypes = 0;
- for (size_t m = 0 ; m < kNbVideoMimeTypes ; m++) {
- if (OK == QueryCodecs(omx, kVideoMimeTypes[m], true /* queryDecoders */,
- true /* hwCodecOnly */, &VideoDecoderCapabilities[m])) {
- if (!VideoDecoderCapabilities[m].empty()) {
- NbSupportedDecoderTypes++;
- }
- // for each decoder of the given decoder ID, verify it is a hardware decoder
- for (size_t c = 0 ; c < VideoDecoderCapabilities[m].size() ; c++) {
- VideoDecoderNbProfLevel[c] = 0;
- const String8& compName =
- VideoDecoderCapabilities[m].itemAt(c).mComponentName;
- // get the number of profiles and levels for this decoder
- VideoDecoderNbProfLevel[m] =
- VideoDecoderCapabilities[m].itemAt(c).mProfileLevels.size();
- if (VideoDecoderNbProfLevel[m] != 0) {
- SL_LOGV("codec %d nb prof/level=%d", m, VideoDecoderNbProfLevel[m]);
- break;
- }
- }
- }
- }
-
- return (NbSupportedDecoderTypes > 0);
-}
-
-
-void android_videoCodec_deinit() {
- SL_LOGV("android_videoCodec_deinit()");
- for (size_t m = 0 ; m < kNbVideoMimeTypes ; m++) {
- VideoDecoderCapabilities[m].clear();
- }
-}
-
-
-XAuint32 android_videoCodec_getNbDecoders() {
- return NbSupportedDecoderTypes;
-}
-
-
-void android_videoCodec_getDecoderIds(XAuint32 nbDecoders, XAuint32 *pDecoderIds) {
- XAuint32 *pIds = pDecoderIds;
- XAuint32 nbFound = 0;
- for (size_t m = 0 ; m < kNbVideoMimeTypes ; m++) {
- if (!VideoDecoderCapabilities[m].empty()) {
- *pIds = VideoDecoderIds[m];
- pIds++;
- nbFound++;
- }
- // range check: function can be called for fewer codecs than there are
- if (nbFound == nbDecoders) {
- break;
- }
- }
-}
-
-
-SLresult android_videoCodec_getProfileLevelCombinationNb(XAuint32 decoderId, XAuint32 *pNb)
-{
- // translate a decoder ID to an index in the codec table
- size_t decoderIndex = 0;
- *pNb = 0;
- while (decoderIndex < kNbVideoMimeTypes) {
- if (decoderId == VideoDecoderIds[decoderIndex]) {
- *pNb = VideoDecoderNbProfLevel[decoderIndex];
- break;
- }
- decoderIndex++;
- }
-
- return XA_RESULT_SUCCESS;
-}
-
-
-SLresult android_videoCodec_getProfileLevelCombination(XAuint32 decoderId, XAuint32 plIndex,
- XAVideoCodecDescriptor *pDescr)
-{
- // translate a decoder ID to an index in the codec table
- size_t decoderIndex = 0;
- while (decoderIndex < kNbVideoMimeTypes) {
- if (decoderId == VideoDecoderIds[decoderIndex]) {
- if (!(plIndex < VideoDecoderCapabilities[decoderIndex].itemAt(0).mProfileLevels.size()))
- {
- // asking for invalid profile/level
- return XA_RESULT_PARAMETER_INVALID;
- }
- // we only look at the first codec, OpenMAX AL doesn't let you expose the capabilities
- // of multiple codecs
- // set the fields we know about
- pDescr->codecId = decoderId;
- pDescr->profileSetting = convertOpenMaxIlToAl(VideoDecoderCapabilities[decoderIndex].
- itemAt(0).mProfileLevels.itemAt(plIndex).mProfile);
- pDescr->levelSetting = convertOpenMaxIlToAl(VideoDecoderCapabilities[decoderIndex].
- itemAt(0).mProfileLevels.itemAt(plIndex).mLevel);
- // initialize the fields we don't know about
- pDescr->maxWidth = 0;
- pDescr->maxHeight = 0;
- pDescr->maxFrameRate = 0;
- pDescr->maxBitRate = 0;
- pDescr->rateControlSupported = 0;
- break;
- }
- decoderIndex++;
- }
- return (decoderIndex < kNbVideoMimeTypes) ? XA_RESULT_SUCCESS : XA_RESULT_PARAMETER_INVALID;
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/VideoCodec_to_android.h b/wilhelm/src/android/VideoCodec_to_android.h
deleted file mode 100644
index 4faa03c..0000000
--- a/wilhelm/src/android/VideoCodec_to_android.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace android {
-
-/**************************************************************************
- * Important note: the functions below are helper functions for the
- * implementation of the XAVideoDecoderCapabilitiesItf interface on
- * Android. They are ONLY exposing the "hardware" video decoders
- * as dynamically discovered on the platform. A hardware video decoder
- * is defined as one where video decoding takes advantage of a hardware-
- * specific feature of the platform, such as DSP or particular GPU.
- * "Software" decoders, such as the ones available as default implementations
- * in the Android tree, as not exposed here, but are rather listed in
- * the CDD.
- */
-
-/*
- * Initializes the list of supported video codecs, with their associated profiles and levels
- * Return
- * false if it failed to list the available codecs, true otherwise
- */
-extern bool android_videoCodec_expose();
-
-/*
- * Frees all resources associated with the listing and query of the available video codecs
- */
-extern void android_videoCodec_deinit();
-
-/*
- * Returns the number of video codecs supported on the platform.
- * Returns 0 if android_videoCodec_expose() hasn't been called before (and returned true)
- */
-extern XAuint32 android_videoCodec_getNbDecoders();
-
-/*
- * Retrieve the supported decoder IDs
- * Pre-condition
- * nbDecoders <= number of decoders
- * pDecoderIds != NULL
- * android_videoCodec_expose() has been called before (and returned true)
- */
-extern void android_videoCodec_getDecoderIds(XAuint32 nbDecoders, XAuint32 *pDecoderIds);
-
-/*
- * Retrieves the number of profile / level combinations for a given codec
- * Pre-condition
- * pNb != NULL
- * android_videoCodec_expose() has been called before (and returned true)
- * Return
- * SL_RESULT_SUCCESS if the number of combinations was successfully retrieved and at least
- * one profile/level is supported (*pNb > 0)
- * SL_RESULT_PARAMETER_INVALID otherwise
- */
-extern SLresult android_videoCodec_getProfileLevelCombinationNb(XAuint32 decoderId, XAuint32 *pNb);
-
-/*
- * Retrieves the profile / level at index plIndex in the list of profile / level combinations
- * supported by the given codec
- * Pre-condition
- * pDescr != NULL
- * android_videoCodec_expose() has been called before (and returned true)
- * Post-condition
- * pDescr->codecId == decoderId
- * Return
- * SL_RESULT_SUCCESS if the profile/level was successfully retrieved
- * SL_RESULT_PARAMETER_INVALID otherwise: invalid codec or invalid profile/level index
- */
-extern SLresult android_videoCodec_getProfileLevelCombination(XAuint32 decoderId,
- XAuint32 plIndex, XAVideoCodecDescriptor *pDescr);
-
-}; // namespace android
diff --git a/wilhelm/src/android/android_AudioSfDecoder.cpp b/wilhelm/src/android/android_AudioSfDecoder.cpp
deleted file mode 100644
index de07265..0000000
--- a/wilhelm/src/android/android_AudioSfDecoder.cpp
+++ /dev/null
@@ -1,801 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-#include "android/android_AudioSfDecoder.h"
-
-#include <binder/IServiceManager.h>
-#include <media/stagefright/foundation/ADebug.h>
-
-
-#define SIZE_CACHED_HIGH_BYTES 1000000
-#define SIZE_CACHED_MED_BYTES 700000
-#define SIZE_CACHED_LOW_BYTES 400000
-
-namespace android {
-
-//--------------------------------------------------------------------------------------------------
-AudioSfDecoder::AudioSfDecoder(const AudioPlayback_Parameters* params) : GenericPlayer(params),
- mDataSource(0),
- mAudioSource(0),
- mAudioSourceStarted(false),
- mBitrate(-1),
- mDurationUsec(ANDROID_UNKNOWN_TIME),
- mDecodeBuffer(NULL),
- mSeekTimeMsec(0),
- // play event logic depends on the initial time being zero not ANDROID_UNKNOWN_TIME
- mLastDecodedPositionUs(0)
-{
- SL_LOGD("AudioSfDecoder::AudioSfDecoder()");
-}
-
-
-AudioSfDecoder::~AudioSfDecoder() {
- SL_LOGD("AudioSfDecoder::~AudioSfDecoder()");
-}
-
-
-void AudioSfDecoder::preDestroy() {
- GenericPlayer::preDestroy();
- SL_LOGD("AudioSfDecoder::preDestroy()");
- {
- Mutex::Autolock _l(mBufferSourceLock);
-
- if (NULL != mDecodeBuffer) {
- mDecodeBuffer->release();
- mDecodeBuffer = NULL;
- }
-
- if ((mAudioSource != 0) && mAudioSourceStarted) {
- mAudioSource->stop();
- mAudioSourceStarted = false;
- }
- }
-}
-
-
-//--------------------------------------------------
-void AudioSfDecoder::play() {
- SL_LOGD("AudioSfDecoder::play");
-
- GenericPlayer::play();
- (new AMessage(kWhatDecode, id()))->post();
-}
-
-
-void AudioSfDecoder::getPositionMsec(int* msec) {
- int64_t timeUsec = getPositionUsec();
- if (timeUsec == ANDROID_UNKNOWN_TIME) {
- *msec = ANDROID_UNKNOWN_TIME;
- } else {
- *msec = timeUsec / 1000;
- }
-}
-
-
-//--------------------------------------------------
-uint32_t AudioSfDecoder::getPcmFormatKeyCount() const {
- return NB_PCMMETADATA_KEYS;
-}
-
-
-//--------------------------------------------------
-bool AudioSfDecoder::getPcmFormatKeySize(uint32_t index, uint32_t* pKeySize) {
- if (index >= NB_PCMMETADATA_KEYS) {
- return false;
- } else {
- *pKeySize = strlen(kPcmDecodeMetadataKeys[index]) +1;
- return true;
- }
-}
-
-
-//--------------------------------------------------
-bool AudioSfDecoder::getPcmFormatKeyName(uint32_t index, uint32_t keySize, char* keyName) {
- uint32_t actualKeySize;
- if (!getPcmFormatKeySize(index, &actualKeySize)) {
- return false;
- }
- if (keySize < actualKeySize) {
- return false;
- }
- strncpy(keyName, kPcmDecodeMetadataKeys[index], actualKeySize);
- return true;
-}
-
-
-//--------------------------------------------------
-bool AudioSfDecoder::getPcmFormatValueSize(uint32_t index, uint32_t* pValueSize) {
- if (index >= NB_PCMMETADATA_KEYS) {
- *pValueSize = 0;
- return false;
- } else {
- *pValueSize = sizeof(uint32_t);
- return true;
- }
-}
-
-
-//--------------------------------------------------
-bool AudioSfDecoder::getPcmFormatKeyValue(uint32_t index, uint32_t size, uint32_t* pValue) {
- uint32_t valueSize = 0;
- if (!getPcmFormatValueSize(index, &valueSize)) {
- return false;
- } else if (size != valueSize) {
- // this ensures we are accessing mPcmFormatValues with a valid size for that index
- SL_LOGE("Error retrieving metadata value at index %d: using size of %d, should be %d",
- index, size, valueSize);
- return false;
- } else {
- android::Mutex::Autolock autoLock(mPcmFormatLock);
- *pValue = mPcmFormatValues[index];
- return true;
- }
-}
-
-
-//--------------------------------------------------
-// Event handlers
-// it is strictly verboten to call those methods outside of the event loop
-
-// Initializes the data and audio sources, and update the PCM format info
-// post-condition: upon successful initialization based on the player data locator
-// GenericPlayer::onPrepare() was called
-// mDataSource != 0
-// mAudioSource != 0
-// mAudioSourceStarted == true
-// All error returns from this method are via notifyPrepared(status) followed by "return".
-void AudioSfDecoder::onPrepare() {
- SL_LOGD("AudioSfDecoder::onPrepare()");
- Mutex::Autolock _l(mBufferSourceLock);
-
- {
- android::Mutex::Autolock autoLock(mPcmFormatLock);
- // Initialize the PCM format info with the known parameters before the start of the decode
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_BITSPERSAMPLE] = SL_PCMSAMPLEFORMAT_FIXED_16;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CONTAINERSIZE] = 16;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_ENDIANNESS] = SL_BYTEORDER_LITTLEENDIAN;
- // initialization with the default values: they will be replaced by the actual values
- // once the decoder has figured them out
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = UNKNOWN_NUMCHANNELS;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = UNKNOWN_SAMPLERATE;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] = UNKNOWN_CHANNELMASK;
- }
-
- //---------------------------------
- // Instantiate and initialize the data source for the decoder
- sp<DataSource> dataSource;
-
- switch (mDataLocatorType) {
-
- case kDataLocatorNone:
- SL_LOGE("AudioSfDecoder::onPrepare: no data locator set");
- notifyPrepared(MEDIA_ERROR_BASE);
- return;
-
- case kDataLocatorUri:
- dataSource = DataSource::CreateFromURI(mDataLocator.uriRef);
- if (dataSource == NULL) {
- SL_LOGE("AudioSfDecoder::onPrepare(): Error opening %s", mDataLocator.uriRef);
- notifyPrepared(MEDIA_ERROR_BASE);
- return;
- }
- break;
-
- case kDataLocatorFd:
- {
- // As FileSource unconditionally takes ownership of the fd and closes it, then
- // we have to make a dup for FileSource if the app wants to keep ownership itself
- int fd = mDataLocator.fdi.fd;
- if (mDataLocator.fdi.mCloseAfterUse) {
- mDataLocator.fdi.mCloseAfterUse = false;
- } else {
- fd = ::dup(fd);
- }
- dataSource = new FileSource(fd, mDataLocator.fdi.offset, mDataLocator.fdi.length);
- status_t err = dataSource->initCheck();
- if (err != OK) {
- notifyPrepared(err);
- return;
- }
- break;
- }
-
- default:
- TRESPASS();
- }
-
- //---------------------------------
- // Instanciate and initialize the decoder attached to the data source
- sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
- if (extractor == NULL) {
- SL_LOGE("AudioSfDecoder::onPrepare: Could not instantiate extractor.");
- notifyPrepared(ERROR_UNSUPPORTED);
- return;
- }
-
- ssize_t audioTrackIndex = -1;
- bool isRawAudio = false;
- for (size_t i = 0; i < extractor->countTracks(); ++i) {
- sp<MetaData> meta = extractor->getTrackMetaData(i);
-
- const char *mime;
- CHECK(meta->findCString(kKeyMIMEType, &mime));
-
- if (!strncasecmp("audio/", mime, 6)) {
- if (isSupportedCodec(mime)) {
- audioTrackIndex = i;
-
- if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_RAW, mime)) {
- isRawAudio = true;
- }
- break;
- }
- }
- }
-
- if (audioTrackIndex < 0) {
- SL_LOGE("AudioSfDecoder::onPrepare: Could not find a supported audio track.");
- notifyPrepared(ERROR_UNSUPPORTED);
- return;
- }
-
- sp<MediaSource> source = extractor->getTrack(audioTrackIndex);
- sp<MetaData> meta = source->getFormat();
-
- // we can't trust the OMXCodec (if there is one) to issue a INFO_FORMAT_CHANGED so we want
- // to have some meaningful values as soon as possible.
- int32_t channelCount;
- bool hasChannelCount = meta->findInt32(kKeyChannelCount, &channelCount);
- int32_t sr;
- bool hasSampleRate = meta->findInt32(kKeySampleRate, &sr);
-
- // first compute the duration
- off64_t size;
- int64_t durationUs;
- int32_t durationMsec;
- if (dataSource->getSize(&size) == OK
- && meta->findInt64(kKeyDuration, &durationUs)) {
- if (durationUs != 0) {
- mBitrate = size * 8000000ll / durationUs; // in bits/sec
- } else {
- mBitrate = -1;
- }
- mDurationUsec = durationUs;
- durationMsec = durationUs / 1000;
- } else {
- mBitrate = -1;
- mDurationUsec = ANDROID_UNKNOWN_TIME;
- durationMsec = ANDROID_UNKNOWN_TIME;
- }
-
- // then assign the duration under the settings lock
- {
- Mutex::Autolock _l(mSettingsLock);
- mDurationMsec = durationMsec;
- }
-
- // the audio content is not raw PCM, so we need a decoder
- if (!isRawAudio) {
- OMXClient client;
- CHECK_EQ(client.connect(), (status_t)OK);
-
- source = OMXCodec::Create(
- client.interface(), meta, false /* createEncoder */,
- source);
-
- if (source == NULL) {
- SL_LOGE("AudioSfDecoder::onPrepare: Could not instantiate decoder.");
- notifyPrepared(ERROR_UNSUPPORTED);
- return;
- }
-
- meta = source->getFormat();
- }
-
-
- if (source->start() != OK) {
- SL_LOGE("AudioSfDecoder::onPrepare: Failed to start source/decoder.");
- notifyPrepared(MEDIA_ERROR_BASE);
- return;
- }
-
- //---------------------------------
- // The data source, and audio source (a decoder if required) are ready to be used
- mDataSource = dataSource;
- mAudioSource = source;
- mAudioSourceStarted = true;
-
- if (!hasChannelCount) {
- CHECK(meta->findInt32(kKeyChannelCount, &channelCount));
- }
-
- if (!hasSampleRate) {
- CHECK(meta->findInt32(kKeySampleRate, &sr));
- }
- // FIXME add code below once channel mask support is in, currently initialized to default
- // value computed from the channel count
- // if (!hasChannelMask) {
- // CHECK(meta->findInt32(kKeyChannelMask, &channelMask));
- // }
-
- if (!wantPrefetch()) {
- SL_LOGV("AudioSfDecoder::onPrepare: no need to prefetch");
- // doesn't need prefetching, notify good to go
- mCacheStatus = kStatusHigh;
- mCacheFill = 1000;
- notifyStatus();
- notifyCacheFill();
- }
-
- {
- android::Mutex::Autolock autoLock(mPcmFormatLock);
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = sr;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = channelCount;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] =
- channelCountToMask(channelCount);
- }
-
- // at this point we have enough information about the source to create the sink that
- // will consume the data
- createAudioSink();
-
- // signal successful completion of prepare
- mStateFlags |= kFlagPrepared;
-
- GenericPlayer::onPrepare();
- SL_LOGD("AudioSfDecoder::onPrepare() done, mStateFlags=0x%x", mStateFlags);
-}
-
-
-void AudioSfDecoder::onPause() {
- SL_LOGV("AudioSfDecoder::onPause()");
- GenericPlayer::onPause();
- pauseAudioSink();
-}
-
-
-void AudioSfDecoder::onPlay() {
- SL_LOGV("AudioSfDecoder::onPlay()");
- GenericPlayer::onPlay();
- startAudioSink();
-}
-
-
-void AudioSfDecoder::onSeek(const sp<AMessage> &msg) {
- SL_LOGV("AudioSfDecoder::onSeek");
- int64_t timeMsec;
- CHECK(msg->findInt64(WHATPARAM_SEEK_SEEKTIME_MS, &timeMsec));
-
- Mutex::Autolock _l(mTimeLock);
- mStateFlags |= kFlagSeeking;
- mSeekTimeMsec = timeMsec;
- // don't set mLastDecodedPositionUs to ANDROID_UNKNOWN_TIME; getPositionUsec
- // ignores mLastDecodedPositionUs while seeking, and substitutes the seek goal instead
-
- // nop for now
- GenericPlayer::onSeek(msg);
-}
-
-
-void AudioSfDecoder::onLoop(const sp<AMessage> &msg) {
- SL_LOGV("AudioSfDecoder::onLoop");
- int32_t loop;
- CHECK(msg->findInt32(WHATPARAM_LOOP_LOOPING, &loop));
-
- if (loop) {
- //SL_LOGV("AudioSfDecoder::onLoop start looping");
- mStateFlags |= kFlagLooping;
- } else {
- //SL_LOGV("AudioSfDecoder::onLoop stop looping");
- mStateFlags &= ~kFlagLooping;
- }
-
- // nop for now
- GenericPlayer::onLoop(msg);
-}
-
-
-void AudioSfDecoder::onCheckCache(const sp<AMessage> &msg) {
- //SL_LOGV("AudioSfDecoder::onCheckCache");
- bool eos;
- CacheStatus_t status = getCacheRemaining(&eos);
-
- if (eos || status == kStatusHigh
- || ((mStateFlags & kFlagPreparing) && (status >= kStatusEnough))) {
- if (mStateFlags & kFlagPlaying) {
- startAudioSink();
- }
- mStateFlags &= ~kFlagBuffering;
-
- SL_LOGV("AudioSfDecoder::onCheckCache: buffering done.");
-
- if (mStateFlags & kFlagPreparing) {
- //SL_LOGV("AudioSfDecoder::onCheckCache: preparation done.");
- mStateFlags &= ~kFlagPreparing;
- }
-
- if (mStateFlags & kFlagPlaying) {
- (new AMessage(kWhatDecode, id()))->post();
- }
- return;
- }
-
- msg->post(100000);
-}
-
-
-void AudioSfDecoder::onDecode() {
- SL_LOGV("AudioSfDecoder::onDecode");
-
- //-------------------------------- Need to buffer some more before decoding?
- bool eos;
- if (mDataSource == 0) {
- // application set play state to paused which failed, then set play state to playing
- return;
- }
-
- if (wantPrefetch()
- && (getCacheRemaining(&eos) == kStatusLow)
- && !eos) {
- SL_LOGV("buffering more.");
-
- if (mStateFlags & kFlagPlaying) {
- pauseAudioSink();
- }
- mStateFlags |= kFlagBuffering;
- (new AMessage(kWhatCheckCache, id()))->post(100000);
- return;
- }
-
- if (!(mStateFlags & (kFlagPlaying | kFlagBuffering | kFlagPreparing))) {
- // don't decode if we're not buffering, prefetching or playing
- //SL_LOGV("don't decode: not buffering, prefetching or playing");
- return;
- }
-
- //-------------------------------- Decode
- status_t err;
- MediaSource::ReadOptions readOptions;
- if (mStateFlags & kFlagSeeking) {
- assert(mSeekTimeMsec != ANDROID_UNKNOWN_TIME);
- readOptions.setSeekTo(mSeekTimeMsec * 1000);
- }
-
- int64_t timeUsec = ANDROID_UNKNOWN_TIME;
- {
- Mutex::Autolock _l(mBufferSourceLock);
-
- if (NULL != mDecodeBuffer) {
- // the current decoded buffer hasn't been rendered, drop it
- mDecodeBuffer->release();
- mDecodeBuffer = NULL;
- }
- if(!mAudioSourceStarted) {
- return;
- }
- err = mAudioSource->read(&mDecodeBuffer, &readOptions);
- if (err == OK) {
- // FIXME workaround apparent bug in AAC decoder: kKeyTime is 3 frames old if length is 0
- if (mDecodeBuffer->range_length() == 0) {
- timeUsec = ANDROID_UNKNOWN_TIME;
- } else {
- CHECK(mDecodeBuffer->meta_data()->findInt64(kKeyTime, &timeUsec));
- }
- }
- }
-
- {
- Mutex::Autolock _l(mTimeLock);
- if (mStateFlags & kFlagSeeking) {
- mStateFlags &= ~kFlagSeeking;
- mSeekTimeMsec = ANDROID_UNKNOWN_TIME;
- }
- if (timeUsec != ANDROID_UNKNOWN_TIME) {
- // Note that though we've decoded this position, we haven't rendered it yet.
- // So a GetPosition called after this point will observe the advanced position,
- // even though the PCM may not have been supplied to the sink. That's OK as
- // we don't claim to provide frame-accurate (let alone sample-accurate) GetPosition.
- mLastDecodedPositionUs = timeUsec;
- }
- }
-
- //-------------------------------- Handle return of decode
- if (err != OK) {
- bool continueDecoding = false;
- switch(err) {
- case ERROR_END_OF_STREAM:
- if (0 < mDurationUsec) {
- Mutex::Autolock _l(mTimeLock);
- mLastDecodedPositionUs = mDurationUsec;
- }
- // handle notification and looping at end of stream
- if (mStateFlags & kFlagPlaying) {
- notify(PLAYEREVENT_ENDOFSTREAM, 1, true);
- }
- if (mStateFlags & kFlagLooping) {
- seek(0);
- // kick-off decoding again
- continueDecoding = true;
- }
- break;
- case INFO_FORMAT_CHANGED:
- SL_LOGD("MediaSource::read encountered INFO_FORMAT_CHANGED");
- // reconfigure output
- {
- Mutex::Autolock _l(mBufferSourceLock);
- hasNewDecodeParams();
- }
- continueDecoding = true;
- break;
- case INFO_DISCONTINUITY:
- SL_LOGD("MediaSource::read encountered INFO_DISCONTINUITY");
- continueDecoding = true;
- break;
- default:
- SL_LOGE("MediaSource::read returned error %d", err);
- break;
- }
- if (continueDecoding) {
- if (NULL == mDecodeBuffer) {
- (new AMessage(kWhatDecode, id()))->post();
- return;
- }
- } else {
- return;
- }
- }
-
- //-------------------------------- Render
- sp<AMessage> msg = new AMessage(kWhatRender, id());
- msg->post();
-
-}
-
-
-void AudioSfDecoder::onMessageReceived(const sp<AMessage> &msg) {
- switch (msg->what()) {
- case kWhatDecode:
- onDecode();
- break;
-
- case kWhatRender:
- onRender();
- break;
-
- case kWhatCheckCache:
- onCheckCache(msg);
- break;
-
- default:
- GenericPlayer::onMessageReceived(msg);
- break;
- }
-}
-
-//--------------------------------------------------
-// Prepared state, prefetch status notifications
-void AudioSfDecoder::notifyPrepared(status_t prepareRes) {
- assert(!(mStateFlags & (kFlagPrepared | kFlagPreparedUnsuccessfully)));
- if (NO_ERROR == prepareRes) {
- // The "then" fork is not currently used, but is kept here to make it easier
- // to replace by a new signalPrepareCompletion(status) if we re-visit this later.
- mStateFlags |= kFlagPrepared;
- } else {
- mStateFlags |= kFlagPreparedUnsuccessfully;
- }
- // Do not call the superclass onPrepare to notify, because it uses a default error
- // status code but we can provide a more specific one.
- // GenericPlayer::onPrepare();
- notify(PLAYEREVENT_PREPARED, (int32_t)prepareRes, true);
- SL_LOGD("AudioSfDecoder::onPrepare() done, mStateFlags=0x%x", mStateFlags);
-}
-
-
-void AudioSfDecoder::onNotify(const sp<AMessage> &msg) {
- notif_cbf_t notifyClient;
- void* notifyUser;
- {
- android::Mutex::Autolock autoLock(mNotifyClientLock);
- if (NULL == mNotifyClient) {
- return;
- } else {
- notifyClient = mNotifyClient;
- notifyUser = mNotifyUser;
- }
- }
- int32_t val;
- if (msg->findInt32(PLAYEREVENT_PREFETCHSTATUSCHANGE, &val)) {
- SL_LOGV("\tASfPlayer notifying %s = %d", PLAYEREVENT_PREFETCHSTATUSCHANGE, val);
- notifyClient(kEventPrefetchStatusChange, val, 0, notifyUser);
- }
- else if (msg->findInt32(PLAYEREVENT_PREFETCHFILLLEVELUPDATE, &val)) {
- SL_LOGV("\tASfPlayer notifying %s = %d", PLAYEREVENT_PREFETCHFILLLEVELUPDATE, val);
- notifyClient(kEventPrefetchFillLevelUpdate, val, 0, notifyUser);
- }
- else if (msg->findInt32(PLAYEREVENT_ENDOFSTREAM, &val)) {
- SL_LOGV("\tASfPlayer notifying %s = %d", PLAYEREVENT_ENDOFSTREAM, val);
- notifyClient(kEventEndOfStream, val, 0, notifyUser);
- }
- else {
- GenericPlayer::onNotify(msg);
- }
-}
-
-
-//--------------------------------------------------
-// Private utility functions
-
-bool AudioSfDecoder::wantPrefetch() {
- if (mDataSource != 0) {
- return (mDataSource->flags() & DataSource::kWantsPrefetching);
- } else {
- // happens if an improper data locator was passed, if the media extractor couldn't be
- // initialized, if there is no audio track in the media, if the OMX decoder couldn't be
- // instantiated, if the source couldn't be opened, or if the MediaSource
- // couldn't be started
- SL_LOGV("AudioSfDecoder::wantPrefetch() tries to access NULL mDataSource");
- return false;
- }
-}
-
-
-int64_t AudioSfDecoder::getPositionUsec() {
- Mutex::Autolock _l(mTimeLock);
- if (mStateFlags & kFlagSeeking) {
- return mSeekTimeMsec * 1000;
- } else {
- return mLastDecodedPositionUs;
- }
-}
-
-
-CacheStatus_t AudioSfDecoder::getCacheRemaining(bool *eos) {
- sp<NuCachedSource2> cachedSource =
- static_cast<NuCachedSource2 *>(mDataSource.get());
-
- CacheStatus_t oldStatus = mCacheStatus;
-
- status_t finalStatus;
- size_t dataRemaining = cachedSource->approxDataRemaining(&finalStatus);
- *eos = (finalStatus != OK);
-
- CHECK_GE(mBitrate, 0);
-
- int64_t dataRemainingUs = dataRemaining * 8000000ll / mBitrate;
- //SL_LOGV("AudioSfDecoder::getCacheRemaining: approx %.2f secs remaining (eos=%d)",
- // dataRemainingUs / 1E6, *eos);
-
- if (*eos) {
- // data is buffered up to the end of the stream, it can't get any better than this
- mCacheStatus = kStatusHigh;
- mCacheFill = 1000;
-
- } else {
- if (mDurationUsec > 0) {
- // known duration:
-
- // fill level is ratio of how much has been played + how much is
- // cached, divided by total duration
- uint32_t currentPositionUsec = getPositionUsec();
- if (currentPositionUsec == ANDROID_UNKNOWN_TIME) {
- // if we don't know where we are, assume the worst for the fill ratio
- currentPositionUsec = 0;
- }
- if (mDurationUsec > 0) {
- mCacheFill = (int16_t) ((1000.0
- * (double)(currentPositionUsec + dataRemainingUs) / mDurationUsec));
- } else {
- mCacheFill = 0;
- }
- //SL_LOGV("cacheFill = %d", mCacheFill);
-
- // cache status is evaluated against duration thresholds
- if (dataRemainingUs > DURATION_CACHED_HIGH_MS*1000) {
- mCacheStatus = kStatusHigh;
- //LOGV("high");
- } else if (dataRemainingUs > DURATION_CACHED_MED_MS*1000) {
- //LOGV("enough");
- mCacheStatus = kStatusEnough;
- } else if (dataRemainingUs < DURATION_CACHED_LOW_MS*1000) {
- //LOGV("low");
- mCacheStatus = kStatusLow;
- } else {
- mCacheStatus = kStatusIntermediate;
- }
-
- } else {
- // unknown duration:
-
- // cache status is evaluated against cache amount thresholds
- // (no duration so we don't have the bitrate either, could be derived from format?)
- if (dataRemaining > SIZE_CACHED_HIGH_BYTES) {
- mCacheStatus = kStatusHigh;
- } else if (dataRemaining > SIZE_CACHED_MED_BYTES) {
- mCacheStatus = kStatusEnough;
- } else if (dataRemaining < SIZE_CACHED_LOW_BYTES) {
- mCacheStatus = kStatusLow;
- } else {
- mCacheStatus = kStatusIntermediate;
- }
- }
-
- }
-
- if (oldStatus != mCacheStatus) {
- notifyStatus();
- }
-
- if (abs(mCacheFill - mLastNotifiedCacheFill) > mCacheFillNotifThreshold) {
- notifyCacheFill();
- }
-
- return mCacheStatus;
-}
-
-
-void AudioSfDecoder::hasNewDecodeParams() {
-
- if ((mAudioSource != 0) && mAudioSourceStarted) {
- sp<MetaData> meta = mAudioSource->getFormat();
-
- int32_t channelCount;
- CHECK(meta->findInt32(kKeyChannelCount, &channelCount));
- int32_t sr;
- CHECK(meta->findInt32(kKeySampleRate, &sr));
-
- // FIXME similar to onPrepare()
- {
- android::Mutex::Autolock autoLock(mPcmFormatLock);
- SL_LOGV("format changed: old sr=%d, channels=%d; new sr=%d, channels=%d",
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE],
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS],
- sr, channelCount);
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS] = channelCount;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE] = sr;
- mPcmFormatValues[ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK] =
- channelCountToMask(channelCount);
- }
- }
-
- // alert users of those params
- updateAudioSink();
-}
-
-static const char* const kPlaybackOnlyCodecs[] = { MEDIA_MIMETYPE_AUDIO_AMR_NB,
- MEDIA_MIMETYPE_AUDIO_AMR_WB };
-#define NB_PLAYBACK_ONLY_CODECS (sizeof(kPlaybackOnlyCodecs)/sizeof(kPlaybackOnlyCodecs[0]))
-
-bool AudioSfDecoder::isSupportedCodec(const char* mime) {
- bool codecRequiresPermission = false;
- for (unsigned int i = 0 ; i < NB_PLAYBACK_ONLY_CODECS ; i++) {
- if (!strcasecmp(mime, kPlaybackOnlyCodecs[i])) {
- codecRequiresPermission = true;
- break;
- }
- }
- if (codecRequiresPermission) {
- // verify only the system can decode, for playback only
- return checkCallingPermission(
- String16("android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK"));
- } else {
- return true;
- }
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/android_AudioSfDecoder.h b/wilhelm/src/android/android_AudioSfDecoder.h
deleted file mode 100644
index ae8e7f6..0000000
--- a/wilhelm/src/android/android_AudioSfDecoder.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AUDIO_SF_DECODER_H_
-#define AUDIO_SF_DECODER_H_
-
-#include <media/stagefright/DataSource.h>
-#include <media/stagefright/MediaSource.h>
-#include <media/stagefright/FileSource.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaExtractor.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/OMXClient.h>
-#include <media/stagefright/OMXCodec.h>
-#include "NuCachedSource2.h"
-#include "ThrottledSource.h"
-
-#include "android_GenericPlayer.h"
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-// keep in sync with the entries of kPcmDecodeMetadataKeys[]
-#define ANDROID_KEY_INDEX_PCMFORMAT_NUMCHANNELS 0
-#define ANDROID_KEY_INDEX_PCMFORMAT_SAMPLERATE 1
-#define ANDROID_KEY_INDEX_PCMFORMAT_BITSPERSAMPLE 2
-#define ANDROID_KEY_INDEX_PCMFORMAT_CONTAINERSIZE 3
-#define ANDROID_KEY_INDEX_PCMFORMAT_CHANNELMASK 4
-#define ANDROID_KEY_INDEX_PCMFORMAT_ENDIANNESS 5
-
-// to keep in sync with the ANDROID_KEY_INDEX_PCMFORMAT_* constants in android_AudioSfDecoder.cpp
-static const char* const kPcmDecodeMetadataKeys[] = {
- ANDROID_KEY_PCMFORMAT_NUMCHANNELS, ANDROID_KEY_PCMFORMAT_SAMPLERATE,
- ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE, ANDROID_KEY_PCMFORMAT_CONTAINERSIZE,
- ANDROID_KEY_PCMFORMAT_CHANNELMASK, ANDROID_KEY_PCMFORMAT_ENDIANNESS };
-#define NB_PCMMETADATA_KEYS (sizeof(kPcmDecodeMetadataKeys)/sizeof(kPcmDecodeMetadataKeys[0]))
-
-// abstract base class for AudioToCbRenderer and it's subclasses
-class AudioSfDecoder : public GenericPlayer
-{
-public:
-
- AudioSfDecoder(const AudioPlayback_Parameters* params);
- virtual ~AudioSfDecoder();
-
- virtual void preDestroy();
-
- // overridden from GenericPlayer
- virtual void play();
- virtual void getPositionMsec(int* msec); //msec != NULL, ANDROID_UNKNOWN_TIME if unknown
-
- uint32_t getPcmFormatKeyCount() const;
- bool getPcmFormatKeySize(uint32_t index, uint32_t* pKeySize);
- bool getPcmFormatKeyName(uint32_t index, uint32_t keySize, char* keyName);
- bool getPcmFormatValueSize(uint32_t index, uint32_t* pValueSize);
- bool getPcmFormatKeyValue(uint32_t index, uint32_t size, uint32_t* pValue);
-
-protected:
-
- enum {
- kWhatDecode = 'deco',
- kWhatRender = 'rend',
- kWhatCheckCache = 'cach'
- };
-
- // Async event handlers (called from the AudioSfDecoder's event loop)
- void onDecode();
- void onCheckCache(const sp<AMessage> &msg);
- virtual void onRender() = 0;
-
- // Async event handlers (called from GenericPlayer's event loop)
- virtual void onPrepare();
- virtual void onPlay();
- virtual void onPause();
- virtual void onSeek(const sp<AMessage> &msg);
- virtual void onLoop(const sp<AMessage> &msg);
-
- // overridden from GenericPlayer
- virtual void onNotify(const sp<AMessage> &msg);
- virtual void onMessageReceived(const sp<AMessage> &msg);
-
- // to be implemented by subclasses of AudioSfDecoder to do something with the audio samples
- // (called from GenericPlayer's event loop)
- virtual void createAudioSink() = 0;
- virtual void updateAudioSink() = 0; // called with mBufferSourceLock held
- virtual void startAudioSink() = 0;
- virtual void pauseAudioSink() = 0;
-
- sp<DataSource> mDataSource; // where the raw data comes from
- sp<MediaSource> mAudioSource;// the decoder reading from the data source
- // used to indicate mAudioSource was successfully started, but wasn't stopped
- bool mAudioSourceStarted;
-
- // negative values indicate invalid value
- int64_t mBitrate; // in bits/sec
- int64_t mDurationUsec; // ANDROID_UNKNOWN_TIME if unknown
-
- // buffer passed from decoder to renderer
- MediaBuffer *mDecodeBuffer;
-
- // mutex used to protect the decode buffer, the audio source and its running state
- Mutex mBufferSourceLock;
-
- void notifyPrepared(status_t prepareRes);
-
- int64_t mSeekTimeMsec;
- int64_t mLastDecodedPositionUs; // ANDROID_UNKNOWN_TIME if unknown
- // mutex used for seek flag, seek time (mSeekTimeMsec),
- // and last decoded position (mLastDecodedPositionUs)
- Mutex mTimeLock;
-
- // informations that can be retrieved in the PCM format queries
- // these values are only written in the event loop
- uint32_t mPcmFormatValues[NB_PCMMETADATA_KEYS];
- // protects mPcmFormatValues
- Mutex mPcmFormatLock;
-
- virtual bool advancesPositionInRealTime() const { return false; }
-
-private:
- bool wantPrefetch();
- CacheStatus_t getCacheRemaining(bool *eos);
- int64_t getPositionUsec(); // ANDROID_UNKNOWN_TIME if unknown
-
- // convenience function to update internal state when decoding parameters have changed,
- // called with a lock on mBufferSourceLock
- void hasNewDecodeParams();
-
- static bool isSupportedCodec(const char* mime);
-
-private:
- DISALLOW_EVIL_CONSTRUCTORS(AudioSfDecoder);
-
-};
-
-} // namespace android
-
-#endif // AUDIO_SF_DECODER_H_
diff --git a/wilhelm/src/android/android_AudioToCbRenderer.cpp b/wilhelm/src/android/android_AudioToCbRenderer.cpp
deleted file mode 100644
index 1cc894b..0000000
--- a/wilhelm/src/android/android_AudioToCbRenderer.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-#include "android/android_AudioToCbRenderer.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-
-namespace android {
-
-//--------------------------------------------------------------------------------------------------
-AudioToCbRenderer::AudioToCbRenderer(AudioPlayback_Parameters* params) : AudioSfDecoder(params),
- mDecodeCbf(NULL),
- mDecodeUser(NULL)
-{
- SL_LOGD("AudioToCbRenderer::AudioToCbRenderer()");
-
-}
-
-
-AudioToCbRenderer::~AudioToCbRenderer() {
- SL_LOGD("AudioToCbRenderer::~AudioToCbRenderer()");
-
-}
-
-void AudioToCbRenderer::setDataPushListener(const data_push_cbf_t pushCbf, CAudioPlayer* pushUser) {
- mDecodeCbf = pushCbf;
- mDecodeUser = pushUser;
-}
-
-//--------------------------------------------------
-// Event handlers
-
-void AudioToCbRenderer::onRender() {
- SL_LOGV("AudioToCbRenderer::onRender");
-
- Mutex::Autolock _l(mBufferSourceLock);
-
- if (NULL == mDecodeBuffer) {
- // nothing to render, move along
- //SL_LOGV("AudioToCbRenderer::onRender NULL buffer, exiting");
- return;
- }
-
- if (mStateFlags & kFlagPlaying) {
- if (NULL != mDecodeCbf) {
- size_t full = mDecodeBuffer->range_length();
- size_t consumed = 0;
- size_t offset = 0;
- while (offset < full) {
- consumed = mDecodeCbf(
- (const uint8_t *)mDecodeBuffer->data()
- + offset + mDecodeBuffer->range_offset(),
- mDecodeBuffer->range_length() - offset,
- mDecodeUser);
- offset += consumed;
- //SL_LOGV("consumed=%u, offset=%u, full=%u", consumed, offset, full);
- if (consumed == 0) {
- // decoded data is not being consumed, skip this buffer
- break;
- }
- }
- }
- (new AMessage(kWhatDecode, id()))->post();
- }
-
- mDecodeBuffer->release();
- mDecodeBuffer = NULL;
-
- updateOneShot();
-}
-
-
-//--------------------------------------------------
-// Audio output
-void AudioToCbRenderer::createAudioSink() {
- SL_LOGD("AudioToCbRenderer::createAudioSink()");
-}
-
-
-void AudioToCbRenderer::updateAudioSink() {
- SL_LOGD("AudioToCbRenderer::updateAudioSink()");
-}
-
-
-void AudioToCbRenderer::startAudioSink() {
- SL_LOGD("AudioToCbRenderer::startAudioSink()");
-}
-
-
-void AudioToCbRenderer::pauseAudioSink() {
- SL_LOGD("AudioToCbRenderer::pauseAudioSink()");
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/android_AudioToCbRenderer.h b/wilhelm/src/android/android_AudioToCbRenderer.h
deleted file mode 100644
index 3d5658d..0000000
--- a/wilhelm/src/android/android_AudioToCbRenderer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AUDIO_TO_CB_RENDERER_H_
-#define AUDIO_TO_CB_RENDERER_H_
-
-#include "android/android_AudioSfDecoder.h"
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-class AudioToCbRenderer : public AudioSfDecoder
-{
-public:
-
- AudioToCbRenderer(AudioPlayback_Parameters* params);
- virtual ~AudioToCbRenderer();
-
- void setDataPushListener(const data_push_cbf_t pushCbf, CAudioPlayer* pushUser);
-
-protected:
-
- // Async event handlers (called from GenericPlayer's event loop)
- virtual void onRender();
-
- // overridden from AudioSfDecoder
- virtual void createAudioSink();
- virtual void updateAudioSink();
- virtual void startAudioSink();
- virtual void pauseAudioSink();
-
-private:
-
- data_push_cbf_t mDecodeCbf;
- CAudioPlayer* mDecodeUser;
-
-private:
- DISALLOW_EVIL_CONSTRUCTORS(AudioToCbRenderer);
-
-};
-
-} // namespace android
-
-#endif //AUDIO_TO_CB_RENDERER_H_
diff --git a/wilhelm/src/android/android_Effect.cpp b/wilhelm/src/android/android_Effect.cpp
deleted file mode 100644
index f277f10..0000000
--- a/wilhelm/src/android/android_Effect.cpp
+++ /dev/null
@@ -1,839 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "sles_allinclusive.h"
-#include "math.h"
-#include "utils/RefBase.h"
-#include <audio_effects/effect_bassboost.h>
-#include <audio_effects/effect_equalizer.h>
-#include <audio_effects/effect_environmentalreverb.h>
-#include <audio_effects/effect_presetreverb.h>
-#include <audio_effects/effect_virtualizer.h>
-
-#include <system/audio.h>
-
-static const int EQUALIZER_PARAM_SIZE_MAX = sizeof(effect_param_t) + 2 * sizeof(int32_t)
- + EFFECT_STRING_LEN_MAX;
-
-static const int BASSBOOST_PARAM_SIZE_MAX = sizeof(effect_param_t) + 2 * sizeof(int32_t);
-
-static const int VIRTUALIZER_PARAM_SIZE_MAX = sizeof(effect_param_t) + 2 * sizeof(int32_t);
-
-static const int ENVREVERB_PARAM_SIZE_MAX_SINGLE = sizeof(effect_param_t) + 2 * sizeof(int32_t);
-
-static const int ENVREVERB_PARAM_SIZE_MAX_ALL = sizeof(effect_param_t) + sizeof(int32_t)
- + sizeof(s_reverb_settings);
-
-static const int PRESETREVERB_PARAM_SIZE_MAX = sizeof(effect_param_t) + 2 * sizeof(int32_t);
-
-static inline SLuint32 KEY_FROM_GUID(SLInterfaceID pUuid) {
- return pUuid->time_low;
-}
-
-
-//-----------------------------------------------------------------------------
-uint32_t eq_paramSize(int32_t param) {
- uint32_t size;
-
- switch (param) {
- case EQ_PARAM_NUM_BANDS:
- case EQ_PARAM_LEVEL_RANGE:
- case EQ_PARAM_CUR_PRESET:
- case EQ_PARAM_GET_NUM_OF_PRESETS:
- size = sizeof(int32_t);
- break;
- case EQ_PARAM_BAND_LEVEL:
- case EQ_PARAM_CENTER_FREQ:
- case EQ_PARAM_BAND_FREQ_RANGE:
- case EQ_PARAM_GET_BAND:
- case EQ_PARAM_GET_PRESET_NAME:
- size = 2 * sizeof(int32_t);
- break;
- default:
- size = 2 * sizeof(int32_t);
- SL_LOGE("Trying to use an unknown EQ parameter %d", param);
- break;
- }
- return size;
-}
-
-uint32_t eq_valueSize(int32_t param) {
- uint32_t size;
-
- switch (param) {
- case EQ_PARAM_NUM_BANDS:
- case EQ_PARAM_CUR_PRESET:
- case EQ_PARAM_GET_NUM_OF_PRESETS:
- case EQ_PARAM_BAND_LEVEL:
- case EQ_PARAM_GET_BAND:
- size = sizeof(int16_t);
- break;
- case EQ_PARAM_LEVEL_RANGE:
- size = 2 * sizeof(int16_t);
- break;
- case EQ_PARAM_CENTER_FREQ:
- size = sizeof(int32_t);
- break;
- case EQ_PARAM_BAND_FREQ_RANGE:
- size = 2 * sizeof(int32_t);
- break;
- case EQ_PARAM_GET_PRESET_NAME:
- size = EFFECT_STRING_LEN_MAX;
- break;
- default:
- size = sizeof(int32_t);
- SL_LOGE("Trying to access an unknown EQ parameter %d", param);
- break;
- }
- return size;
-}
-
-//-----------------------------------------------------------------------------
-/**
- * returns the size in bytes of the value of each bass boost parameter
- */
-uint32_t bb_valueSize(int32_t param) {
- uint32_t size;
-
- switch (param) {
- case BASSBOOST_PARAM_STRENGTH_SUPPORTED:
- size = sizeof(int32_t);
- break;
- case BASSBOOST_PARAM_STRENGTH:
- size = sizeof(int16_t);
- break;
- default:
- size = sizeof(int32_t);
- SL_LOGE("Trying to access an unknown BassBoost parameter %d", param);
- break;
- }
-
- return size;
-}
-
-//-----------------------------------------------------------------------------
-/**
- * returns the size in bytes of the value of each virtualizer parameter
- */
-uint32_t virt_valueSize(int32_t param) {
- uint32_t size;
-
- switch (param) {
- case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED:
- size = sizeof(int32_t);
- break;
- case VIRTUALIZER_PARAM_STRENGTH:
- size = sizeof(int16_t);
- break;
- default:
- size = sizeof(int32_t);
- SL_LOGE("Trying to access an unknown Virtualizer parameter %d", param);
- break;
- }
-
- return size;
-}
-
-//-----------------------------------------------------------------------------
-/**
- * returns the size in bytes of the value of each environmental reverb parameter
- */
-uint32_t erev_valueSize(int32_t param) {
- uint32_t size;
-
- switch (param) {
- case REVERB_PARAM_ROOM_LEVEL:
- case REVERB_PARAM_ROOM_HF_LEVEL:
- case REVERB_PARAM_REFLECTIONS_LEVEL:
- case REVERB_PARAM_REVERB_LEVEL:
- size = sizeof(int16_t); // millibel
- break;
- case REVERB_PARAM_DECAY_TIME:
- case REVERB_PARAM_REFLECTIONS_DELAY:
- case REVERB_PARAM_REVERB_DELAY:
- size = sizeof(uint32_t); // milliseconds
- break;
- case REVERB_PARAM_DECAY_HF_RATIO:
- case REVERB_PARAM_DIFFUSION:
- case REVERB_PARAM_DENSITY:
- size = sizeof(int16_t); // permille
- break;
- case REVERB_PARAM_PROPERTIES:
- size = sizeof(s_reverb_settings); // struct of all reverb properties
- break;
- default:
- size = sizeof(int32_t);
- SL_LOGE("Trying to access an unknown Environmental Reverb parameter %d", param);
- break;
- }
-
- return size;
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_eq_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, int32_t param2, void *pValue)
-{
- android::status_t status;
- uint32_t buf32[(EQUALIZER_PARAM_SIZE_MAX - 1) / sizeof(uint32_t) + 1];
- effect_param_t *p = (effect_param_t *)buf32;
-
- p->psize = eq_paramSize(param);
- *(int32_t *)p->data = param;
- if (p->psize == 2 * sizeof(int32_t)) {
- *((int32_t *)p->data + 1) = param2;
- }
- p->vsize = eq_valueSize(param);
- status = pFx->getParameter(p);
- if (android::NO_ERROR == status) {
- status = p->status;
- if (android::NO_ERROR == status) {
- memcpy(pValue, p->data + p->psize, p->vsize);
- }
- }
-
- return status;
- }
-
-
-//-----------------------------------------------------------------------------
-android::status_t android_eq_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, int32_t param2, void *pValue)
-{
- android::status_t status;
- uint32_t buf32[(EQUALIZER_PARAM_SIZE_MAX - 1) / sizeof(uint32_t) + 1];
- effect_param_t *p = (effect_param_t *)buf32;
-
- p->psize = eq_paramSize(param);
- *(int32_t *)p->data = param;
- if (p->psize == 2 * sizeof(int32_t)) {
- *((int32_t *)p->data + 1) = param2;
- }
- p->vsize = eq_valueSize(param);
- memcpy(p->data + p->psize, pValue, p->vsize);
- status = pFx->setParameter(p);
- if (android::NO_ERROR == status) {
- status = p->status;
- }
-
- return status;
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_bb_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue) {
-
- return android_fx_setParam(pFx, param, BASSBOOST_PARAM_SIZE_MAX,
- pValue, bb_valueSize(param));
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_bb_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue) {
-
- return android_fx_getParam(pFx, param, BASSBOOST_PARAM_SIZE_MAX,
- pValue, bb_valueSize(param));
-}
-
-//-----------------------------------------------------------------------------
-void android_bb_init(int sessionId, IBassBoost* ibb) {
- SL_LOGV("session %d", sessionId);
-
- if (!android_fx_initEffectObj(sessionId, ibb->mBassBoostEffect,
- &ibb->mBassBoostDescriptor.type))
- {
- SL_LOGE("BassBoost effect initialization failed");
- return;
- }
-
- // initialize strength
- int16_t strength;
- if (android::NO_ERROR == android_bb_getParam(ibb->mBassBoostEffect,
- BASSBOOST_PARAM_STRENGTH, &strength)) {
- ibb->mStrength = (SLpermille) strength;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-void android_eq_init(int sessionId, IEqualizer* ieq) {
- SL_LOGV("android_eq_init on session %d", sessionId);
-
- if (!android_fx_initEffectObj(sessionId, ieq->mEqEffect, &ieq->mEqDescriptor.type)) {
- SL_LOGE("Equalizer effect initialization failed");
- return;
- }
-
- // initialize number of bands, band level range, and number of presets
- uint16_t num = 0;
- if (android::NO_ERROR == android_eq_getParam(ieq->mEqEffect, EQ_PARAM_NUM_BANDS, 0, &num)) {
- ieq->mNumBands = num;
- }
- int16_t range[2] = {0, 0};
- if (android::NO_ERROR == android_eq_getParam(ieq->mEqEffect, EQ_PARAM_LEVEL_RANGE, 0, range)) {
- ieq->mBandLevelRangeMin = range[0];
- ieq->mBandLevelRangeMax = range[1];
- }
-
- SL_LOGV(" EQ init: num bands = %u, band range=[%d %d]mB", num, range[0], range[1]);
-
- // FIXME don't store presets names, they can be queried each time they're needed
- // initialize preset number and names, store in IEngine
- uint16_t numPresets = 0;
- if (android::NO_ERROR == android_eq_getParam(ieq->mEqEffect,
- EQ_PARAM_GET_NUM_OF_PRESETS, 0, &numPresets)) {
- ieq->mThis->mEngine->mEqNumPresets = numPresets;
- ieq->mNumPresets = numPresets;
- }
-
- object_lock_exclusive(&ieq->mThis->mEngine->mObject);
- char name[EFFECT_STRING_LEN_MAX];
- if ((0 < numPresets) && (NULL == ieq->mThis->mEngine->mEqPresetNames)) {
- ieq->mThis->mEngine->mEqPresetNames = (char **)new char *[numPresets];
- for(uint32_t i = 0 ; i < numPresets ; i++) {
- if (android::NO_ERROR == android_eq_getParam(ieq->mEqEffect,
- EQ_PARAM_GET_PRESET_NAME, i, name)) {
- ieq->mThis->mEngine->mEqPresetNames[i] = new char[strlen(name) + 1];
- strcpy(ieq->mThis->mEngine->mEqPresetNames[i], name);
- SL_LOGV(" EQ init: presets = %u is %s", i, ieq->mThis->mEngine->mEqPresetNames[i]);
- }
- }
- }
- object_unlock_exclusive(&ieq->mThis->mEngine->mObject);
-
-}
-
-
-//-----------------------------------------------------------------------------
-void android_virt_init(int sessionId, IVirtualizer* ivi) {
- SL_LOGV("android_virt_init on session %d", sessionId);
-
- if (!android_fx_initEffectObj(sessionId, ivi->mVirtualizerEffect,
- &ivi->mVirtualizerDescriptor.type)) {
- SL_LOGE("Virtualizer effect initialization failed");
- return;
- }
-
- // initialize strength
- int16_t strength;
- if (android::NO_ERROR == android_virt_getParam(ivi->mVirtualizerEffect,
- VIRTUALIZER_PARAM_STRENGTH, &strength)) {
- ivi->mStrength = (SLpermille) strength;
- }
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_virt_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue) {
-
- return android_fx_setParam(pFx, param, VIRTUALIZER_PARAM_SIZE_MAX,
- pValue, virt_valueSize(param));
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_virt_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue) {
-
- return android_fx_getParam(pFx, param, VIRTUALIZER_PARAM_SIZE_MAX,
- pValue, virt_valueSize(param));
-}
-
-
-//-----------------------------------------------------------------------------
-void android_prev_init(IPresetReverb* ipr) {
- SL_LOGV("session is implicitly %d (aux effect)", AUDIO_SESSION_OUTPUT_MIX);
-
- if (!android_fx_initEffectObj(AUDIO_SESSION_OUTPUT_MIX /*sessionId*/,
- ipr->mPresetReverbEffect, &ipr->mPresetReverbDescriptor.type)) {
- SL_LOGE("PresetReverb effect initialization failed");
- return;
- }
-
- // initialize preset
- uint16_t preset;
- if (android::NO_ERROR == android_prev_getPreset(ipr->mPresetReverbEffect, &preset)) {
- ipr->mPreset = preset;
- // enable the effect is it has a effective preset loaded
- ipr->mPresetReverbEffect->setEnabled(SL_REVERBPRESET_NONE != preset);
- }
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_prev_setPreset(android::sp<android::AudioEffect> pFx, uint16_t preset) {
- android::status_t status = android_fx_setParam(pFx, REVERB_PARAM_PRESET,
- PRESETREVERB_PARAM_SIZE_MAX, &preset, sizeof(uint16_t));
- // enable the effect if the preset is different from SL_REVERBPRESET_NONE
- pFx->setEnabled(SL_REVERBPRESET_NONE != preset);
- return status;
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_prev_getPreset(android::sp<android::AudioEffect> pFx, uint16_t* preset) {
- return android_fx_getParam(pFx, REVERB_PARAM_PRESET, PRESETREVERB_PARAM_SIZE_MAX, preset,
- sizeof(uint16_t));
-}
-
-
-//-----------------------------------------------------------------------------
-void android_erev_init(IEnvironmentalReverb* ier) {
- SL_LOGV("session is implicitly %d (aux effect)", AUDIO_SESSION_OUTPUT_MIX);
-
- if (!android_fx_initEffectObj(AUDIO_SESSION_OUTPUT_MIX /*sessionId*/,
- ier->mEnvironmentalReverbEffect, &ier->mEnvironmentalReverbDescriptor.type)) {
- SL_LOGE("EnvironmentalReverb effect initialization failed");
- return;
- }
-
- // enable env reverb: other SL ES effects have an explicit SetEnabled() function, and the
- // preset reverb state depends on the selected preset.
- ier->mEnvironmentalReverbEffect->setEnabled(true);
-
- // initialize reverb properties
- SLEnvironmentalReverbSettings properties;
- if (android::NO_ERROR == android_erev_getParam(ier->mEnvironmentalReverbEffect,
- REVERB_PARAM_PROPERTIES, &properties)) {
- ier->mProperties = properties;
- }
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_erev_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue) {
-
- // given the size difference between a single reverb property and the whole set of reverb
- // properties, select which max size to pass to avoid allocating too much memory
- if (param == REVERB_PARAM_PROPERTIES) {
- return android_fx_setParam(pFx, param, ENVREVERB_PARAM_SIZE_MAX_ALL,
- pValue, erev_valueSize(param));
- } else {
- return android_fx_setParam(pFx, param, ENVREVERB_PARAM_SIZE_MAX_SINGLE,
- pValue, erev_valueSize(param));
- }
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_erev_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue) {
-
- // given the size difference between a single reverb property and the whole set of reverb
- // properties, select which max size to pass to avoid allocating too much memory
- if (param == REVERB_PARAM_PROPERTIES) {
- return android_fx_getParam(pFx, param, ENVREVERB_PARAM_SIZE_MAX_ALL,
- pValue, erev_valueSize(param));
- } else {
- return android_fx_getParam(pFx, param, ENVREVERB_PARAM_SIZE_MAX_SINGLE,
- pValue, erev_valueSize(param));
- }
-}
-
-
-//-----------------------------------------------------------------------------
-android::status_t android_fxSend_attach(CAudioPlayer* ap, bool attach,
- android::sp<android::AudioEffect> pFx, SLmillibel sendLevel) {
-
- if (pFx == 0) {
- return android::INVALID_OPERATION;
- }
-
- // There are 3 cases:
- // mAPlayer != 0 && mAudioTrack == 0 means playing decoded audio
- // mAPlayer == 0 && mAudioTrack != 0 means playing PCM audio
- // mAPlayer == 0 && mAudioTrack == 0 means player not fully configured yet
- // The asserts document and verify this.
- if (ap->mAPlayer != 0) {
- assert(ap->mAudioTrack == 0);
- if (attach) {
- ap->mAPlayer->attachAuxEffect(pFx->id());
- ap->mAPlayer->setAuxEffectSendLevel( sles_to_android_amplification(sendLevel) );
- } else {
- ap->mAPlayer->attachAuxEffect(0);
- }
- return android::NO_ERROR;
- }
-
- if (ap->mAudioTrack == 0) {
- // the player doesn't have an AudioTrack at the moment, so store this info to use it
- // when the AudioTrack becomes available
- if (attach) {
- ap->mAuxEffect = pFx;
- } else {
- ap->mAuxEffect.clear();
- }
- // we keep track of the send level, independently of the current audio player level
- ap->mAuxSendLevel = sendLevel - ap->mVolume.mLevel;
- return android::NO_ERROR;
- }
-
- if (attach) {
- android::status_t status = ap->mAudioTrack->attachAuxEffect(pFx->id());
- //SL_LOGV("attachAuxEffect(%d) returned %d", pFx->id(), status);
- if (android::NO_ERROR == status) {
- status =
- ap->mAudioTrack->setAuxEffectSendLevel( sles_to_android_amplification(sendLevel) );
- }
- return status;
- } else {
- return ap->mAudioTrack->attachAuxEffect(0);
- }
-}
-
-//-----------------------------------------------------------------------------
-/**
- * pre-condition:
- * ap != NULL
- * ap->mOutputMix != NULL
- */
-SLresult android_fxSend_attachToAux(CAudioPlayer* ap, SLInterfaceID pUuid, SLboolean attach,
- SLmillibel sendLevel) {
- COutputMix *outputMix = CAudioPlayer_GetOutputMix(ap);
- ssize_t index = outputMix->mAndroidEffect.mEffects->indexOfKey(KEY_FROM_GUID(pUuid));
-
- if (0 > index) {
- SL_LOGE("invalid effect ID: no such effect attached to the OutputMix");
- return SL_RESULT_PARAMETER_INVALID;
- }
-
- android::AudioEffect* pFx = outputMix->mAndroidEffect.mEffects->valueAt(index);
- if (NULL == pFx) {
- return SL_RESULT_RESOURCE_ERROR;
- }
- if (android::NO_ERROR == android_fxSend_attach( ap, (bool) attach, pFx, sendLevel) ) {
- return SL_RESULT_SUCCESS;
- } else {
- return SL_RESULT_RESOURCE_ERROR;
- }
-
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_fxSend_setSendLevel(CAudioPlayer* ap, SLmillibel sendLevel) {
- // we keep track of the send level, independently of the current audio player level
- ap->mAuxSendLevel = sendLevel - ap->mVolume.mLevel;
-
- if (ap->mAPlayer != 0) {
- assert(ap->mAudioTrack == 0);
- ap->mAPlayer->setAuxEffectSendLevel( sles_to_android_amplification(sendLevel) );
- return android::NO_ERROR;
- }
-
- if (ap->mAudioTrack == 0) {
- return android::NO_ERROR;
- }
-
- return ap->mAudioTrack->setAuxEffectSendLevel( sles_to_android_amplification(sendLevel) );
-}
-
-//-----------------------------------------------------------------------------
-android::status_t android_fx_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, uint32_t paramSizeMax, void *pValue, uint32_t valueSize)
-{
-
- android::status_t status;
- uint32_t buf32[(paramSizeMax - 1) / sizeof(uint32_t) + 1];
- effect_param_t *p = (effect_param_t *)buf32;
-
- p->psize = sizeof(int32_t);
- *(int32_t *)p->data = param;
- p->vsize = valueSize;
- memcpy(p->data + p->psize, pValue, p->vsize);
- status = pFx->setParameter(p);
- if (android::NO_ERROR == status) {
- status = p->status;
- }
- return status;
-}
-
-
-//-----------------------------------------------------------------------------
-android::status_t android_fx_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, uint32_t paramSizeMax, void *pValue, uint32_t valueSize)
-{
- android::status_t status;
- uint32_t buf32[(paramSizeMax - 1) / sizeof(uint32_t) + 1];
- effect_param_t *p = (effect_param_t *)buf32;
-
- p->psize = sizeof(int32_t);
- *(int32_t *)p->data = param;
- p->vsize = valueSize;
- status = pFx->getParameter(p);
- if (android::NO_ERROR == status) {
- status = p->status;
- if (android::NO_ERROR == status) {
- memcpy(pValue, p->data + p->psize, p->vsize);
- }
- }
-
- return status;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_fx_statusToResult(android::status_t status) {
-
- if ((android::INVALID_OPERATION == status) || (android::DEAD_OBJECT == status)) {
- return SL_RESULT_CONTROL_LOST;
- } else {
- return SL_RESULT_SUCCESS;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-bool android_fx_initEffectObj(int sessionId, android::sp<android::AudioEffect>& effect,
- const effect_uuid_t *type) {
- //SL_LOGV("android_fx_initEffectObj on session %d", sessionId);
-
- effect = new android::AudioEffect(type, EFFECT_UUID_NULL,
- 0,// priority
- 0,// effect callback
- 0,// callback data
- sessionId,// session ID
- 0 );// output
-
- android::status_t status = effect->initCheck();
- if (android::NO_ERROR != status) {
- effect.clear();
- SL_LOGE("Effect initCheck() returned %d", status);
- return false;
- }
-
- return true;
-}
-
-
-//-----------------------------------------------------------------------------
-bool android_fx_initEffectDescriptor(const SLInterfaceID effectId,
- effect_descriptor_t* fxDescrLoc) {
- uint32_t numEffects = 0;
- effect_descriptor_t descriptor;
- bool foundEffect = false;
-
- // any effects?
- android::status_t res = android::AudioEffect::queryNumberEffects(&numEffects);
- if (android::NO_ERROR != res) {
- SL_LOGE("unable to find any effects.");
- goto effectError;
- }
-
- // request effect in the effects?
- for (uint32_t i=0 ; i < numEffects ; i++) {
- res = android::AudioEffect::queryEffect(i, &descriptor);
- if ((android::NO_ERROR == res) &&
- (0 == memcmp(effectId, &descriptor.type, sizeof(effect_uuid_t)))) {
- SL_LOGV("found effect %d %s", i, descriptor.name);
- foundEffect = true;
- break;
- }
- }
- if (foundEffect) {
- memcpy(fxDescrLoc, &descriptor, sizeof(effect_descriptor_t));
- } else {
- SL_LOGE("unable to find an implementation for the requested effect.");
- goto effectError;
- }
-
- return true;
-
-effectError:
- // the requested effect wasn't found
- memset(fxDescrLoc, 0, sizeof(effect_descriptor_t));
-
- return false;
-}
-
-//-----------------------------------------------------------------------------
-SLresult android_genericFx_queryNumEffects(SLuint32 *pNumSupportedAudioEffects) {
-
- if (NULL == pNumSupportedAudioEffects) {
- return SL_RESULT_PARAMETER_INVALID;
- }
-
- android::status_t status =
- android::AudioEffect::queryNumberEffects((uint32_t*)pNumSupportedAudioEffects);
-
- SLresult result = SL_RESULT_SUCCESS;
- switch(status) {
- case android::NO_ERROR:
- result = SL_RESULT_SUCCESS;
- break;
- case android::PERMISSION_DENIED:
- result = SL_RESULT_PERMISSION_DENIED;
- break;
- case android::NO_INIT:
- result = SL_RESULT_RESOURCE_ERROR;
- break;
- case android::BAD_VALUE:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- default:
- result = SL_RESULT_INTERNAL_ERROR;
- SL_LOGE("received invalid status %d from AudioEffect::queryNumberEffects()", status);
- break;
- }
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_genericFx_queryEffect(SLuint32 index, effect_descriptor_t* pDescriptor) {
-
- if (NULL == pDescriptor) {
- return SL_RESULT_PARAMETER_INVALID;
- }
-
- android::status_t status =
- android::AudioEffect::queryEffect(index, pDescriptor);
-
- SLresult result = SL_RESULT_SUCCESS;
- if (android::NO_ERROR != status) {
- switch(status) {
- case android::PERMISSION_DENIED:
- result = SL_RESULT_PERMISSION_DENIED;
- break;
- case android::NO_INIT:
- case android::INVALID_OPERATION:
- result = SL_RESULT_RESOURCE_ERROR;
- break;
- case android::BAD_VALUE:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- default:
- result = SL_RESULT_INTERNAL_ERROR;
- SL_LOGE("received invalid status %d from AudioEffect::queryNumberEffects()", status);
- break;
- }
- // an error occurred, reset the effect descriptor
- memset(pDescriptor, 0, sizeof(effect_descriptor_t));
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_genericFx_createEffect(IAndroidEffect* iae, SLInterfaceID pUuid, int sessionId) {
-
- SLresult result = SL_RESULT_SUCCESS;
-
- // does this effect already exist?
- if (0 <= iae->mEffects->indexOfKey(KEY_FROM_GUID(pUuid))) {
- return result;
- }
-
- // create new effect
- android::AudioEffect* pFx = new android::AudioEffect(
- NULL, // not using type to create effect
- (const effect_uuid_t*)pUuid,
- 0,// priority
- 0,// effect callback
- 0,// callback data
- sessionId,
- 0 );// output
-
- // verify effect was successfully created before storing it
- android::status_t status = pFx->initCheck();
- if (android::NO_ERROR != status) {
- SL_LOGE("AudioEffect initCheck() returned %d, effect will not be stored", status);
- delete pFx;
- result = SL_RESULT_RESOURCE_ERROR;
- } else {
- SL_LOGV("AudioEffect successfully created on session %d", sessionId);
- iae->mEffects->add(KEY_FROM_GUID(pUuid), pFx);
- }
-
- return result;
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_genericFx_releaseEffect(IAndroidEffect* iae, SLInterfaceID pUuid) {
-
- ssize_t index = iae->mEffects->indexOfKey(KEY_FROM_GUID(pUuid));
-
- if (0 > index) {
- return SL_RESULT_PARAMETER_INVALID;
- } else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
- delete pFx;
- iae->mEffects->removeItem(index);
- return SL_RESULT_SUCCESS;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_genericFx_setEnabled(IAndroidEffect* iae, SLInterfaceID pUuid, SLboolean enabled) {
-
- ssize_t index = iae->mEffects->indexOfKey(KEY_FROM_GUID(pUuid));
-
- if (0 > index) {
- return SL_RESULT_PARAMETER_INVALID;
- } else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
- android::status_t status = pFx->setEnabled(SL_BOOLEAN_TRUE == enabled);
- return android_fx_statusToResult(status);
- }
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_genericFx_isEnabled(IAndroidEffect* iae, SLInterfaceID pUuid, SLboolean *pEnabled)
-{
- ssize_t index = iae->mEffects->indexOfKey(KEY_FROM_GUID(pUuid));
-
- if (0 > index) {
- return SL_RESULT_PARAMETER_INVALID;
- } else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
- *pEnabled = (SLboolean) pFx->getEnabled();
- return SL_RESULT_SUCCESS;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-SLresult android_genericFx_sendCommand(IAndroidEffect* iae, SLInterfaceID pUuid,
- SLuint32 command, SLuint32 commandSize, void* pCommandData,
- SLuint32 *replySize, void *pReplyData) {
-
- ssize_t index = iae->mEffects->indexOfKey(KEY_FROM_GUID(pUuid));
-
- if (0 > index) {
- return SL_RESULT_PARAMETER_INVALID;
- } else {
- android::AudioEffect* pFx = iae->mEffects->valueAt(index);
- android::status_t status = pFx->command(
- (uint32_t) command,
- (uint32_t) commandSize,
- pCommandData,
- (uint32_t*)replySize,
- pReplyData);
- if (android::BAD_VALUE == status) {
- return SL_RESULT_PARAMETER_INVALID;
- } else {
- return SL_RESULT_SUCCESS;
- }
- }
-}
-
-//-----------------------------------------------------------------------------
-/**
- * returns true if the given effect id is present in the AndroidEffect interface
- */
-bool android_genericFx_hasEffect(IAndroidEffect* iae, SLInterfaceID pUuid) {
- return( 0 <= iae->mEffects->indexOfKey(KEY_FROM_GUID(pUuid)));
-}
diff --git a/wilhelm/src/android/android_Effect.h b/wilhelm/src/android/android_Effect.h
deleted file mode 100644
index d58c72e..0000000
--- a/wilhelm/src/android/android_Effect.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**************************************************************************************************
- * Equalizer functions
- ****************************/
-extern void android_eq_init(int sessionId, IEqualizer* ieq);
-
-extern android::status_t android_eq_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, int32_t param2, void *pValue);
-
-extern android::status_t android_eq_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, int32_t param2, void *pValue);
-
-/**************************************************************************************************
- * BassBoost functions
- ****************************/
-extern void android_bb_init(int sessionId, IBassBoost* ibb);
-
-extern android::status_t android_bb_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue);
-
-extern android::status_t android_bb_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue);
-
-/**************************************************************************************************
- * Virtualizer functions
- ****************************/
-extern void android_virt_init(int sessionId, IVirtualizer* ivi);
-
-extern android::status_t android_virt_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue);
-
-extern android::status_t android_virt_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue);
-
-/**************************************************************************************************
- * PresetReverb functions
- ****************************/
-extern void android_prev_init(IPresetReverb* ipr);
-
-extern android::status_t android_prev_setPreset(android::sp<android::AudioEffect> pFx,
- uint16_t preset);
-
-extern android::status_t android_prev_getPreset(android::sp<android::AudioEffect> pFx,
- uint16_t* preset);
-
-/**************************************************************************************************
- * EnvironmentalReverb functions
- ****************************/
-extern void android_erev_init(IEnvironmentalReverb* ier);
-
-extern android::status_t android_erev_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue);
-
-extern android::status_t android_erev_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, void *pValue);
-
-/**************************************************************************************************
- * Generic Effect functions
- ****************************/
-extern SLresult android_genericFx_queryNumEffects(SLuint32 *pNumSupportedAudioEffects);
-
-extern SLresult android_genericFx_queryEffect(SLuint32 index, effect_descriptor_t* pDescriptor);
-
-extern SLresult android_genericFx_createEffect(IAndroidEffect* iae, SLInterfaceID pUuid,
- int sessionId);
-
-extern SLresult android_genericFx_releaseEffect(IAndroidEffect* iae, SLInterfaceID pUuid);
-
-extern SLresult android_genericFx_setEnabled(IAndroidEffect* iae, SLInterfaceID pUuid,
- SLboolean enabled);
-
-extern SLresult android_genericFx_isEnabled(IAndroidEffect* iae, SLInterfaceID pUuid,
- SLboolean *pEnabled);
-
-extern SLresult android_genericFx_sendCommand(IAndroidEffect* iae, SLInterfaceID pUuid,
- SLuint32 command, SLuint32 commandSize, void* pCommandData,
- SLuint32 *replySize, void *pReplyData);
-
-extern bool android_genericFx_hasEffect(IAndroidEffect* iae, SLInterfaceID pUuid);
-
-
-/**************************************************************************************************
- * EffectSend functions
- ****************************/
-/**
- * sendLevel is the total energy going to the send bus. This implies that the volume attenuation
- * should be combined with the send level for the aux level to follow volume changes.
- */
-extern android::status_t android_fxSend_attach(CAudioPlayer* ap, bool attach,
- android::sp<android::AudioEffect> pFx, SLmillibel sendLevel);
-
-/**
- * sendLevel is the total energy going to the send bus. This implies that the volume attenuation
- * should be combined with the send level for the aux level to follow volume changes.
- */
-extern SLresult android_fxSend_attachToAux(CAudioPlayer* ap, SLInterfaceID pUuid,
- SLboolean attach, SLmillibel sendLevel);
-
-/**
- * sendLevel is the total energy going to the send bus. This implies that the volume attenuation
- * should be combined with the send level for the aux level to follow volume changes.
- */
-extern android::status_t android_fxSend_setSendLevel(CAudioPlayer* ap, SLmillibel sendLevel);
-
-/**************************************************************************************************
- * Effect-agnostic functions
- ****************************/
-extern android::status_t android_fx_setParam(android::sp<android::AudioEffect> pFx,
- int32_t param, uint32_t paramSizeMax, void *pValue, uint32_t valueSize);
-
-extern android::status_t android_fx_getParam(android::sp<android::AudioEffect> pFx,
- int32_t param, uint32_t paramSizeMax, void *pValue, uint32_t valueSize);
-
-extern SLresult android_fx_statusToResult(android::status_t status);
-
-extern bool android_fx_initEffectObj(int sessionId, android::sp<android::AudioEffect>& effect,
- const effect_uuid_t *type);
-
-extern bool android_fx_initEffectDescriptor(const SLInterfaceID effectId,
- effect_descriptor_t* fxDescrLoc);
diff --git a/wilhelm/src/android/android_GenericMediaPlayer.cpp b/wilhelm/src/android/android_GenericMediaPlayer.cpp
deleted file mode 100644
index 4abea4c..0000000
--- a/wilhelm/src/android/android_GenericMediaPlayer.cpp
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-#include "android_GenericMediaPlayer.h"
-
-#include <media/IMediaPlayerService.h>
-#include <surfaceflinger/ISurfaceComposer.h>
-#include <surfaceflinger/SurfaceComposerClient.h>
-#include <media/stagefright/foundation/ADebug.h>
-
-// default delay in Us used when reposting an event when the player is not ready to accept
-// the command yet. This is for instance used when seeking on a MediaPlayer that's still preparing
-#define DEFAULT_COMMAND_DELAY_FOR_REPOST_US (100*1000) // 100ms
-
-// table of prefixes for known distant protocols; these are immediately dispatched to mediaserver
-static const char* const kDistantProtocolPrefix[] = { "http://", "https://", "rtsp://"};
-#define NB_DISTANT_PROTOCOLS (sizeof(kDistantProtocolPrefix)/sizeof(kDistantProtocolPrefix[0]))
-
-// is the specified URI a known distant protocol?
-bool isDistantProtocol(const char *uri)
-{
- for (unsigned int i = 0; i < NB_DISTANT_PROTOCOLS; i++) {
- if (!strncasecmp(uri, kDistantProtocolPrefix[i], strlen(kDistantProtocolPrefix[i]))) {
- return true;
- }
- }
- return false;
-}
-
-namespace android {
-
-//--------------------------------------------------------------------------------------------------
-MediaPlayerNotificationClient::MediaPlayerNotificationClient(GenericMediaPlayer* gmp) :
- mGenericMediaPlayer(gmp),
- mPlayerPrepared(PREPARE_NOT_STARTED)
-{
- SL_LOGV("MediaPlayerNotificationClient::MediaPlayerNotificationClient()");
-}
-
-MediaPlayerNotificationClient::~MediaPlayerNotificationClient() {
- SL_LOGV("MediaPlayerNotificationClient::~MediaPlayerNotificationClient()");
-}
-
-// Map a MEDIA_* enum to a string
-static const char *media_to_string(int msg)
-{
- switch (msg) {
-#define _(x) case MEDIA_##x: return "MEDIA_" #x;
- _(PREPARED)
- _(SET_VIDEO_SIZE)
- _(SEEK_COMPLETE)
- _(PLAYBACK_COMPLETE)
- _(BUFFERING_UPDATE)
- _(ERROR)
- _(NOP)
- _(TIMED_TEXT)
- _(INFO)
-#undef _
- default:
- return NULL;
- }
-}
-
-//--------------------------------------------------
-// IMediaPlayerClient implementation
-void MediaPlayerNotificationClient::notify(int msg, int ext1, int ext2, const Parcel *obj) {
- SL_LOGV("MediaPlayerNotificationClient::notify(msg=%s (%d), ext1=%d, ext2=%d)",
- media_to_string(msg), msg, ext1, ext2);
-
- sp<GenericMediaPlayer> genericMediaPlayer(mGenericMediaPlayer.promote());
- if (genericMediaPlayer == NULL) {
- SL_LOGW("MediaPlayerNotificationClient::notify after GenericMediaPlayer destroyed");
- return;
- }
-
- switch (msg) {
- case MEDIA_PREPARED:
- {
- Mutex::Autolock _l(mLock);
- if (PREPARE_IN_PROGRESS == mPlayerPrepared) {
- mPlayerPrepared = PREPARE_COMPLETED_SUCCESSFULLY;
- mPlayerPreparedCondition.signal();
- } else {
- SL_LOGE("Unexpected MEDIA_PREPARED");
- }
- }
- break;
-
- case MEDIA_SET_VIDEO_SIZE:
- // only send video size updates if the player was flagged as having video, to avoid
- // sending video size updates of (0,0)
- // We're running on a different thread than genericMediaPlayer's ALooper thread,
- // so it would normally be racy to access fields within genericMediaPlayer.
- // But in this case mHasVideo is const, so it is safe to access.
- // Or alternatively, we could notify unconditionally and let it decide whether to handle.
- if (genericMediaPlayer->mHasVideo) {
- genericMediaPlayer->notify(PLAYEREVENT_VIDEO_SIZE_UPDATE,
- (int32_t)ext1, (int32_t)ext2, true /*async*/);
- }
- break;
-
- case MEDIA_SEEK_COMPLETE:
- genericMediaPlayer->seekComplete();
- break;
-
- case MEDIA_PLAYBACK_COMPLETE:
- genericMediaPlayer->notify(PLAYEREVENT_ENDOFSTREAM, 1, true /*async*/);
- break;
-
- case MEDIA_BUFFERING_UPDATE:
- // values received from Android framework for buffer fill level use percent,
- // while SL/XA use permille, so does GenericPlayer
- genericMediaPlayer->bufferingUpdate(ext1 * 10 /*fillLevelPerMille*/);
- break;
-
- case MEDIA_ERROR:
- {
- Mutex::Autolock _l(mLock);
- if (PREPARE_IN_PROGRESS == mPlayerPrepared) {
- mPlayerPrepared = PREPARE_COMPLETED_UNSUCCESSFULLY;
- mPlayerPreparedCondition.signal();
- } else {
- // inform client of errors after preparation
- genericMediaPlayer->notify(PLAYEREVENT_ERRORAFTERPREPARE, ext1, true /*async*/);
- }
- }
- break;
-
- case MEDIA_NOP:
- case MEDIA_TIMED_TEXT:
- case MEDIA_INFO:
- break;
-
- default: { }
- }
-
-}
-
-//--------------------------------------------------
-void MediaPlayerNotificationClient::beforePrepare()
-{
- Mutex::Autolock _l(mLock);
- assert(mPlayerPrepared == PREPARE_NOT_STARTED);
- mPlayerPrepared = PREPARE_IN_PROGRESS;
-}
-
-//--------------------------------------------------
-bool MediaPlayerNotificationClient::blockUntilPlayerPrepared() {
- Mutex::Autolock _l(mLock);
- assert(mPlayerPrepared != PREPARE_NOT_STARTED);
- while (mPlayerPrepared == PREPARE_IN_PROGRESS) {
- mPlayerPreparedCondition.wait(mLock);
- }
- assert(mPlayerPrepared == PREPARE_COMPLETED_SUCCESSFULLY ||
- mPlayerPrepared == PREPARE_COMPLETED_UNSUCCESSFULLY);
- return mPlayerPrepared == PREPARE_COMPLETED_SUCCESSFULLY;
-}
-
-//--------------------------------------------------------------------------------------------------
-GenericMediaPlayer::GenericMediaPlayer(const AudioPlayback_Parameters* params, bool hasVideo) :
- GenericPlayer(params),
- mHasVideo(hasVideo),
- mSeekTimeMsec(0),
- mVideoSurfaceTexture(0),
- mPlayer(0),
- mPlayerClient(new MediaPlayerNotificationClient(this)),
- mPlayerDeathNotifier(new MediaPlayerDeathNotifier(mPlayerClient))
-{
- SL_LOGD("GenericMediaPlayer::GenericMediaPlayer()");
-
-}
-
-GenericMediaPlayer::~GenericMediaPlayer() {
- SL_LOGD("GenericMediaPlayer::~GenericMediaPlayer()");
-}
-
-void GenericMediaPlayer::preDestroy() {
- // FIXME can't access mPlayer from outside the looper (no mutex!) so using mPreparedPlayer
- sp<IMediaPlayer> player;
- getPreparedPlayer(player);
- if (player != NULL) {
- player->stop();
- // causes CHECK failure in Nuplayer, but commented out in the subclass preDestroy
- // randomly causes a NPE in StagefrightPlayer, heap corruption, or app hang
- //player->setDataSource(NULL);
- player->setVideoSurfaceTexture(NULL);
- player->disconnect();
- // release all references to the IMediaPlayer
- // FIXME illegal if not on looper
- //mPlayer.clear();
- {
- Mutex::Autolock _l(mPreparedPlayerLock);
- mPreparedPlayer.clear();
- }
- }
- GenericPlayer::preDestroy();
-}
-
-//--------------------------------------------------
-// overridden from GenericPlayer
-// pre-condition:
-// msec != NULL
-// post-condition
-// *msec ==
-// ANDROID_UNKNOWN_TIME if position is unknown at time of query,
-// or the current MediaPlayer position
-void GenericMediaPlayer::getPositionMsec(int* msec) {
- SL_LOGD("GenericMediaPlayer::getPositionMsec()");
- sp<IMediaPlayer> player;
- getPreparedPlayer(player);
- // To avoid deadlock, directly call the MediaPlayer object
- if (player == 0 || player->getCurrentPosition(msec) != NO_ERROR) {
- *msec = ANDROID_UNKNOWN_TIME;
- }
-}
-
-//--------------------------------------------------
-void GenericMediaPlayer::setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) {
- SL_LOGV("GenericMediaPlayer::setVideoSurfaceTexture()");
- // FIXME bug - race condition, should do in looper
- if (mVideoSurfaceTexture.get() == surfaceTexture.get()) {
- return;
- }
- if ((mStateFlags & kFlagPrepared) && (mPlayer != 0)) {
- mPlayer->setVideoSurfaceTexture(surfaceTexture);
- }
- mVideoSurfaceTexture = surfaceTexture;
-}
-
-
-//--------------------------------------------------
-// Event handlers
-
-// blocks until mPlayer is prepared
-void GenericMediaPlayer::onPrepare() {
- SL_LOGD("GenericMediaPlayer::onPrepare()");
- // Attempt to prepare at most once, and only if there is a MediaPlayer
- if (!(mStateFlags & (kFlagPrepared | kFlagPreparedUnsuccessfully)) && (mPlayer != 0)) {
- if (mHasVideo) {
- if (mVideoSurfaceTexture != 0) {
- mPlayer->setVideoSurfaceTexture(mVideoSurfaceTexture);
- }
- }
- mPlayer->setAudioStreamType(mPlaybackParams.streamType);
- mPlayerClient->beforePrepare();
- mPlayer->prepareAsync();
- if (mPlayerClient->blockUntilPlayerPrepared()) {
- mStateFlags |= kFlagPrepared;
- afterMediaPlayerPreparedSuccessfully();
- } else {
- mStateFlags |= kFlagPreparedUnsuccessfully;
- }
- }
- GenericPlayer::onPrepare();
- SL_LOGD("GenericMediaPlayer::onPrepare() done, mStateFlags=0x%x", mStateFlags);
-}
-
-
-void GenericMediaPlayer::onPlay() {
- SL_LOGD("GenericMediaPlayer::onPlay()");
- if (((mStateFlags & (kFlagPrepared | kFlagPlaying)) == kFlagPrepared) && (mPlayer != 0)) {
- mPlayer->start();
- }
- GenericPlayer::onPlay();
-}
-
-
-void GenericMediaPlayer::onPause() {
- SL_LOGD("GenericMediaPlayer::onPause()");
- if (!(~mStateFlags & (kFlagPrepared | kFlagPlaying)) && (mPlayer != 0)) {
- mPlayer->pause();
- }
- GenericPlayer::onPause();
-}
-
-
-void GenericMediaPlayer::onSeekComplete() {
- SL_LOGV("GenericMediaPlayer::onSeekComplete()");
- // did we initiate the seek?
- if (!(mStateFlags & kFlagSeeking)) {
- // no, are we looping?
- if (mStateFlags & kFlagLooping) {
- // yes, per OpenSL ES 1.0.1 and 1.1 do NOT report it to client
- // notify(PLAYEREVENT_ENDOFSTREAM, 1, true /*async*/);
- // no, well that's surprising, but it's probably just a benign race condition
- } else {
- SL_LOGW("Unexpected seek complete event ignored");
- }
- }
- GenericPlayer::onSeekComplete();
-}
-
-
-/**
- * pre-condition: WHATPARAM_SEEK_SEEKTIME_MS parameter value >= 0
- */
-void GenericMediaPlayer::onSeek(const sp<AMessage> &msg) {
- SL_LOGV("GenericMediaPlayer::onSeek");
- int64_t timeMsec = ANDROID_UNKNOWN_TIME;
- if (!msg->findInt64(WHATPARAM_SEEK_SEEKTIME_MS, &timeMsec)) {
- // invalid command, drop it
- return;
- }
- if ((mStateFlags & kFlagSeeking) && (timeMsec == mSeekTimeMsec) &&
- (timeMsec != ANDROID_UNKNOWN_TIME)) {
- // already seeking to the same non-unknown time, cancel this command
- return;
- } else if (mStateFlags & kFlagPreparedUnsuccessfully) {
- // discard seeks after unsuccessful prepare
- } else if (!(mStateFlags & kFlagPrepared)) {
- // we are not ready to accept a seek command at this time, retry later
- msg->post(DEFAULT_COMMAND_DELAY_FOR_REPOST_US);
- } else {
- if (mPlayer != 0) {
- mStateFlags |= kFlagSeeking;
- mSeekTimeMsec = (int32_t)timeMsec;
- // seek to unknown time is used by StreamPlayer after discontinuity
- if (timeMsec == ANDROID_UNKNOWN_TIME) {
- // FIXME simulate a MEDIA_SEEK_COMPLETE event in 250 ms;
- // this is a terrible hack to make up for mediaserver not sending one
- (new AMessage(kWhatSeekComplete, id()))->post(250000);
- } else if (OK != mPlayer->seekTo(timeMsec)) {
- mStateFlags &= ~kFlagSeeking;
- mSeekTimeMsec = ANDROID_UNKNOWN_TIME;
- }
- }
- }
-}
-
-
-void GenericMediaPlayer::onLoop(const sp<AMessage> &msg) {
- SL_LOGV("GenericMediaPlayer::onLoop");
- int32_t loop = 0;
- if (msg->findInt32(WHATPARAM_LOOP_LOOPING, &loop)) {
- if (loop) {
- mStateFlags |= kFlagLooping;
- } else {
- mStateFlags &= ~kFlagLooping;
- }
- // if we have a MediaPlayer then tell it now, otherwise we'll tell it after it's created
- if (mPlayer != 0) {
- (void) mPlayer->setLooping(loop);
- }
- }
-}
-
-
-void GenericMediaPlayer::onVolumeUpdate() {
- SL_LOGD("GenericMediaPlayer::onVolumeUpdate()");
- // use settings lock to read the volume settings
- Mutex::Autolock _l(mSettingsLock);
- if (mPlayer != 0) {
- mPlayer->setVolume(mAndroidAudioLevels.mFinalVolume[0],
- mAndroidAudioLevels.mFinalVolume[1]);
- }
-}
-
-
-void GenericMediaPlayer::onAttachAuxEffect(const sp<AMessage> &msg) {
- SL_LOGD("GenericMediaPlayer::onAttachAuxEffect()");
- int32_t effectId = 0;
- if (msg->findInt32(WHATPARAM_ATTACHAUXEFFECT, &effectId)) {
- if (mPlayer != 0) {
- status_t status;
- status = mPlayer->attachAuxEffect(effectId);
- // attachAuxEffect returns a status but we have no way to report it back to app
- (void) status;
- }
- }
-}
-
-
-void GenericMediaPlayer::onSetAuxEffectSendLevel(const sp<AMessage> &msg) {
- SL_LOGD("GenericMediaPlayer::onSetAuxEffectSendLevel()");
- float level = 0.0f;
- if (msg->findFloat(WHATPARAM_SETAUXEFFECTSENDLEVEL, &level)) {
- if (mPlayer != 0) {
- status_t status;
- status = mPlayer->setAuxEffectSendLevel(level);
- // setAuxEffectSendLevel returns a status but we have no way to report it back to app
- (void) status;
- }
- }
-}
-
-
-void GenericMediaPlayer::onBufferingUpdate(const sp<AMessage> &msg) {
- int32_t fillLevel = 0;
- if (msg->findInt32(WHATPARAM_BUFFERING_UPDATE, &fillLevel)) {
- SL_LOGD("GenericMediaPlayer::onBufferingUpdate(fillLevel=%d)", fillLevel);
-
- Mutex::Autolock _l(mSettingsLock);
- mCacheFill = fillLevel;
- // handle cache fill update
- if (mCacheFill - mLastNotifiedCacheFill >= mCacheFillNotifThreshold) {
- notifyCacheFill();
- }
- // handle prefetch status update
- // compute how much time ahead of position is buffered
- int durationMsec, positionMsec = -1;
- if ((mStateFlags & kFlagPrepared) && (mPlayer != 0)
- && (OK == mPlayer->getDuration(&durationMsec))
- && (OK == mPlayer->getCurrentPosition(&positionMsec))) {
- if ((-1 != durationMsec) && (-1 != positionMsec)) {
- // evaluate prefetch status based on buffer time thresholds
- int64_t bufferedDurationMsec = (durationMsec * fillLevel / 100) - positionMsec;
- CacheStatus_t newCacheStatus = mCacheStatus;
- if (bufferedDurationMsec > DURATION_CACHED_HIGH_MS) {
- newCacheStatus = kStatusHigh;
- } else if (bufferedDurationMsec > DURATION_CACHED_MED_MS) {
- newCacheStatus = kStatusEnough;
- } else if (bufferedDurationMsec > DURATION_CACHED_LOW_MS) {
- newCacheStatus = kStatusIntermediate;
- } else if (bufferedDurationMsec == 0) {
- newCacheStatus = kStatusEmpty;
- } else {
- newCacheStatus = kStatusLow;
- }
-
- if (newCacheStatus != mCacheStatus) {
- mCacheStatus = newCacheStatus;
- notifyStatus();
- }
- }
- }
- } else {
- SL_LOGV("GenericMediaPlayer::onBufferingUpdate(fillLevel=unknown)");
- }
-}
-
-
-//--------------------------------------------------
-/**
- * called from GenericMediaPlayer::onPrepare after the MediaPlayer mPlayer is prepared successfully
- * pre-conditions:
- * mPlayer != 0
- * mPlayer is prepared successfully
- */
-void GenericMediaPlayer::afterMediaPlayerPreparedSuccessfully() {
- SL_LOGV("GenericMediaPlayer::afterMediaPlayerPrepared()");
- assert(mPlayer != 0);
- assert(mStateFlags & kFlagPrepared);
- // Mark this player as prepared successfully, so safe to directly call getCurrentPosition
- {
- Mutex::Autolock _l(mPreparedPlayerLock);
- assert(mPreparedPlayer == 0);
- mPreparedPlayer = mPlayer;
- }
- // retrieve channel count
- int32_t channelCount;
- Parcel *reply = new Parcel();
- status_t status = mPlayer->getParameter(KEY_PARAMETER_AUDIO_CHANNEL_COUNT, reply);
- if (status == NO_ERROR) {
- channelCount = reply->readInt32();
- } else {
- // FIXME MPEG-2 TS doesn't yet implement this key, so default to stereo
- channelCount = 2;
- }
- if (UNKNOWN_NUMCHANNELS != channelCount) {
- // now that we know the channel count, re-calculate the volumes
- notify(PLAYEREVENT_CHANNEL_COUNT, channelCount, true /*async*/);
- } else {
- LOGW("channel count is still unknown after prepare");
- }
- delete reply;
- // retrieve duration
- {
- int msec = 0;
- if (OK == mPlayer->getDuration(&msec)) {
- Mutex::Autolock _l(mSettingsLock);
- mDurationMsec = msec;
- }
- }
- // now that we have a MediaPlayer, set the looping flag
- if (mStateFlags & kFlagLooping) {
- (void) mPlayer->setLooping(1);
- }
- // when the MediaPlayer mPlayer is prepared, there is "sufficient data" in the playback buffers
- // if the data source was local, and the buffers are considered full so we need to notify that
- bool isLocalSource = true;
- if (kDataLocatorUri == mDataLocatorType) {
- isLocalSource = !isDistantProtocol(mDataLocator.uriRef);
- }
- if (isLocalSource) {
- SL_LOGD("media player prepared on local source");
- {
- Mutex::Autolock _l(mSettingsLock);
- mCacheStatus = kStatusHigh;
- mCacheFill = 1000;
- notifyStatus();
- notifyCacheFill();
- }
- } else {
- SL_LOGD("media player prepared on non-local source");
- }
-}
-
-
-//--------------------------------------------------
-// If player is prepared successfully, set output parameter to that reference, otherwise NULL
-void GenericMediaPlayer::getPreparedPlayer(sp<IMediaPlayer> &preparedPlayer)
-{
- Mutex::Autolock _l(mPreparedPlayerLock);
- preparedPlayer = mPreparedPlayer;
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/android_GenericMediaPlayer.h b/wilhelm/src/android/android_GenericMediaPlayer.h
deleted file mode 100644
index 3e8fe81..0000000
--- a/wilhelm/src/android/android_GenericMediaPlayer.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __ANDROID_GENERICMEDIAPLAYER_H__
-#define __ANDROID_GENERICMEDIAPLAYER_H__
-
-#include "android_GenericPlayer.h"
-
-#include <binder/IServiceManager.h>
-#include <surfaceflinger/Surface.h>
-#include <gui/ISurfaceTexture.h>
-
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-class GenericMediaPlayer;
-class MediaPlayerNotificationClient : public BnMediaPlayerClient
-{
-public:
- MediaPlayerNotificationClient(GenericMediaPlayer* gmp);
-
- // IMediaPlayerClient implementation
- virtual void notify(int msg, int ext1, int ext2, const Parcel *obj);
-
- // Call before enqueuing a prepare event
- void beforePrepare();
-
- // Call after enqueueing the prepare event; returns true if the prepare
- // completed successfully, or false if it completed unsuccessfully
- bool blockUntilPlayerPrepared();
-
-protected:
- virtual ~MediaPlayerNotificationClient();
-
-private:
- const wp<GenericMediaPlayer> mGenericMediaPlayer;
- Mutex mLock; // protects mPlayerPrepared
- Condition mPlayerPreparedCondition; // signalled when mPlayerPrepared is changed
- enum {
- PREPARE_NOT_STARTED,
- PREPARE_IN_PROGRESS,
- PREPARE_COMPLETED_SUCCESSFULLY,
- PREPARE_COMPLETED_UNSUCCESSFULLY
- } mPlayerPrepared;
-};
-
-
-class MediaPlayerDeathNotifier : public IMediaDeathNotifier {
-public:
- MediaPlayerDeathNotifier(const sp<MediaPlayerNotificationClient> playerClient) :
- mPlayerClient(playerClient) {
- }
-
- void died() {
- mPlayerClient->notify(MEDIA_ERROR, MEDIA_ERROR_SERVER_DIED, 0, NULL);
- }
-
-protected:
- virtual ~MediaPlayerDeathNotifier() { }
-
-private:
- const sp<MediaPlayerNotificationClient> mPlayerClient;
-};
-
-
-//--------------------------------------------------------------------------------------------------
-class GenericMediaPlayer : public GenericPlayer
-{
-public:
-
- GenericMediaPlayer(const AudioPlayback_Parameters* params, bool hasVideo);
- virtual ~GenericMediaPlayer();
-
- virtual void preDestroy();
-
- // overridden from GenericPlayer
- virtual void getPositionMsec(int* msec); // ANDROID_UNKNOWN_TIME if unknown
-
- virtual void setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture);
-
-protected:
- friend class MediaPlayerNotificationClient;
-
- // Async event handlers (called from GenericPlayer's event loop)
- virtual void onPrepare();
- virtual void onPlay();
- virtual void onPause();
- virtual void onSeek(const sp<AMessage> &msg);
- virtual void onLoop(const sp<AMessage> &msg);
- virtual void onSeekComplete();
- virtual void onVolumeUpdate();
- virtual void onBufferingUpdate(const sp<AMessage> &msg);
- virtual void onAttachAuxEffect(const sp<AMessage> &msg);
- virtual void onSetAuxEffectSendLevel(const sp<AMessage> &msg);
-
- const bool mHasVideo; // const allows MediaPlayerNotificationClient::notify to safely access
- int32_t mSeekTimeMsec;
-
- sp<ISurfaceTexture> mVideoSurfaceTexture;
-
- // only safe to access from within Realize and looper
- sp<IMediaPlayer> mPlayer;
- // Receives Android MediaPlayer events from mPlayer
- const sp<MediaPlayerNotificationClient> mPlayerClient;
-
- // Receives notifications about death of media.player service
- const sp<MediaPlayerDeathNotifier> mPlayerDeathNotifier;
-
- // Return a reference to the media player service, or LOGE and return NULL after retries fail
- static const sp<IMediaPlayerService> getMediaPlayerService() {
- return IMediaDeathNotifier::getMediaPlayerService();
- }
-
-private:
- DISALLOW_EVIL_CONSTRUCTORS(GenericMediaPlayer);
- void afterMediaPlayerPreparedSuccessfully();
-
-protected: // FIXME temporary
- Mutex mPreparedPlayerLock; // protects mPreparedPlayer
- sp<IMediaPlayer> mPreparedPlayer; // non-NULL if MediaPlayer exists and prepared, write once
-private:
- void getPreparedPlayer(sp<IMediaPlayer> &preparedPlayer); // safely read mPreparedPlayer
-
-};
-
-} // namespace android
-
-// is the specified URI a known distant protocol?
-bool isDistantProtocol(const char *uri);
-
-#endif /* __ANDROID_GENERICMEDIAPLAYER_H__ */
diff --git a/wilhelm/src/android/android_GenericPlayer.cpp b/wilhelm/src/android/android_GenericPlayer.cpp
deleted file mode 100644
index 85a8b1a..0000000
--- a/wilhelm/src/android/android_GenericPlayer.cpp
+++ /dev/null
@@ -1,690 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <sys/stat.h>
-
-namespace android {
-
-//--------------------------------------------------------------------------------------------------
-GenericPlayer::GenericPlayer(const AudioPlayback_Parameters* params) :
- mDataLocatorType(kDataLocatorNone),
- mNotifyClient(NULL),
- mNotifyUser(NULL),
- mStateFlags(0),
- mPlaybackParams(*params),
- mDurationMsec(ANDROID_UNKNOWN_TIME),
- mCacheStatus(kStatusEmpty),
- mCacheFill(0),
- mLastNotifiedCacheFill(0),
- mCacheFillNotifThreshold(100),
- mEventFlags(0),
- mMarkerPositionMs(ANDROID_UNKNOWN_TIME),
- mPositionUpdatePeriodMs(1000), // per spec
- mOneShotGeneration(0),
- mDeliveredNewPosMs(ANDROID_UNKNOWN_TIME),
- mObservedPositionMs(ANDROID_UNKNOWN_TIME)
-{
- SL_LOGD("GenericPlayer::GenericPlayer()");
-
- mLooper = new android::ALooper();
-
- mAndroidAudioLevels.mFinalVolume[0] = 1.0f;
- mAndroidAudioLevels.mFinalVolume[1] = 1.0f;
-}
-
-
-GenericPlayer::~GenericPlayer() {
- SL_LOGV("GenericPlayer::~GenericPlayer()");
-
- resetDataLocator();
-}
-
-
-void GenericPlayer::init(const notif_cbf_t cbf, void* notifUser) {
- SL_LOGD("GenericPlayer::init()");
-
- {
- android::Mutex::Autolock autoLock(mNotifyClientLock);
- mNotifyClient = cbf;
- mNotifyUser = notifUser;
- }
-
- mLooper->registerHandler(this);
- mLooper->start(false /*runOnCallingThread*/, false /*canCallJava*/, PRIORITY_DEFAULT);
-}
-
-
-void GenericPlayer::preDestroy() {
- SL_LOGD("GenericPlayer::preDestroy()");
- {
- android::Mutex::Autolock autoLock(mNotifyClientLock);
- mNotifyClient = NULL;
- mNotifyUser = NULL;
- }
-
- mLooper->stop();
- mLooper->unregisterHandler(id());
-}
-
-
-void GenericPlayer::setDataSource(const char *uri) {
- SL_LOGV("GenericPlayer::setDataSource(uri=%s)", uri);
- resetDataLocator();
-
- mDataLocator.uriRef = uri;
-
- mDataLocatorType = kDataLocatorUri;
-}
-
-
-void GenericPlayer::setDataSource(int fd, int64_t offset, int64_t length, bool closeAfterUse) {
- SL_LOGV("GenericPlayer::setDataSource(fd=%d, offset=%lld, length=%lld, closeAfterUse=%s)", fd,
- offset, length, closeAfterUse ? "true" : "false");
- resetDataLocator();
-
- mDataLocator.fdi.fd = fd;
-
- struct stat sb;
- int ret = fstat(fd, &sb);
- if (ret != 0) {
- SL_LOGE("GenericPlayer::setDataSource: fstat(%d) failed: %d, %s", fd, ret, strerror(errno));
- return;
- }
-
- if (offset >= sb.st_size) {
- SL_LOGE("SfPlayer::setDataSource: invalid offset");
- return;
- }
- mDataLocator.fdi.offset = offset;
-
- if (PLAYER_FD_FIND_FILE_SIZE == length) {
- mDataLocator.fdi.length = sb.st_size;
- } else if (offset + length > sb.st_size) {
- mDataLocator.fdi.length = sb.st_size - offset;
- } else {
- mDataLocator.fdi.length = length;
- }
-
- mDataLocator.fdi.mCloseAfterUse = closeAfterUse;
-
- mDataLocatorType = kDataLocatorFd;
-}
-
-
-void GenericPlayer::prepare() {
- SL_LOGD("GenericPlayer::prepare()");
- // do not attempt prepare more than once
- if (!(mStateFlags & (kFlagPrepared | kFlagPreparedUnsuccessfully))) {
- sp<AMessage> msg = new AMessage(kWhatPrepare, id());
- msg->post();
- }
-}
-
-
-void GenericPlayer::play() {
- SL_LOGD("GenericPlayer::play()");
- sp<AMessage> msg = new AMessage(kWhatPlay, id());
- msg->post();
-}
-
-
-void GenericPlayer::pause() {
- SL_LOGD("GenericPlayer::pause()");
- sp<AMessage> msg = new AMessage(kWhatPause, id());
- msg->post();
-}
-
-
-void GenericPlayer::stop() {
- SL_LOGD("GenericPlayer::stop()");
- (new AMessage(kWhatPause, id()))->post();
-
- // after a stop, playback should resume from the start.
- seek(0);
-}
-
-
-void GenericPlayer::seek(int64_t timeMsec) {
- SL_LOGV("GenericPlayer::seek %lld", timeMsec);
- if (timeMsec < 0 && timeMsec != ANDROID_UNKNOWN_TIME) {
- SL_LOGE("GenericPlayer::seek error, can't seek to negative time %lldms", timeMsec);
- return;
- }
- sp<AMessage> msg = new AMessage(kWhatSeek, id());
- msg->setInt64(WHATPARAM_SEEK_SEEKTIME_MS, timeMsec);
- msg->post();
-}
-
-
-void GenericPlayer::loop(bool loop) {
- SL_LOGV("GenericPlayer::loop %s", loop ? "true" : "false");
- sp<AMessage> msg = new AMessage(kWhatLoop, id());
- msg->setInt32(WHATPARAM_LOOP_LOOPING, (int32_t)loop);
- msg->post();
-}
-
-
-void GenericPlayer::setBufferingUpdateThreshold(int16_t thresholdPercent) {
- SL_LOGV("GenericPlayer::setBufferingUpdateThreshold %d", thresholdPercent);
- sp<AMessage> msg = new AMessage(kWhatBuffUpdateThres, id());
- msg->setInt32(WHATPARAM_BUFFERING_UPDATETHRESHOLD_PERCENT, (int32_t)thresholdPercent);
- msg->post();
-}
-
-
-//--------------------------------------------------
-void GenericPlayer::getDurationMsec(int* msec) {
- Mutex::Autolock _l(mSettingsLock);
- *msec = mDurationMsec;
-}
-
-//--------------------------------------------------
-void GenericPlayer::setVolume(float leftVol, float rightVol)
-{
- {
- Mutex::Autolock _l(mSettingsLock);
- mAndroidAudioLevels.mFinalVolume[0] = leftVol;
- mAndroidAudioLevels.mFinalVolume[1] = rightVol;
- }
- // send a message for the volume to be updated by the object which implements the volume
- (new AMessage(kWhatVolumeUpdate, id()))->post();
-}
-
-
-//--------------------------------------------------
-void GenericPlayer::attachAuxEffect(int32_t effectId)
-{
- SL_LOGV("GenericPlayer::attachAuxEffect(id=%d)", effectId);
- sp<AMessage> msg = new AMessage(kWhatAttachAuxEffect, id());
- msg->setInt32(WHATPARAM_ATTACHAUXEFFECT, effectId);
- msg->post();
-}
-
-
-//--------------------------------------------------
-void GenericPlayer::setAuxEffectSendLevel(float level)
-{
- SL_LOGV("GenericPlayer::setAuxEffectSendLevel(level=%g)", level);
- sp<AMessage> msg = new AMessage(kWhatSetAuxEffectSendLevel, id());
- msg->setFloat(WHATPARAM_SETAUXEFFECTSENDLEVEL, level);
- msg->post();
-}
-
-
-//--------------------------------------------------
-// Call after changing any of the IPlay settings related to SL_PLAYEVENT_*
-void GenericPlayer::setPlayEvents(int32_t eventFlags, int32_t markerPositionMs,
- int32_t positionUpdatePeriodMs)
-{
- // Normalize ms that are within the valid unsigned range, but not in the int32_t range
- if (markerPositionMs < 0) {
- markerPositionMs = ANDROID_UNKNOWN_TIME;
- }
- if (positionUpdatePeriodMs < 0) {
- positionUpdatePeriodMs = ANDROID_UNKNOWN_TIME;
- }
- // markers are delivered accurately, but new position updates are limited to every 100 ms
- if (positionUpdatePeriodMs < 100) {
- positionUpdatePeriodMs = 100;
- }
- sp<AMessage> msg = new AMessage(kWhatSetPlayEvents, id());
- msg->setInt32(WHATPARAM_SETPLAYEVENTS_FLAGS, eventFlags);
- msg->setInt32(WHATPARAM_SETPLAYEVENTS_MARKER, markerPositionMs);
- msg->setInt32(WHATPARAM_SETPLAYEVENTS_UPDATE, positionUpdatePeriodMs);
- msg->post();
-}
-
-
-//--------------------------------------------------
-/*
- * post-condition: mDataLocatorType == kDataLocatorNone
- *
- */
-void GenericPlayer::resetDataLocator() {
- SL_LOGV("GenericPlayer::resetDataLocator()");
- if (mDataLocatorType == kDataLocatorFd && mDataLocator.fdi.mCloseAfterUse) {
- (void) ::close(mDataLocator.fdi.fd);
- // would be redundant, as we're about to invalidate the union mDataLocator
- //mDataLocator.fdi.fd = -1;
- //mDataLocator.fdi.mCloseAfterUse = false;
- }
- mDataLocatorType = kDataLocatorNone;
-}
-
-
-void GenericPlayer::notify(const char* event, int data, bool async) {
- SL_LOGV("GenericPlayer::notify(event=%s, data=%d, async=%s)", event, data,
- async ? "true" : "false");
- sp<AMessage> msg = new AMessage(kWhatNotif, id());
- msg->setInt32(event, (int32_t)data);
- if (async) {
- msg->post();
- } else {
- this->onNotify(msg);
- }
-}
-
-
-void GenericPlayer::notify(const char* event, int data1, int data2, bool async) {
- SL_LOGV("GenericPlayer::notify(event=%s, data1=%d, data2=%d, async=%s)", event, data1, data2,
- async ? "true" : "false");
- sp<AMessage> msg = new AMessage(kWhatNotif, id());
- msg->setRect(event, 0, 0, (int32_t)data1, (int32_t)data2);
- if (async) {
- msg->post();
- } else {
- this->onNotify(msg);
- }
-}
-
-
-//--------------------------------------------------
-// AHandler implementation
-void GenericPlayer::onMessageReceived(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onMessageReceived()");
- switch (msg->what()) {
- case kWhatPrepare:
- SL_LOGV("kWhatPrepare");
- onPrepare();
- break;
-
- case kWhatNotif:
- SL_LOGV("kWhatNotif");
- onNotify(msg);
- break;
-
- case kWhatPlay:
- SL_LOGV("kWhatPlay");
- onPlay();
- break;
-
- case kWhatPause:
- SL_LOGV("kWhatPause");
- onPause();
- break;
-
- case kWhatSeek:
- SL_LOGV("kWhatSeek");
- onSeek(msg);
- break;
-
- case kWhatLoop:
- SL_LOGV("kWhatLoop");
- onLoop(msg);
- break;
-
- case kWhatVolumeUpdate:
- SL_LOGV("kWhatVolumeUpdate");
- onVolumeUpdate();
- break;
-
- case kWhatSeekComplete:
- SL_LOGV("kWhatSeekComplete");
- onSeekComplete();
- break;
-
- case kWhatBufferingUpdate:
- SL_LOGV("kWhatBufferingUpdate");
- onBufferingUpdate(msg);
- break;
-
- case kWhatBuffUpdateThres:
- SL_LOGV("kWhatBuffUpdateThres");
- onSetBufferingUpdateThreshold(msg);
- break;
-
- case kWhatAttachAuxEffect:
- SL_LOGV("kWhatAttachAuxEffect");
- onAttachAuxEffect(msg);
- break;
-
- case kWhatSetAuxEffectSendLevel:
- SL_LOGV("kWhatSetAuxEffectSendLevel");
- onSetAuxEffectSendLevel(msg);
- break;
-
- case kWhatSetPlayEvents:
- SL_LOGV("kWhatSetPlayEvents");
- onSetPlayEvents(msg);
- break;
-
- case kWhatOneShot:
- SL_LOGV("kWhatOneShot");
- onOneShot(msg);
- break;
-
- default:
- SL_LOGE("GenericPlayer::onMessageReceived unknown message %d", msg->what());
- TRESPASS();
- }
-}
-
-
-//--------------------------------------------------
-// Event handlers
-// it is strictly verboten to call those methods outside of the event loop
-
-void GenericPlayer::onPrepare() {
- SL_LOGV("GenericPlayer::onPrepare()");
- // Subclass is responsible for indicating whether prepare was successful or unsuccessful
- // by updating mStateFlags accordingly. It must set exactly one of these two flags.
- assert(!(mStateFlags & kFlagPrepared) != !(mStateFlags & kFlagPreparedUnsuccessfully));
- notify(PLAYEREVENT_PREPARED, mStateFlags & kFlagPrepared ? PLAYER_SUCCESS : PLAYER_FAILURE,
- true /*async*/);
- SL_LOGD("GenericPlayer::onPrepare() done, mStateFlags=0x%x", mStateFlags);
-}
-
-
-void GenericPlayer::onNotify(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onNotify()");
- notif_cbf_t notifClient;
- void* notifUser;
- {
- android::Mutex::Autolock autoLock(mNotifyClientLock);
- if (NULL == mNotifyClient) {
- return;
- } else {
- notifClient = mNotifyClient;
- notifUser = mNotifyUser;
- }
- }
-
- int32_t val1, val2;
- if (msg->findInt32(PLAYEREVENT_PREFETCHSTATUSCHANGE, &val1)) {
- SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_PREFETCHSTATUSCHANGE, val1);
- notifClient(kEventPrefetchStatusChange, val1, 0, notifUser);
- } else if (msg->findInt32(PLAYEREVENT_PREFETCHFILLLEVELUPDATE, &val1)) {
- SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_PREFETCHFILLLEVELUPDATE, val1);
- notifClient(kEventPrefetchFillLevelUpdate, val1, 0, notifUser);
- } else if (msg->findInt32(PLAYEREVENT_ENDOFSTREAM, &val1)) {
- SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_ENDOFSTREAM, val1);
- notifClient(kEventEndOfStream, val1, 0, notifUser);
- } else if (msg->findInt32(PLAYEREVENT_PREPARED, &val1)) {
- SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_PREPARED, val1);
- notifClient(kEventPrepared, val1, 0, notifUser);
- } else if (msg->findInt32(PLAYEREVENT_CHANNEL_COUNT, &val1)) {
- SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_CHANNEL_COUNT, val1);
- notifClient(kEventChannelCount, val1, 0, notifUser);
- } else if (msg->findRect(PLAYEREVENT_VIDEO_SIZE_UPDATE, &val1, &val2, &val1, &val2)) {
- SL_LOGV("GenericPlayer notifying %s = %d, %d", PLAYEREVENT_VIDEO_SIZE_UPDATE, val1, val2);
- notifClient(kEventHasVideoSize, val1, val2, notifUser);
- } else if (msg->findInt32(PLAYEREVENT_PLAY, &val1)) {
- SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_PLAY, val1);
- notifClient(kEventPlay, val1, 0, notifUser);
- } else if (msg->findInt32(PLAYEREVENT_ERRORAFTERPREPARE, &val1)) {
- SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_ERRORAFTERPREPARE, val1);
- notifClient(kEventErrorAfterPrepare, val1, 0, notifUser);
- } else {
- SL_LOGV("GenericPlayer notifying unknown");
- }
-}
-
-
-void GenericPlayer::onPlay() {
- SL_LOGD("GenericPlayer::onPlay()");
- if ((mStateFlags & (kFlagPrepared | kFlagPlaying)) == kFlagPrepared) {
- SL_LOGD("starting player");
- mStateFlags |= kFlagPlaying;
- updateOneShot();
- }
-}
-
-
-void GenericPlayer::onPause() {
- SL_LOGD("GenericPlayer::onPause()");
- if (!(~mStateFlags & (kFlagPrepared | kFlagPlaying))) {
- SL_LOGV("pausing player");
- mStateFlags &= ~kFlagPlaying;
- updateOneShot();
- }
-}
-
-
-void GenericPlayer::onSeek(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onSeek");
-}
-
-
-void GenericPlayer::onLoop(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onLoop");
-}
-
-
-void GenericPlayer::onVolumeUpdate() {
- SL_LOGV("GenericPlayer::onVolumeUpdate");
-}
-
-
-void GenericPlayer::onSeekComplete() {
- SL_LOGD("GenericPlayer::onSeekComplete()");
- mStateFlags &= ~kFlagSeeking;
- // avoid spurious or lost events caused by seeking past a marker
- mDeliveredNewPosMs = ANDROID_UNKNOWN_TIME;
- mObservedPositionMs = ANDROID_UNKNOWN_TIME;
- updateOneShot();
-}
-
-
-void GenericPlayer::onBufferingUpdate(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onBufferingUpdate");
-}
-
-
-void GenericPlayer::onSetBufferingUpdateThreshold(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onSetBufferingUpdateThreshold");
- int32_t thresholdPercent = 0;
- if (msg->findInt32(WHATPARAM_BUFFERING_UPDATETHRESHOLD_PERCENT, &thresholdPercent)) {
- Mutex::Autolock _l(mSettingsLock);
- mCacheFillNotifThreshold = (int16_t)thresholdPercent;
- }
-}
-
-
-void GenericPlayer::onAttachAuxEffect(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onAttachAuxEffect()");
-}
-
-
-void GenericPlayer::onSetAuxEffectSendLevel(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onSetAuxEffectSendLevel()");
-}
-
-
-void GenericPlayer::onSetPlayEvents(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onSetPlayEvents()");
- int32_t eventFlags, markerPositionMs, positionUpdatePeriodMs;
- if (msg->findInt32(WHATPARAM_SETPLAYEVENTS_FLAGS, &eventFlags) &&
- msg->findInt32(WHATPARAM_SETPLAYEVENTS_MARKER, &markerPositionMs) &&
- msg->findInt32(WHATPARAM_SETPLAYEVENTS_UPDATE, &positionUpdatePeriodMs)) {
- mEventFlags = eventFlags;
- mMarkerPositionMs = markerPositionMs;
- mPositionUpdatePeriodMs = positionUpdatePeriodMs;
- updateOneShot();
- }
-}
-
-
-void GenericPlayer::onOneShot(const sp<AMessage> &msg) {
- SL_LOGV("GenericPlayer::onOneShot()");
- int32_t generation;
- if (msg->findInt32(WHATPARAM_ONESHOT_GENERATION, &generation)) {
- if (generation != mOneShotGeneration) {
- SL_LOGV("GenericPlayer::onOneShot() generation %d cancelled; latest is %d",
- generation, mOneShotGeneration);
- return;
- }
- updateOneShot();
- }
-}
-
-
-//-------------------------------------------------
-void GenericPlayer::notifyStatus() {
- SL_LOGV("GenericPlayer::notifyStatus");
- notify(PLAYEREVENT_PREFETCHSTATUSCHANGE, (int32_t)mCacheStatus, true /*async*/);
-}
-
-
-void GenericPlayer::notifyCacheFill() {
- SL_LOGV("GenericPlayer::notifyCacheFill");
- mLastNotifiedCacheFill = mCacheFill;
- notify(PLAYEREVENT_PREFETCHFILLLEVELUPDATE, (int32_t)mLastNotifiedCacheFill, true/*async*/);
-}
-
-
-void GenericPlayer::seekComplete() {
- SL_LOGV("GenericPlayer::seekComplete");
- sp<AMessage> msg = new AMessage(kWhatSeekComplete, id());
- msg->post();
-}
-
-
-void GenericPlayer::bufferingUpdate(int16_t fillLevelPerMille) {
- SL_LOGV("GenericPlayer::bufferingUpdate");
- sp<AMessage> msg = new AMessage(kWhatBufferingUpdate, id());
- msg->setInt32(WHATPARAM_BUFFERING_UPDATE, fillLevelPerMille);
- msg->post();
-}
-
-
-// For the meaning of positionMs, see comment in declaration at android_GenericPlayer.h
-void GenericPlayer::updateOneShot(int positionMs)
-{
- SL_LOGV("GenericPlayer::updateOneShot");
-
- // nop until prepared
- if (!(mStateFlags & kFlagPrepared)) {
- return;
- }
-
- // cancel any pending one-shot(s)
- ++mOneShotGeneration;
-
- // don't restart one-shot if player is paused or stopped
- if (!(mStateFlags & kFlagPlaying)) {
- return;
- }
-
- // get current player position in milliseconds
- if (positionMs < 0) {
- positionMs = ANDROID_UNKNOWN_TIME;
- }
- if (positionMs == ANDROID_UNKNOWN_TIME) {
- getPositionMsec(&positionMs);
- // normalize it
- if (positionMs < 0) {
- positionMs = ANDROID_UNKNOWN_TIME;
- }
- if (ANDROID_UNKNOWN_TIME == positionMs) {
- // getPositionMsec is not working for some reason, give up
- //LOGV("Does anyone really know what time it is?");
- return;
- }
- }
-
- // if we observe the player position going backwards, even without without a seek, then recover
- if (mObservedPositionMs != ANDROID_UNKNOWN_TIME && positionMs < mObservedPositionMs) {
- mDeliveredNewPosMs = ANDROID_UNKNOWN_TIME;
- mObservedPositionMs = positionMs;
- }
-
- // delayUs is the expected delay between current position and marker;
- // the default is infinity in case there are no upcoming marker(s)
- int64_t delayUs = -1;
-
- // is there a marker?
- if ((mEventFlags & SL_PLAYEVENT_HEADATMARKER) && (mMarkerPositionMs != ANDROID_UNKNOWN_TIME)) {
- // check to see if we have observed the position passing through the marker
- if (mObservedPositionMs <= mMarkerPositionMs && mMarkerPositionMs <= positionMs) {
- notify(PLAYEREVENT_PLAY, (int32_t) SL_PLAYEVENT_HEADATMARKER, true /*async*/);
- } else if (positionMs < mMarkerPositionMs) {
- delayUs = (mMarkerPositionMs - positionMs) * 1000LL;
- }
- }
-
- // are periodic position updates needed?
- if ((mEventFlags & SL_PLAYEVENT_HEADATNEWPOS) &&
- (mPositionUpdatePeriodMs != ANDROID_UNKNOWN_TIME)) {
- // check to see if we have observed the position passing through a virtual marker, where the
- // virtual marker is at the previously delivered new position plus position update period
- int32_t virtualMarkerMs;
- if (mDeliveredNewPosMs != ANDROID_UNKNOWN_TIME) {
- virtualMarkerMs = mDeliveredNewPosMs + mPositionUpdatePeriodMs;
- } else if (mObservedPositionMs != ANDROID_UNKNOWN_TIME) {
- virtualMarkerMs = mObservedPositionMs + mPositionUpdatePeriodMs;
- // pretend there has been an update in the past
- mDeliveredNewPosMs = mObservedPositionMs;
- } else {
- virtualMarkerMs = positionMs + mPositionUpdatePeriodMs;
- // pretend there has been an update in the past
- mDeliveredNewPosMs = positionMs;
- }
- // nextVirtualMarkerMs will be set to the position of the next upcoming virtual marker
- int32_t nextVirtualMarkerMs;
- if (mObservedPositionMs <= virtualMarkerMs && virtualMarkerMs <= positionMs) {
- // we did pass through the virtual marker, now compute the next virtual marker
- mDeliveredNewPosMs = virtualMarkerMs;
- nextVirtualMarkerMs = virtualMarkerMs + mPositionUpdatePeriodMs;
- // re-synchronize if we missed an update
- if (nextVirtualMarkerMs <= positionMs) {
- SL_LOGW("Missed SL_PLAYEVENT_HEADATNEWPOS for position %d; current position %d",
- nextVirtualMarkerMs, positionMs);
- // try to catch up by setting next goal to current position plus update period
- mDeliveredNewPosMs = positionMs;
- nextVirtualMarkerMs = positionMs + mPositionUpdatePeriodMs;
- }
- notify(PLAYEREVENT_PLAY, (int32_t) SL_PLAYEVENT_HEADATNEWPOS, true /*async*/);
- } else {
- // we did not pass through the virtual marker yet, so use same marker again
- nextVirtualMarkerMs = virtualMarkerMs;
- }
- // note that if arithmetic overflow occurred, nextVirtualMarkerMs will be negative
- if (positionMs < nextVirtualMarkerMs) {
- int64_t trialDelayUs;
- trialDelayUs = (nextVirtualMarkerMs - positionMs) * 1000LL;
- if (trialDelayUs > 0 && (delayUs == -1 || trialDelayUs < delayUs)) {
- delayUs = trialDelayUs;
- }
- }
- }
-
- // we have a new observed position
- mObservedPositionMs = positionMs;
-
- // post the new one-shot message if needed
- if (advancesPositionInRealTime() && delayUs >= 0) {
- // 20 ms min delay to avoid near busy waiting
- if (delayUs < 20000LL) {
- delayUs = 20000LL;
- }
- // 1 minute max delay avoids indefinite memory leaks caused by cancelled one-shots
- if (delayUs > 60000000LL) {
- delayUs = 60000000LL;
- }
- //SL_LOGI("delayUs = %lld", delayUs);
- sp<AMessage> msg = new AMessage(kWhatOneShot, id());
- msg->setInt32(WHATPARAM_ONESHOT_GENERATION, mOneShotGeneration);
- msg->post(delayUs);
- }
-
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/android_GenericPlayer.h b/wilhelm/src/android/android_GenericPlayer.h
deleted file mode 100644
index cbea27c..0000000
--- a/wilhelm/src/android/android_GenericPlayer.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __ANDROID_GENERICPLAYER_H__
-#define __ANDROID_GENERICPLAYER_H__
-
-#include <media/stagefright/foundation/AHandler.h>
-#include <media/stagefright/foundation/ALooper.h>
-#include <media/stagefright/foundation/AMessage.h>
-
-//--------------------------------------------------------------------------------------------------
-/**
- * Message parameters for AHandler messages, see list in GenericPlayer::kWhatxxx
- */
-#define WHATPARAM_SEEK_SEEKTIME_MS "seekTimeMs"
-#define WHATPARAM_LOOP_LOOPING "looping"
-#define WHATPARAM_BUFFERING_UPDATE "bufferingUpdate"
-#define WHATPARAM_BUFFERING_UPDATETHRESHOLD_PERCENT "buffUpdateThreshold"
-#define WHATPARAM_ATTACHAUXEFFECT "attachAuxEffect"
-#define WHATPARAM_SETAUXEFFECTSENDLEVEL "setAuxEffectSendLevel"
-// Parameters for kWhatSetPlayEvents
-#define WHATPARAM_SETPLAYEVENTS_FLAGS "setPlayEventsFlags"
-#define WHATPARAM_SETPLAYEVENTS_MARKER "setPlayEventsMarker"
-#define WHATPARAM_SETPLAYEVENTS_UPDATE "setPlayEventsUpdate"
-// Parameters for kWhatOneShot (see explanation at definition of kWhatOneShot below)
-#define WHATPARAM_ONESHOT_GENERATION "oneShotGeneration"
-
-namespace android {
-
-class GenericPlayer : public AHandler
-{
-public:
-
- enum {
- kEventPrepared = 'prep',
- kEventHasVideoSize = 'vsiz',
- kEventPrefetchStatusChange = 'pfsc',
- kEventPrefetchFillLevelUpdate = 'pflu',
- kEventEndOfStream = 'eos',
- kEventChannelCount = 'ccnt',
- kEventPlay = 'play', // SL_PLAYEVENT_*
- kEventErrorAfterPrepare = 'easp', // error after successful prepare
- };
-
-
- GenericPlayer(const AudioPlayback_Parameters* params);
- virtual ~GenericPlayer();
-
- virtual void init(const notif_cbf_t cbf, void* notifUser);
- virtual void preDestroy();
-
- void setDataSource(const char *uri);
- void setDataSource(int fd, int64_t offset, int64_t length, bool closeAfterUse = false);
-
- void prepare();
- virtual void play();
- virtual void pause();
- virtual void stop();
- // timeMsec must be >= 0 or == ANDROID_UNKNOWN_TIME (used by StreamPlayer after discontinuity)
- virtual void seek(int64_t timeMsec);
- virtual void loop(bool loop);
- virtual void setBufferingUpdateThreshold(int16_t thresholdPercent);
-
- virtual void getDurationMsec(int* msec); //msec != NULL, ANDROID_UNKNOWN_TIME if unknown
- virtual void getPositionMsec(int* msec) = 0; //msec != NULL, ANDROID_UNKNOWN_TIME if unknown
-
- virtual void setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) {}
-
- void setVolume(float leftVol, float rightVol);
- void attachAuxEffect(int32_t effectId);
- void setAuxEffectSendLevel(float level);
-
- // Call after changing any of the IPlay settings related to SL_PLAYEVENT_*
- void setPlayEvents(int32_t eventFlags, int32_t markerPosition, int32_t positionUpdatePeriod);
-
-protected:
- // mutex used for set vs use of volume, duration, and cache (fill, threshold) settings
- Mutex mSettingsLock;
-
- void resetDataLocator();
- DataLocator2 mDataLocator;
- int mDataLocatorType;
-
- // Constants used to identify the messages in this player's AHandler message loop
- // in onMessageReceived()
- enum {
- kWhatPrepare = 'prep',
- kWhatNotif = 'noti',
- kWhatPlay = 'play',
- kWhatPause = 'paus',
- kWhatSeek = 'seek',
- kWhatSeekComplete = 'skcp',
- kWhatLoop = 'loop',
- kWhatVolumeUpdate = 'volu',
- kWhatBufferingUpdate = 'bufu',
- kWhatBuffUpdateThres = 'buut',
- kWhatAttachAuxEffect = 'aaux',
- kWhatSetAuxEffectSendLevel = 'saux',
- kWhatSetPlayEvents = 'spev', // process new IPlay settings related to SL_PLAYEVENT_*
- kWhatOneShot = 'ones', // deferred (non-0 timeout) handler for SL_PLAYEVENT_*
- // As used here, "one-shot" is the software equivalent of a "retriggerable monostable
- // multivibrator" from electronics. Briefly, a one-shot is a timer that can be triggered
- // to fire at some point in the future. It is "retriggerable" because while the timer
- // is active, it is possible to replace the current timeout value by a new value.
- // This is done by cancelling the current timer (using a generation count),
- // and then posting another timer with the new desired value.
- };
-
- // Send a notification to one of the event listeners
- virtual void notify(const char* event, int data1, bool async);
- virtual void notify(const char* event, int data1, int data2, bool async);
-
- // AHandler implementation
- virtual void onMessageReceived(const sp<AMessage> &msg);
-
- // Async event handlers (called from GenericPlayer's event loop)
- virtual void onPrepare();
- virtual void onNotify(const sp<AMessage> &msg);
- virtual void onPlay();
- virtual void onPause();
- virtual void onSeek(const sp<AMessage> &msg);
- virtual void onLoop(const sp<AMessage> &msg);
- virtual void onVolumeUpdate();
- virtual void onSeekComplete();
- virtual void onBufferingUpdate(const sp<AMessage> &msg);
- virtual void onSetBufferingUpdateThreshold(const sp<AMessage> &msg);
- virtual void onAttachAuxEffect(const sp<AMessage> &msg);
- virtual void onSetAuxEffectSendLevel(const sp<AMessage> &msg);
- void onSetPlayEvents(const sp<AMessage> &msg);
- void onOneShot(const sp<AMessage> &msg);
-
- // Convenience methods
- // for async notifications of prefetch status and cache fill level, needs to be called
- // with mSettingsLock locked
- void notifyStatus();
- void notifyCacheFill();
- // for internal async notification to update state that the player is no longer seeking
- void seekComplete();
- void bufferingUpdate(int16_t fillLevelPerMille);
-
- // Event notification from GenericPlayer to OpenSL ES / OpenMAX AL framework
- notif_cbf_t mNotifyClient;
- void* mNotifyUser;
- // lock to protect mNotifyClient and mNotifyUser updates
- Mutex mNotifyClientLock;
-
- // Bits for mStateFlags
- enum {
- kFlagPrepared = 1 << 0, // use only for successful preparation
- kFlagPreparing = 1 << 1,
- kFlagPlaying = 1 << 2,
- kFlagBuffering = 1 << 3,
- kFlagSeeking = 1 << 4, // set if we (not Stagefright) initiated a seek
- kFlagLooping = 1 << 5, // set if looping is enabled
- kFlagPreparedUnsuccessfully = 1 << 6,
- };
-
- uint32_t mStateFlags;
-
- sp<ALooper> mLooper;
-
- AudioPlayback_Parameters mPlaybackParams;
-
- AndroidAudioLevels mAndroidAudioLevels;
-
- // protected by mSettingsLock
- int32_t mDurationMsec;
-
- CacheStatus_t mCacheStatus;
- int16_t mCacheFill; // cache fill level + played back level in permille
- int16_t mLastNotifiedCacheFill; // last cache fill level communicated to the listener
- int16_t mCacheFillNotifThreshold; // threshold in cache fill level for cache fill to be reported
-
- // Call any time any of the IPlay copies, current position, or play state changes, and
- // supply the latest known position or ANDROID_UNKNOWN_TIME if position is unknown to caller.
- void updateOneShot(int positionMs = ANDROID_UNKNOWN_TIME);
-
- virtual bool advancesPositionInRealTime() const { return true; }
-
-private:
-
- // Our copy of some important IPlay member variables, except in Android units
- int32_t mEventFlags;
- int32_t mMarkerPositionMs;
- int32_t mPositionUpdatePeriodMs;
-
- // We need to be able to cancel any pending one-shot event(s) prior to posting
- // a new one-shot. As AMessage does not currently support cancellation by
- // "what" category, we simulate this by keeping a generation counter for
- // one-shots. When a one-shot event is delivered, it checks to see if it is
- // still the current one-shot. If not, it returns immediately, thus
- // effectively cancelling itself. Note that counter wrap-around is possible
- // but unlikely and benign.
- int32_t mOneShotGeneration;
-
- // Play position at time of the most recently delivered SL_PLAYEVENT_HEADATNEWPOS,
- // or ANDROID_UNKNOWN_TIME if a SL_PLAYEVENT_HEADATNEWPOS has never been delivered.
- int32_t mDeliveredNewPosMs;
-
- // Play position most recently observed by updateOneShot, or ANDROID_UNKNOWN_TIME
- // if the play position has never been observed.
- int32_t mObservedPositionMs;
-
- DISALLOW_EVIL_CONSTRUCTORS(GenericPlayer);
-};
-
-} // namespace android
-
-extern void android_player_volumeUpdate(float *pVolumes /*[2]*/, const IVolume *volumeItf,
- unsigned channelCount, float amplFromDirectLevel, const bool *audibilityFactors /*[2]*/);
-
-#endif /* __ANDROID_GENERICPLAYER_H__ */
diff --git a/wilhelm/src/android/android_LocAVPlayer.cpp b/wilhelm/src/android/android_LocAVPlayer.cpp
deleted file mode 100644
index 3b23ae1..0000000
--- a/wilhelm/src/android/android_LocAVPlayer.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-#include <media/IMediaPlayerService.h>
-#include "android_LocAVPlayer.h"
-
-
-namespace android {
-
-//--------------------------------------------------------------------------------------------------
-LocAVPlayer::LocAVPlayer(AudioPlayback_Parameters* params, bool hasVideo) :
- GenericMediaPlayer(params, hasVideo)
-{
- SL_LOGD("LocAVPlayer::LocAVPlayer()");
-
-}
-
-
-LocAVPlayer::~LocAVPlayer() {
- SL_LOGD("LocAVPlayer::~LocAVPlayer()");
-
-}
-
-
-//--------------------------------------------------
-// Event handlers
-void LocAVPlayer::onPrepare() {
- SL_LOGD("LocAVPlayer::onPrepare()");
- sp<IMediaPlayerService> mediaPlayerService(getMediaPlayerService());
- if (mediaPlayerService != NULL) {
- switch (mDataLocatorType) {
- case kDataLocatorUri:
- mPlayer = mediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/,
- mPlaybackParams.sessionId);
- if (mPlayer == NULL) {
- SL_LOGE("media player service failed to create player by URI");
- } else if (mPlayer->setDataSource(mDataLocator.uriRef, NULL /*headers*/) != NO_ERROR) {
- SL_LOGE("setDataSource failed");
- mPlayer.clear();
- }
- break;
- case kDataLocatorFd:
- mPlayer = mediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/,
- mPlaybackParams.sessionId);
- if (mPlayer == NULL) {
- SL_LOGE("media player service failed to create player by FD");
- } else if (mPlayer->setDataSource(mDataLocator.fdi.fd, mDataLocator.fdi.offset,
- mDataLocator.fdi.length) != NO_ERROR) {
- SL_LOGE("setDataSource failed");
- mPlayer.clear();
- }
- // Binder dups the fd for use by mediaserver, so if we own the fd then OK to close now
- if (mDataLocator.fdi.mCloseAfterUse) {
- (void) ::close(mDataLocator.fdi.fd);
- mDataLocator.fdi.fd = -1;
- mDataLocator.fdi.mCloseAfterUse = false;
- }
- break;
- case kDataLocatorNone:
- SL_LOGE("no data locator for MediaPlayer object");
- break;
- default:
- SL_LOGE("unsupported data locator %d for MediaPlayer object", mDataLocatorType);
- break;
- }
- }
- if (mPlayer == NULL) {
- mStateFlags |= kFlagPreparedUnsuccessfully;
- }
- // blocks until mPlayer is prepared
- GenericMediaPlayer::onPrepare();
- SL_LOGD("LocAVPlayer::onPrepare() done");
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/android_LocAVPlayer.h b/wilhelm/src/android/android_LocAVPlayer.h
deleted file mode 100644
index 64115e0..0000000
--- a/wilhelm/src/android/android_LocAVPlayer.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "android_GenericMediaPlayer.h"
-
-namespace android {
-
-//--------------------------------------------------------------------------------------------------
-class LocAVPlayer : public GenericMediaPlayer
-{
-public:
- LocAVPlayer(AudioPlayback_Parameters* params, bool hasVideo);
- virtual ~LocAVPlayer();
-
-protected:
- // overridden from AVPlayer
- virtual void onPrepare();
-
-private:
- DISALLOW_EVIL_CONSTRUCTORS(LocAVPlayer);
-};
-
-} // namespace android
diff --git a/wilhelm/src/android/android_StreamPlayer.cpp b/wilhelm/src/android/android_StreamPlayer.cpp
deleted file mode 100644
index b87733c..0000000
--- a/wilhelm/src/android/android_StreamPlayer.cpp
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-#include "android_StreamPlayer.h"
-
-#include <media/IStreamSource.h>
-#include <media/IMediaPlayerService.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <binder/IPCThreadState.h>
-
-#include "mpeg2ts/ATSParser.h"
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-StreamSourceAppProxy::StreamSourceAppProxy(
- IAndroidBufferQueue *androidBufferQueue,
- const sp<CallbackProtector> &callbackProtector,
- // sp<StreamPlayer> would cause StreamPlayer's destructor to run during it's own
- // construction. If you pass in a sp<> to 'this' inside a constructor, then first the
- // refcount is increased from 0 to 1, then decreased from 1 to 0, which causes the object's
- // destructor to run from inside it's own constructor.
- StreamPlayer * /* const sp<StreamPlayer> & */ player) :
- mBuffersHasBeenSet(false),
- mAndroidBufferQueue(androidBufferQueue),
- mCallbackProtector(callbackProtector),
- mPlayer(player)
-{
- SL_LOGV("StreamSourceAppProxy::StreamSourceAppProxy()");
-}
-
-StreamSourceAppProxy::~StreamSourceAppProxy() {
- SL_LOGV("StreamSourceAppProxy::~StreamSourceAppProxy()");
- disconnect();
-}
-
-const SLuint32 StreamSourceAppProxy::kItemProcessed[NB_BUFFEREVENT_ITEM_FIELDS] = {
- SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT, // item key
- sizeof(SLuint32), // item size
- SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED // item data
-};
-
-//--------------------------------------------------
-// IStreamSource implementation
-void StreamSourceAppProxy::setListener(const sp<IStreamListener> &listener) {
- assert(listener != NULL);
- Mutex::Autolock _l(mLock);
- assert(mListener == NULL);
- mListener = listener;
-}
-
-void StreamSourceAppProxy::setBuffers(const Vector<sp<IMemory> > &buffers) {
- Mutex::Autolock _l(mLock);
- assert(!mBuffersHasBeenSet);
- mBuffers = buffers;
- mBuffersHasBeenSet = true;
-}
-
-void StreamSourceAppProxy::onBufferAvailable(size_t index) {
- //SL_LOGD("StreamSourceAppProxy::onBufferAvailable(%d)", index);
-
- {
- Mutex::Autolock _l(mLock);
- // assert not needed because if not set, size() will be zero and the CHECK_LT will also fail
- // assert(mBuffersHasBeenSet);
- CHECK_LT(index, mBuffers.size());
-#if 0 // enable if needed for debugging
- sp<IMemory> mem = mBuffers.itemAt(index);
- SLAint64 length = (SLAint64) mem->size();
-#endif
- mAvailableBuffers.push_back(index);
- //SL_LOGD("onBufferAvailable() now %d buffers available in queue", mAvailableBuffers.size());
- }
-
- // a new shared mem buffer is available: let's try to fill immediately
- pullFromBuffQueue();
-}
-
-void StreamSourceAppProxy::receivedCmd_l(IStreamListener::Command cmd, const sp<AMessage> &msg) {
- if (mListener != 0) {
- mListener->issueCommand(cmd, false /* synchronous */, msg);
- }
-}
-
-void StreamSourceAppProxy::receivedBuffer_l(size_t buffIndex, size_t buffLength) {
- if (mListener != 0) {
- mListener->queueBuffer(buffIndex, buffLength);
- }
-}
-
-void StreamSourceAppProxy::disconnect() {
- Mutex::Autolock _l(mLock);
- mListener.clear();
- // Force binder to push the decremented reference count for sp<IStreamListener>.
- // mediaserver and client both have sp<> to the other. When you decrement an sp<>
- // reference count, binder doesn't push that to the other process immediately.
- IPCThreadState::self()->flushCommands();
- mBuffers.clear();
- mBuffersHasBeenSet = false;
- mAvailableBuffers.clear();
-}
-
-//--------------------------------------------------
-// consumption from ABQ: pull from the ABQ, and push to shared memory (media server)
-void StreamSourceAppProxy::pullFromBuffQueue() {
-
- if (android::CallbackProtector::enterCbIfOk(mCallbackProtector)) {
-
- size_t bufferId;
- void* bufferLoc;
- size_t buffSize;
-
- slAndroidBufferQueueCallback callback = NULL;
- void* pBufferContext, *pBufferData, *callbackPContext = NULL;
- AdvancedBufferHeader *oldFront = NULL;
- uint32_t dataSize /* , dataUsed */;
-
- // retrieve data from the buffer queue
- interface_lock_exclusive(mAndroidBufferQueue);
-
- // can this read operation cause us to call the buffer queue callback
- // (either because there was a command with no data, or all the data has been consumed)
- bool queueCallbackCandidate = false;
-
- if (mAndroidBufferQueue->mState.count != 0) {
- // SL_LOGD("nbBuffers in ABQ = %u, buffSize=%u",abq->mState.count, buffSize);
- assert(mAndroidBufferQueue->mFront != mAndroidBufferQueue->mRear);
-
- oldFront = mAndroidBufferQueue->mFront;
- AdvancedBufferHeader *newFront = &oldFront[1];
-
- // consume events when starting to read data from a buffer for the first time
- if (oldFront->mDataSizeConsumed == 0) {
- // note this code assumes at most one event per buffer; see IAndroidBufferQueue_Enqueue
- if (oldFront->mItems.mTsCmdData.mTsCmdCode & ANDROID_MP2TSEVENT_EOS) {
- receivedCmd_l(IStreamListener::EOS);
- // EOS has no associated data
- queueCallbackCandidate = true;
- } else if (oldFront->mItems.mTsCmdData.mTsCmdCode & ANDROID_MP2TSEVENT_DISCONTINUITY) {
- receivedCmd_l(IStreamListener::DISCONTINUITY);
- } else if (oldFront->mItems.mTsCmdData.mTsCmdCode & ANDROID_MP2TSEVENT_DISCON_NEWPTS) {
- sp<AMessage> msg = new AMessage();
- msg->setInt64(IStreamListener::kKeyResumeAtPTS,
- (int64_t)oldFront->mItems.mTsCmdData.mPts);
- receivedCmd_l(IStreamListener::DISCONTINUITY, msg /*msg*/);
- } else if (oldFront->mItems.mTsCmdData.mTsCmdCode
- & ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL) {
- sp<AMessage> msg = new AMessage();
- msg->setInt32(
- IStreamListener::kKeyDiscontinuityMask,
- ATSParser::DISCONTINUITY_FORMATCHANGE);
- receivedCmd_l(IStreamListener::DISCONTINUITY, msg /*msg*/);
- } else if (oldFront->mItems.mTsCmdData.mTsCmdCode
- & ANDROID_MP2TSEVENT_FORMAT_CHANGE_VIDEO) {
- sp<AMessage> msg = new AMessage();
- msg->setInt32(
- IStreamListener::kKeyDiscontinuityMask,
- ATSParser::DISCONTINUITY_VIDEO_FORMAT);
- receivedCmd_l(IStreamListener::DISCONTINUITY, msg /*msg*/);
- }
- // note that here we are intentionally only supporting
- // ANDROID_MP2TSEVENT_FORMAT_CHANGE_VIDEO, see IAndroidBufferQueue.c
-
- // some commands may introduce a time discontinuity, reevaluate position if needed
- if (oldFront->mItems.mTsCmdData.mTsCmdCode & (ANDROID_MP2TSEVENT_DISCONTINUITY |
- ANDROID_MP2TSEVENT_DISCON_NEWPTS | ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL)) {
- const sp<StreamPlayer> player(mPlayer.promote());
- if (player != NULL) {
- // FIXME see note at onSeek
- player->seek(ANDROID_UNKNOWN_TIME);
- }
- }
- oldFront->mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE;
- }
-
- {
- // we're going to change the shared mem buffer queue, so lock it
- Mutex::Autolock _l(mLock);
- if (!mAvailableBuffers.empty()) {
- bufferId = *mAvailableBuffers.begin();
- CHECK_LT(bufferId, mBuffers.size());
- sp<IMemory> mem = mBuffers.itemAt(bufferId);
- bufferLoc = mem->pointer();
- buffSize = mem->size();
-
- char *pSrc = ((char*)oldFront->mDataBuffer) + oldFront->mDataSizeConsumed;
- if (oldFront->mDataSizeConsumed + buffSize < oldFront->mDataSize) {
- // more available than requested, copy as much as requested
- // consume data: 1/ copy to given destination
- memcpy(bufferLoc, pSrc, buffSize);
- // 2/ keep track of how much has been consumed
- oldFront->mDataSizeConsumed += buffSize;
- // 3/ notify shared mem listener that new data is available
- receivedBuffer_l(bufferId, buffSize);
- mAvailableBuffers.erase(mAvailableBuffers.begin());
- } else {
- // requested as much available or more: consume the whole of the current
- // buffer and move to the next
- size_t consumed = oldFront->mDataSize - oldFront->mDataSizeConsumed;
- //SL_LOGD("consuming rest of buffer: enqueueing=%u", consumed);
- oldFront->mDataSizeConsumed = oldFront->mDataSize;
-
- // move queue to next
- if (newFront == &mAndroidBufferQueue->
- mBufferArray[mAndroidBufferQueue->mNumBuffers + 1]) {
- // reached the end, circle back
- newFront = mAndroidBufferQueue->mBufferArray;
- }
- mAndroidBufferQueue->mFront = newFront;
- mAndroidBufferQueue->mState.count--;
- mAndroidBufferQueue->mState.index++;
-
- if (consumed > 0) {
- // consume data: 1/ copy to given destination
- memcpy(bufferLoc, pSrc, consumed);
- // 2/ keep track of how much has been consumed
- // here nothing to do because we are done with this buffer
- // 3/ notify StreamPlayer that new data is available
- receivedBuffer_l(bufferId, consumed);
- mAvailableBuffers.erase(mAvailableBuffers.begin());
- }
-
- // data has been consumed, and the buffer queue state has been updated
- // we will notify the client if applicable
- queueCallbackCandidate = true;
- }
- }
-
- if (queueCallbackCandidate) {
- if (mAndroidBufferQueue->mCallbackEventsMask &
- SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED) {
- callback = mAndroidBufferQueue->mCallback;
- // save callback data while under lock
- callbackPContext = mAndroidBufferQueue->mContext;
- pBufferContext = (void *)oldFront->mBufferContext;
- pBufferData = (void *)oldFront->mDataBuffer;
- dataSize = oldFront->mDataSize;
- // here a buffer is only dequeued when fully consumed
- //dataUsed = oldFront->mDataSizeConsumed;
- }
- }
- //SL_LOGD("%d buffers available after reading from queue", mAvailableBuffers.size());
- if (!mAvailableBuffers.empty()) {
- // there is still room in the shared memory, recheck later if we can pull
- // data from the buffer queue and write it to shared memory
- const sp<StreamPlayer> player(mPlayer.promote());
- if (player != NULL) {
- player->queueRefilled();
- }
- }
- }
-
- } else { // empty queue
- SL_LOGD("ABQ empty, starving!");
- }
-
- interface_unlock_exclusive(mAndroidBufferQueue);
-
- // notify client of buffer processed
- if (NULL != callback) {
- SLresult result = (*callback)(&mAndroidBufferQueue->mItf, callbackPContext,
- pBufferContext, pBufferData, dataSize,
- dataSize, /* dataUsed */
- // no messages during playback other than marking the buffer as processed
- (const SLAndroidBufferItem*)(&kItemProcessed) /* pItems */,
- NB_BUFFEREVENT_ITEM_FIELDS *sizeof(SLuint32) /* itemsLength */ );
- if (SL_RESULT_SUCCESS != result) {
- // Reserved for future use
- SL_LOGW("Unsuccessful result %d returned from AndroidBufferQueueCallback", result);
- }
- }
-
- mCallbackProtector->exitCb();
- } // enterCbIfOk
-}
-
-
-//--------------------------------------------------------------------------------------------------
-StreamPlayer::StreamPlayer(AudioPlayback_Parameters* params, bool hasVideo,
- IAndroidBufferQueue *androidBufferQueue, const sp<CallbackProtector> &callbackProtector) :
- GenericMediaPlayer(params, hasVideo),
- mAppProxy(new StreamSourceAppProxy(androidBufferQueue, callbackProtector, this)),
- mStopForDestroyCompleted(false)
-{
- SL_LOGD("StreamPlayer::StreamPlayer()");
-
- mPlaybackParams = *params;
-
-}
-
-StreamPlayer::~StreamPlayer() {
- SL_LOGD("StreamPlayer::~StreamPlayer()");
- mAppProxy->disconnect();
-}
-
-
-void StreamPlayer::onMessageReceived(const sp<AMessage> &msg) {
- switch (msg->what()) {
- case kWhatPullFromAbq:
- onPullFromAndroidBufferQueue();
- break;
-
- case kWhatStopForDestroy:
- onStopForDestroy();
- break;
-
- default:
- GenericMediaPlayer::onMessageReceived(msg);
- break;
- }
-}
-
-
-void StreamPlayer::preDestroy() {
- // FIXME NuPlayerDriver is currently not thread-safe, so stop() must be called by looper
- (new AMessage(kWhatStopForDestroy, id()))->post();
- {
- Mutex::Autolock _l(mStopForDestroyLock);
- while (!mStopForDestroyCompleted) {
- mStopForDestroyCondition.wait(mStopForDestroyLock);
- }
- }
- // GenericMediaPlayer::preDestroy will repeat some of what we've done, but that's benign
- GenericMediaPlayer::preDestroy();
-}
-
-
-void StreamPlayer::onStopForDestroy() {
- if (mPlayer != 0) {
- mPlayer->stop();
- // causes CHECK failure in Nuplayer
- //mPlayer->setDataSource(NULL);
- mPlayer->setVideoSurfaceTexture(NULL);
- mPlayer->disconnect();
- mPlayer.clear();
- {
- // FIXME ugh make this a method
- Mutex::Autolock _l(mPreparedPlayerLock);
- mPreparedPlayer.clear();
- }
- }
- {
- Mutex::Autolock _l(mStopForDestroyLock);
- mStopForDestroyCompleted = true;
- }
- mStopForDestroyCondition.signal();
-}
-
-
-/**
- * Asynchronously notify the player that the queue is ready to be pulled from.
- */
-void StreamPlayer::queueRefilled() {
- // async notification that the ABQ was refilled: the player should pull from the ABQ, and
- // and push to shared memory (to the media server)
- (new AMessage(kWhatPullFromAbq, id()))->post();
-}
-
-
-void StreamPlayer::appClear_l() {
- // the user of StreamPlayer has cleared its AndroidBufferQueue:
- // there's no clear() for the shared memory queue, so this is a no-op
-}
-
-
-//--------------------------------------------------
-// Event handlers
-void StreamPlayer::onPrepare() {
- SL_LOGD("StreamPlayer::onPrepare()");
- sp<IMediaPlayerService> mediaPlayerService(getMediaPlayerService());
- if (mediaPlayerService != NULL) {
- mPlayer = mediaPlayerService->create(getpid(), mPlayerClient /*IMediaPlayerClient*/,
- mPlaybackParams.sessionId);
- if (mPlayer == NULL) {
- SL_LOGE("media player service failed to create player by app proxy");
- } else if (mPlayer->setDataSource(mAppProxy /*IStreamSource*/) != NO_ERROR) {
- SL_LOGE("setDataSource failed");
- mPlayer.clear();
- }
- }
- if (mPlayer == NULL) {
- mStateFlags |= kFlagPreparedUnsuccessfully;
- }
- GenericMediaPlayer::onPrepare();
- SL_LOGD("StreamPlayer::onPrepare() done");
-}
-
-
-void StreamPlayer::onPlay() {
- SL_LOGD("StreamPlayer::onPlay()");
- // enqueue a message that will cause StreamAppProxy to consume from the queue (again if the
- // player had starved the shared memory)
- queueRefilled();
-
- GenericMediaPlayer::onPlay();
-}
-
-
-void StreamPlayer::onPullFromAndroidBufferQueue() {
- SL_LOGD("StreamPlayer::onPullFromAndroidBufferQueue()");
- mAppProxy->pullFromBuffQueue();
-}
-
-} // namespace android
diff --git a/wilhelm/src/android/android_StreamPlayer.h b/wilhelm/src/android/android_StreamPlayer.h
deleted file mode 100644
index 1f520ca..0000000
--- a/wilhelm/src/android/android_StreamPlayer.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <media/IStreamSource.h>
-#include <binder/IServiceManager.h>
-#include "android/android_GenericMediaPlayer.h"
-
-// number of SLuint32 fields to store a buffer event message in an item, by mapping each
-// to the item key (SLuint32), the item size (SLuint32), and the item data (mask on SLuint32)
-#define NB_BUFFEREVENT_ITEM_FIELDS 3
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-//--------------------------------------------------------------------------------------------------
-class StreamPlayer;
-
-class StreamSourceAppProxy : public BnStreamSource {
-public:
- StreamSourceAppProxy(
- IAndroidBufferQueue *androidBufferQueue,
- const sp<CallbackProtector> &callbackProtector,
- StreamPlayer *player);
- virtual ~StreamSourceAppProxy();
-
- // store an item structure to indicate a processed buffer
- static const SLuint32 kItemProcessed[NB_BUFFEREVENT_ITEM_FIELDS];
-
- // IStreamSource implementation
- virtual void setListener(const sp<IStreamListener> &listener); // mediaserver calls exactly once
- virtual void setBuffers(const Vector<sp<IMemory> > &buffers); // mediaserver calls exactly once
- virtual void onBufferAvailable(size_t index);
-
- // Consumption from ABQ
- void pullFromBuffQueue();
-
-private:
- void receivedCmd_l(IStreamListener::Command cmd, const sp<AMessage> &msg = NULL);
- void receivedBuffer_l(size_t buffIndex, size_t buffLength);
-
-public:
- // Call at least once prior to releasing the last strong reference to this object. It causes
- // the player to release all of its resources, similar to android.media.MediaPlayer disconnect.
- void disconnect();
-
-private:
- // protects mListener, mBuffers, mBuffersHasBeenSet, and mAvailableBuffers
- Mutex mLock;
-
- sp<IStreamListener> mListener;
- // array of shared memory buffers
- Vector<sp<IMemory> > mBuffers;
- bool mBuffersHasBeenSet;
- // list of available buffers in shared memory, identified by their index
- List<size_t> mAvailableBuffers;
-
- // the Android Buffer Queue from which data is consumed and written to shared memory
- IAndroidBufferQueue* const mAndroidBufferQueue;
-
- const sp<CallbackProtector> mCallbackProtector;
- const wp<StreamPlayer> mPlayer;
-
- DISALLOW_EVIL_CONSTRUCTORS(StreamSourceAppProxy);
-};
-
-
-//--------------------------------------------------------------------------------------------------
-class StreamPlayer : public GenericMediaPlayer
-{
-public:
- StreamPlayer(AudioPlayback_Parameters* params, bool hasVideo,
- IAndroidBufferQueue *androidBufferQueue, const sp<CallbackProtector> &callbackProtector);
- virtual ~StreamPlayer();
-
- // overridden from GenericPlayer
- virtual void onMessageReceived(const sp<AMessage> &msg);
- virtual void preDestroy();
-
- void queueRefilled();
- void appClear_l();
-
-protected:
-
- enum {
- // message to asynchronously notify mAppProxy it should try to pull from the Android
- // Buffer Queue and push to shared memory (media server), either because the buffer queue
- // was refilled, or because during playback, the shared memory buffers should remain
- // filled to prevent it from draining (this can happen if the ABQ is not ready
- // whenever a shared memory buffer becomes available)
- kWhatPullFromAbq = 'plfq',
- kWhatStopForDestroy = 's4ds'
- };
-
- const sp<StreamSourceAppProxy> mAppProxy; // application proxy for the shared memory source
-
- // overridden from GenericMediaPlayer
- virtual void onPrepare();
- virtual void onPlay();
-
- void onPullFromAndroidBufferQueue();
-
-private:
- void onStopForDestroy();
-
- Mutex mStopForDestroyLock;
- Condition mStopForDestroyCondition;
- bool mStopForDestroyCompleted;
-
- DISALLOW_EVIL_CONSTRUCTORS(StreamPlayer);
-};
-
-} // namespace android
diff --git a/wilhelm/src/android/android_defs.h b/wilhelm/src/android/android_defs.h
deleted file mode 100644
index 3106b41..0000000
--- a/wilhelm/src/android/android_defs.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * Used to define the mapping from an OpenSL ES or OpenMAX AL object to an Android
- * media framework object
- */
-enum AndroidObjectType {
- INVALID_TYPE =-1,
- // audio player, playing from a URI or FD data source
- AUDIOPLAYER_FROM_URIFD = 0,
- // audio player, playing PCM buffers in a buffer queue data source
- AUDIOPLAYER_FROM_PCM_BUFFERQUEUE = 1,
- // audio player, playing transport stream packets in an Android buffer queue data source
- AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE = 2,
- // audio player, decoding from a URI or FD data source to a buffer queue data sink in PCM format
- AUDIOPLAYER_FROM_URIFD_TO_PCM_BUFFERQUEUE = 3,
- // audio video player, playing transport stream packets in an Android buffer queue data source
- AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE = 4,
- // audio video player, playing from a URI or FD data source
- AUDIOVIDEOPLAYER_FROM_URIFD = 5,
- // audio recorder, recording from an input device data source, streamed into a
- // PCM buffer queue data sink
- AUDIORECORDER_FROM_MIC_TO_PCM_BUFFERQUEUE = 6,
- // audio player, decoding from an Android buffer queue with ADTS data,
- // to a buffer queue data sink in PCM format
- AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE = 7,
- NUM_AUDIOPLAYER_MAP_TYPES
-};
-
-
-/**
- * Used to define the states of the OpenSL ES / OpenMAX AL object initialization and preparation
- * with regards to the Android-side of the data, in particular as affected by the play state.
- */
-enum AndroidObjectState {
- ANDROID_UNINITIALIZED = -1, // never called SetPlayState(PAUSED or PLAYING)
- ANDROID_PREPARING, // currently preparing due to first SetPlayState(PAUSED or PLAYING)
- ANDROID_READY, // preparation has completed, and will not be attempted again
- // NUM_ANDROID_STATES // unused
-};
-
-
-#define ANDROID_DEFAULT_OUTPUT_STREAM_TYPE AUDIO_STREAM_MUSIC
-
-#define PLAYER_FAILURE ((int32_t) android::UNKNOWN_ERROR)
-#define PLAYER_SUCCESS ((int32_t) android::NO_ERROR)
-
-#define PLAYER_FD_FIND_FILE_SIZE ((int64_t)0xFFFFFFFFFFFFFFFFll)
-
-#define MPEG2_TS_BLOCK_SIZE 188
-
-typedef struct AudioPlayback_Parameters_struct {
- int streamType;
- int sessionId;
-} AudioPlayback_Parameters;
-
-/**
- * Structure to maintain the set of audio levels about a player
- */
-typedef struct AndroidAudioLevels_t {
- /**
- * Send level to aux effect, there's a single aux bus, so there's a single level
- */
- // FIXME not used yet, will be used when supporting effects in OpenMAX AL
- //SLmillibel mAuxSendLevel;
- /**
- * Attenuation factor derived from direct level
- */
- // FIXME not used yet, will be used when supporting effects in OpenMAX AL
- //float mAmplFromDirectLevel;
- /**
- * Android Left/Right volume
- * The final volume of an Android AudioTrack or MediaPlayer is a stereo amplification
- * (or attenuation) represented as a float from 0.0f to 1.0f
- */
- float mFinalVolume[STEREO_CHANNELS];
-} AndroidAudioLevels;
-
-
-/**
- * Event notification callback from Android to SL ES framework
- */
-typedef void (*notif_cbf_t)(int event, int data1, int data2, void* notifUser);
-
-/**
- * Audio data push callback from Android objects to SL ES framework
- */
-typedef size_t (*data_push_cbf_t)(const uint8_t *data, size_t size, CAudioPlayer* ap);
-
-
-/**
- * Events sent to mNotifyClient during prepare, prefetch, and playback
- * used in APlayer::notify() and AMessage::findxxx()
- */
-#define PLAYEREVENT_PREPARED "prep"
-#define PLAYEREVENT_PREFETCHSTATUSCHANGE "prsc"
-#define PLAYEREVENT_PREFETCHFILLLEVELUPDATE "pflu"
-#define PLAYEREVENT_ENDOFSTREAM "eos"
-#define PLAYEREVENT_VIDEO_SIZE_UPDATE "vsiz"
-#define PLAYEREVENT_CHANNEL_COUNT "ccnt" // channel count is now known
-#define PLAYEREVENT_PLAY "play" // SL_PLAYEVENT_*
-#define PLAYEREVENT_ERRORAFTERPREPARE "easp" // error after successful prepare
-
-
-/**
- * Time value when time is unknown. Used for instance for duration or playback position
- */
-#define ANDROID_UNKNOWN_TIME -1
-
-/**
- * Event mask for MPEG-2 TS events associated with TS data
- */
-#define ANDROID_MP2TSEVENT_NONE ((SLuint32) 0x0)
-// buffer is at End Of Stream
-#define ANDROID_MP2TSEVENT_EOS ((SLuint32) 0x1)
-// buffer marks a discontinuity with previous TS data, resume display as soon as possible
-#define ANDROID_MP2TSEVENT_DISCONTINUITY ((SLuint32) 0x1 << 1)
-// buffer marks a discontinuity with previous TS data, resume display upon reaching the
-// associated presentation time stamp
-#define ANDROID_MP2TSEVENT_DISCON_NEWPTS ((SLuint32) 0x1 << 2)
-// buffer marks a format change with previous TS data, resume display as soon as possible
-#define ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL ((SLuint32) 0x1 << 3)
-#define ANDROID_MP2TSEVENT_FORMAT_CHANGE_VIDEO ((SLuint32) 0x1 << 4)
-
-/**
- * Event mask for AAC ADTS events associated with ADTS data
- */
-#define ANDROID_ADTSEVENT_NONE ANDROID_MP2TSEVENT_NONE
-// buffer is at End Of Stream
-#define ANDROID_ADTSEVENT_EOS ANDROID_MP2TSEVENT_EOS
-
-/**
- * Types of buffers stored in Android Buffer Queues, see IAndroidBufferQueue.mBufferType
- */
-enum AndroidBufferType_type {
- kAndroidBufferTypeInvalid = ((SLuint16) 0x0),
- kAndroidBufferTypeMpeg2Ts = ((SLuint16) 0x1),
- kAndroidBufferTypeAacadts = ((SLuint16) 0x2),
-};
-
-/**
- * MIME types required for data in Android Buffer Queues
- */
-// The preferred MIME types for new applications are in ../../include/*/OpenMAXAL_Android.h
-// The legacy MIME type used elsewhere in the Android framework for AAC ADTS is below:
-#define ANDROID_MIME_AACADTS_ANDROID_FRAMEWORK "audio/aac-adts"
-
-/**
- * Notification thresholds relative to content duration in the cache
- */
-#define DURATION_CACHED_HIGH_MS 30000 // 30s
-#define DURATION_CACHED_MED_MS 10000 // 10s
-#define DURATION_CACHED_LOW_MS 2000 // 2s
-
-
-namespace android {
-
-/**
- * Prefetch cache status
- */
-enum CacheStatus_t {
- kStatusUnknown = -1,
- kStatusEmpty = 0,
- kStatusLow,
- kStatusIntermediate,
- kStatusEnough,
- kStatusHigh
-};
-
-enum {
- kDataLocatorNone = 'none',
- kDataLocatorUri = 'uri',
- kDataLocatorFd = 'fd',
-};
-
-struct FdInfo {
- int fd;
- int64_t offset;
- int64_t length;
- bool mCloseAfterUse; // whether to close fd after last reference to fd
-};
-
-// TODO currently used by SfPlayer, to replace by DataLocator2
-union DataLocator {
- char* uri;
- FdInfo fdi;
-};
-
-union DataLocator2 {
- const char* uriRef;
- FdInfo fdi;
-};
-
-} // namespace android
diff --git a/wilhelm/src/android/android_prompts.h b/wilhelm/src/android/android_prompts.h
deleted file mode 100644
index 9feeda1..0000000
--- a/wilhelm/src/android/android_prompts.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//-----------------------------------------------------------------------------
-// Android general purpose errors
-//----------------------
-#define ERROR_SHOULDNT_BE_HERE_S \
- "Reached an invalid code path in %s"
-
-//-----------------------------------------------------------------------------
-// Android AudioPlayer errors
-//----------------------
-#define ERROR_PLAYERSTREAMTYPE_SET_UNKNOWN_TYPE \
- "Cannot set stream type: unknown or invalid stream type"
-#define ERROR_PLAYERSTREAMTYPE_REALIZED \
- "Cannot set stream type: audio player already realized"
-#define ERROR_PLAYERREALIZE_UNKNOWN_DATASOURCE_LOCATOR \
- "Cannot realize AudioPlayer: with unknown data source locator"
-#define ERROR_PLAYERREALIZE_UNEXPECTED_OBJECT_TYPE_D \
- "Cannot realize AudioPlayer: unexpected object type \%d"
-#define ERROR_PLAYERDESTROY_UNEXPECTED_OBJECT_TYPE_D \
- "Cannot destroy AudioPlayer: unexpected object type \%d"
-#define ERROR_PLAYERSETPLAYSTATE_UNEXPECTED_OBJECT_TYPE_D \
- "Cannot set AudioPlayer playstate: unexpected object type \%d"
-#define ERROR_PLAYERSETPLAYSTATE_INVALID_OBJECT_STATE_D \
- "Cannot set AudioPlayer playstate to %d: Android object in invalid state"
-#define ERROR_PLAYER_NEW_NULL_TRACK \
- "Internal error: new AudioTrack shouldn't be NULL"
-#define ERROR_PLAYER_PREFETCH_d \
- "Error (%d) encountered while prefetching"
-
-//-----------------------------------------------------------------------------
-// Android AudioRecorder errors
-//----------------------
-#define ERROR_RECORDER_SINK_MUST_BE_ANDROIDSIMPLEBUFFERQUEUE \
- "Cannot create AudioRecorder: data sink must be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE"
-#define ERROR_RECORDER_SINK_FORMAT_MUST_BE_PCM \
- "Cannot create AudioRecorder: data sink must be in PCM format"
-#define ERROR_RECORDER_SOURCE_MUST_BE_IODEVICE \
- "Cannot create AudioRecorder: data source must be SL_DATALOCATOR_IODEVICE"
-#define ERROR_RECORDER_IODEVICE_MUST_BE_AUDIOINPUT \
- "Cannot create AudioRecorder: data source device type must be SL_IODEVICE_AUDIOINPUT"
-#define ERROR_RECORDER_INPUT_ID_MUST_BE_DEFAULT \
- "Cannot create AudioRecorder: data source device ID must be SL_DEFAULTDEVICEID_AUDIOINPUT"
-#define ERROR_RECORDERPRESET_SET_UNKNOWN_PRESET \
- "Cannot set recording preset: unknown or invalid preset"
-#define ERROR_RECORDERPRESET_REALIZED \
- "Cannot set recording preset: audio recorder already realized"
-
-//-----------------------------------------------------------------------------
-// Android Configuration errors
-//----------------------
-#define ERROR_CONFIG_UNKNOWN_KEY \
- "Configuration error: unknown key"
-#define ERROR_CONFIG_VALUESIZE_TOO_LOW \
- "Configuration error: value size too low to store valid value"
-#define ERROR_CONFIG_NULL_PARAM \
- "Configuration error: invalid NULL parameter"
diff --git a/wilhelm/src/android/android_sles_conversions.h b/wilhelm/src/android/android_sles_conversions.h
deleted file mode 100644
index ebef1e6..0000000
--- a/wilhelm/src/android/android_sles_conversions.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "math.h"
-
-#include <system/audio.h>
-
-//-----------------------------------------------------------------------------
-// Android to OpenSL ES
-//----------------------
-static inline SLuint32 android_to_sles_streamType(int type) {
- return (SLuint32) type;
-}
-
-
-static inline SLuint32 android_to_sles_sampleRate(uint32_t srHz) {
- // convert to milliHertz
- return (SLuint32) srHz*1000;
-}
-
-
-//-----------------------------------------------------------------------------
-// OpenSL ES to Android
-//----------------------
-static inline int sles_to_android_streamType(SLuint32 type) {
- return (int)type;
-}
-
-
-static inline uint32_t sles_to_android_sampleRate(SLuint32 sampleRateMilliHertz) {
- return (uint32_t)(sampleRateMilliHertz / 1000);
-}
-
-static inline int sles_to_android_sampleFormat(SLuint32 pcmFormat) {
- switch (pcmFormat) {
- case SL_PCMSAMPLEFORMAT_FIXED_16:
- return AUDIO_FORMAT_PCM_16_BIT;
- break;
- case SL_PCMSAMPLEFORMAT_FIXED_8:
- return AUDIO_FORMAT_PCM_8_BIT;
- break;
- case SL_PCMSAMPLEFORMAT_FIXED_20:
- case SL_PCMSAMPLEFORMAT_FIXED_24:
- case SL_PCMSAMPLEFORMAT_FIXED_28:
- case SL_PCMSAMPLEFORMAT_FIXED_32:
- default:
- return AUDIO_FORMAT_INVALID;
- }
-}
-
-
-static inline int sles_to_android_channelMaskIn(SLuint32 nbChannels, SLuint32 channelMask) {
- // FIXME handle channel mask mapping between SL ES and Android
- return (nbChannels == 1 ?
- AUDIO_CHANNEL_IN_MONO :
- AUDIO_CHANNEL_IN_STEREO);
-}
-
-
-static inline int sles_to_android_channelMaskOut(SLuint32 nbChannels, SLuint32 channelMask) {
- // FIXME handle channel mask mapping between SL ES and Android
- return (nbChannels == 1 ?
- AUDIO_CHANNEL_OUT_MONO :
- AUDIO_CHANNEL_OUT_STEREO);
-}
-
-
-static inline float sles_to_android_amplification(SLmillibel level) {
- // FIXME use the FX Framework conversions
- return pow(10, (float)level/2000);
-}
-
-
-static inline uint32_t channelCountToMask(uint32_t channelCount)
-{
- // FIXME channel mask is not yet implemented by Stagefright, so use a reasonable default
- // that is computed from the channel count
- uint32_t channelMask;
- switch (channelCount) {
- case 1:
- // see explanation in data.c re: default channel mask for mono
- return SL_SPEAKER_FRONT_LEFT;
- case 2:
- return SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- default:
- return UNKNOWN_CHANNELMASK;
- }
-}
diff --git a/wilhelm/src/android/include/AacAdtsExtractor.h b/wilhelm/src/android/include/AacAdtsExtractor.h
deleted file mode 100644
index af0b38b..0000000
--- a/wilhelm/src/android/include/AacAdtsExtractor.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AAC_ADTS_EXTRACTOR_H_
-#define AAC_ADTS_EXTRACTOR_H_
-
-#include <utils/Vector.h>
-
-#include <media/stagefright/foundation/ABuffer.h>
-#include <media/stagefright/DataSource.h>
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MediaExtractor.h>
-#include <media/stagefright/MediaSource.h>
-#include <media/stagefright/MetaData.h>
-#include <utils/String8.h>
-
-namespace android {
-
-struct AMessage;
-class String8;
-
-
-class AacAdtsSource : public MediaSource {
-public:
- AacAdtsSource(const sp<DataSource> &source,
- const sp<MetaData> &meta,
- //const Vector<uint64_t> &offset_vector,
- int64_t frame_duration_us);
-
- virtual status_t start(MetaData *params = NULL);
- virtual status_t stop();
-
- virtual sp<MetaData> getFormat();
-
- virtual status_t read(
- MediaBuffer **buffer, const ReadOptions *options = NULL);
-
-protected:
- virtual ~AacAdtsSource();
-
-private:
- static const size_t kMaxFrameSize;
- sp<DataSource> mDataSource;
- sp<MetaData> mMeta;
-
- off64_t mOffset;
- int64_t mCurrentTimeUs;
- bool mStarted;
- MediaBufferGroup *mGroup;
-
- int64_t mFrameDurationUs;
-
- AacAdtsSource(const AacAdtsSource &);
- AacAdtsSource &operator=(const AacAdtsSource &);
-};
-
-
-class AacAdtsExtractor : public MediaExtractor {
-public:
- AacAdtsExtractor(const sp<DataSource> &source);
-
- virtual size_t countTracks();
- virtual sp<MediaSource> getTrack(size_t index);
- virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
-
- virtual sp<MetaData> getMetaData();
-
-protected:
- virtual ~AacAdtsExtractor();
-
-private:
- sp<DataSource> mDataSource;
- sp<MetaData> mMeta;
- status_t mInitCheck;
-
- int64_t mFrameDurationUs;
-
- AacAdtsExtractor(const AacAdtsExtractor &);
- AacAdtsExtractor &operator=(const AacAdtsExtractor &);
-
-};
-
-} // namespace android
-
-#endif // AAC_ADTS_EXTRACTOR_H_
diff --git a/wilhelm/src/android/include/AacBqToPcmCbRenderer.h b/wilhelm/src/android/include/AacBqToPcmCbRenderer.h
deleted file mode 100644
index cd1020c..0000000
--- a/wilhelm/src/android/include/AacBqToPcmCbRenderer.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AAC_BQ_TO_PCM_H_
-#define AAC_BQ_TO_PCM_H_
-
-#include "android/android_AudioToCbRenderer.h"
-#include "android/BufferQueueSource.h"
-#include "android/include/AacAdtsExtractor.h"
-
-//--------------------------------------------------------------------------------------------------
-namespace android {
-
-// Class to receive AAC ADTS data through an Android Buffer Queue, decode it and output
-// the PCM samples through a registered callback (just like its superclass, AudioToCbRenderer).
-// The implementation mainly overrides AudioSfDecoder::onPrepare() for the specificities
-// of the data source creation, but all other behavior remains the same (e.g. PCM format metadata)
-
-class AacBqToPcmCbRenderer : public AudioToCbRenderer
-{
-public:
-
- AacBqToPcmCbRenderer(AudioPlayback_Parameters* params);
- virtual ~AacBqToPcmCbRenderer();
-
- void registerSourceQueueCallback(const void* user, void *context, const void *caller);
-
- // verifies the given memory starts and ends on ADTS frame boundaries.
- // This is for instance used whenever ADTS data is being enqueued through an
- // SL / XA AndroidBufferQueue interface so only parseable ADTS data goes in
- // the buffer queue, and no ADTS frame is stored across two buffers.
- static SLresult validateBufferStartEndOnFrameBoundaries(void* data, size_t size);
-
-protected:
-
- // Async event handlers (called from GenericPlayer's event loop)
- virtual void onPrepare();
-
-
-private:
- // mutex used to protect mBqSource
- Mutex mBqSourceLock;
- sp<BufferQueueSource> mBqSource;
-
-private:
- DISALLOW_EVIL_CONSTRUCTORS(AacBqToPcmCbRenderer);
-
-};
-
-} // namespace android
-
-#endif //AAC_BQ_TO_PCM_H_
diff --git a/wilhelm/src/android/util/AacAdtsExtractor.cpp b/wilhelm/src/android/util/AacAdtsExtractor.cpp
deleted file mode 100644
index d405cf6..0000000
--- a/wilhelm/src/android/util/AacAdtsExtractor.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sllog.h"
-#include <utils/Log.h>
-
-#include "android/include/AacAdtsExtractor.h"
-#include "include/avc_utils.h"
-
-
-namespace android {
-
-#define ADTS_HEADER_LENGTH 7
-// ADTS header size is 7, but frame size information ends on byte 6 (when counting from byte 1)
-#define ADTS_HEADER_SIZE_UP_TO_FRAMESIZE 6
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Returns the sample rate based on the sampling frequency index
-static uint32_t get_sample_rate(const uint8_t sf_index)
-{
- static const uint32_t sample_rates[] =
- {
- 96000, 88200, 64000, 48000, 44100, 32000,
- 24000, 22050, 16000, 12000, 11025, 8000
- };
-
- if (sf_index < sizeof(sample_rates) / sizeof(sample_rates[0])) {
- return sample_rates[sf_index];
- }
-
- return 0;
-}
-
-static size_t getFrameSize(const sp<DataSource> &source, off64_t offset) {
- size_t frameSize = 0;
-
- uint8_t syncHeader[ADTS_HEADER_SIZE_UP_TO_FRAMESIZE];
- const uint8_t *syncword = syncHeader;
- const uint8_t *header = syncHeader + 3;
-
- ssize_t readSize = source->readAt(offset, &syncHeader, ADTS_HEADER_SIZE_UP_TO_FRAMESIZE);
- if (readSize == 0) {
- // EOS is normal, not an error
- SL_LOGV("AacAdtsExtractor::getFrameSize EOS");
- return 0;
- }
- if (readSize != ADTS_HEADER_SIZE_UP_TO_FRAMESIZE) {
- SL_LOGE("AacAdtsExtractor:: getFrameSize() returns %d (syncword and header read error)",
- (int) readSize);
- return 0;
- }
-
- if ((syncword[0] != 0xff) || ((syncword[1] & 0xf6) != 0xf0)) {
- SL_LOGE("AacAdtsExtractor:: getFrameSize() returns 0 (syncword pb)");
- return 0;
- }
-
- const uint8_t protectionAbsent = syncword[1] & 0x1;
-
- frameSize = (header[0] & 0x3) << 11 | header[1] << 3 | header[2] >> 5;
- // the frame size read already contains the size of the ADTS header, so no need to add it here
-
- // protectionAbsent is 0 if there is CRC
- static const size_t kAdtsHeaderLengthNoCrc = 7;
- static const size_t kAdtsHeaderLengthWithCrc = 9;
- size_t headSize = protectionAbsent ? kAdtsHeaderLengthNoCrc : kAdtsHeaderLengthWithCrc;
- if (headSize > frameSize) {
- SL_LOGE("AacAdtsExtractor:: getFrameSize() returns 0 (frameSize %u < headSize %u)",
- frameSize, headSize);
- return 0;
- }
-
- //SL_LOGV("AacAdtsExtractor:: getFrameSize() returns %u", frameSize);
-
- return frameSize;
-}
-
-
-AacAdtsExtractor::AacAdtsExtractor(const sp<DataSource> &source)
- : mDataSource(source),
- mInitCheck(NO_INIT),
- mFrameDurationUs(0) {
-
- // difference with framework's AAC Extractor: we have already validated the data
- // upon enqueueing, so no need to sniff the data:
- // String8 mimeType;
- // float confidence;
- // if (!SniffAAC(mDataSource, &mimeType, &confidence, NULL)) {
- // return;
- // }
-
- uint8_t profile, sf_index, channel, header[2];
- ssize_t readSize = mDataSource->readAt(2, &header, 2);
- if (readSize != 2) {
- SL_LOGE("Unable to determine sample rate");
- return;
- }
-
- profile = (header[0] >> 6) & 0x3;
- sf_index = (header[0] >> 2) & 0xf;
- uint32_t sr = get_sample_rate(sf_index);
-
- if (sr == 0) {
- SL_LOGE("Invalid sample rate");
- return;
- }
- channel = (header[0] & 0x1) << 2 | (header[1] >> 6);
-
- SL_LOGV("AacAdtsExtractor has found sr=%d channel=%d", sr, channel);
-
- // Never fails
- mMeta = MakeAACCodecSpecificData(profile, sf_index, channel);
-
- off64_t offset = 0;
- off64_t streamSize, numFrames = 0;
- size_t frameSize = 0;
- int64_t duration = 0;
-
- if (mDataSource->getSize(&streamSize) == OK) {
- while (offset < streamSize) {
- if ((frameSize = getFrameSize(mDataSource, offset)) == 0) {
- // Usually frameSize == 0 due to EOS is benign (and getFrameSize() doesn't SL_LOGE),
- // but in this case we were told the total size of the data source and so an EOS
- // should not happen.
- SL_LOGE("AacAdtsExtractor() failed querying framesize at offset=%lld", offset);
- return;
- }
-
- offset += frameSize;
- if (offset > streamSize) {
- SL_LOGE("AacAdtsExtractor() frame of size %zu at offset=%lld is beyond EOF %lld",
- frameSize, offset, streamSize);
- return;
- }
- numFrames ++;
- }
-
- // Round up and get the duration
- mFrameDurationUs = (1024 * 1000000ll + (sr - 1)) / sr;
- duration = numFrames * mFrameDurationUs;
- mMeta->setInt64(kKeyDuration, duration);
- }
-
- // Any earlier "return" would leave mInitCheck as NO_INIT, causing later methods to fail quickly
- mInitCheck = OK;
-
-}
-
-
-AacAdtsExtractor::~AacAdtsExtractor() {
-}
-
-
-sp<MetaData> AacAdtsExtractor::getMetaData() {
- sp<MetaData> meta = new MetaData;
-
- if (mInitCheck != OK) {
- return meta;
- }
-
- meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AAC_ADTS);
-
- return meta;
-}
-
-
-size_t AacAdtsExtractor::countTracks() {
- return mInitCheck == OK ? 1 : 0;
-}
-
-
-sp<MediaSource> AacAdtsExtractor::getTrack(size_t index) {
- if (mInitCheck != OK || index != 0) {
- return NULL;
- }
-
- return new AacAdtsSource(mDataSource, mMeta, mFrameDurationUs);
-}
-
-
-sp<MetaData> AacAdtsExtractor::getTrackMetaData(size_t index, uint32_t flags) {
- if (mInitCheck != OK || index != 0) {
- return NULL;
- }
-
- return mMeta;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-
-// 8192 = 2^13, 13bit AAC frame size (in bytes)
-const size_t AacAdtsSource::kMaxFrameSize = 8192;
-
-AacAdtsSource::AacAdtsSource(
- const sp<DataSource> &source, const sp<MetaData> &meta,
- int64_t frame_duration_us)
- : mDataSource(source),
- mMeta(meta),
- mOffset(0),
- mCurrentTimeUs(0),
- mStarted(false),
- mGroup(NULL),
- mFrameDurationUs(frame_duration_us) {
-}
-
-
-AacAdtsSource::~AacAdtsSource() {
- if (mStarted) {
- stop();
- }
-}
-
-
-status_t AacAdtsSource::start(MetaData *params) {
- CHECK(!mStarted);
-
- mOffset = 0;
- mCurrentTimeUs = 0;
- mGroup = new MediaBufferGroup;
- mGroup->add_buffer(new MediaBuffer(kMaxFrameSize));
- mStarted = true;
-
- return OK;
-}
-
-
-status_t AacAdtsSource::stop() {
- CHECK(mStarted);
-
- delete mGroup;
- mGroup = NULL;
-
- mStarted = false;
- return OK;
-}
-
-
-sp<MetaData> AacAdtsSource::getFormat() {
- return mMeta;
-}
-
-
-status_t AacAdtsSource::read(
- MediaBuffer **out, const ReadOptions *options) {
- *out = NULL;
-
- int64_t seekTimeUs;
- ReadOptions::SeekMode mode;
- if (options && options->getSeekTo(&seekTimeUs, &mode)) {
- // difference with framework's AAC Extractor: no seeking
- SL_LOGE("Can't seek in AAC ADTS buffer queue");
- }
-
- size_t frameSize, frameSizeWithoutHeader;
- SL_LOGV("AacAdtsSource::read() offset=%lld", mOffset);
- if ((frameSize = getFrameSize(mDataSource, mOffset)) == 0) {
- // EOS is normal, not an error
- SL_LOGV("AacAdtsSource::read() returns EOS");
- return ERROR_END_OF_STREAM;
- }
-
- MediaBuffer *buffer;
- status_t err = mGroup->acquire_buffer(&buffer);
- if (err != OK) {
- return err;
- }
-
- frameSizeWithoutHeader = frameSize - ADTS_HEADER_LENGTH;
- ssize_t readSize = mDataSource->readAt(mOffset + ADTS_HEADER_LENGTH, buffer->data(),
- frameSizeWithoutHeader);
- //SL_LOGV("AacAdtsSource::read() readAt returned %u bytes", readSize);
- if (readSize != (ssize_t)frameSizeWithoutHeader) {
- SL_LOGW("AacAdtsSource::read() readSize != frameSizeWithoutHeader");
- buffer->release();
- buffer = NULL;
- return ERROR_IO;
- }
-
- buffer->set_range(0, frameSizeWithoutHeader);
- buffer->meta_data()->setInt64(kKeyTime, mCurrentTimeUs);
- buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
-
- mOffset += frameSize;
- mCurrentTimeUs += mFrameDurationUs;
-
- *out = buffer;
- return OK;
-}
-
-} // namespace android
diff --git a/wilhelm/src/assert.c b/wilhelm/src/assert.c
deleted file mode 100644
index b315422..0000000
--- a/wilhelm/src/assert.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Replace bionic/libc/stdlib/assert.c which logs to stderr with our version which does LOGF.
-// To be effective, add CFLAGS += -UNDEBUG and explicitly link in assert.c in all build modules.
-
-#include <utils/Log.h>
-
-void __assert(const char *file, int line, const char *failedexpr)
-{
- LOG_ALWAYS_FATAL("assertion \"%s\" failed: file \"%s\", line %d", failedexpr, file, line);
- // not reached
-}
-
-void __assert2(const char *file, int line, const char *func, const char *failedexpr)
-{
- LOG_ALWAYS_FATAL("assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"",
- failedexpr, file, line, func);
- // not reached
-}
diff --git a/wilhelm/src/attr.h b/wilhelm/src/attr.h
deleted file mode 100644
index 31533a2..0000000
--- a/wilhelm/src/attr.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Attributes
-
-// bit indices, used for fast lookup into handler table
-
-#define ATTR_INDEX_GAIN 0 // volume: volume, stereo position, mute
- // mute solo: channel mute, channel solo
- // effect send: set direct level
-#define ATTR_INDEX_TRANSPORT 1 // play: callback events mask,
- // marker position, position update period
- // (currently looping is done differently, not by attributes)
- // recorder: duration limit, events mask,
- // marker position, position update period
-#define ATTR_INDEX_POSITION 2 // requested position (a.k.a. seek position)
-#define ATTR_INDEX_BQ_ENQUEUE 3 // (buffer queue non-empty and in playing state) became true
-#define ATTR_INDEX_ABQ_ENQUEUE 4 // Android buffer queue became non-empty and in playing state
-#define ATTR_INDEX_PLAY_STATE 5 // play: play state
-#define ATTR_INDEX_UNUSED6 6 // reserved for future use
-#define ATTR_INDEX_UNUSED7 7 // reserved for future use
-#define ATTR_INDEX_MAX 8 // total number of bits used so far
-
-// bit masks, used with unlock_exclusive_attributes
-
-#define ATTR_NONE 0
-#define ATTR_GAIN (1 << ATTR_INDEX_GAIN)
-#define ATTR_TRANSPORT (1 << ATTR_INDEX_TRANSPORT)
-#define ATTR_POSITION (1 << ATTR_INDEX_POSITION)
-#define ATTR_BQ_ENQUEUE (1 << ATTR_INDEX_BQ_ENQUEUE)
-#define ATTR_ABQ_ENQUEUE (1 << ATTR_INDEX_ABQ_ENQUEUE)
-#define ATTR_PLAY_STATE (1 << ATTR_INDEX_PLAY_STATE)
-#define ATTR_UNUSED6 (1 << ATTR_INDEX_UNUSED6)
-#define ATTR_UNUSED7 (1 << ATTR_INDEX_UNUSED7)
diff --git a/wilhelm/src/autogen/IID_to_MPH.c b/wilhelm/src/autogen/IID_to_MPH.c
deleted file mode 100644
index 35046ce..0000000
--- a/wilhelm/src/autogen/IID_to_MPH.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This file is automagically generated by hashgen, do not edit
-
-/** \file IID_to_MPH.c Interface ID to MPH mapping */
-
-#include <SLES/OpenSLES.h>
-#include "MPH.h"
-#include <assert.h>
-#include <string.h>
-
-extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];
-
-/** \brief Map SLInterfaceID to its minimal perfect hash (MPH), or -1 if unknown */
-
-int IID_to_MPH(const SLInterfaceID iid)
-{
-#define MAX_HASH_VALUE 180
- static const unsigned char asso_values[] =
- {
- 35, 20, 54, 84, 181, 181, 59, 181, 181, 181,
- 181, 181, 181, 181, 69, 181, 64, 44, 181, 181,
- 181, 181, 39, 181, 54, 14, 181, 181, 14, 181,
- 181, 125, 5, 181, 181, 181, 181, 181, 181, 181,
- 127, 181, 181, 181, 9, 181, 112, 181, 181, 181,
- 181, 181, 122, 181, 181, 181, 181, 181, 14, 100,
- 181, 9, 24, 181, 50, 181, 181, 181, 181, 117,
- 181, 181, 97, 85, 181, 181, 181, 181, 181, 181,
- 181, 181, 181, 181, 181, 181, 117, 181, 19, 181,
- 181, 181, 9, 181, 181, 181, 25, 181, 14, 102,
- 181, 181, 181, 181, 181, 181, 181, 4, 181, 97,
- 181, 181, 0, 181, 4, 92, 117, 181, 67, 45,
- 181, 181, 110, 181, 181, 181, 72, 181, 40, 181,
- 181, 181, 181, 181, 181, 102, 52, 181, 181, 181,
- 181, 181, 57, 67, 181, 62, 181, 125, 181, 181,
- 181, 181, 181, 82, 181, 181, 72, 181, 181, 65,
- 5, 181, 32, 181, 181, 67, 120, 181, 181, 37,
- 181, 57, 55, 181, 181, 47, 181, 45, 181, 181,
- 181, 181, 7, 181, 17, 30, 181, 181, 181, 181,
- 181, 181, 0, 181, 181, 181, 105, 32, 181, 181,
- 181, 181, 181, 181, 181, 181, 115, 181, 181, 181,
- 95, 32, 181, 181, 181, 22, 181, 181, 2, 181,
- 181, 181, 181, 12, 10, 181, 181, 12, 181, 181,
- 181, 181, 181, 181, 2, 181, 70, 181, 181, 181,
- 10, 2, 181, 181, 70, 181, 120, 115, 181, 181,
- 181, 80, 105, 100, 181, 181
- };
- static const signed char hash_to_MPH[] = {
- MPH_ANDROIDEFFECTSEND,
- -1,
- MPH_XADYNAMICINTERFACEMANAGEMENT,
- -1,
- MPH_XAAUDIODECODERCAPABILITIES,
- MPH_XALED,
- -1,
- MPH_XATHREADSYNC,
- -1,
- MPH_XAOUTPUTMIX,
- MPH_MIDITIME,
- -1,
- MPH_XAIMAGECONTROLS,
- -1,
- MPH_AUDIOIODEVICECAPABILITIES,
- MPH_MUTESOLO,
- -1,
- MPH_XAVOLUME,
- -1,
- MPH_ANDROIDCONFIGURATION,
- MPH_XASNAPSHOT,
- -1,
- MPH_XAPLAY,
- -1,
- MPH_SEEK,
- MPH_3DLOCATION,
- -1,
- MPH_XACONFIGEXTENSION,
- -1,
- MPH_XAIMAGEDECODERCAPABILITIES,
- MPH_XACAMERACAPABILITIES,
- -1,
- MPH_3DMACROSCOPIC,
- -1,
- MPH_VIBRA,
- MPH_XAIMAGEEFFECTS,
- -1,
- MPH_XAMETADATAEXTRACTION,
- -1,
- MPH_PRESETREVERB,
- MPH_XAOBJECT,
- -1,
- MPH_RATEPITCH,
- -1,
- MPH_PITCH,
- MPH_XAVIBRA,
- -1,
- MPH_XARADIO,
- -1,
- MPH_OUTPUTMIXEXT,
- MPH_ENGINECAPABILITIES,
- -1,
- MPH_XAVIDEOPOSTPROCESSING,
- -1,
- MPH_3DCOMMIT,
- MPH_XAVIDEODECODERCAPABILITIES,
- -1,
- MPH_METADATATRAVERSAL,
- -1,
- MPH_XASEEK,
- MPH_AUDIODECODERCAPABILITIES,
- -1,
- MPH_DEVICEVOLUME,
- -1,
- MPH_OBJECT,
- MPH_ENVIRONMENTALREVERB,
- -1,
- MPH_XARDS,
- -1,
- MPH_XAVIDEOENCODER,
- MPH_OUTPUTMIX,
- -1,
- MPH_XADYNAMICSOURCE,
- -1,
- MPH_3DGROUPING,
- MPH_XASTREAMINFORMATION,
- -1,
- MPH_XAPREFETCHSTATUS,
- -1,
- MPH_XAMETADATATRAVERSAL,
- MPH_VIRTUALIZER,
- -1,
- MPH_BUFFERQUEUE,
- -1,
- MPH_ANDROIDBUFFERQUEUESOURCE,
- MPH_PLAY,
- -1,
- MPH_XAMETADATAINSERTION,
- -1,
- MPH_XADEVICEVOLUME,
- MPH_XAVIDEOENCODERCAPABILITIES,
- -1,
- MPH_ENGINE,
- -1,
- MPH_MIDIMUTESOLO,
- MPH_XAEQUALIZER,
- -1,
- MPH_METADATAEXTRACTION,
- -1,
- -1,
- MPH_XARECORD,
- -1,
- MPH_XAIMAGEENCODER,
- -1,
- -1,
- MPH_VISUALIZATION,
- -1,
- MPH_XACAMERA,
- -1,
- -1,
- MPH_BASSBOOST,
- -1,
- MPH_LED,
- -1,
- -1,
- MPH_EFFECTSEND,
- -1,
- MPH_XAENGINE,
- -1,
- -1,
- MPH_RECORD,
- -1,
- MPH_MIDIMESSAGE,
- -1,
- -1,
- MPH_ANDROIDEFFECTCAPABILITIES,
- -1,
- MPH_3DSOURCE,
- -1,
- -1,
- MPH_VOLUME,
- -1,
- MPH_XAAUDIOENCODERCAPABILITIES,
- -1,
- -1,
- MPH_PLAYBACKRATE,
- -1,
- MPH_XAAUDIOIODEVICECAPABILITIES,
- -1,
- -1,
- MPH_NULL,
- -1,
- MPH_ANDROIDEFFECT,
- -1,
- -1,
- MPH_XAIMAGEENCODERCAPABILITIES,
- -1,
- MPH_XAPLAYBACKRATE,
- -1,
- -1,
- MPH_MIDITEMPO,
- -1,
- MPH_DYNAMICSOURCE,
- -1,
- -1,
- MPH_DYNAMICINTERFACEMANAGEMENT,
- -1,
- MPH_EQUALIZER,
- -1,
- -1,
- MPH_XAAUDIOENCODER,
- -1,
- MPH_THREADSYNC,
- -1,
- -1,
- MPH_PREFETCHSTATUS,
- -1,
- MPH_3DDOPPLER,
- -1,
- -1,
- MPH_ANDROIDSIMPLEBUFFERQUEUE,
- -1,
- -1,
- -1,
- -1,
- MPH_AUDIOENCODERCAPABILITIES,
- -1,
- -1,
- -1,
- -1,
- MPH_AUDIOENCODER
- };
- if (&SL_IID_array[0] <= iid && &SL_IID_array[MPH_MAX] > iid)
- return iid - &SL_IID_array[0];
- if (NULL != iid) {
- static const unsigned len = sizeof(struct SLInterfaceID_);
- unsigned key = asso_values[((unsigned char *)iid)[8]] +
- asso_values[((unsigned char *)iid)[0]];
- if (key <= MAX_HASH_VALUE) {
- int MPH = hash_to_MPH[key];
- if (MPH >= 0) {
- assert(MPH < MPH_MAX);
- SLInterfaceID trial = &SL_IID_array[MPH];
- if (!memcmp(iid, trial, sizeof(struct SLInterfaceID_)))
- return MPH;
- }
- }
- }
- return -1;
-}
diff --git a/wilhelm/src/autogen/MPH_to_3DGroup.h b/wilhelm/src/autogen/MPH_to_3DGroup.h
deleted file mode 100644
index c0ecf01..0000000
--- a/wilhelm/src/autogen/MPH_to_3DGroup.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, 3, -1, 2, 5, 4, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_AudioPlayer.h b/wilhelm/src/autogen/MPH_to_AudioPlayer.h
deleted file mode 100644
index dbfa871..0000000
--- a/wilhelm/src/autogen/MPH_to_AudioPlayer.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, 3, 4, 5, 16, 6, -1, -1, -1, -1, 17, 7, -1, 1, 18, 8, -1, -1, 19, 20,
- -1, 10, 11, -1, -1, -1, -1, 9, -1, 0, -1, 21, 2, 23, 12, 22, 13, -1, 14, -1,
- -1, 24, 25, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_AudioRecorder.h b/wilhelm/src/autogen/MPH_to_AudioRecorder.h
deleted file mode 100644
index d4759de..0000000
--- a/wilhelm/src/autogen/MPH_to_AudioRecorder.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, -1, -1, -1, -1, -1, -1, 3, -1, -1, 4, -1, -1, 1, 5, -1, -1, -1, -1, 6,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1,
- -1, -1, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_Engine.h b/wilhelm/src/autogen/MPH_to_Engine.h
deleted file mode 100644
index c3a9e23..0000000
--- a/wilhelm/src/autogen/MPH_to_Engine.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- 8, -1, -1, -1, -1, -1, 6, -1, 7, 5, -1, -1, 9, 1, -1, -1, 2, 3, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 12, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_LEDDevice.h b/wilhelm/src/autogen/MPH_to_LEDDevice.h
deleted file mode 100644
index d315c8f..0000000
--- a/wilhelm/src/autogen/MPH_to_LEDDevice.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1,
- 2, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_Listener.h b/wilhelm/src/autogen/MPH_to_Listener.h
deleted file mode 100644
index fbfc8da..0000000
--- a/wilhelm/src/autogen/MPH_to_Listener.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, 2, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_MediaPlayer.h b/wilhelm/src/autogen/MPH_to_MediaPlayer.h
deleted file mode 100644
index 4b11c6a..0000000
--- a/wilhelm/src/autogen/MPH_to_MediaPlayer.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 2, -1, 6, -1, -1, -1,
- 5, -1, 3, -1, -1, -1, -1, -1, -1, 4
diff --git a/wilhelm/src/autogen/MPH_to_MetadataExtractor.h b/wilhelm/src/autogen/MPH_to_MetadataExtractor.h
deleted file mode 100644
index 9db501b..0000000
--- a/wilhelm/src/autogen/MPH_to_MetadataExtractor.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, -1, -1, -1, -1, -1,
- -1, 3, 4, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_MidiPlayer.h b/wilhelm/src/autogen/MPH_to_MidiPlayer.h
deleted file mode 100644
index 6d33f3c..0000000
--- a/wilhelm/src/autogen/MPH_to_MidiPlayer.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, 3, 4, 5, 19, 6, -1, -1, -1, -1, 20, 7, -1, 1, 21, 8, -1, -1, 22, 23,
- -1, 10, 11, 12, 15, 14, 13, 9, -1, 0, -1, 24, 2, 26, 16, 25, -1, -1, 17, -1,
- -1, 27, 28, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_OutputMix.h b/wilhelm/src/autogen/MPH_to_OutputMix.h
deleted file mode 100644
index 5767d66..0000000
--- a/wilhelm/src/autogen/MPH_to_OutputMix.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, 1, -1, -1, -1, -1, 4, 5,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2, -1, -1, -1, -1, 6, -1, -1, -1, -1,
- -1, 7, 10, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/autogen/MPH_to_Vibra.h b/wilhelm/src/autogen/MPH_to_Vibra.h
deleted file mode 100644
index 269adb8..0000000
--- a/wilhelm/src/autogen/MPH_to_Vibra.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is automagically generated by mphtogen, do not edit
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
diff --git a/wilhelm/src/classes.c b/wilhelm/src/classes.c
deleted file mode 100644
index bf707bd..0000000
--- a/wilhelm/src/classes.c
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Classes vs. interfaces */
-
-#include "sles_allinclusive.h"
-
-
-#if USE_PROFILES & USE_PROFILES_GAME
-
-// 3DGroup class
-
-static const struct iid_vtable _3DGroup_interfaces[INTERFACES_3DGroup] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(C3DGroup, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(C3DGroup, mDynamicInterfaceManagement)},
- {MPH_3DLOCATION, INTERFACE_IMPLICIT, offsetof(C3DGroup, m3DLocation)},
- {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(C3DGroup, m3DDoppler)},
- {MPH_3DSOURCE, INTERFACE_EXPLICIT_GAME, offsetof(C3DGroup, m3DSource)},
- {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(C3DGroup, m3DMacroscopic)},
-};
-
-static const ClassTable C3DGroup_class = {
- _3DGroup_interfaces,
- INTERFACES_3DGroup,
- MPH_to_3DGroup,
- "3DGroup",
- sizeof(C3DGroup),
- SL_OBJECTID_3DGROUP,
- 0, // OpenMAX AL object ID
- NULL,
- NULL,
- NULL,
- C3DGroup_PreDestroy
-};
-
-#endif
-
-
-// AudioPlayer class
-
-static const struct iid_vtable AudioPlayer_interfaces[INTERFACES_AudioPlayer] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CAudioPlayer, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CAudioPlayer, mDynamicInterfaceManagement)},
- {MPH_PLAY, INTERFACE_IMPLICIT, offsetof(CAudioPlayer, mPlay)},
- {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(CAudioPlayer, m3DDoppler)},
- {MPH_3DGROUPING, INTERFACE_EXPLICIT_GAME, offsetof(CAudioPlayer, m3DGrouping)},
- {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME, offsetof(CAudioPlayer, m3DLocation)},
- {MPH_3DSOURCE, INTERFACE_EXPLICIT_GAME, offsetof(CAudioPlayer, m3DSource)},
- {MPH_BUFFERQUEUE, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mBufferQueue)},
- {MPH_EFFECTSEND, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mEffectSend)},
- {MPH_MUTESOLO, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mMuteSolo)},
- {MPH_METADATAEXTRACTION, INTERFACE_DYNAMIC,
- offsetof(CAudioPlayer, mMetadataExtraction)},
- {MPH_METADATATRAVERSAL, INTERFACE_DYNAMIC_GAME_MUSIC,
- offsetof(CAudioPlayer, mMetadataTraversal)},
- {MPH_PREFETCHSTATUS, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mPrefetchStatus)},
- {MPH_RATEPITCH, INTERFACE_DYNAMIC_GAME, offsetof(CAudioPlayer, mRatePitch)},
- {MPH_SEEK, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mSeek)},
- // The base Volume interface is explicit, but portions are only for Game and Music profiles
- {MPH_VOLUME, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mVolume)},
- {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, m3DMacroscopic)},
- {MPH_BASSBOOST, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mBassBoost)},
- {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mDynamicSource)},
- {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC,
- offsetof(CAudioPlayer, mEnvironmentalReverb)},
- {MPH_EQUALIZER, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mEqualizer)},
- {MPH_PITCH, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CAudioPlayer, mPitch)},
- {MPH_PRESETREVERB, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mPresetReverb)},
- {MPH_PLAYBACKRATE, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mPlaybackRate)},
- {MPH_VIRTUALIZER, INTERFACE_DYNAMIC, offsetof(CAudioPlayer, mVirtualizer)},
- {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mVisualization)},
-#ifdef ANDROID
- {MPH_ANDROIDEFFECT, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mAndroidEffect)},
- {MPH_ANDROIDEFFECTSEND, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mAndroidEffectSend)},
- {MPH_ANDROIDCONFIGURATION, INTERFACE_EXPLICIT_PREREALIZE,
- offsetof(CAudioPlayer, mAndroidConfiguration)},
- {MPH_ANDROIDBUFFERQUEUESOURCE, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mAndroidBufferQueue)},
-#endif
-};
-
-static const ClassTable CAudioPlayer_class = {
- AudioPlayer_interfaces,
- INTERFACES_AudioPlayer,
- MPH_to_AudioPlayer,
- "AudioPlayer",
- sizeof(CAudioPlayer),
- SL_OBJECTID_AUDIOPLAYER,
- 0, // OpenMAX AL object ID
- CAudioPlayer_Realize,
- CAudioPlayer_Resume,
- CAudioPlayer_Destroy,
- CAudioPlayer_PreDestroy
-};
-
-
-#if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
-
-// AudioRecorder class
-
-static const struct iid_vtable AudioRecorder_interfaces[INTERFACES_AudioRecorder] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CAudioRecorder, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CAudioRecorder, mDynamicInterfaceManagement)},
- {MPH_RECORD, INTERFACE_IMPLICIT, offsetof(CAudioRecorder, mRecord)},
- {MPH_AUDIOENCODER, INTERFACE_EXPLICIT, offsetof(CAudioRecorder, mAudioEncoder)},
- {MPH_BASSBOOST, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CAudioRecorder, mBassBoost)},
- {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mDynamicSource)},
- {MPH_EQUALIZER, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CAudioRecorder, mEqualizer)},
- {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mVisualization)},
- {MPH_VOLUME, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mVolume)},
-#ifdef ANDROID
- {MPH_ANDROIDSIMPLEBUFFERQUEUE, INTERFACE_EXPLICIT, offsetof(CAudioRecorder, mBufferQueue)},
- {MPH_ANDROIDCONFIGURATION, INTERFACE_EXPLICIT_PREREALIZE,
- offsetof(CAudioRecorder, mAndroidConfiguration)},
-#endif
-};
-
-static const ClassTable CAudioRecorder_class = {
- AudioRecorder_interfaces,
- INTERFACES_AudioRecorder,
- MPH_to_AudioRecorder,
- "AudioRecorder",
- sizeof(CAudioRecorder),
- SL_OBJECTID_AUDIORECORDER,
- 0, // OpenMAX AL object ID
- CAudioRecorder_Realize,
- CAudioRecorder_Resume,
- CAudioRecorder_Destroy,
- CAudioRecorder_PreDestroy
-};
-
-#endif
-
-
-// Engine class
-
-static const struct iid_vtable Engine_interfaces[INTERFACES_Engine] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CEngine, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CEngine, mDynamicInterfaceManagement)},
- {MPH_ENGINE, INTERFACE_IMPLICIT, offsetof(CEngine, mEngine)},
- {MPH_ENGINECAPABILITIES, INTERFACE_IMPLICIT_BASE, offsetof(CEngine, mEngineCapabilities)},
- {MPH_THREADSYNC, INTERFACE_IMPLICIT_BASE, offsetof(CEngine, mThreadSync)},
- {MPH_AUDIOIODEVICECAPABILITIES, INTERFACE_IMPLICIT_BASE,
- offsetof(CEngine, mAudioIODeviceCapabilities)},
- {MPH_AUDIODECODERCAPABILITIES, INTERFACE_EXPLICIT_BASE,
- offsetof(CEngine, mAudioDecoderCapabilities)},
- {MPH_AUDIOENCODERCAPABILITIES, INTERFACE_EXPLICIT_BASE,
- offsetof(CEngine, mAudioEncoderCapabilities)},
- {MPH_3DCOMMIT, INTERFACE_EXPLICIT_GAME, offsetof(CEngine, m3DCommit)},
- {MPH_DEVICEVOLUME, INTERFACE_OPTIONAL, offsetof(CEngine, mDeviceVolume)},
- {MPH_XAENGINE, INTERFACE_IMPLICIT, offsetof(CEngine, mXAEngine)},
-#ifdef ANDROID
- {MPH_ANDROIDEFFECTCAPABILITIES, INTERFACE_EXPLICIT,
- offsetof(CEngine, mAndroidEffectCapabilities)},
-#endif
- {MPH_XAVIDEODECODERCAPABILITIES, INTERFACE_EXPLICIT,
- offsetof(CEngine, mVideoDecoderCapabilities)},
-};
-
-static const ClassTable CEngine_class = {
- Engine_interfaces,
- INTERFACES_Engine,
- MPH_to_Engine,
- "Engine",
- sizeof(CEngine),
- SL_OBJECTID_ENGINE,
- XA_OBJECTID_ENGINE,
- CEngine_Realize,
- CEngine_Resume,
- CEngine_Destroy,
- CEngine_PreDestroy
-};
-
-
-#if USE_PROFILES & USE_PROFILES_OPTIONAL
-
-// LEDDevice class
-
-static const struct iid_vtable LEDDevice_interfaces[INTERFACES_LEDDevice] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CLEDDevice, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CLEDDevice, mDynamicInterfaceManagement)},
- {MPH_LED, INTERFACE_IMPLICIT, offsetof(CLEDDevice, mLEDArray)},
-};
-
-static const ClassTable CLEDDevice_class = {
- LEDDevice_interfaces,
- INTERFACES_LEDDevice,
- MPH_to_LEDDevice,
- "LEDDevice",
- sizeof(CLEDDevice),
- SL_OBJECTID_LEDDEVICE,
- XA_OBJECTID_LEDDEVICE,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-#endif
-
-
-#if USE_PROFILES & USE_PROFILES_GAME
-
-// Listener class
-
-static const struct iid_vtable Listener_interfaces[INTERFACES_Listener] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CListener, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CListener, mDynamicInterfaceManagement)},
- {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(CListener, m3DDoppler)},
- {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME, offsetof(CListener, m3DLocation)},
-};
-
-static const ClassTable CListener_class = {
- Listener_interfaces,
- INTERFACES_Listener,
- MPH_to_Listener,
- "Listener",
- sizeof(CListener),
- SL_OBJECTID_LISTENER,
- 0, // OpenMAX AL object ID
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-#endif
-
-
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
-
-// MetadataExtractor class
-
-static const struct iid_vtable MetadataExtractor_interfaces[INTERFACES_MetadataExtractor] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CMetadataExtractor, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CMetadataExtractor, mDynamicInterfaceManagement)},
- {MPH_DYNAMICSOURCE, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mDynamicSource)},
- {MPH_METADATAEXTRACTION, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mMetadataExtraction)},
- {MPH_METADATATRAVERSAL, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mMetadataTraversal)},
-};
-
-static const ClassTable CMetadataExtractor_class = {
- MetadataExtractor_interfaces,
- INTERFACES_MetadataExtractor,
- MPH_to_MetadataExtractor,
- "MetadataExtractor",
- sizeof(CMetadataExtractor),
- SL_OBJECTID_METADATAEXTRACTOR,
- XA_OBJECTID_METADATAEXTRACTOR,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-#endif
-
-
-#if USE_PROFILES & USE_PROFILES_GAME
-
-// MidiPlayer class
-
-static const struct iid_vtable MidiPlayer_interfaces[INTERFACES_MidiPlayer] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CMidiPlayer, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CMidiPlayer, mDynamicInterfaceManagement)},
- {MPH_PLAY, INTERFACE_IMPLICIT, offsetof(CMidiPlayer, mPlay)},
- {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(C3DGroup, m3DDoppler)},
- {MPH_3DGROUPING, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, m3DGrouping)},
- {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, m3DLocation)},
- {MPH_3DSOURCE, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, m3DSource)},
- {MPH_BUFFERQUEUE, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mBufferQueue)},
- {MPH_EFFECTSEND, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mEffectSend)},
- {MPH_MUTESOLO, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mMuteSolo)},
- {MPH_METADATAEXTRACTION, INTERFACE_DYNAMIC_GAME, offsetof(CMidiPlayer, mMetadataExtraction)},
- {MPH_METADATATRAVERSAL, INTERFACE_DYNAMIC_GAME, offsetof(CMidiPlayer, mMetadataTraversal)},
- {MPH_MIDIMESSAGE, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mMIDIMessage)},
- {MPH_MIDITIME, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mMIDITime)},
- {MPH_MIDITEMPO, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mMIDITempo)},
- {MPH_MIDIMUTESOLO, INTERFACE_EXPLICIT_GAME, offsetof(CMidiPlayer, mMIDIMuteSolo)},
- {MPH_PREFETCHSTATUS, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mPrefetchStatus)},
- {MPH_SEEK, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mSeek)},
- {MPH_VOLUME, INTERFACE_EXPLICIT_GAME_PHONE, offsetof(CMidiPlayer, mVolume)},
- {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, m3DMacroscopic)},
- {MPH_BASSBOOST, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mBassBoost)},
- {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mDynamicSource)},
- {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC_OPTIONAL,
- offsetof(CMidiPlayer, mEnvironmentalReverb)},
- {MPH_EQUALIZER, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mEqualizer)},
- {MPH_PITCH, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mPitch)},
- {MPH_PRESETREVERB, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mPresetReverb)},
- {MPH_PLAYBACKRATE, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mPlaybackRate)},
- {MPH_VIRTUALIZER, INTERFACE_DYNAMIC_OPTIONAL, offsetof(CMidiPlayer, mVirtualizer)},
- {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mVisualization)},
-};
-
-static const ClassTable CMidiPlayer_class = {
- MidiPlayer_interfaces,
- INTERFACES_MidiPlayer,
- MPH_to_MidiPlayer,
- "MidiPlayer",
- sizeof(CMidiPlayer),
- SL_OBJECTID_MIDIPLAYER,
- 0, // OpenMAX AL object ID
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-#endif
-
-
-// OutputMix class
-
-static const struct iid_vtable OutputMix_interfaces[INTERFACES_OutputMix] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(COutputMix, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(COutputMix, mDynamicInterfaceManagement)},
- {MPH_OUTPUTMIX, INTERFACE_IMPLICIT, offsetof(COutputMix, mOutputMix)},
-#ifdef USE_OUTPUTMIXEXT
- {MPH_OUTPUTMIXEXT, INTERFACE_UNAVAILABLE, offsetof(COutputMix, mOutputMixExt)},
-#else
- {MPH_OUTPUTMIXEXT, INTERFACE_UNAVAILABLE, 0},
-#endif
- {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC,
- offsetof(COutputMix, mEnvironmentalReverb)},
- {MPH_EQUALIZER, INTERFACE_DYNAMIC, offsetof(COutputMix, mEqualizer)},
- {MPH_PRESETREVERB, INTERFACE_DYNAMIC, offsetof(COutputMix, mPresetReverb)},
- {MPH_VIRTUALIZER, INTERFACE_DYNAMIC, offsetof(COutputMix, mVirtualizer)},
- // The overall Volume interface is explicit optional,
- // but portions of Volume are mandated only in Game and Music profiles
- {MPH_VOLUME, INTERFACE_OPTIONAL, offsetof(COutputMix, mVolume)},
- {MPH_BASSBOOST, INTERFACE_DYNAMIC, offsetof(COutputMix, mBassBoost)},
- {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(COutputMix, mVisualization)},
-#ifdef ANDROID
- {MPH_ANDROIDEFFECT, INTERFACE_EXPLICIT, offsetof(COutputMix, mAndroidEffect)},
-#endif
-};
-
-static const ClassTable COutputMix_class = {
- OutputMix_interfaces,
- INTERFACES_OutputMix,
- MPH_to_OutputMix,
- "OutputMix",
- sizeof(COutputMix),
- SL_OBJECTID_OUTPUTMIX,
- XA_OBJECTID_OUTPUTMIX,
- COutputMix_Realize,
- COutputMix_Resume,
- COutputMix_Destroy,
- COutputMix_PreDestroy
-};
-
-
-#if USE_PROFILES & USE_PROFILES_OPTIONAL
-
-// Vibra class
-
-static const struct iid_vtable VibraDevice_interfaces[INTERFACES_VibraDevice] = {
- {MPH_OBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CVibraDevice, mObject)},
- {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CVibraDevice, mDynamicInterfaceManagement)},
- {MPH_VIBRA, INTERFACE_IMPLICIT, offsetof(CVibraDevice, mVibra)},
-};
-
-static const ClassTable CVibraDevice_class = {
- VibraDevice_interfaces,
- INTERFACES_VibraDevice,
- MPH_to_Vibra,
- "VibraDevice",
- sizeof(CVibraDevice),
- SL_OBJECTID_VIBRADEVICE,
- XA_OBJECTID_VIBRADEVICE,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-#endif
-
-
-// Media player class
-
-static const struct iid_vtable MediaPlayer_interfaces[INTERFACES_MediaPlayer] = {
- {MPH_XAOBJECT, INTERFACE_IMPLICIT_PREREALIZE, offsetof(CMediaPlayer, mObject)},
- {MPH_XADYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
- offsetof(CMediaPlayer, mDynamicInterfaceManagement)},
- {MPH_XAPLAY, INTERFACE_IMPLICIT, offsetof(CMediaPlayer, mPlay)},
- {MPH_XASTREAMINFORMATION, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mStreamInfo)},
- {MPH_XAVOLUME, INTERFACE_IMPLICIT, offsetof(CMediaPlayer, mVolume)},
- {MPH_XASEEK, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mSeek)},
- {MPH_XAPREFETCHSTATUS, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mPrefetchStatus)},
-#ifdef ANDROID
- {MPH_ANDROIDBUFFERQUEUESOURCE, INTERFACE_EXPLICIT, offsetof(CMediaPlayer, mAndroidBufferQueue)},
-#endif
-};
-
-static const ClassTable CMediaPlayer_class = {
- MediaPlayer_interfaces,
- INTERFACES_MediaPlayer,
- MPH_to_MediaPlayer,
- "MediaPlayer",
- sizeof(CMediaPlayer),
- 0, // OpenSL ES object ID
- XA_OBJECTID_MEDIAPLAYER,
- CMediaPlayer_Realize,
- CMediaPlayer_Resume,
- CMediaPlayer_Destroy,
- CMediaPlayer_PreDestroy
-};
-
-
-static const ClassTable * const slClasses[] = {
- // Do not change order of these entries; they are in numerical order
- &CEngine_class,
-#if USE_PROFILES & USE_PROFILES_OPTIONAL
- &CLEDDevice_class,
- &CVibraDevice_class,
-#else
- NULL,
- NULL,
-#endif
- &CAudioPlayer_class,
-#if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
- &CAudioRecorder_class,
-#else
- NULL,
-#endif
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_PHONE)
- &CMidiPlayer_class,
-#else
- NULL,
-#endif
-#if USE_PROFILES & USE_PROFILES_GAME
- &CListener_class,
- &C3DGroup_class,
-#else
- NULL,
- NULL,
-#endif
- &COutputMix_class,
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
- &CMetadataExtractor_class
-#else
- NULL
-#endif
-};
-
-
-static const ClassTable * const xaClasses[] = {
- &CEngine_class,
-#if USE_PROFILES & USE_PROFILES_OPTIONAL
- &CLEDDevice_class,
- &CVibraDevice_class,
-#else
- NULL,
- NULL,
-#endif
- &CMediaPlayer_class,
-#if 1
- NULL,
- NULL,
-#else
- &CMediaRecorder_class,
- &CRadioDevice_class,
-#endif
- &COutputMix_class,
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
- &CMetadataExtractor_class,
-#else
- NULL,
-#endif
-#if 1
- NULL
-#else
- &CCameraDevice_class
-#endif
-};
-
-
-/* \brief Map SL_OBJECTID to class or NULL if object ID not supported */
-
-LI_API const ClassTable *objectIDtoClass(SLuint32 objectID)
-{
- // object ID is the engine and always present
- assert(NULL != slClasses[0]);
- SLuint32 slObjectID0 = slClasses[0]->mSLObjectID;
- if ((slObjectID0 <= objectID) && ((slObjectID0 + sizeof(slClasses)/sizeof(slClasses[0])) >
- objectID)) {
- return slClasses[objectID - slObjectID0];
- }
- assert(NULL != xaClasses[0]);
- SLuint32 xaObjectID0 = xaClasses[0]->mXAObjectID;
- if ((xaObjectID0 <= objectID) && ((xaObjectID0 + sizeof(xaClasses)/sizeof(xaClasses[0])) >
- objectID)) {
- return xaClasses[objectID - xaObjectID0];
- }
- return NULL;
-}
diff --git a/wilhelm/src/classes.h b/wilhelm/src/classes.h
deleted file mode 100644
index 6bbadd1..0000000
--- a/wilhelm/src/classes.h
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifdef ANDROID
-#include "android/AudioTrackProxy.h"
-#include "android/CallbackProtector.h"
-#include "android/android_Effect.h"
-#include "android/android_GenericPlayer.h"
-#endif
-
-// Class structures
-
-
-/*typedef*/ struct CAudioPlayer_struct {
- IObject mObject;
-#ifdef ANDROID
-#define INTERFACES_AudioPlayer 30 // see MPH_to_AudioPlayer in MPH_to.c for list of interfaces
-#else
-#define INTERFACES_AudioPlayer 26 // see MPH_to_AudioPlayer in MPH_to.c for list of interfaces
-#endif
- SLuint8 mInterfaceStates2[INTERFACES_AudioPlayer - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IPlay mPlay;
- I3DDoppler m3DDoppler;
- I3DGrouping m3DGrouping;
- I3DLocation m3DLocation;
- I3DSource m3DSource;
- IBufferQueue mBufferQueue;
- IEffectSend mEffectSend;
- IMetadataExtraction mMetadataExtraction;
- IMetadataTraversal mMetadataTraversal;
- IPrefetchStatus mPrefetchStatus;
- IRatePitch mRatePitch;
- ISeek mSeek;
- IVolume mVolume;
- IMuteSolo mMuteSolo;
-#ifdef ANDROID
- IAndroidEffect mAndroidEffect;
- IAndroidEffectSend mAndroidEffectSend;
- IAndroidConfiguration mAndroidConfiguration;
- IAndroidBufferQueue mAndroidBufferQueue;
-#endif
- // optional interfaces
- I3DMacroscopic m3DMacroscopic;
- IBassBoost mBassBoost;
- IDynamicSource mDynamicSource;
- IEnvironmentalReverb mEnvironmentalReverb;
- IEqualizer mEqualizer;
- IPitch mPitch;
- IPresetReverb mPresetReverb;
- IPlaybackRate mPlaybackRate;
- IVirtualizer mVirtualizer;
- IVisualization mVisualization;
- // fields below are per-instance private fields not associated with an interface
- DataLocatorFormat mDataSource;
- DataLocatorFormat mDataSink;
- // cached data for this instance
- // Formerly at IMuteSolo
- SLuint8 mMuteMask; // Mask for which channels are muted: bit 0=left, 1=right
- SLuint8 mSoloMask; // Mask for which channels are soloed: bit 0=left, 1=right
- SLuint8 mNumChannels; // initially UNKNOWN_NUMCHANNELS, then const once it is known,
- // range 1 <= x <= 8
- // End of former IMuteSolo fields
- SLuint32 mSampleRateMilliHz;// initially UNKNOWN_SAMPLERATE, then const once it is known
- // Formerly at IEffectSend
- /**
- * Dry volume modified by effect send interfaces: SLEffectSendItf and SLAndroidEffectSendItf
- */
- SLmillibel mDirectLevel;
- // implementation-specific data for this instance
-#ifdef USE_OUTPUTMIXEXT
- Track *mTrack;
- float mGains[STEREO_CHANNELS]; ///< Computed gain based on volume, mute, solo, stereo position
- SLboolean mDestroyRequested; ///< Mixer to acknowledge application's call to Object::Destroy
-#endif
-#ifdef USE_SNDFILE
- struct SndFile mSndFile;
-#endif // USE_SNDFILE
-#ifdef ANDROID
- enum AndroidObjectType mAndroidObjType;
- /** identifies the initialization and preparation state */
- enum AndroidObjectState mAndroidObjState;
- /** identifies which group of effects ("session") this player belongs to */
- int mSessionId;
- /** identifies the Android stream type playback will occur on */
- int mStreamType;
- // FIXME consolidate the next several variables into one class to avoid placement new
- /** plays the PCM data for this player */
- android::sp<android::AudioTrackProxy> mAudioTrack;
- android::sp<android::CallbackProtector> mCallbackProtector;
- android::sp<android::GenericPlayer> mAPlayer;
- /** aux effect the AudioTrack will be attached to if aux send enabled */
- android::sp<android::AudioEffect> mAuxEffect;
- // FIXME all levels below need to be encapsulated in a field of type AndroidAudioLevels
- /** send level to aux effect, there's a single aux bus, so there's a single level */
- SLmillibel mAuxSendLevel;
- /**
- * Attenuation factor derived from direct level
- */
- float mAmplFromDirectLevel;
- /** FIXME whether to call AudioTrack::start() at the next safe opportunity */
- bool mDeferredStart;
-#endif
-} /*CAudioPlayer*/;
-
-
-/*typedef*/ struct CAudioRecorder_struct {
- // mandated interfaces
- IObject mObject;
-#ifdef ANDROID
-#define INTERFACES_AudioRecorder 11 // see MPH_to_AudioRecorder in MPH_to.c for list of interfaces
-#else
-#define INTERFACES_AudioRecorder 9 // see MPH_to_AudioRecorder in MPH_to.c for list of interfaces
-#endif
- SLuint8 mInterfaceStates2[INTERFACES_AudioRecorder - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IRecord mRecord;
- IAudioEncoder mAudioEncoder;
- // optional interfaces
- IBassBoost mBassBoost;
- IDynamicSource mDynamicSource;
- IEqualizer mEqualizer;
- IVisualization mVisualization;
- IVolume mVolume;
-#ifdef ANDROID
- IBufferQueue mBufferQueue;
- IAndroidConfiguration mAndroidConfiguration;
-#endif
- // remaining are per-instance private fields not associated with an interface
- DataLocatorFormat mDataSource;
- DataLocatorFormat mDataSink;
- // cached data for this instance
- SLuint8 mNumChannels; // initially UNKNOWN_NUMCHANNELS, then const once it is known,
- // range 1 <= x <= 8
- SLuint32 mSampleRateMilliHz;// initially UNKNOWN_SAMPLERATE, then const once it is known
- // implementation-specific data for this instance
-#ifdef ANDROID
- enum AndroidObjectType mAndroidObjType;
- android::AudioRecord *mAudioRecord; //FIXME candidate to be encapsulated in a ARecorder subclass
- int mRecordSource; //FIXME candidate to be encapsulated in a ARecorder subclass
-#endif
-} /*CAudioRecorder*/;
-
-
-/*typedef*/ struct CEngine_struct {
- // mandated implicit interfaces
- IObject mObject;
-#ifdef ANDROID
-#define INTERFACES_Engine 13 // see MPH_to_Engine in MPH_to.c for list of interfaces
-#else
-#define INTERFACES_Engine 12 // see MPH_to_Engine in MPH_to.c for list of interfaces
-#endif
- SLuint8 mInterfaceStates2[INTERFACES_Engine - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IEngine mEngine;
- IEngineCapabilities mEngineCapabilities;
- IThreadSync mThreadSync;
- // mandated explicit interfaces
- IAudioIODeviceCapabilities mAudioIODeviceCapabilities;
- IAudioDecoderCapabilities mAudioDecoderCapabilities;
- IAudioEncoderCapabilities mAudioEncoderCapabilities;
- I3DCommit m3DCommit;
- // optional interfaces
- IDeviceVolume mDeviceVolume;
- // OpenMAX AL mandated implicit interfaces
- IXAEngine mXAEngine;
-#ifdef ANDROID
- IAndroidEffectCapabilities mAndroidEffectCapabilities;
-#endif
- // OpenMAX AL explicit interfaces
- IVideoDecoderCapabilities mVideoDecoderCapabilities;
- // remaining are per-instance private fields not associated with an interface
- ThreadPool mThreadPool; // for asynchronous operations
- pthread_t mSyncThread;
-#if defined(ANDROID)
- // FIXME number of presets will only be saved in IEqualizer, preset names will not be stored
- SLuint32 mEqNumPresets;
- char** mEqPresetNames;
-#endif
-} /*CEngine*/;
-
-typedef struct {
- // mandated interfaces
- IObject mObject;
-#define INTERFACES_LEDDevice 3 // see MPH_to_LEDDevice in MPH_to.c for list of interfaces
- SLuint8 mInterfaceStates2[INTERFACES_LEDDevice - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- ILEDArray mLEDArray;
- // remaining are per-instance private fields not associated with an interface
- SLuint32 mDeviceID;
-} CLEDDevice;
-
-typedef struct {
- // mandated interfaces
- IObject mObject;
-#define INTERFACES_Listener 4 // see MPH_to_Listener in MPH_to.c for list of interfaces
- SLuint8 mInterfaceStates2[INTERFACES_Listener - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- I3DDoppler m3DDoppler;
- I3DLocation m3DLocation;
- // remaining are per-instance private fields not associated with an interface
-} CListener;
-
-typedef struct {
- // mandated interfaces
- IObject mObject;
-#define INTERFACES_MetadataExtractor 5 // see MPH_to_MetadataExtractor in MPH_to.c for list of
- // interfaces
- SLuint8 mInterfaceStates2[INTERFACES_MetadataExtractor - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IDynamicSource mDynamicSource;
- IMetadataExtraction mMetadataExtraction;
- IMetadataTraversal mMetadataTraversal;
- // remaining are per-instance private fields not associated with an interface
-} CMetadataExtractor;
-
-typedef struct {
- // mandated interfaces
- IObject mObject;
-
-#define INTERFACES_MidiPlayer 29 // see MPH_to_MidiPlayer in MPH_to.c for list of interfaces
- SLuint8 mInterfaceStates2[INTERFACES_MidiPlayer - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IPlay mPlay;
- I3DDoppler m3DDoppler;
- I3DGrouping m3DGrouping;
- I3DLocation m3DLocation;
- I3DSource m3DSource;
- IBufferQueue mBufferQueue;
- IEffectSend mEffectSend;
- IMetadataExtraction mMetadataExtraction;
- IMetadataTraversal mMetadataTraversal;
- IMIDIMessage mMIDIMessage;
- IMIDITime mMIDITime;
- IMIDITempo mMIDITempo;
- IMIDIMuteSolo mMIDIMuteSolo;
- IPrefetchStatus mPrefetchStatus;
- ISeek mSeek;
- IVolume mVolume;
- IMuteSolo mMuteSolo;
- // optional interfaces
- I3DMacroscopic m3DMacroscopic;
- IBassBoost mBassBoost;
- IDynamicSource mDynamicSource;
- IEnvironmentalReverb mEnvironmentalReverb;
- IEqualizer mEqualizer;
- IPitch mPitch;
- IPresetReverb mPresetReverb;
- IPlaybackRate mPlaybackRate;
- IVirtualizer mVirtualizer;
- IVisualization mVisualization;
- // remaining are per-instance private fields not associated with an interface
-} CMidiPlayer;
-
-/*typedef*/ struct COutputMix_struct {
- // mandated interfaces
- IObject mObject;
-#ifdef ANDROID
-#define INTERFACES_OutputMix 12 // see MPH_to_OutputMix in MPH_to.c for list of interfaces
-#else
-#define INTERFACES_OutputMix 11 // see MPH_to_OutputMix in MPH_to.c for list of interfaces
-#endif
- SLuint8 mInterfaceStates2[INTERFACES_OutputMix - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IOutputMix mOutputMix;
-#ifdef USE_OUTPUTMIXEXT
- IOutputMixExt mOutputMixExt;
-#endif
- IEnvironmentalReverb mEnvironmentalReverb;
- IEqualizer mEqualizer;
- IPresetReverb mPresetReverb;
- IVirtualizer mVirtualizer;
- IVolume mVolume;
- // optional interfaces
- IBassBoost mBassBoost;
- IVisualization mVisualization;
-#ifdef ANDROID
- IAndroidEffect mAndroidEffect;
-#endif
- // remaining are per-instance private fields not associated with an interface
-} /*COutputMix*/;
-
-typedef struct {
- // mandated interfaces
- IObject mObject;
-#define INTERFACES_VibraDevice 3 // see MPH_to_VibraDevice in MPH_to.c for list of interfaces
- SLuint8 mInterfaceStates2[INTERFACES_VibraDevice - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IVibra mVibra;
- // remaining are per-instance private fields not associated with an interface
- SLuint32 mDeviceID;
-} CVibraDevice;
-
-
-typedef struct CMediaPlayer_struct {
- IObject mObject;
-#ifdef ANDROID
-#define INTERFACES_MediaPlayer 8
-#else
-#define INTERFACES_MediaPlayer 7
-#endif
- XAuint8 mInterfaceStates2[INTERFACES_MediaPlayer - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- IDynamicSource mDynamicSource;
- IPlay mPlay;
- IStreamInformation mStreamInfo;
- IVolume mVolume;
- ISeek mSeek;
- IPrefetchStatus mPrefetchStatus;
-#ifdef ANDROID
- IAndroidBufferQueue mAndroidBufferQueue;
-#endif
- // fields below are per-instance private fields not associated with an interface
- DataLocatorFormat mDataSource;
- DataLocatorFormat mBankSource;
- DataLocatorFormat mAudioSink;
- DataLocatorFormat mImageVideoSink;
- DataLocatorFormat mVibraSink;
- DataLocatorFormat mLEDArraySink;
- SLuint8 mNumChannels; // initially UNKNOWN_NUMCHANNELS, then const once it is known,
- // range 1 <= x <= 8
-#ifdef ANDROID
- android::sp<android::GenericPlayer> mAVPlayer;
- android::sp<android::CallbackProtector> mCallbackProtector;
- enum AndroidObjectType mAndroidObjType;
- /** identifies the initialization and preparation state */
- enum AndroidObjectState mAndroidObjState;
- /** identifies which group of effects ("session") this player belongs to */
- int mSessionId;
- /** identifies the Android stream type playback will occur on */
- int mStreamType;
-#endif
-} CMediaPlayer;
diff --git a/wilhelm/src/data.c b/wilhelm/src/data.c
deleted file mode 100644
index 727b484..0000000
--- a/wilhelm/src/data.c
+++ /dev/null
@@ -1,896 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Data locator, data format, data source, and data sink support */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Check a data locator and make local deep copy */
-
-static SLresult checkDataLocator(const char *name, void *pLocator, DataLocator *pDataLocator,
- SLuint32 allowedDataLocatorMask)
-{
- assert(NULL != name && NULL != pDataLocator);
- SLresult result = SL_RESULT_SUCCESS;
-
- SLuint32 locatorType;
- if (NULL == pLocator) {
- pDataLocator->mLocatorType = locatorType = SL_DATALOCATOR_NULL;
- } else {
- locatorType = *(SLuint32 *)pLocator;
- switch (locatorType) {
-
- case SL_DATALOCATOR_ADDRESS:
- pDataLocator->mAddress = *(SLDataLocator_Address *)pLocator;
- // if length is greater than zero, then the address must be non-NULL
- if ((0 < pDataLocator->mAddress.length) && (NULL == pDataLocator->mAddress.pAddress)) {
- SL_LOGE("%s: pAddress=NULL", name);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
-
- case SL_DATALOCATOR_BUFFERQUEUE:
-#ifdef ANDROID
- // This is an alias that is _not_ converted; the rest of the code must check for both
- // locator types. That's because it is only an alias for audio players, not audio recorder
- // objects so we have to remember the distinction.
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
-#endif
- pDataLocator->mBufferQueue = *(SLDataLocator_BufferQueue *)pLocator;
- // number of buffers must be specified, there is no default value, and can't be too big
- if (!((1 <= pDataLocator->mBufferQueue.numBuffers) &&
- (pDataLocator->mBufferQueue.numBuffers <= 255))) {
- SL_LOGE("%s: numBuffers=%u", name, pDataLocator->mBufferQueue.numBuffers);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
-
- case SL_DATALOCATOR_IODEVICE:
- {
- pDataLocator->mIODevice = *(SLDataLocator_IODevice *)pLocator;
- SLuint32 deviceType = pDataLocator->mIODevice.deviceType;
- SLObjectItf device = pDataLocator->mIODevice.device;
- if (NULL != device) {
- pDataLocator->mIODevice.deviceID = 0;
- SLuint32 expectedObjectID;
- switch (deviceType) {
- case SL_IODEVICE_LEDARRAY:
- expectedObjectID = SL_OBJECTID_LEDDEVICE;
- break;
- case SL_IODEVICE_VIBRA:
- expectedObjectID = SL_OBJECTID_VIBRADEVICE;
- break;
- case XA_IODEVICE_CAMERA:
- expectedObjectID = XA_OBJECTID_CAMERADEVICE;
- break;
- case XA_IODEVICE_RADIO:
- expectedObjectID = XA_OBJECTID_RADIODEVICE;
- break;
- // audio input and audio output cannot be specified via objects
- case SL_IODEVICE_AUDIOINPUT:
- // case SL_IODEVICE_AUDIOOUTPUT: // does not exist in 1.0.1, added in 1.1
- default:
- SL_LOGE("%s: deviceType=%u", name, deviceType);
- pDataLocator->mIODevice.device = NULL;
- expectedObjectID = 0;
- result = SL_RESULT_PARAMETER_INVALID;
- }
- if (result == SL_RESULT_SUCCESS) {
- // check that device has the correct object ID and is realized,
- // and acquire a strong reference to it
- result = AcquireStrongRef((IObject *) device, expectedObjectID);
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: locatorType=IODEVICE, but device field %p has wrong " \
- "object ID or is not realized", name, device);
- pDataLocator->mIODevice.device = NULL;
- }
- }
- } else {
- SLuint32 deviceID = pDataLocator->mIODevice.deviceID;
- switch (deviceType) {
- case SL_IODEVICE_LEDARRAY:
- if (SL_DEFAULTDEVICEID_LED != deviceID) {
- SL_LOGE("%s: invalid LED deviceID=%u", name, deviceID);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- case SL_IODEVICE_VIBRA:
- if (SL_DEFAULTDEVICEID_VIBRA != deviceID) {
- SL_LOGE("%s: invalid vibra deviceID=%u", name, deviceID);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- case SL_IODEVICE_AUDIOINPUT:
- if (SL_DEFAULTDEVICEID_AUDIOINPUT != deviceID) {
- SL_LOGE("%s: invalid audio input deviceID=%u", name, deviceID);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- case XA_IODEVICE_RADIO:
- // no default device ID for radio; see Khronos bug XXXX
- break;
- case XA_IODEVICE_CAMERA:
- if (XA_DEFAULTDEVICEID_CAMERA != deviceID) {
- SL_LOGE("%s: invalid audio input deviceID=%u", name, deviceID);
- result = XA_RESULT_PARAMETER_INVALID;
- }
- break;
- // case SL_IODEVICE_AUDIOOUTPUT:
- // does not exist in 1.0.1, added in 1.1
- // break;
- default:
- SL_LOGE("%s: deviceType=%u is invalid", name, deviceType);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
- }
- break;
-
- case SL_DATALOCATOR_MIDIBUFFERQUEUE:
- pDataLocator->mMIDIBufferQueue = *(SLDataLocator_MIDIBufferQueue *)pLocator;
- if (0 == pDataLocator->mMIDIBufferQueue.tpqn) {
- pDataLocator->mMIDIBufferQueue.tpqn = 192;
- }
- // number of buffers must be specified, there is no default value, and can't be too big
- if (!((1 <= pDataLocator->mMIDIBufferQueue.numBuffers) &&
- (pDataLocator->mMIDIBufferQueue.numBuffers <= 255))) {
- SL_LOGE("%s: SLDataLocator_MIDIBufferQueue.numBuffers=%d", name,
- pDataLocator->mMIDIBufferQueue.numBuffers);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
-
- case SL_DATALOCATOR_OUTPUTMIX:
- pDataLocator->mOutputMix = *(SLDataLocator_OutputMix *)pLocator;
- // check that output mix object has the correct object ID and is realized,
- // and acquire a strong reference to it
- result = AcquireStrongRef((IObject *) pDataLocator->mOutputMix.outputMix,
- SL_OBJECTID_OUTPUTMIX);
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: locatorType=SL_DATALOCATOR_OUTPUTMIX, but outputMix field %p does " \
- "not refer to an SL_OBJECTID_OUTPUTMIX or the output mix is not realized", \
- name, pDataLocator->mOutputMix.outputMix);
- pDataLocator->mOutputMix.outputMix = NULL;
- }
- break;
-
- case XA_DATALOCATOR_NATIVEDISPLAY:
- pDataLocator->mNativeDisplay = *(XADataLocator_NativeDisplay *)pLocator;
- // hWindow is NDK C ANativeWindow * and hDisplay must be NULL
- if (pDataLocator->mNativeDisplay.hWindow == NULL) {
- SL_LOGE("%s: hWindow must be non-NULL ANativeWindow *", name);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- if (pDataLocator->mNativeDisplay.hDisplay != NULL) {
- SL_LOGE("%s: hDisplay must be NULL, but is %p", name,
- pDataLocator->mNativeDisplay.hDisplay);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
-
- case SL_DATALOCATOR_URI:
- {
- pDataLocator->mURI = *(SLDataLocator_URI *)pLocator;
- if (NULL == pDataLocator->mURI.URI) {
- SL_LOGE("%s: invalid URI=NULL", name);
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- // NTH verify URI address for validity
- size_t len = strlen((const char *) pDataLocator->mURI.URI);
- SLchar *myURI = (SLchar *) malloc(len + 1);
- if (NULL == myURI) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
- memcpy(myURI, pDataLocator->mURI.URI, len + 1);
- // Verify that another thread didn't change the NUL-terminator after we used it
- // to determine length of string to copy. It's OK if the string became shorter.
- if ('\0' != myURI[len]) {
- free(myURI);
- myURI = NULL;
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
- pDataLocator->mURI.URI = myURI;
- }
- }
- break;
-
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDFD:
- {
- pDataLocator->mFD = *(SLDataLocator_AndroidFD *)pLocator;
- SL_LOGV("%s: fd=%d offset=%lld length=%lld", name, pDataLocator->mFD.fd,
- pDataLocator->mFD.offset, pDataLocator->mFD.length);
- // NTH check against process fd limit
- if (0 > pDataLocator->mFD.fd) {
- SL_LOGE("%s: fd=%d\n", name, pDataLocator->mFD.fd);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- }
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- {
- pDataLocator->mABQ = *(SLDataLocator_AndroidBufferQueue*)pLocator;
- // number of buffers must be specified, there is no default value, and can't be too big
- if (!((1 <= pDataLocator->mBufferQueue.numBuffers) &&
- (pDataLocator->mBufferQueue.numBuffers <= 255))) {
- SL_LOGE("%s: numBuffers=%u", name, pDataLocator->mABQ.numBuffers);
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- }
-#endif
-
- case SL_DATALOCATOR_NULL: // a NULL pointer is allowed, but not a pointer to NULL
- default:
- SL_LOGE("%s: locatorType=%u", name, locatorType);
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- // Verify that another thread didn't change the locatorType field after we used it
- // to determine sizeof struct to copy.
- if ((SL_RESULT_SUCCESS == result) && (locatorType != pDataLocator->mLocatorType)) {
- SL_LOGE("%s: locatorType changed from %u to %u", name, locatorType,
- pDataLocator->mLocatorType);
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- }
-
- }
-
- // Verify that the data locator type is allowed in this context
- if (SL_RESULT_SUCCESS == result) {
- SLuint32 actualMask;
- switch (locatorType) {
- case SL_DATALOCATOR_NULL:
- case SL_DATALOCATOR_URI:
- case SL_DATALOCATOR_ADDRESS:
- case SL_DATALOCATOR_IODEVICE:
- case SL_DATALOCATOR_OUTPUTMIX:
- case XA_DATALOCATOR_NATIVEDISPLAY:
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_MIDIBUFFERQUEUE:
- actualMask = 1L << locatorType;
- break;
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDFD:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- actualMask = 0x100L << (locatorType - SL_DATALOCATOR_ANDROIDFD);
- break;
-#endif
- default:
- assert(false);
- actualMask = 0L;
- break;
- }
- if (!(allowedDataLocatorMask & actualMask)) {
- SL_LOGE("%s: data locator type 0x%x not allowed", name, locatorType);
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- }
- }
-
- return result;
-}
-
-
-/** \brief Free the local deep copy of a data locator */
-
-static void freeDataLocator(DataLocator *pDataLocator)
-{
- switch (pDataLocator->mLocatorType) {
- case SL_DATALOCATOR_NULL:
- case SL_DATALOCATOR_ADDRESS:
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_MIDIBUFFERQUEUE:
- case XA_DATALOCATOR_NATIVEDISPLAY:
- break;
- case SL_DATALOCATOR_URI:
- if (NULL != pDataLocator->mURI.URI) {
- free(pDataLocator->mURI.URI);
- pDataLocator->mURI.URI = NULL;
- }
- pDataLocator->mURI.URI = NULL;
- break;
- case SL_DATALOCATOR_IODEVICE:
- if (NULL != pDataLocator->mIODevice.device) {
- ReleaseStrongRef((IObject *) pDataLocator->mIODevice.device);
- pDataLocator->mIODevice.device = NULL;
- }
- break;
- case SL_DATALOCATOR_OUTPUTMIX:
- if (NULL != pDataLocator->mOutputMix.outputMix) {
- ReleaseStrongRef((IObject *) pDataLocator->mOutputMix.outputMix);
- pDataLocator->mOutputMix.outputMix = NULL;
- }
- break;
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDFD:
- break;
-#endif
- default:
- // an invalid data locator is caught earlier when making the copy
- assert(false);
- break;
- }
-}
-
-
-/** \brief Check a data format and make local deep copy */
-
-static SLresult checkDataFormat(const char *name, void *pFormat, DataFormat *pDataFormat,
- SLuint32 allowedDataFormatMask)
-{
- assert(NULL != name && NULL != pDataFormat);
- SLresult result = SL_RESULT_SUCCESS;
-
- SLuint32 formatType;
- if (NULL == pFormat) {
- pDataFormat->mFormatType = formatType = SL_DATAFORMAT_NULL;
- } else {
- formatType = *(SLuint32 *)pFormat;
- switch (formatType) {
-
- case SL_DATAFORMAT_PCM:
- pDataFormat->mPCM = *(SLDataFormat_PCM *)pFormat;
- do {
-
- // check the channel count
- switch (pDataFormat->mPCM.numChannels) {
- case 1: // mono
- case 2: // stereo
- break;
- case 0: // unknown
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- default: // multi-channel
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- break;
- }
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: numChannels=%u", name, (unsigned) pDataFormat->mPCM.numChannels);
- break;
- }
-
- // check the sampling rate
- switch (pDataFormat->mPCM.samplesPerSec) {
- case SL_SAMPLINGRATE_8:
- case SL_SAMPLINGRATE_11_025:
- case SL_SAMPLINGRATE_12:
- case SL_SAMPLINGRATE_16:
- case SL_SAMPLINGRATE_22_05:
- case SL_SAMPLINGRATE_24:
- case SL_SAMPLINGRATE_32:
- case SL_SAMPLINGRATE_44_1:
- case SL_SAMPLINGRATE_48:
- case SL_SAMPLINGRATE_64:
- case SL_SAMPLINGRATE_88_2:
- case SL_SAMPLINGRATE_96:
- case SL_SAMPLINGRATE_192:
- break;
- case 0:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- default:
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- break;
- }
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: samplesPerSec=%u", name, pDataFormat->mPCM.samplesPerSec);
- break;
- }
-
- // check the sample bit depth
- switch (pDataFormat->mPCM.bitsPerSample) {
- case SL_PCMSAMPLEFORMAT_FIXED_8:
- case SL_PCMSAMPLEFORMAT_FIXED_16:
- break;
- case SL_PCMSAMPLEFORMAT_FIXED_20:
- case SL_PCMSAMPLEFORMAT_FIXED_24:
- case SL_PCMSAMPLEFORMAT_FIXED_28:
- case SL_PCMSAMPLEFORMAT_FIXED_32:
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: bitsPerSample=%u", name, pDataFormat->mPCM.bitsPerSample);
- break;
- }
-
- // check the container bit depth
- if (pDataFormat->mPCM.containerSize < pDataFormat->mPCM.bitsPerSample) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else if (pDataFormat->mPCM.containerSize != pDataFormat->mPCM.bitsPerSample) {
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- }
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: containerSize=%u, bitsPerSample=%u", name,
- (unsigned) pDataFormat->mPCM.containerSize,
- (unsigned) pDataFormat->mPCM.bitsPerSample);
- break;
- }
-
- // check the channel mask
- switch (pDataFormat->mPCM.channelMask) {
- case SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT:
- if (2 != pDataFormat->mPCM.numChannels) {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- case SL_SPEAKER_FRONT_LEFT:
- case SL_SPEAKER_FRONT_RIGHT:
- case SL_SPEAKER_FRONT_CENTER:
- if (1 != pDataFormat->mPCM.numChannels) {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- case 0:
- // The default of front left rather than center for mono may be non-intuitive,
- // but the left channel is the first channel for stereo or multichannel content.
- pDataFormat->mPCM.channelMask = pDataFormat->mPCM.numChannels == 2 ?
- SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT : SL_SPEAKER_FRONT_LEFT;
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: channelMask=0x%x numChannels=%u", name,
- pDataFormat->mPCM.channelMask, pDataFormat->mPCM.numChannels);
- break;
- }
-
- // check the endianness / byte order
- switch (pDataFormat->mPCM.endianness) {
- case SL_BYTEORDER_LITTLEENDIAN:
- case SL_BYTEORDER_BIGENDIAN:
- break;
- // native is proposed but not yet in spec
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("%s: endianness=%u", name, (unsigned) pDataFormat->mPCM.endianness);
- break;
- }
-
- // here if all checks passed successfully
-
- } while(0);
- break;
-
- case SL_DATAFORMAT_MIME:
- pDataFormat->mMIME = *(SLDataFormat_MIME *)pFormat;
- if (NULL != pDataFormat->mMIME.mimeType) {
- // NTH check address for validity
- size_t len = strlen((const char *) pDataFormat->mMIME.mimeType);
- SLchar *myMIME = (SLchar *) malloc(len + 1);
- if (NULL == myMIME) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
- memcpy(myMIME, pDataFormat->mMIME.mimeType, len + 1);
- // make sure MIME string was not modified asynchronously
- if ('\0' != myMIME[len]) {
- free(myMIME);
- myMIME = NULL;
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- }
- }
- pDataFormat->mMIME.mimeType = myMIME;
- }
- break;
-
- case XA_DATAFORMAT_RAWIMAGE:
- pDataFormat->mRawImage = *(XADataFormat_RawImage *)pFormat;
- switch (pDataFormat->mRawImage.colorFormat) {
- case XA_COLORFORMAT_MONOCHROME:
- case XA_COLORFORMAT_8BITRGB332:
- case XA_COLORFORMAT_12BITRGB444:
- case XA_COLORFORMAT_16BITARGB4444:
- case XA_COLORFORMAT_16BITARGB1555:
- case XA_COLORFORMAT_16BITRGB565:
- case XA_COLORFORMAT_16BITBGR565:
- case XA_COLORFORMAT_18BITRGB666:
- case XA_COLORFORMAT_18BITARGB1665:
- case XA_COLORFORMAT_19BITARGB1666:
- case XA_COLORFORMAT_24BITRGB888:
- case XA_COLORFORMAT_24BITBGR888:
- case XA_COLORFORMAT_24BITARGB1887:
- case XA_COLORFORMAT_25BITARGB1888:
- case XA_COLORFORMAT_32BITBGRA8888:
- case XA_COLORFORMAT_32BITARGB8888:
- case XA_COLORFORMAT_YUV411PLANAR:
- case XA_COLORFORMAT_YUV420PLANAR:
- case XA_COLORFORMAT_YUV420SEMIPLANAR:
- case XA_COLORFORMAT_YUV422PLANAR:
- case XA_COLORFORMAT_YUV422SEMIPLANAR:
- case XA_COLORFORMAT_YCBYCR:
- case XA_COLORFORMAT_YCRYCB:
- case XA_COLORFORMAT_CBYCRY:
- case XA_COLORFORMAT_CRYCBY:
- case XA_COLORFORMAT_YUV444INTERLEAVED:
- case XA_COLORFORMAT_RAWBAYER8BIT:
- case XA_COLORFORMAT_RAWBAYER10BIT:
- case XA_COLORFORMAT_RAWBAYER8BITCOMPRESSED:
- case XA_COLORFORMAT_L2:
- case XA_COLORFORMAT_L4:
- case XA_COLORFORMAT_L8:
- case XA_COLORFORMAT_L16:
- case XA_COLORFORMAT_L24:
- case XA_COLORFORMAT_L32:
- case XA_COLORFORMAT_18BITBGR666:
- case XA_COLORFORMAT_24BITARGB6666:
- case XA_COLORFORMAT_24BITABGR6666:
- break;
- case XA_COLORFORMAT_UNUSED:
- default:
- result = XA_RESULT_PARAMETER_INVALID;
- SL_LOGE("%s: unsupported color format %d", name,
- pDataFormat->mRawImage.colorFormat);
- break;
- }
- // no checks for height, width, or stride
- break;
-
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- SL_LOGE("%s: formatType=%u", name, (unsigned) formatType);
- break;
-
- }
-
- // make sure format type was not modified asynchronously
- if ((SL_RESULT_SUCCESS == result) && (formatType != pDataFormat->mFormatType)) {
- SL_LOGE("%s: formatType changed from %u to %u", name, formatType,
- pDataFormat->mFormatType);
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- }
-
- }
-
- // Verify that the data format type is allowed in this context
- if (SL_RESULT_SUCCESS == result) {
- SLuint32 actualMask;
- switch (formatType) {
- case SL_DATAFORMAT_NULL:
- case SL_DATAFORMAT_MIME:
- case SL_DATAFORMAT_PCM:
- case XA_DATAFORMAT_RAWIMAGE:
- actualMask = 1L << formatType;
- break;
- default:
- assert(false);
- actualMask = 0L;
- break;
- }
- if (!(allowedDataFormatMask & actualMask)) {
- SL_LOGE("%s: data format %d not allowed", name, formatType);
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- }
- }
-
- return result;
-}
-
-
-/** \brief Check interface ID compatibility with respect to a particular source
- * and sink data locator format
- */
-
-SLresult checkSourceSinkVsInterfacesCompatibility(const DataLocatorFormat *pSrcDataLocatorFormat,
- const DataLocatorFormat *pSinkDataLocatorFormat,
- const ClassTable *clazz, unsigned requiredMask) {
- int index;
- switch (pSrcDataLocatorFormat->mLocator.mLocatorType) {
- case SL_DATALOCATOR_URI:
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDFD:
-#endif
- // URIs and FD can be sources when "playing" to an OutputMix or a Buffer Queue for decode
- // so we don't prevent the retrieval of the BufferQueue interfaces for those sources
- switch (pSinkDataLocatorFormat->mLocator.mLocatorType) {
- case SL_DATALOCATOR_BUFFERQUEUE:
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
-#endif
- break;
- default:
- // can't require SLBufferQueueItf or its alias SLAndroidSimpleBufferQueueItf
- // if the data sink is not a buffer queue
- index = clazz->mMPH_to_index[MPH_BUFFERQUEUE];
-#ifdef ANDROID
- assert(index == clazz->mMPH_to_index[MPH_ANDROIDSIMPLEBUFFERQUEUE]);
-#endif
- if (0 <= index) {
- if (requiredMask & (1 << index)) {
- SL_LOGE("can't require SL_IID_BUFFERQUEUE "
-#ifdef ANDROID
- "or SL_IID_ANDROIDSIMPLEBUFFERQUEUE "
-#endif
- "with a non-buffer queue data sink");
- return SL_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- break;
- }
- break;
-
- case SL_DATALOCATOR_BUFFERQUEUE:
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
-#endif
- // can't require SLSeekItf if data source is a buffer queue
- index = clazz->mMPH_to_index[MPH_SEEK];
- if (0 <= index) {
- if (requiredMask & (1 << index)) {
- SL_LOGE("can't require SL_IID_SEEK with a buffer queue data source");
- return SL_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- // can't require SLMuteSoloItf if data source is a mono buffer queue
- index = clazz->mMPH_to_index[MPH_MUTESOLO];
- if (0 <= index) {
- if ((requiredMask & (1 << index)) &&
- (SL_DATAFORMAT_PCM == pSrcDataLocatorFormat->mFormat.mFormatType) &&
- (1 == pSrcDataLocatorFormat->mFormat.mPCM.numChannels)) {
- SL_LOGE("can't require SL_IID_MUTESOLO with a mono buffer queue data source");
- return SL_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- break;
-
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- // can't require SLSeekItf if data source is an Android buffer queue
- index = clazz->mMPH_to_index[MPH_SEEK];
- if (0 <= index) {
- if (requiredMask & (1 << index)) {
- SL_LOGE("can't require SL_IID_SEEK with a SL_DATALOCATOR_ANDROIDBUFFERQUEUE "\
- "source");
- return SL_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- switch (pSinkDataLocatorFormat->mLocator.mLocatorType) {
- // for use-case AAC decode from SLAndroidBufferQueueItf with AAC ADTS data
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- break;
- // for use-case audio playback from SLAndroidBufferQueueItf with MP2TS data
- case SL_DATALOCATOR_OUTPUTMIX:
- break;
- default:
- SL_LOGE("Invalid sink for SL_DATALOCATOR_ANDROIDBUFFERQUEUE source");
- return SL_RESULT_FEATURE_UNSUPPORTED;
- break;
- }
- break;
-#endif
- case SL_DATALOCATOR_ADDRESS:
- case SL_DATALOCATOR_MIDIBUFFERQUEUE:
- case XA_DATALOCATOR_NATIVEDISPLAY:
- // any special checks here???
- default:
- // can't require SLBufferQueueItf or its alias SLAndroidSimpleBufferQueueItf
- // if the data source is not a buffer queue
- index = clazz->mMPH_to_index[MPH_BUFFERQUEUE];
-#ifdef ANDROID
- assert(index == clazz->mMPH_to_index[MPH_ANDROIDSIMPLEBUFFERQUEUE]);
-#endif
- if (0 <= index) {
- if (requiredMask & (1 << index)) {
- SL_LOGE("can't require SL_IID_BUFFERQUEUE "
-#ifdef ANDROID
- "or SL_IID_ANDROIDSIMPLEBUFFERQUEUE "
-#endif
- "with a non-buffer queue data source");
- return SL_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- break;
- }
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Free the local deep copy of a data format */
-
-static void freeDataFormat(DataFormat *pDataFormat)
-{
- switch (pDataFormat->mFormatType) {
- case SL_DATAFORMAT_MIME:
- if (NULL != pDataFormat->mMIME.mimeType) {
- free(pDataFormat->mMIME.mimeType);
- pDataFormat->mMIME.mimeType = NULL;
- }
- break;
- case SL_DATAFORMAT_PCM:
- case XA_DATAFORMAT_RAWIMAGE:
- case SL_DATAFORMAT_NULL:
- break;
- default:
- // an invalid data format is caught earlier during the copy
- assert(false);
- break;
- }
-}
-
-
-/** \brief Check a data source and make local deep copy */
-
-SLresult checkDataSource(const char *name, const SLDataSource *pDataSrc,
- DataLocatorFormat *pDataLocatorFormat, SLuint32 allowedDataLocatorMask,
- SLuint32 allowedDataFormatMask)
-{
- assert(NULL != name && NULL != pDataLocatorFormat);
- pDataLocatorFormat->u.mSource.pLocator = &pDataLocatorFormat->mLocator;
- pDataLocatorFormat->u.mSource.pFormat = &pDataLocatorFormat->mFormat;
-
- if (NULL == pDataSrc) {
- pDataLocatorFormat->mLocator.mLocatorType = SL_DATALOCATOR_NULL;
- pDataLocatorFormat->mFormat.mFormatType = SL_DATAFORMAT_NULL;
- if ((allowedDataLocatorMask & DATALOCATOR_MASK_NULL) &&
- (allowedDataFormatMask & DATAFORMAT_MASK_NULL)) {
- return SL_RESULT_SUCCESS;
- }
- SL_LOGE("%s: data source cannot be NULL", name);
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLDataSource myDataSrc = *pDataSrc;
- SLresult result;
- result = checkDataLocator(name, myDataSrc.pLocator, &pDataLocatorFormat->mLocator,
- allowedDataLocatorMask);
- if (SL_RESULT_SUCCESS != result) {
- return result;
- }
-
- switch (pDataLocatorFormat->mLocator.mLocatorType) {
- case SL_DATALOCATOR_URI:
- allowedDataFormatMask &= DATAFORMAT_MASK_MIME;
- break;
- case SL_DATALOCATOR_ADDRESS:
- case SL_DATALOCATOR_BUFFERQUEUE:
- allowedDataFormatMask &= DATAFORMAT_MASK_PCM;
- break;
- // Per the spec, the pFormat field is ignored in some cases
- case SL_DATALOCATOR_IODEVICE:
- myDataSrc.pFormat = NULL;
- // fall through
- case SL_DATALOCATOR_NULL:
- case SL_DATALOCATOR_MIDIBUFFERQUEUE:
- allowedDataFormatMask &= DATAFORMAT_MASK_NULL;
- break;
- case SL_DATALOCATOR_OUTPUTMIX:
- case XA_DATALOCATOR_NATIVEDISPLAY:
- allowedDataFormatMask = DATAFORMAT_MASK_NONE;
- break;
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDFD:
- allowedDataFormatMask &= DATAFORMAT_MASK_MIME;
- break;
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- allowedDataFormatMask &= DATAFORMAT_MASK_PCM;
- break;
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- allowedDataFormatMask &= DATAFORMAT_MASK_MIME;;
- break;
-#endif
- default:
- // invalid data locator type is caught earlier
- assert(false);
- allowedDataFormatMask = DATAFORMAT_MASK_NONE;
- break;
- }
-
- result = checkDataFormat(name, myDataSrc.pFormat, &pDataLocatorFormat->mFormat,
- allowedDataFormatMask);
- if (SL_RESULT_SUCCESS != result) {
- freeDataLocator(&pDataLocatorFormat->mLocator);
- return result;
- }
-
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Check a data sink and make local deep copy */
-
-SLresult checkDataSink(const char *name, const SLDataSink *pDataSink,
- DataLocatorFormat *pDataLocatorFormat, SLuint32 allowedDataLocatorMask,
- SLuint32 allowedDataFormatMask)
-{
- assert(NULL != name && NULL != pDataLocatorFormat);
- pDataLocatorFormat->u.mSink.pLocator = &pDataLocatorFormat->mLocator;
- pDataLocatorFormat->u.mSink.pFormat = &pDataLocatorFormat->mFormat;
-
- if (NULL == pDataSink) {
- pDataLocatorFormat->mLocator.mLocatorType = SL_DATALOCATOR_NULL;
- pDataLocatorFormat->mFormat.mFormatType = SL_DATAFORMAT_NULL;
- if ((allowedDataLocatorMask & DATALOCATOR_MASK_NULL) &&
- (allowedDataFormatMask & DATAFORMAT_MASK_NULL)) {
- return SL_RESULT_SUCCESS;
- }
- SL_LOGE("%s: data sink cannot be NULL", name);
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLDataSink myDataSink = *pDataSink;
- SLresult result;
- result = checkDataLocator(name, myDataSink.pLocator, &pDataLocatorFormat->mLocator,
- allowedDataLocatorMask);
- if (SL_RESULT_SUCCESS != result) {
- return result;
- }
-
- switch (pDataLocatorFormat->mLocator.mLocatorType) {
- case SL_DATALOCATOR_URI:
- allowedDataFormatMask &= DATAFORMAT_MASK_MIME;
- break;
- case SL_DATALOCATOR_ADDRESS:
- case SL_DATALOCATOR_BUFFERQUEUE:
- allowedDataFormatMask &= DATAFORMAT_MASK_PCM;
- break;
- // Per the spec, the pFormat field is ignored in some cases
- case SL_DATALOCATOR_IODEVICE:
- case SL_DATALOCATOR_OUTPUTMIX:
- case XA_DATALOCATOR_NATIVEDISPLAY:
- myDataSink.pFormat = NULL;
- // fall through
- case SL_DATALOCATOR_NULL:
- case SL_DATALOCATOR_MIDIBUFFERQUEUE:
- allowedDataFormatMask &= DATAFORMAT_MASK_NULL;
- break;
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDFD:
- allowedDataFormatMask = DATAFORMAT_MASK_NONE;
- break;
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- allowedDataFormatMask &= DATAFORMAT_MASK_PCM;
- break;
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- allowedDataFormatMask = DATAFORMAT_MASK_NONE;
- break;
-#endif
- default:
- // invalid data locator type is caught earlier
- assert(false);
- allowedDataFormatMask = DATAFORMAT_MASK_NONE;
- break;
- }
-
- result = checkDataFormat(name, myDataSink.pFormat, &pDataLocatorFormat->mFormat,
- allowedDataFormatMask);
- if (SL_RESULT_SUCCESS != result) {
- freeDataLocator(&pDataLocatorFormat->mLocator);
- return result;
- }
-
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Free the local deep copy of a data locator format */
-
-void freeDataLocatorFormat(DataLocatorFormat *dlf)
-{
- assert(NULL != dlf);
- freeDataLocator(&dlf->mLocator);
- freeDataFormat(&dlf->mFormat);
-}
diff --git a/wilhelm/src/data.h b/wilhelm/src/data.h
deleted file mode 100644
index a5f7faf..0000000
--- a/wilhelm/src/data.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Our own merged version of SLDataSource and SLDataSink */
-
-typedef union {
- SLuint32 mLocatorType;
- SLDataLocator_Address mAddress;
- SLDataLocator_BufferQueue mBufferQueue;
- SLDataLocator_IODevice mIODevice;
- SLDataLocator_MIDIBufferQueue mMIDIBufferQueue;
- SLDataLocator_OutputMix mOutputMix;
- SLDataLocator_URI mURI;
- XADataLocator_NativeDisplay mNativeDisplay;
-#ifdef ANDROID
- SLDataLocator_AndroidFD mFD;
- SLDataLocator_AndroidBufferQueue mABQ;
-#endif
-} DataLocator;
-
-typedef union {
- SLuint32 mFormatType;
- SLDataFormat_PCM mPCM;
- SLDataFormat_MIME mMIME;
- XADataFormat_RawImage mRawImage;
-} DataFormat;
-
-typedef struct {
- union {
- SLDataSource mSource;
- SLDataSink mSink;
- struct {
- DataLocator *pLocator;
- DataFormat *pFormat;
- } mNeutral;
- } u;
- DataLocator mLocator;
- DataFormat mFormat;
-} DataLocatorFormat;
-
-#define SL_DATALOCATOR_NULL 0 // application specified a NULL value for pLocator
- // (not a valid value for mLocatorType)
-#define XA_DATALOCATOR_NULL SL_DATALOCATOR_NULL
-#define SL_DATAFORMAT_NULL 0 // application specified a NULL value for pFormat
- // (not a valid value for mLocatorType)
-#define XA_DATAFORMAT_NULL SL_DATAFORMAT_NULL
-
-// bit masks used to configure the allowed data locators for a given data source or data sink
-#define DATALOCATOR_MASK_NONE 0L
-#define DATALOCATOR_MASK_NULL (1L << SL_DATALOCATOR_NULL)
-#define DATALOCATOR_MASK_URI (1L << SL_DATALOCATOR_URI)
-#define DATALOCATOR_MASK_ADDRESS (1L << SL_DATALOCATOR_ADDRESS)
-#define DATALOCATOR_MASK_IODEVICE (1L << SL_DATALOCATOR_IODEVICE)
-#define DATALOCATOR_MASK_OUTPUTMIX (1L << SL_DATALOCATOR_OUTPUTMIX)
-#define DATALOCATOR_MASK_NATIVEDISPLAY (1L << XA_DATALOCATOR_NATIVEDISPLAY)
-#define DATALOCATOR_MASK_BUFFERQUEUE (1L << SL_DATALOCATOR_BUFFERQUEUE)
-#define DATALOCATOR_MASK_MIDIBUFFERQUEUE (1L << SL_DATALOCATOR_MIDIBUFFERQUEUE)
-#define DATALOCATOR_MASK_ANDROIDFD \
- (0x100L << (SL_DATALOCATOR_ANDROIDFD - SL_DATALOCATOR_ANDROIDFD))
-#define DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE \
- (0x100L << (SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
-#define DATALOCATOR_MASK_ANDROIDBUFFERQUEUE \
- (0x100L << (SL_DATALOCATOR_ANDROIDBUFFERQUEUE - SL_DATALOCATOR_ANDROIDFD))
-#define DATALOCATOR_MASK_ALL 0x7FFL
-
-// bit masks used to configure the allowed data formats for a given data source or data sink
-#define DATAFORMAT_MASK_NONE 0L
-#define DATAFORMAT_MASK_NULL (1L << SL_DATAFORMAT_NULL)
-#define DATAFORMAT_MASK_MIME (1L << SL_DATAFORMAT_MIME)
-#define DATAFORMAT_MASK_PCM (1L << SL_DATAFORMAT_PCM)
-#define DATAFORMAT_MASK_RAWIMAGE (1L << XA_DATAFORMAT_RAWIMAGE)
-#define DATAFORMAT_MASK_ALL 0xFL
-
-extern SLresult checkDataSource(const char *name, const SLDataSource *pDataSrc,
- DataLocatorFormat *myDataSourceLocator, SLuint32 allowedDataLocatorMask,
- SLuint32 allowedDataFormatMask);
-extern SLresult checkDataSink(const char *name, const SLDataSink *pDataSink,
- DataLocatorFormat *myDataSinkLocator, SLuint32 allowedDataLocatorMask,
- SLuint32 allowedDataFormatMask);
-extern SLresult checkSourceSinkVsInterfacesCompatibility(
- const DataLocatorFormat *pSrcDataLocatorFormat,
- const DataLocatorFormat *pSinkDataLocatorFormat,
- const ClassTable *clazz, unsigned requiredMask);
-extern void freeDataLocatorFormat(DataLocatorFormat *dlf);
-
-
-/* For stream information storage */
-typedef struct {
- XAuint32 domain;
- union {
- XAMediaContainerInformation containerInfo;
- XAVideoStreamInformation videoInfo;
- XAAudioStreamInformation audioInfo;
- XAImageStreamInformation imageInfo;
- XATimedTextStreamInformation textInfo;
- XAMIDIStreamInformation midiInfo;
- XAVendorStreamInformation vendorInfo;
- };
-} StreamInfo;
-
-// FIXME a terrible hack until OpenMAX AL spec is updated
-#define XA_DOMAINTYPE_CONTAINER 0
diff --git a/wilhelm/src/desktop/OutputMixExt.h b/wilhelm/src/desktop/OutputMixExt.h
deleted file mode 100644
index aa4e3d9..0000000
--- a/wilhelm/src/desktop/OutputMixExt.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file OutputMixExt.h OutputMixExt interface */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern const SLInterfaceID SL_IID_OUTPUTMIXEXT;
-#ifdef __cplusplus
-}
-#endif
-
-typedef const struct SLOutputMixExtItf_ * const * SLOutputMixExtItf;
-
-/** \brief v-table for IOutputMixExt */
-
-struct SLOutputMixExtItf_ {
- void (*FillBuffer)(SLOutputMixExtItf self, void *pBuffer, SLuint32 size);
-};
-
-/** \brief Track describes each PCM input source to OutputMix */
-
-typedef struct {
- struct BufferQueue_interface *mBufferQueue;
- CAudioPlayer *mAudioPlayer; ///< Mixer examines this track if non-NULL
- const void *mReader; ///< Pointer to next frame in BufferHeader.mBuffer
- SLuint32 mAvail; ///< Number of available bytes in the current buffer
- float mGains[STEREO_CHANNELS]; ///< Copied from CAudioPlayer::mGains
- SLuint32 mFramesMixed; ///< Number of sample frames mixed from track; reset periodically
-} Track;
-
-extern SLresult IOutputMixExt_checkAudioPlayerSourceSink(CAudioPlayer *thiz);
-extern void audioPlayerGainUpdate(CAudioPlayer *thiz);
-extern void IOutputMixExt_FillBuffer(SLOutputMixExtItf self, void *pBuffer, SLuint32 size);
diff --git a/wilhelm/src/desktop/SDL.c b/wilhelm/src/desktop/SDL.c
deleted file mode 100644
index edc27c9..0000000
--- a/wilhelm/src/desktop/SDL.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file SDL.c SDL platform implementation */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Called by SDL to fill the next audio output buffer */
-
-static void SDLCALL SDL_callback(void *context, Uint8 *stream, int len)
-{
- assert(len > 0);
- IEngine *thisEngine = (IEngine *) context;
- // A peek lock would be risky if output mixes are dynamic, so we use SDL_PauseAudio to
- // temporarily disable callbacks during any change to the current output mix, and use a
- // shared lock here
- interface_lock_shared(thisEngine);
- COutputMix *outputMix = thisEngine->mOutputMix;
- interface_unlock_shared(thisEngine);
- if (NULL != outputMix) {
- SLOutputMixExtItf OutputMixExt = &outputMix->mOutputMixExt.mItf;
- IOutputMixExt_FillBuffer(OutputMixExt, stream, (SLuint32) len);
- } else {
- memset(stream, 0, (size_t) len);
- }
-}
-
-
-/** \brief Called during slCreateEngine to initialize SDL */
-
-void SDL_open(IEngine *thisEngine)
-{
- SDL_AudioSpec fmt;
- fmt.freq = 44100;
- fmt.format = AUDIO_S16;
- fmt.channels = STEREO_CHANNELS;
-#ifdef _WIN32 // FIXME Either a bug or a serious misunderstanding
- fmt.samples = SndFile_BUFSIZE;
-#else
- fmt.samples = SndFile_BUFSIZE / sizeof(short);
-#endif
- fmt.callback = SDL_callback;
- fmt.userdata = (void *) thisEngine;
-
- if (SDL_OpenAudio(&fmt, NULL) < 0) {
- SL_LOGE("Unable to open audio: %s", SDL_GetError());
- exit(EXIT_FAILURE);
- }
-}
-
-
-/** \brief Called during Object::Destroy for engine to shutdown SDL */
-
-void SDL_close(void)
-{
- SDL_CloseAudio();
-}
diff --git a/wilhelm/src/desktop/SLSndFile.h b/wilhelm/src/desktop/SLSndFile.h
deleted file mode 100644
index 87504bb..0000000
--- a/wilhelm/src/desktop/SLSndFile.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file SLSndFile.h libsndfile interface */
-
-extern void SndFile_Callback(SLBufferQueueItf caller, void *pContext);
-extern SLboolean SndFile_IsSupported(const SF_INFO *sfinfo);
-extern SLresult SndFile_checkAudioPlayerSourceSink(CAudioPlayer *thiz);
-extern void audioPlayerTransportUpdate(CAudioPlayer *thiz);
-extern SLresult SndFile_Realize(CAudioPlayer *thiz);
-extern void SndFile_Destroy(CAudioPlayer *thiz);
diff --git a/wilhelm/src/desktop/SndFile.c b/wilhelm/src/desktop/SndFile.c
deleted file mode 100644
index 91d0e03..0000000
--- a/wilhelm/src/desktop/SndFile.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \brief libsndfile integration */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Called by SndFile.c:audioPlayerTransportUpdate after a play state change or seek,
- * and by IOutputMixExt::FillBuffer after each buffer is consumed.
- */
-
-void SndFile_Callback(SLBufferQueueItf caller, void *pContext)
-{
- CAudioPlayer *thisAP = (CAudioPlayer *) pContext;
- object_lock_peek(&thisAP->mObject);
- SLuint32 state = thisAP->mPlay.mState;
- object_unlock_peek(&thisAP->mObject);
- if (SL_PLAYSTATE_PLAYING != state) {
- return;
- }
- struct SndFile *thiz = &thisAP->mSndFile;
- SLresult result;
- pthread_mutex_lock(&thiz->mMutex);
- if (thiz->mEOF) {
- pthread_mutex_unlock(&thiz->mMutex);
- return;
- }
- short *pBuffer = &thiz->mBuffer[thiz->mWhich * SndFile_BUFSIZE];
- if (++thiz->mWhich >= SndFile_NUMBUFS) {
- thiz->mWhich = 0;
- }
- sf_count_t count;
- count = sf_read_short(thiz->mSNDFILE, pBuffer, (sf_count_t) SndFile_BUFSIZE);
- pthread_mutex_unlock(&thiz->mMutex);
- bool headAtNewPos = false;
- object_lock_exclusive(&thisAP->mObject);
- slPlayCallback callback = thisAP->mPlay.mCallback;
- void *context = thisAP->mPlay.mContext;
- // make a copy of sample rate so we are absolutely sure we will not divide by zero
- SLuint32 sampleRateMilliHz = thisAP->mSampleRateMilliHz;
- if (UNKNOWN_SAMPLERATE != sampleRateMilliHz) {
- // this will overflow after 49 days, but no fix possible as it's part of the API
- thisAP->mPlay.mPosition = (SLuint32) (((long long) thisAP->mPlay.mFramesSinceLastSeek *
- 1000000LL) / sampleRateMilliHz) + thisAP->mPlay.mLastSeekPosition;
- // make a good faith effort for the mean time between "head at new position" callbacks to
- // occur at the requested update period, but there will be jitter
- SLuint32 frameUpdatePeriod = thisAP->mPlay.mFrameUpdatePeriod;
- if ((0 != frameUpdatePeriod) &&
- (thisAP->mPlay.mFramesSincePositionUpdate >= frameUpdatePeriod) &&
- (SL_PLAYEVENT_HEADATNEWPOS & thisAP->mPlay.mEventFlags)) {
- // if we overrun a requested update period, then reset the clock modulo the
- // update period so that it appears to the application as one or more lost callbacks,
- // but no additional jitter
- if ((thisAP->mPlay.mFramesSincePositionUpdate -= thisAP->mPlay.mFrameUpdatePeriod) >=
- frameUpdatePeriod) {
- thisAP->mPlay.mFramesSincePositionUpdate %= frameUpdatePeriod;
- }
- headAtNewPos = true;
- }
- }
- if (0 < count) {
- object_unlock_exclusive(&thisAP->mObject);
- SLuint32 size = (SLuint32) (count * sizeof(short));
- result = IBufferQueue_Enqueue(caller, pBuffer, size);
- // not much we can do if the Enqueue fails, so we'll just drop the decoded data
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("enqueue failed 0x%x", result);
- }
- } else {
- thisAP->mPlay.mState = SL_PLAYSTATE_PAUSED;
- thiz->mEOF = SL_BOOLEAN_TRUE;
- // this would result in a non-monotonically increasing position, so don't do it
- // thisAP->mPlay.mPosition = thisAP->mPlay.mDuration;
- object_unlock_exclusive_attributes(&thisAP->mObject, ATTR_TRANSPORT);
- }
- // callbacks are called with mutex unlocked
- if (NULL != callback) {
- if (headAtNewPos) {
- (*callback)(&thisAP->mPlay.mItf, context, SL_PLAYEVENT_HEADATNEWPOS);
- }
- }
-}
-
-
-/** \brief Check whether the supplied libsndfile format is supported by us */
-
-SLboolean SndFile_IsSupported(const SF_INFO *sfinfo)
-{
- switch (sfinfo->format & SF_FORMAT_TYPEMASK) {
- case SF_FORMAT_WAV:
- break;
- default:
- return SL_BOOLEAN_FALSE;
- }
- switch (sfinfo->format & SF_FORMAT_SUBMASK) {
- case SF_FORMAT_PCM_U8:
- case SF_FORMAT_PCM_16:
- break;
- default:
- return SL_BOOLEAN_FALSE;
- }
- switch (sfinfo->samplerate) {
- case 11025:
- case 22050:
- case 44100:
- break;
- default:
- return SL_BOOLEAN_FALSE;
- }
- switch (sfinfo->channels) {
- case 1:
- case 2:
- break;
- default:
- return SL_BOOLEAN_FALSE;
- }
- return SL_BOOLEAN_TRUE;
-}
-
-
-/** \brief Check whether the partially-constructed AudioPlayer is compatible with libsndfile */
-
-SLresult SndFile_checkAudioPlayerSourceSink(CAudioPlayer *thiz)
-{
- const SLDataSource *pAudioSrc = &thiz->mDataSource.u.mSource;
- SLuint32 locatorType = *(SLuint32 *)pAudioSrc->pLocator;
- SLuint32 formatType = *(SLuint32 *)pAudioSrc->pFormat;
- switch (locatorType) {
- case SL_DATALOCATOR_BUFFERQUEUE:
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
-#endif
- break;
- case SL_DATALOCATOR_URI:
- {
- SLDataLocator_URI *dl_uri = (SLDataLocator_URI *) pAudioSrc->pLocator;
- SLchar *uri = dl_uri->URI;
- if (NULL == uri) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- if (!strncmp((const char *) uri, "file:///", 8)) {
- uri += 8;
- }
- switch (formatType) {
- case SL_DATAFORMAT_NULL: // OK to omit the data format
- case SL_DATAFORMAT_MIME: // we ignore a MIME type if specified
- break;
- case SL_DATAFORMAT_PCM:
- case XA_DATAFORMAT_RAWIMAGE:
- return SL_RESULT_CONTENT_UNSUPPORTED;
- default:
- // an invalid data format is detected earlier during the deep copy
- assert(false);
- return SL_RESULT_INTERNAL_ERROR;
- }
- thiz->mSndFile.mPathname = uri;
- thiz->mBufferQueue.mNumBuffers = SndFile_NUMBUFS;
- }
- break;
- default:
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- thiz->mSndFile.mWhich = 0;
- thiz->mSndFile.mSNDFILE = NULL;
- // thiz->mSndFile.mMutex is initialized only when there is a valid mSNDFILE
- thiz->mSndFile.mEOF = SL_BOOLEAN_FALSE;
-
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Called with mutex unlocked for marker and position updates, and play state change */
-
-void audioPlayerTransportUpdate(CAudioPlayer *audioPlayer)
-{
-
- if (NULL != audioPlayer->mSndFile.mSNDFILE) {
-
- object_lock_exclusive(&audioPlayer->mObject);
- SLboolean empty = 0 == audioPlayer->mBufferQueue.mState.count;
- // FIXME a made-up number that should depend on player state and prefetch status
- audioPlayer->mPrefetchStatus.mLevel = 1000;
- SLmillisecond pos = audioPlayer->mSeek.mPos;
- if (SL_TIME_UNKNOWN != pos) {
- audioPlayer->mSeek.mPos = SL_TIME_UNKNOWN;
- // trim seek position to the current known duration
- if (pos > audioPlayer->mPlay.mDuration) {
- pos = audioPlayer->mPlay.mDuration;
- }
- audioPlayer->mPlay.mLastSeekPosition = pos;
- audioPlayer->mPlay.mFramesSinceLastSeek = 0;
- // seek postpones the next head at new position callback
- audioPlayer->mPlay.mFramesSincePositionUpdate = 0;
- }
- object_unlock_exclusive(&audioPlayer->mObject);
-
- if (SL_TIME_UNKNOWN != pos) {
-
- // discard any enqueued buffers for the old position
- IBufferQueue_Clear(&audioPlayer->mBufferQueue.mItf);
- empty = SL_BOOLEAN_TRUE;
-
- pthread_mutex_lock(&audioPlayer->mSndFile.mMutex);
- // FIXME why void?
- (void) sf_seek(audioPlayer->mSndFile.mSNDFILE, (sf_count_t) (((long long) pos *
- audioPlayer->mSndFile.mSfInfo.samplerate) / 1000LL), SEEK_SET);
- audioPlayer->mSndFile.mEOF = SL_BOOLEAN_FALSE;
- audioPlayer->mSndFile.mWhich = 0;
- pthread_mutex_unlock(&audioPlayer->mSndFile.mMutex);
-
- }
-
- // FIXME only on seek or play state change (STOPPED, PAUSED) -> PLAYING
- if (empty) {
- SndFile_Callback(&audioPlayer->mBufferQueue.mItf, audioPlayer);
- }
-
- }
-
-}
-
-
-/** \brief Called by CAudioPlayer_Realize */
-
-SLresult SndFile_Realize(CAudioPlayer *thiz)
-{
- SLresult result = SL_RESULT_SUCCESS;
- if (NULL != thiz->mSndFile.mPathname) {
- thiz->mSndFile.mSfInfo.format = 0;
- thiz->mSndFile.mSNDFILE = sf_open(
- (const char *) thiz->mSndFile.mPathname, SFM_READ, &thiz->mSndFile.mSfInfo);
- if (NULL == thiz->mSndFile.mSNDFILE) {
- result = SL_RESULT_CONTENT_NOT_FOUND;
- } else if (!SndFile_IsSupported(&thiz->mSndFile.mSfInfo)) {
- sf_close(thiz->mSndFile.mSNDFILE);
- thiz->mSndFile.mSNDFILE = NULL;
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- } else {
- int ok;
- ok = pthread_mutex_init(&thiz->mSndFile.mMutex, (const pthread_mutexattr_t *) NULL);
- assert(0 == ok);
- SLBufferQueueItf bufferQueue = &thiz->mBufferQueue.mItf;
- IBufferQueue *thisBQ = (IBufferQueue *) bufferQueue;
- IBufferQueue_RegisterCallback(&thisBQ->mItf, SndFile_Callback, thiz);
- thiz->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
- // this is the initial duration; will update when a new maximum position is detected
- thiz->mPlay.mDuration = (SLmillisecond) (((long long) thiz->mSndFile.mSfInfo.frames *
- 1000LL) / thiz->mSndFile.mSfInfo.samplerate);
- thiz->mNumChannels = thiz->mSndFile.mSfInfo.channels;
- thiz->mSampleRateMilliHz = thiz->mSndFile.mSfInfo.samplerate * 1000;
-#ifdef USE_OUTPUTMIXEXT
- thiz->mPlay.mFrameUpdatePeriod = ((long long) thiz->mPlay.mPositionUpdatePeriod *
- (long long) thiz->mSampleRateMilliHz) / 1000000LL;
-#endif
- }
- }
- return result;
-}
-
-
-/** \brief Called by CAudioPlayer_Destroy */
-
-void SndFile_Destroy(CAudioPlayer *thiz)
-{
- if (NULL != thiz->mSndFile.mSNDFILE) {
- sf_close(thiz->mSndFile.mSNDFILE);
- thiz->mSndFile.mSNDFILE = NULL;
- int ok;
- ok = pthread_mutex_destroy(&thiz->mSndFile.mMutex);
- assert(0 == ok);
- }
-}
diff --git a/wilhelm/src/devices.c b/wilhelm/src/devices.c
deleted file mode 100644
index bb110f1..0000000
--- a/wilhelm/src/devices.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-/* Device table (change this when you port!) */
-
-static const SLAudioInputDescriptor AudioInputDescriptor_mic = {
- (SLchar *) "mic", // deviceName
- SL_DEVCONNECTION_INTEGRATED, // deviceConnection
- SL_DEVSCOPE_ENVIRONMENT, // deviceScope
- SL_DEVLOCATION_HANDSET, // deviceLocation
- SL_BOOLEAN_TRUE, // isForTelephony
- SL_SAMPLINGRATE_44_1, // minSampleRate
- SL_SAMPLINGRATE_44_1, // maxSampleRate
- SL_BOOLEAN_TRUE, // isFreqRangeContinuous
- NULL, // samplingRatesSupported
- 0, // numOfSamplingRatesSupported
- 1 // maxChannels
-};
-
-const struct AudioInput_id_descriptor AudioInput_id_descriptors[] = {
- {SL_DEFAULTDEVICEID_AUDIOINPUT, &AudioInputDescriptor_mic},
- {0, NULL}
-};
-
-static const SLAudioOutputDescriptor AudioOutputDescriptor_speaker = {
- (SLchar *) "speaker", // deviceName
- SL_DEVCONNECTION_INTEGRATED, // deviceConnection
- SL_DEVSCOPE_USER, // deviceScope
- SL_DEVLOCATION_HEADSET, // deviceLocation
- SL_BOOLEAN_TRUE, // isForTelephony
- SL_SAMPLINGRATE_44_1, // minSamplingRate
- SL_SAMPLINGRATE_44_1, // maxSamplingRate
- SL_BOOLEAN_TRUE, // isFreqRangeContinuous
- NULL, // samplingRatesSupported
- 0, // numOfSamplingRatesSupported
- 2 // maxChannels
-};
-
-static const SLAudioOutputDescriptor AudioOutputDescriptor_headset = {
- (SLchar *) "headset",
- SL_DEVCONNECTION_ATTACHED_WIRED,
- SL_DEVSCOPE_USER,
- SL_DEVLOCATION_HEADSET,
- SL_BOOLEAN_FALSE,
- SL_SAMPLINGRATE_44_1,
- SL_SAMPLINGRATE_44_1,
- SL_BOOLEAN_TRUE,
- NULL,
- 0,
- 2
-};
-
-static const SLAudioOutputDescriptor AudioOutputDescriptor_handsfree = {
- (SLchar *) "handsfree",
- SL_DEVCONNECTION_INTEGRATED,
- SL_DEVSCOPE_ENVIRONMENT,
- SL_DEVLOCATION_HANDSET,
- SL_BOOLEAN_FALSE,
- SL_SAMPLINGRATE_44_1,
- SL_SAMPLINGRATE_44_1,
- SL_BOOLEAN_TRUE,
- NULL,
- 0,
- 2
-};
-
-const struct AudioOutput_id_descriptor AudioOutput_id_descriptors[] = {
- {SL_DEFAULTDEVICEID_AUDIOOUTPUT, &AudioOutputDescriptor_speaker},
- {DEVICE_ID_HEADSET, &AudioOutputDescriptor_headset},
- {DEVICE_ID_HANDSFREE, &AudioOutputDescriptor_handsfree},
- {0, NULL}
-};
-
-static const SLLEDDescriptor SLLEDDescriptor_default = {
- 32, // ledCount
- 0, // primaryLED
- ~0 // colorMask
-};
-
-const struct LED_id_descriptor LED_id_descriptors[] = {
- {SL_DEFAULTDEVICEID_LED, &SLLEDDescriptor_default},
- {0, NULL}
-};
-
-static const SLVibraDescriptor SLVibraDescriptor_default = {
- SL_BOOLEAN_TRUE, // supportsFrequency
- SL_BOOLEAN_TRUE, // supportsIntensity
- 20000, // minFrequency
- 100000 // maxFrequency
-};
-
-const struct Vibra_id_descriptor Vibra_id_descriptors[] = {
- {SL_DEFAULTDEVICEID_VIBRA, &SLVibraDescriptor_default},
- {0, NULL}
-};
-
-// should build this table from Caps table below
-
-static const SLuint32 Codec_IDs[] = {
- SL_AUDIOCODEC_PCM,
- SL_AUDIOCODEC_MP3,
- SL_AUDIOCODEC_AMR,
- SL_AUDIOCODEC_AMRWB,
- SL_AUDIOCODEC_AMRWBPLUS,
- SL_AUDIOCODEC_AAC,
- SL_AUDIOCODEC_WMA,
- SL_AUDIOCODEC_REAL,
- SL_AUDIOCODEC_VORBIS
-};
-
-const SLuint32 *Decoder_IDs = Codec_IDs;
-const SLuint32 *Encoder_IDs = Codec_IDs;
-
-static const SLuint32 VideoCodecIds[] = {
- XA_VIDEOCODEC_MPEG2,
- XA_VIDEOCODEC_H263,
- XA_VIDEOCODEC_MPEG4,
- XA_VIDEOCODEC_AVC,
-#ifndef ANDROID
- XA_VIDEOCODEC_VC1,
-#endif
-#ifdef ANDROID
- XA_ANDROID_VIDEOCODEC_VP8
-#endif
-};
-
-const SLuint32 *VideoDecoderIds = VideoCodecIds;
-
-const XAuint32 kMaxVideoDecoders = sizeof(VideoCodecIds) / sizeof(VideoCodecIds[0]);
-
-static const SLmilliHertz SamplingRates_A[] = {
- SL_SAMPLINGRATE_8,
- SL_SAMPLINGRATE_11_025,
- SL_SAMPLINGRATE_12,
- SL_SAMPLINGRATE_16,
- SL_SAMPLINGRATE_22_05,
- SL_SAMPLINGRATE_24,
- SL_SAMPLINGRATE_32,
- SL_SAMPLINGRATE_44_1,
- SL_SAMPLINGRATE_48
-};
-
-static const SLAudioCodecDescriptor CodecDescriptor_A = {
- 2, // maxChannels
- 8, // minBitsPerSample
- 16, // maxBitsPerSample
- SL_SAMPLINGRATE_8, // minSampleRate
- SL_SAMPLINGRATE_48, // maxSampleRate
- SL_BOOLEAN_FALSE, // isFreqRangeContinuous
- (SLmilliHertz *) SamplingRates_A,
- // pSampleRatesSupported;
- sizeof(SamplingRates_A) / sizeof(SamplingRates_A[0]),
- // numSampleRatesSupported
- 1, // minBitRate
- ~0, // maxBitRate
- SL_BOOLEAN_TRUE, // isBitrateRangeContinuous
- NULL, // pBitratesSupported
- 0, // numBitratesSupported
- SL_AUDIOPROFILE_PCM, // profileSetting
- 0 // modeSetting
-};
-
-const CodecDescriptor DecoderDescriptors[] = {
- {SL_AUDIOCODEC_PCM, &CodecDescriptor_A},
- {SL_AUDIOCODEC_MP3, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AMR, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AMRWB, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AMRWBPLUS, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AAC, &CodecDescriptor_A},
- {SL_AUDIOCODEC_WMA, &CodecDescriptor_A},
- {SL_AUDIOCODEC_REAL, &CodecDescriptor_A},
- {SL_AUDIOCODEC_VORBIS, &CodecDescriptor_A},
- {SL_AUDIOCODEC_NULL, NULL}
-};
-
-const CodecDescriptor EncoderDescriptors[] = {
- {SL_AUDIOCODEC_PCM, &CodecDescriptor_A},
- {SL_AUDIOCODEC_MP3, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AMR, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AMRWB, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AMRWBPLUS, &CodecDescriptor_A},
- {SL_AUDIOCODEC_AAC, &CodecDescriptor_A},
- {SL_AUDIOCODEC_WMA, &CodecDescriptor_A},
- {SL_AUDIOCODEC_REAL, &CodecDescriptor_A},
- {SL_AUDIOCODEC_VORBIS, &CodecDescriptor_A},
- {SL_AUDIOCODEC_NULL, NULL}
-};
-
-
-/** \brief Helper shared by decoder and encoder */
-
-SLresult GetCodecCapabilities(SLuint32 codecId, SLuint32 *pIndex,
- SLAudioCodecDescriptor *pDescriptor, const CodecDescriptor *codecDescriptors)
-{
- if (NULL == pIndex) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- const CodecDescriptor *cd = codecDescriptors;
- SLuint32 index;
- if (NULL == pDescriptor) {
- for (index = 0 ; NULL != cd->mDescriptor; ++cd) {
- if (cd->mCodecID == codecId) {
- ++index;
- }
- }
- *pIndex = index;
- return SL_RESULT_SUCCESS;
- }
- index = *pIndex;
- for ( ; NULL != cd->mDescriptor; ++cd) {
- if (cd->mCodecID == codecId) {
- if (0 == index) {
- *pDescriptor = *cd->mDescriptor;
-#if 0 // Temporary workaround for Khronos bug 6331
- if (0 < pDescriptor->numSampleRatesSupported) {
- // The malloc is not in the 1.0.1 specification
- SLmilliHertz *temp = (SLmilliHertz *) malloc(sizeof(SLmilliHertz) *
- pDescriptor->numSampleRatesSupported);
- assert(NULL != temp);
- memcpy(temp, pDescriptor->pSampleRatesSupported, sizeof(SLmilliHertz) *
- pDescriptor->numSampleRatesSupported);
- pDescriptor->pSampleRatesSupported = temp;
- } else {
- pDescriptor->pSampleRatesSupported = NULL;
- }
-#endif
- return SL_RESULT_SUCCESS;
- }
- --index;
- }
- }
- return SL_RESULT_PARAMETER_INVALID;
-}
diff --git a/wilhelm/src/devices.h b/wilhelm/src/devices.h
deleted file mode 100644
index 5dd99bd..0000000
--- a/wilhelm/src/devices.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define DEVICE_ID_HEADSET 1
-#define DEVICE_ID_HANDSFREE 2
-
-extern const struct AudioInput_id_descriptor {
- SLuint32 id;
- const SLAudioInputDescriptor *descriptor;
-} AudioInput_id_descriptors[];
-
-extern const struct AudioOutput_id_descriptor {
- SLuint32 id;
- const SLAudioOutputDescriptor *descriptor;
-} AudioOutput_id_descriptors[];
-
-extern const struct LED_id_descriptor {
- SLuint32 id;
- const SLLEDDescriptor *descriptor;
-} LED_id_descriptors[];
-
-extern const struct Vibra_id_descriptor {
- SLuint32 id;
- const SLVibraDescriptor *descriptor;
-} Vibra_id_descriptors[];
-
-// These are not in 1.0.1 header file
-#define SL_AUDIOCODEC_NULL 0
-#define SL_AUDIOCODEC_VORBIS 9
-
-/** \brief Associates a codec ID with a corresponding codec descriptor */
-
-typedef struct {
- SLuint32 mCodecID; ///< The codec ID
- const SLAudioCodecDescriptor *mDescriptor; ///< The corresponding descriptor
-} CodecDescriptor;
-
-#define MAX_DECODERS 9 ///< (sizeof(Decoder_IDs) / sizeof(Decoder_IDs[0]))
-#define MAX_ENCODERS 9 ///< (sizeof(Encoder_IDs) / sizeof(Encoder_IDs[0]))
-
-extern const XAuint32 *VideoDecoderIds;
-extern const XAuint32 kMaxVideoDecoders;
-
-// For now, but encoders might be different than decoders later
-extern const SLuint32 *Decoder_IDs, *Encoder_IDs;
-
-extern const CodecDescriptor DecoderDescriptors[], EncoderDescriptors[];
-
-extern SLresult GetCodecCapabilities(SLuint32 decoderId, SLuint32 *pIndex,
- SLAudioCodecDescriptor *pDescriptor,
- const CodecDescriptor *codecDescriptors);
diff --git a/wilhelm/src/entry.c b/wilhelm/src/entry.c
deleted file mode 100644
index 8ee0430..0000000
--- a/wilhelm/src/entry.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Initial global entry points */
-
-#include "sles_allinclusive.h"
-
-#ifdef ANDROID
-#include <media/stagefright/DataSource.h>
-#include <binder/ProcessState.h>
-#endif
-
-/** \brief Internal code shared by slCreateEngine and xaCreateEngine */
-
-LI_API SLresult liCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions,
- const SLEngineOption *pEngineOptions, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired,
- const ClassTable *pCEngine_class)
-{
- SLresult result;
-
- int ok;
- ok = pthread_mutex_lock(&theOneTrueMutex);
- assert(0 == ok);
- bool needToUnlockTheOneTrueMutex = true;
-
- do {
-
- if (NULL == pEngine) {
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- *pEngine = NULL;
-
- if ((0 < numOptions) && (NULL == pEngineOptions)) {
- SL_LOGE("numOptions=%u and pEngineOptions=NULL", numOptions);
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- // default values
- SLboolean threadSafe = SL_BOOLEAN_TRUE;
- SLboolean lossOfControlGlobal = SL_BOOLEAN_FALSE;
-
- // process engine options
- SLuint32 i;
- const SLEngineOption *option = pEngineOptions;
- result = SL_RESULT_SUCCESS;
- for (i = 0; i < numOptions; ++i, ++option) {
- switch (option->feature) {
- case SL_ENGINEOPTION_THREADSAFE:
- threadSafe = SL_BOOLEAN_FALSE != (SLboolean) option->data; // normalize
- break;
- case SL_ENGINEOPTION_LOSSOFCONTROL:
- lossOfControlGlobal = SL_BOOLEAN_FALSE != (SLboolean) option->data; // normalize
- break;
- default:
- SL_LOGE("unknown engine option: feature=%u data=%u",
- option->feature, option->data);
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- }
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-
- unsigned exposedMask;
- assert(NULL != pCEngine_class);
- result = checkInterfaces(pCEngine_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-
- // if an engine already exists, then increment its ref count
- CEngine *thiz = theOneTrueEngine;
- if (NULL != thiz) {
- assert(0 < theOneTrueRefCount);
- ++theOneTrueRefCount;
-
- // In order to update the engine object, we need to lock it,
- // but that would violate the lock order and potentially deadlock.
- // So we unlock now and note that it should not be unlocked later.
- ok = pthread_mutex_unlock(&theOneTrueMutex);
- assert(0 == ok);
- needToUnlockTheOneTrueMutex = false;
- object_lock_exclusive(&thiz->mObject);
-
- // now expose additional interfaces not requested by the earlier engine create
- const struct iid_vtable *x = pCEngine_class->mInterfaces;
- SLuint8 *interfaceStateP = thiz->mObject.mInterfaceStates;
- SLuint32 index;
- for (index = 0; index < pCEngine_class->mInterfaceCount; ++index, ++x,
- exposedMask >>= 1, ++interfaceStateP) {
- switch (*interfaceStateP) {
- case INTERFACE_EXPOSED: // previously exposed
- break;
- case INTERFACE_INITIALIZED: // not exposed during the earlier create
- if (exposedMask & 1) {
- const struct MPH_init *mi = &MPH_init_table[x->mMPH];
- BoolHook expose = mi->mExpose;
- if ((NULL == expose) || (*expose)((char *) thiz + x->mOffset)) {
- *interfaceStateP = INTERFACE_EXPOSED;
- }
- // FIXME log or report to application that expose hook failed
- }
- break;
- case INTERFACE_UNINITIALIZED: // no init hook
- break;
- default: // impossible
- assert(false);
- break;
- }
- }
- object_unlock_exclusive(&thiz->mObject);
- // return the shared engine object
- *pEngine = &thiz->mObject.mItf;
- break;
- }
-
- // here when creating the first engine reference
- assert(0 == theOneTrueRefCount);
-
-#ifdef ANDROID
- android::ProcessState::self()->startThreadPool();
- android::DataSource::RegisterDefaultSniffers();
-#endif
-
- thiz = (CEngine *) construct(pCEngine_class, exposedMask, NULL);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- break;
- }
-
- // initialize fields not associated with an interface
- // mThreadPool is initialized in CEngine_Realize
- memset(&thiz->mThreadPool, 0, sizeof(ThreadPool));
- memset(&thiz->mSyncThread, 0, sizeof(pthread_t));
-#if defined(ANDROID)
- thiz->mEqNumPresets = 0;
- thiz->mEqPresetNames = NULL;
-#endif
- // initialize fields related to an interface
- thiz->mObject.mLossOfControlMask = lossOfControlGlobal ? ~0 : 0;
- thiz->mEngine.mLossOfControlGlobal = lossOfControlGlobal;
- thiz->mEngineCapabilities.mThreadSafe = threadSafe;
- IObject_Publish(&thiz->mObject);
- theOneTrueEngine = thiz;
- theOneTrueRefCount = 1;
- // return the new engine object
- *pEngine = &thiz->mObject.mItf;
-
- } while(0);
-
- if (needToUnlockTheOneTrueMutex) {
- ok = pthread_mutex_unlock(&theOneTrueMutex);
- assert(0 == ok);
- }
-
- return result;
-}
-
-
-/** Internal function for slQuerySupportedEngineInterfaces and xaQuerySupportedEngineInterfaces */
-
-LI_API SLresult liQueryNumSupportedInterfaces(SLuint32 *pNumSupportedInterfaces,
- const ClassTable *clazz)
-{
- SLresult result;
- if (NULL == pNumSupportedInterfaces) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- assert(NULL != clazz);
- SLuint32 count = 0;
- SLuint32 i;
- for (i = 0; i < clazz->mInterfaceCount; ++i) {
- switch (clazz->mInterfaces[i].mInterface) {
- case INTERFACE_IMPLICIT:
- case INTERFACE_IMPLICIT_PREREALIZE:
- case INTERFACE_EXPLICIT:
- case INTERFACE_EXPLICIT_PREREALIZE:
- case INTERFACE_DYNAMIC:
- ++count;
- break;
- case INTERFACE_UNAVAILABLE:
- break;
- default:
- assert(false);
- break;
- }
- }
- *pNumSupportedInterfaces = count;
- result = SL_RESULT_SUCCESS;
- }
- return result;
-}
-
-
-/** Internal function for slQuerySupportedEngineInterfaces and xaQuerySupportedEngineInterfaces */
-
-LI_API SLresult liQuerySupportedInterfaces(SLuint32 index, SLInterfaceID *pInterfaceId,
- const ClassTable *clazz)
-{
- SLresult result;
- if (NULL == pInterfaceId) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pInterfaceId = NULL;
- assert(NULL != clazz);
- result = SL_RESULT_PARAMETER_INVALID; // will be reset later
- SLuint32 i;
- for (i = 0; i < clazz->mInterfaceCount; ++i) {
- switch (clazz->mInterfaces[i].mInterface) {
- case INTERFACE_IMPLICIT:
- case INTERFACE_IMPLICIT_PREREALIZE:
- case INTERFACE_EXPLICIT:
- case INTERFACE_EXPLICIT_PREREALIZE:
- case INTERFACE_DYNAMIC:
- break;
- case INTERFACE_UNAVAILABLE:
- continue;
- default:
- assert(false);
- break;
- }
- if (index == 0) {
- *pInterfaceId = &SL_IID_array[clazz->mInterfaces[i].mMPH];
- result = SL_RESULT_SUCCESS;
- break;
- }
- --index;
- }
- }
- return result;
-}
diff --git a/wilhelm/src/handler_bodies.c b/wilhelm/src/handler_bodies.c
deleted file mode 100644
index b1af8e0..0000000
--- a/wilhelm/src/handler_bodies.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-// Handlers should return a mask of the attributes which they actually handled,
-// or ATTR_NONE if they did not completely handle the attribute change.
-
-#ifdef ANDROID
-
-// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
-unsigned handler_AudioPlayer_gain(IObject *thiz)
-{
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- android_audioPlayer_volumeUpdate(ap);
- return ATTR_GAIN;
-}
-
-
-// SL_OBJECTID_OUTPUTMIX, ATTR_GAIN
-unsigned handler_OutputMix_gain(IObject *thiz)
-{
- // FIXME update gains on all players attached to this outputmix
- SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]");
- return ATTR_GAIN;
-}
-
-
-// SL_OBJECTID_MIDIPLAYER, ATTR_GAIN
-unsigned handler_MidiPlayer_gain(IObject *thiz)
-{
- SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
- return ATTR_GAIN;
-}
-
-
-// XA_OBJECTID_MEDIAPLAYER, ATTR_GAIN
-unsigned handler_MediaPlayer_gain(IObject *thiz)
-{
- CMediaPlayer *mp = (CMediaPlayer *) thiz;
- android_Player_volumeUpdate(mp);
- return ATTR_GAIN;
-}
-
-
-// SL_OBJECTID_AUDIOPLAYER, ATTR_POSITION
-unsigned handler_AudioPlayer_position(IObject *thiz)
-{
- CAudioPlayer *ap;
- ap = (CAudioPlayer *) thiz;
- // FIXME provide means to return result for invalid use cases (e.g. buffer queue data source)
- (void) android_audioPlayer_seek(ap, ap->mSeek.mPos);
- return ATTR_POSITION;
-}
-
-
-// SL_OBJECTID_MIDIPLAYER, ATTR_POSITION
-unsigned handler_MidiPlayer_position(IObject *thiz)
-{
- SL_LOGD("[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
- return ATTR_POSITION;
-}
-
-
-// SL_OBJECTID_AUDIOPLAYER, ATTR_TRANSPORT
-unsigned handler_AudioPlayer_transport(IObject *thiz)
-{
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- android_audioPlayer_usePlayEventMask(ap);
- return ATTR_TRANSPORT;
-}
-
-
-// SL_OBJECTID_AUDIOPLAYER, ATTR_PLAY_STATE
-unsigned handler_AudioPlayer_play_state(IObject *thiz)
-{
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- android_audioPlayer_setPlayState(ap);
- return ATTR_PLAY_STATE;
-}
-
-
-// SL_OBJECTID_AUDIORECORDER, ATTR_TRANSPORT
-unsigned handler_AudioRecorder_transport(IObject *thiz)
-{
- CAudioRecorder* ar = (CAudioRecorder *) thiz;
- android_audioRecorder_useRecordEventMask(ar);
- return ATTR_TRANSPORT;
-}
-
-
-// XA_OBJECTID_MEDIAPLAYER, ATTR_TRANSPORT
-unsigned handler_MediaPlayer_transport(IObject *thiz)
-{
- CMediaPlayer *mp = (CMediaPlayer *) thiz;
- android_Player_usePlayEventMask(mp);
- return ATTR_TRANSPORT;
-}
-
-
-// XA_OBJECTID_MEDIAPLAYER, ATTR_PLAY_STATE
-unsigned handler_MediaPlayer_play_state(IObject *thiz)
-{
- CMediaPlayer *mp = (CMediaPlayer *) thiz;
- android::GenericPlayer* avp = mp->mAVPlayer.get();
- if (avp != NULL) {
- android_Player_setPlayState(avp, mp->mPlay.mState, &(mp->mAndroidObjState));
- }
- return ATTR_PLAY_STATE;
-}
-
-
-// SL_OBJECTID_AUDIOPLAYER, ATTR_BQ_ENQUEUE
-unsigned handler_AudioPlayer_bq_enqueue(IObject *thiz)
-{
- // ( buffer queue count is non-empty and play state == PLAYING ) became true
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState);
- android_audioPlayer_bufferQueue_onRefilled_l(ap);
- return ATTR_BQ_ENQUEUE;
-}
-
-
-// SL_OBJECTID_AUDIOPLAYER, ATTR_ABQ_ENQUEUE
-unsigned handler_AudioPlayer_abq_enqueue(IObject *thiz)
-{
- // (Android buffer queue count is non-empty and play state == PLAYING ) became true
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState);
- android_audioPlayer_androidBufferQueue_onRefilled_l(ap);
- return ATTR_ABQ_ENQUEUE;
-}
-
-
-// XA_OBJECTID_MEDIAPLAYER, ATTR_ABQ_ENQUEUE
-unsigned handler_MediaPlayer_abq_enqueue(IObject *thiz)
-{
- CMediaPlayer* mp = (CMediaPlayer *)thiz;
- if (SL_PLAYSTATE_PLAYING == mp->mPlay.mState) {
- android_Player_androidBufferQueue_onRefilled_l(mp);
- }
- return ATTR_ABQ_ENQUEUE;
-}
-
-// XA_OBJECTID_MEDIAPLAYER, ATTR_POSITION
-unsigned handler_MediaPlayer_position(IObject *thiz)
-{
- CMediaPlayer *mp = (CMediaPlayer *) thiz;
- // FIXME provide means to return result for invalid use cases (e.g. buffer queue data source)
- (void) android_Player_seek(mp, mp->mSeek.mPos);
- return ATTR_POSITION;
-}
-
-#else // !defined(ANDROID)
-
-// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
-unsigned handler_AudioPlayer_gain(IObject *thiz)
-{
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- audioPlayerGainUpdate(ap);
- return ATTR_GAIN;
-}
-
-#endif
diff --git a/wilhelm/src/handlers.c b/wilhelm/src/handlers.c
deleted file mode 100644
index 8e21734..0000000
--- a/wilhelm/src/handlers.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <SLES/OpenSLES.h>
-#include <OMXAL/OpenMAXAL.h>
-#include "attr.h"
-#include "handlers.h"
-
-/* The entries in this table are sorted first by object ID, and second
- * by attribute mask. The holes in the table are deliberate to permit
- * direct lookup. Don't cross streams!
- */
-const AttributeHandler handlerTable[1 + XA_OBJECTID_CAMERADEVICE +
- (SL_OBJECTID_METADATAEXTRACTOR - SL_OBJECTID_ENGINE) + 1][ATTR_INDEX_MAX] = {
-
-// XA IDs map directly to table indices
-
- [XA_OBJECTID_MEDIAPLAYER] = {
- [ATTR_INDEX_GAIN] = handler_MediaPlayer_gain,
- [ATTR_INDEX_TRANSPORT] = handler_MediaPlayer_transport,
- [ATTR_INDEX_POSITION] = handler_MediaPlayer_position,
- [ATTR_INDEX_ABQ_ENQUEUE] = handler_MediaPlayer_abq_enqueue,
- [ATTR_INDEX_PLAY_STATE] = handler_MediaPlayer_play_state},
-
-// SL IDs need a little arithmetic to make them contiguous with XA IDs
-#define _(id) ((id) - SL_OBJECTID_ENGINE + XA_OBJECTID_CAMERADEVICE + 1)
-
- [_(SL_OBJECTID_AUDIOPLAYER)] = {
- [ATTR_INDEX_GAIN] = handler_AudioPlayer_gain,
- [ATTR_INDEX_TRANSPORT] = handler_AudioPlayer_transport,
- [ATTR_INDEX_POSITION] = handler_AudioPlayer_position,
- [ATTR_INDEX_BQ_ENQUEUE] = handler_AudioPlayer_bq_enqueue,
- [ATTR_INDEX_ABQ_ENQUEUE] = handler_AudioPlayer_abq_enqueue,
- [ATTR_INDEX_PLAY_STATE] = handler_AudioPlayer_play_state},
-
- [_(SL_OBJECTID_AUDIORECORDER)] = {
- [ATTR_INDEX_TRANSPORT] = handler_AudioRecorder_transport},
-
- [_(SL_OBJECTID_MIDIPLAYER)] = {
- [ATTR_INDEX_GAIN] = handler_MidiPlayer_gain,
- [ATTR_INDEX_POSITION] = handler_MidiPlayer_position},
-
- [_(SL_OBJECTID_OUTPUTMIX)] = {
- [ATTR_INDEX_GAIN] = handler_OutputMix_gain},
-
-};
diff --git a/wilhelm/src/handlers.h b/wilhelm/src/handlers.h
deleted file mode 100644
index c66cbb2..0000000
--- a/wilhelm/src/handlers.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __handlers_h
-#define __handlers_h
-
-#define IObject struct Object_interface
-IObject;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern unsigned handler_MediaPlayer_gain(IObject *thiz);
-#ifdef ANDROID
-extern unsigned handler_MediaPlayer_transport(IObject *thiz);
-extern unsigned handler_MediaPlayer_position(IObject *thiz);
-extern unsigned handler_MediaPlayer_abq_enqueue(IObject *thiz);
-extern unsigned handler_MediaPlayer_play_state(IObject *thiz);
-extern unsigned handler_AudioPlayer_gain(IObject *thiz);
-extern unsigned handler_AudioPlayer_transport(IObject *thiz);
-extern unsigned handler_AudioPlayer_position(IObject *thiz);
-extern unsigned handler_AudioPlayer_bq_enqueue(IObject *thiz);
-extern unsigned handler_AudioPlayer_abq_enqueue(IObject *thiz);
-extern unsigned handler_AudioPlayer_play_state(IObject *thiz);
-extern unsigned handler_AudioRecorder_transport(IObject *thiz);
-extern unsigned handler_MidiPlayer_gain(IObject *thiz);
-extern unsigned handler_MidiPlayer_position(IObject *thiz);
-extern unsigned handler_OutputMix_gain(IObject *thiz);
-#else
-#define handler_MediaPlayer_gain NULL
-#define handler_MediaPlayer_transport NULL
-#define handler_MediaPlayer_position NULL
-#define handler_MediaPlayer_abq_enqueue NULL
-#define handler_MediaPlayer_play_state NULL
-#define handler_AudioPlayer_transport NULL
-#define handler_AudioPlayer_position NULL
-#define handler_AudioPlayer_bq_enqueue NULL
-#define handler_AudioPlayer_abq_enqueue NULL
-#define handler_AudioPlayer_play_state NULL
-#define handler_AudioRecorder_transport NULL
-#define handler_MidiPlayer_gain NULL
-#define handler_MidiPlayer_position NULL
-#define handler_OutputMix_gain NULL
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/* Table entry for an attribute update handler.
- *
- * If the Object ID table index matches the object's ID, and the attribute table index
- * match any of the updated attributes, then the specified handler
- * is called. The handler is called with the object's mutex locked,
- * and should return with mutex locked. The handler returns a bitmask of the attributes which
- * were actually handled. This is normally the same as the attribute index,
- * but could be a subset (including 0) if the handler discovers that the
- * update is too complex to be handled synchronously and so must
- * be deferred to the sync thread. Note that this direct lookup table organization
- * gives O(1) search.
- */
-
-typedef unsigned (*AttributeHandler)(IObject *thiz);
-
-extern const AttributeHandler handlerTable[][ATTR_INDEX_MAX];
-
-#undef IObject
-
-#endif // !defined(__handlers_h)
diff --git a/wilhelm/src/interfaces.c b/wilhelm/src/interfaces.c
deleted file mode 100644
index b0cbd9d..0000000
--- a/wilhelm/src/interfaces.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Map minimal perfect hash of an interface ID to its name
-
-#include <assert.h>
-#include <string.h>
-#include "MPH.h"
-
-const char * const interface_names[MPH_MAX] = {
-
- // OpenSL ES 1.0.1 interfaces
- "3DCOMMIT",
- "3DDOPPLER",
- "3DGROUPING",
- "3DLOCATION",
- "3DMACROSCOPIC",
- "3DSOURCE",
- "AUDIODECODERCAPABILITIES",
- "AUDIOENCODER",
- "AUDIOENCODERCAPABILITIES",
- "AUDIOIODEVICECAPABILITIES",
- "BASSBOOST",
- "BUFFERQUEUE",
- "DEVICEVOLUME",
- "DYNAMICINTERFACEMANAGEMENT",
- "DYNAMICSOURCE",
- "EFFECTSEND",
- "ENGINE",
- "ENGINECAPABILITIES",
- "ENVIRONMENTALREVERB",
- "EQUALIZER",
- "LED",
- "METADATAEXTRACTION",
- "METADATATRAVERSAL",
- "MIDIMESSAGE",
- "MIDIMUTESOLO",
- "MIDITEMPO",
- "MIDITIME",
- "MUTESOLO",
- "NULL",
- "OBJECT",
- "OUTPUTMIX",
- "PITCH",
- "PLAY",
- "PLAYBACKRATE",
- "PREFETCHSTATUS",
- "PRESETREVERB",
- "RATEPITCH",
- "RECORD",
- "SEEK",
- "THREADSYNC",
- "VIBRA",
- "VIRTUALIZER",
- "VISUALIZATION",
- "VOLUME",
-
- // Wilhelm desktop extended interfaces
- "OUTPUTMIXEXT",
-
- // Android API level 9 extended interfaces
- "ANDROIDEFFECT",
- "ANDROIDEFFECTCAPABILITIES",
- "ANDROIDEFFECTSEND",
- "ANDROIDCONFIGURATION",
- "ANDROIDSIMPLEBUFFERQUEUE",
-
- // Android API level 12 extended interfaces
- "ANDROIDBUFFERQUEUESOURCE",
-
- // OpenMAX AL 1.0.1 interfaces
- "XAAUDIODECODERCAPABILITIES",
- "XAAUDIOENCODER",
- "XAAUDIOENCODERCAPABILITIES",
- "XAAUDIOIODEVICECAPABILITIES",
- "XACAMERA",
- "XACAMERACAPABILITIES",
- "XACONFIGEXTENSION",
- "XADEVICEVOLUME",
- "XADYNAMICINTERFACEMANAGEMENT",
- "XADYNAMICSOURCE",
- "XAENGINE",
- "XAEQUALIZER",
- "XAIMAGECONTROLS",
- "XAIMAGEDECODERCAPABILITIES",
- "XAIMAGEEFFECTS",
- "XAIMAGEENCODER",
- "XAIMAGEENCODERCAPABILITIES",
- "XALED",
- "XAMETADATAEXTRACTION",
- "XAMETADATAINSERTION",
- "XAMETADATATRAVERSAL",
- // "XANULL",
- "XAOBJECT",
- "XAOUTPUTMIX",
- "XAPLAY",
- "XAPLAYBACKRATE",
- "XAPREFETCHSTATUS",
- "XARADIO",
- "XARDS",
- "XARECORD",
- "XASEEK",
- "XASNAPSHOT",
- "XASTREAMINFORMATION",
- "XATHREADSYNC",
- "XAVIBRA",
- "XAVIDEODECODERCAPABILITIES",
- "XAVIDEOENCODER",
- "XAVIDEOENCODERCAPABILITIES",
- "XAVIDEOPOSTPROCESSING",
- "XAVOLUME",
-
-};
-
-
-/** Convert an MPH value to an MPH identifier */
-
-void MPH_to_MPH_string(unsigned MPH, char buffer[40])
-{
- assert(MPH_MAX > MPH);
- const char *infix;
- infix = "";
- strcpy(buffer, "MPH");
- strcpy(&buffer[3], infix);
- strcat(buffer, "_");
- strcat(buffer, interface_names[MPH]);
-}
diff --git a/wilhelm/src/itf/I3DCommit.c b/wilhelm/src/itf/I3DCommit.c
deleted file mode 100644
index 7ad4601..0000000
--- a/wilhelm/src/itf/I3DCommit.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* 3DCommit implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult I3DCommit_Commit(SL3DCommitItf self)
-{
- SL_ENTER_INTERFACE
-
- I3DCommit *thiz = (I3DCommit *) self;
- IObject *thisObject = InterfaceToIObject(thiz);
- object_lock_exclusive(thisObject);
- if (thiz->mDeferred) {
- SLuint32 myGeneration = thiz->mGeneration;
- do {
- ++thiz->mWaiting;
- object_cond_wait(thisObject);
- } while (thiz->mGeneration == myGeneration);
- }
- object_unlock_exclusive(thisObject);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DCommit_SetDeferred(SL3DCommitItf self, SLboolean deferred)
-{
- SL_ENTER_INTERFACE
-
- I3DCommit *thiz = (I3DCommit *) self;
- IObject *thisObject = InterfaceToIObject(thiz);
- object_lock_exclusive(thisObject);
- thiz->mDeferred = SL_BOOLEAN_FALSE != deferred; // normalize
- object_unlock_exclusive(thisObject);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SL3DCommitItf_ I3DCommit_Itf = {
- I3DCommit_Commit,
- I3DCommit_SetDeferred
-};
-
-void I3DCommit_init(void *self)
-{
- I3DCommit *thiz = (I3DCommit *) self;
- thiz->mItf = &I3DCommit_Itf;
- thiz->mDeferred = SL_BOOLEAN_FALSE;
- thiz->mGeneration = 0;
- thiz->mWaiting = 0;
-}
diff --git a/wilhelm/src/itf/I3DDoppler.c b/wilhelm/src/itf/I3DDoppler.c
deleted file mode 100644
index 8a20f81..0000000
--- a/wilhelm/src/itf/I3DDoppler.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* 3DDoppler implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult I3DDoppler_SetVelocityCartesian(SL3DDopplerItf self, const SLVec3D *pVelocity)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pVelocity) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DDoppler *thiz = (I3DDoppler *) self;
- SLVec3D velocityCartesian = *pVelocity;
- interface_lock_exclusive(thiz);
- thiz->mVelocityCartesian = velocityCartesian;
- thiz->mVelocityActive = CARTESIAN_SET_SPHERICAL_UNKNOWN;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DDoppler_SetVelocitySpherical(SL3DDopplerItf self,
- SLmillidegree azimuth, SLmillidegree elevation, SLmillimeter speed)
-{
- SL_ENTER_INTERFACE
-
- I3DDoppler *thiz = (I3DDoppler *) self;
- interface_lock_exclusive(thiz);
- thiz->mVelocitySpherical.mAzimuth = azimuth;
- thiz->mVelocitySpherical.mElevation = elevation;
- thiz->mVelocitySpherical.mSpeed = speed;
- thiz->mVelocityActive = CARTESIAN_UNKNOWN_SPHERICAL_SET;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DDoppler_GetVelocityCartesian(SL3DDopplerItf self, SLVec3D *pVelocity)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pVelocity) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DDoppler *thiz = (I3DDoppler *) self;
- interface_lock_exclusive(thiz);
- for (;;) {
- enum CartesianSphericalActive velocityActive = thiz->mVelocityActive;
- switch (velocityActive) {
- case CARTESIAN_COMPUTED_SPHERICAL_SET:
- case CARTESIAN_SET_SPHERICAL_COMPUTED: // not in 1.0.1
- case CARTESIAN_SET_SPHERICAL_REQUESTED: // not in 1.0.1
- case CARTESIAN_SET_SPHERICAL_UNKNOWN:
- {
- SLVec3D velocityCartesian = thiz->mVelocityCartesian;
- interface_unlock_exclusive(thiz);
- *pVelocity = velocityCartesian;
- }
- break;
- case CARTESIAN_UNKNOWN_SPHERICAL_SET:
- thiz->mVelocityActive = CARTESIAN_REQUESTED_SPHERICAL_SET;
- // fall through
- case CARTESIAN_REQUESTED_SPHERICAL_SET:
- // matched by cond_broadcast in case multiple requesters
-#if 0
- interface_cond_wait(thiz);
-#else
- thiz->mVelocityActive = CARTESIAN_COMPUTED_SPHERICAL_SET;
-#endif
- continue;
- default:
- assert(SL_BOOLEAN_FALSE);
- interface_unlock_exclusive(thiz);
- pVelocity->x = 0;
- pVelocity->y = 0;
- pVelocity->z = 0;
- break;
- }
- break;
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DDoppler_SetDopplerFactor(SL3DDopplerItf self, SLpermille dopplerFactor)
-{
- SL_ENTER_INTERFACE
-
- I3DDoppler *thiz = (I3DDoppler *) self;
- interface_lock_poke(thiz);
- thiz->mDopplerFactor = dopplerFactor;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DDoppler_GetDopplerFactor(SL3DDopplerItf self, SLpermille *pDopplerFactor)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDopplerFactor) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DDoppler *thiz = (I3DDoppler *) self;
- interface_lock_peek(thiz);
- SLpermille dopplerFactor = thiz->mDopplerFactor;
- interface_unlock_peek(thiz);
- *pDopplerFactor = dopplerFactor;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SL3DDopplerItf_ I3DDoppler_Itf = {
- I3DDoppler_SetVelocityCartesian,
- I3DDoppler_SetVelocitySpherical,
- I3DDoppler_GetVelocityCartesian,
- I3DDoppler_SetDopplerFactor,
- I3DDoppler_GetDopplerFactor
-};
-
-void I3DDoppler_init(void *self)
-{
- I3DDoppler *thiz = (I3DDoppler *) self;
- thiz->mItf = &I3DDoppler_Itf;
- thiz->mVelocityCartesian.x = 0;
- thiz->mVelocityCartesian.y = 0;
- thiz->mVelocityCartesian.z = 0;
- memset(&thiz->mVelocitySpherical, 0x55, sizeof(thiz->mVelocitySpherical));
- thiz->mVelocityActive = CARTESIAN_SET_SPHERICAL_UNKNOWN;
- thiz->mDopplerFactor = 1000;
-}
diff --git a/wilhelm/src/itf/I3DGrouping.c b/wilhelm/src/itf/I3DGrouping.c
deleted file mode 100644
index 45172b3..0000000
--- a/wilhelm/src/itf/I3DGrouping.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* 3DGrouping implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult I3DGrouping_Set3DGroup(SL3DGroupingItf self, SLObjectItf group)
-{
- SL_ENTER_INTERFACE
-
- // validate input parameters
- C3DGroup *newGroup = (C3DGroup *) group;
- result = SL_RESULT_SUCCESS;
- if (NULL != newGroup) {
- // check that new group has the correct object ID and is realized, and acquire a strong
- // reference to it. FYI note that a deadlock will occur if application incorrectly
- // specifies group as this audio player
- result = AcquireStrongRef(&newGroup->mObject, SL_OBJECTID_3DGROUP);
- // the new group is left unlocked, but it will be locked again below
- }
- if (SL_RESULT_SUCCESS == result) {
- I3DGrouping *thiz = (I3DGrouping *) self;
- IObject *thisObject = InterfaceToIObject(thiz);
- unsigned id = thisObject->mInstanceID;
- assert(0 != id); // player object must be published by this point
- --id;
- assert(MAX_INSTANCE > id);
- unsigned mask = 1 << id;
- interface_lock_exclusive(thiz);
- C3DGroup *oldGroup = thiz->mGroup;
- if (newGroup != oldGroup) {
- // remove this object from the old group's set of objects
- if (NULL != oldGroup) {
- IObject *oldGroupObject = &oldGroup->mObject;
- // note that we already have a strong reference to the old group
- object_lock_exclusive(oldGroupObject);
- assert(oldGroup->mMemberMask & mask);
- oldGroup->mMemberMask &= ~mask;
- ReleaseStrongRefAndUnlockExclusive(oldGroupObject);
- }
- // add this object to the new group's set of objects
- if (NULL != newGroup) {
- IObject *newGroupObject = &newGroup->mObject;
- // we already have a strong reference to the new group, but we need to re-lock it
- // so that we always lock objects in the same nesting order to prevent a deadlock
- object_lock_exclusive(newGroupObject);
- assert(!(newGroup->mMemberMask & mask));
- newGroup->mMemberMask |= mask;
- object_unlock_exclusive(newGroupObject);
- }
- thiz->mGroup = newGroup;
- }
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DGrouping_Get3DGroup(SL3DGroupingItf self, SLObjectItf *pGroup)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pGroup) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DGrouping *thiz = (I3DGrouping *) self;
- interface_lock_shared(thiz);
- C3DGroup *group = thiz->mGroup;
- *pGroup = (NULL != group) ? &group->mObject.mItf : NULL;
- interface_unlock_shared(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SL3DGroupingItf_ I3DGrouping_Itf = {
- I3DGrouping_Set3DGroup,
- I3DGrouping_Get3DGroup
-};
-
-void I3DGrouping_init(void *self)
-{
- I3DGrouping *thiz = (I3DGrouping *) self;
- thiz->mItf = &I3DGrouping_Itf;
- thiz->mGroup = NULL;
-}
-
-void I3DGrouping_deinit(void *self)
-{
- I3DGrouping *thiz = (I3DGrouping *) self;
- C3DGroup *group = thiz->mGroup;
- if (NULL != group) {
- unsigned mask = 1 << (InterfaceToIObject(thiz)->mInstanceID - 1);
- IObject *groupObject = &group->mObject;
- object_lock_exclusive(groupObject);
- assert(group->mMemberMask & mask);
- group->mMemberMask &= ~mask;
- ReleaseStrongRefAndUnlockExclusive(groupObject);
- }
-}
diff --git a/wilhelm/src/itf/I3DLocation.c b/wilhelm/src/itf/I3DLocation.c
deleted file mode 100644
index c0eff3b..0000000
--- a/wilhelm/src/itf/I3DLocation.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* 3DLocation implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult I3DLocation_SetLocationCartesian(SL3DLocationItf self, const SLVec3D *pLocation)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pLocation) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DLocation *thiz = (I3DLocation *) self;
- SLVec3D locationCartesian = *pLocation;
- interface_lock_exclusive(thiz);
- thiz->mLocationCartesian = locationCartesian;
- thiz->mLocationActive = CARTESIAN_SET_SPHERICAL_UNKNOWN;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DLocation_SetLocationSpherical(SL3DLocationItf self,
- SLmillidegree azimuth, SLmillidegree elevation, SLmillimeter distance)
-{
- SL_ENTER_INTERFACE
-
- if (!((-360000 <= azimuth) && (azimuth <= 360000) &&
- (-90000 <= elevation) && (elevation <= 90000) &&
- (0 <= distance) && (distance <= SL_MILLIMETER_MAX))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DLocation *thiz = (I3DLocation *) self;
- interface_lock_exclusive(thiz);
- thiz->mLocationSpherical.mAzimuth = azimuth;
- thiz->mLocationSpherical.mElevation = elevation;
- thiz->mLocationSpherical.mDistance = distance;
- thiz->mLocationActive = CARTESIAN_UNKNOWN_SPHERICAL_SET;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DLocation_Move(SL3DLocationItf self, const SLVec3D *pMovement)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMovement) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DLocation *thiz = (I3DLocation *) self;
- SLVec3D movementCartesian = *pMovement;
- interface_lock_exclusive(thiz);
- for (;;) {
- enum CartesianSphericalActive locationActive = thiz->mLocationActive;
- switch (locationActive) {
- case CARTESIAN_COMPUTED_SPHERICAL_SET:
- case CARTESIAN_SET_SPHERICAL_COMPUTED: // not in 1.0.1
- case CARTESIAN_SET_SPHERICAL_REQUESTED: // not in 1.0.1
- case CARTESIAN_SET_SPHERICAL_UNKNOWN:
- thiz->mLocationCartesian.x += movementCartesian.x;
- thiz->mLocationCartesian.y += movementCartesian.y;
- thiz->mLocationCartesian.z += movementCartesian.z;
- thiz->mLocationActive = CARTESIAN_SET_SPHERICAL_UNKNOWN;
- break;
- case CARTESIAN_UNKNOWN_SPHERICAL_SET:
- thiz->mLocationActive = CARTESIAN_REQUESTED_SPHERICAL_SET;
- // fall through
- case CARTESIAN_REQUESTED_SPHERICAL_SET:
- // matched by cond_broadcast in case multiple requesters
-#if 0
- interface_cond_wait(thiz);
-#else
- thiz->mLocationActive = CARTESIAN_COMPUTED_SPHERICAL_SET;
-#endif
- continue;
- default:
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- break;
- }
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DLocation_GetLocationCartesian(SL3DLocationItf self, SLVec3D *pLocation)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pLocation) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DLocation *thiz = (I3DLocation *) self;
- interface_lock_exclusive(thiz);
- for (;;) {
- enum CartesianSphericalActive locationActive = thiz->mLocationActive;
- switch (locationActive) {
- case CARTESIAN_COMPUTED_SPHERICAL_SET:
- case CARTESIAN_SET_SPHERICAL_COMPUTED: // not in 1.0.1
- case CARTESIAN_SET_SPHERICAL_REQUESTED: // not in 1.0.1
- case CARTESIAN_SET_SPHERICAL_UNKNOWN:
- {
- SLVec3D locationCartesian = thiz->mLocationCartesian;
- interface_unlock_exclusive(thiz);
- *pLocation = locationCartesian;
- }
- break;
- case CARTESIAN_UNKNOWN_SPHERICAL_SET:
- thiz->mLocationActive = CARTESIAN_REQUESTED_SPHERICAL_SET;
- // fall through
- case CARTESIAN_REQUESTED_SPHERICAL_SET:
- // matched by cond_broadcast in case multiple requesters
-#if 0
- interface_cond_wait(thiz);
-#else
- thiz->mLocationActive = CARTESIAN_COMPUTED_SPHERICAL_SET;
-#endif
- continue;
- default:
- assert(SL_BOOLEAN_FALSE);
- interface_unlock_exclusive(thiz);
- pLocation->x = 0;
- pLocation->y = 0;
- pLocation->z = 0;
- break;
- }
- break;
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DLocation_SetOrientationVectors(SL3DLocationItf self,
- const SLVec3D *pFront, const SLVec3D *pAbove)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pFront || NULL == pAbove) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLVec3D front = *pFront;
- SLVec3D above = *pAbove;
- // NTH Check for vectors close to zero or close to parallel
- I3DLocation *thiz = (I3DLocation *) self;
- interface_lock_exclusive(thiz);
- thiz->mOrientationVectors.mFront = front;
- thiz->mOrientationVectors.mAbove = above;
- thiz->mOrientationActive = ANGLES_UNKNOWN_VECTORS_SET;
- thiz->mRotatePending = SL_BOOLEAN_FALSE;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DLocation_SetOrientationAngles(SL3DLocationItf self,
- SLmillidegree heading, SLmillidegree pitch, SLmillidegree roll)
-{
- SL_ENTER_INTERFACE
-
- if (!((-360000 <= heading) && (heading <= 360000) &&
- (-90000 <= pitch) && (pitch <= 90000) &&
- (-360000 <= roll) && (roll <= 360000))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DLocation *thiz = (I3DLocation *) self;
- interface_lock_exclusive(thiz);
- thiz->mOrientationAngles.mHeading = heading;
- thiz->mOrientationAngles.mPitch = pitch;
- thiz->mOrientationAngles.mRoll = roll;
- thiz->mOrientationActive = ANGLES_SET_VECTORS_UNKNOWN;
- thiz->mRotatePending = SL_BOOLEAN_FALSE;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DLocation_Rotate(SL3DLocationItf self, SLmillidegree theta, const SLVec3D *pAxis)
-{
- SL_ENTER_INTERFACE
-
- if (!((-360000 <= theta) && (theta <= 360000)) || (NULL == pAxis)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLVec3D axis = *pAxis;
- // NTH Check that axis is not (close to) zero vector, length does not matter
- I3DLocation *thiz = (I3DLocation *) self;
- interface_lock_exclusive(thiz);
- while (thiz->mRotatePending)
-#if 0
- interface_cond_wait(thiz);
-#else
- break;
-#endif
- thiz->mTheta = theta;
- thiz->mAxis = axis;
- thiz->mRotatePending = SL_BOOLEAN_TRUE;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DLocation_GetOrientationVectors(SL3DLocationItf self,
- SLVec3D *pFront, SLVec3D *pUp)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pFront || NULL == pUp) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DLocation *thiz = (I3DLocation *) self;
- interface_lock_shared(thiz);
- SLVec3D front = thiz->mOrientationVectors.mFront;
- SLVec3D up = thiz->mOrientationVectors.mUp;
- interface_unlock_shared(thiz);
- *pFront = front;
- *pUp = up;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SL3DLocationItf_ I3DLocation_Itf = {
- I3DLocation_SetLocationCartesian,
- I3DLocation_SetLocationSpherical,
- I3DLocation_Move,
- I3DLocation_GetLocationCartesian,
- I3DLocation_SetOrientationVectors,
- I3DLocation_SetOrientationAngles,
- I3DLocation_Rotate,
- I3DLocation_GetOrientationVectors
-};
-
-void I3DLocation_init(void *self)
-{
- I3DLocation *thiz = (I3DLocation *) self;
- thiz->mItf = &I3DLocation_Itf;
- thiz->mLocationCartesian.x = 0;
- thiz->mLocationCartesian.y = 0;
- thiz->mLocationCartesian.z = 0;
- memset(&thiz->mLocationSpherical, 0x55, sizeof(thiz->mLocationSpherical));
- thiz->mLocationActive = CARTESIAN_SET_SPHERICAL_UNKNOWN;
- thiz->mOrientationAngles.mHeading = 0;
- thiz->mOrientationAngles.mPitch = 0;
- thiz->mOrientationAngles.mRoll = 0;
- memset(&thiz->mOrientationVectors, 0x55, sizeof(thiz->mOrientationVectors));
- thiz->mOrientationActive = ANGLES_SET_VECTORS_UNKNOWN;
- thiz->mTheta = 0x55555555;
- thiz->mAxis.x = 0x55555555;
- thiz->mAxis.y = 0x55555555;
- thiz->mAxis.z = 0x55555555;
- thiz->mRotatePending = SL_BOOLEAN_FALSE;
-}
diff --git a/wilhelm/src/itf/I3DMacroscopic.c b/wilhelm/src/itf/I3DMacroscopic.c
deleted file mode 100644
index feb91e2..0000000
--- a/wilhelm/src/itf/I3DMacroscopic.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* 3DMacroscopic implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult I3DMacroscopic_SetSize(SL3DMacroscopicItf self,
- SLmillimeter width, SLmillimeter height, SLmillimeter depth)
-{
- SL_ENTER_INTERFACE
-
- if (!((0 <= width) && (width <= SL_MILLIMETER_MAX) &&
- (0 <= height) && (height <= SL_MILLIMETER_MAX) &&
- (0 <= depth) && (depth <= SL_MILLIMETER_MAX))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DMacroscopic *thiz = (I3DMacroscopic *) self;
- interface_lock_exclusive(thiz);
- thiz->mSize.mWidth = width;
- thiz->mSize.mHeight = height;
- thiz->mSize.mDepth = depth;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DMacroscopic_GetSize(SL3DMacroscopicItf self,
- SLmillimeter *pWidth, SLmillimeter *pHeight, SLmillimeter *pDepth)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pWidth || NULL == pHeight || NULL == pDepth) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DMacroscopic *thiz = (I3DMacroscopic *) self;
- interface_lock_shared(thiz);
- SLmillimeter width = thiz->mSize.mWidth;
- SLmillimeter height = thiz->mSize.mHeight;
- SLmillimeter depth = thiz->mSize.mDepth;
- interface_unlock_shared(thiz);
- *pWidth = width;
- *pHeight = height;
- *pDepth = depth;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DMacroscopic_SetOrientationAngles(SL3DMacroscopicItf self,
- SLmillidegree heading, SLmillidegree pitch, SLmillidegree roll)
-{
- SL_ENTER_INTERFACE
-
- if (!((-360000 <= heading) && (heading <= 360000) &&
- (-90000 <= pitch) && (pitch <= 90000) &&
- (-360000 <= roll) && (roll <= 360000))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DMacroscopic *thiz = (I3DMacroscopic *) self;
- interface_lock_exclusive(thiz);
- thiz->mOrientationAngles.mHeading = heading;
- thiz->mOrientationAngles.mPitch = pitch;
- thiz->mOrientationAngles.mRoll = roll;
- thiz->mOrientationActive = ANGLES_SET_VECTORS_UNKNOWN;
- thiz->mRotatePending = SL_BOOLEAN_FALSE;
- // ++thiz->mGeneration;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DMacroscopic_SetOrientationVectors(SL3DMacroscopicItf self,
- const SLVec3D *pFront, const SLVec3D *pAbove)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pFront || NULL == pAbove) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DMacroscopic *thiz = (I3DMacroscopic *) self;
- SLVec3D front = *pFront;
- SLVec3D above = *pAbove;
- // NTH Check for vectors close to zero or close to parallel
- interface_lock_exclusive(thiz);
- thiz->mOrientationVectors.mFront = front;
- thiz->mOrientationVectors.mAbove = above;
- thiz->mOrientationVectors.mUp = above; // wrong
- thiz->mOrientationActive = ANGLES_UNKNOWN_VECTORS_SET;
- thiz->mRotatePending = SL_BOOLEAN_FALSE;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DMacroscopic_Rotate(SL3DMacroscopicItf self,
- SLmillidegree theta, const SLVec3D *pAxis)
-{
- SL_ENTER_INTERFACE
-
- if (!((-360000 <= theta) && (theta <= 360000)) || NULL == pAxis) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLVec3D axis = *pAxis;
- // NTH Check that axis is not (close to) zero vector, length does not matter
- I3DMacroscopic *thiz = (I3DMacroscopic *) self;
- interface_lock_exclusive(thiz);
- while (thiz->mRotatePending)
- interface_cond_wait(thiz);
- thiz->mTheta = theta;
- thiz->mAxis = axis;
- thiz->mRotatePending = SL_BOOLEAN_TRUE;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DMacroscopic_GetOrientationVectors(SL3DMacroscopicItf self,
- SLVec3D *pFront, SLVec3D *pUp)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pFront || NULL == pUp) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DMacroscopic *thiz = (I3DMacroscopic *) self;
- interface_lock_exclusive(thiz);
- for (;;) {
- enum AnglesVectorsActive orientationActive = thiz->mOrientationActive;
- switch (orientationActive) {
- case ANGLES_COMPUTED_VECTORS_SET: // not in 1.0.1
- case ANGLES_REQUESTED_VECTORS_SET: // not in 1.0.1
- case ANGLES_UNKNOWN_VECTORS_SET:
- case ANGLES_SET_VECTORS_COMPUTED:
- {
- SLVec3D front = thiz->mOrientationVectors.mFront;
- SLVec3D up = thiz->mOrientationVectors.mUp;
- interface_unlock_exclusive(thiz);
- *pFront = front;
- *pUp = up;
- }
- break;
- case ANGLES_SET_VECTORS_UNKNOWN:
- thiz->mOrientationActive = ANGLES_SET_VECTORS_REQUESTED;
- // fall through
- case ANGLES_SET_VECTORS_REQUESTED:
- // matched by cond_broadcast in case multiple requesters
-#if 0
- interface_cond_wait(thiz);
-#else
- thiz->mOrientationActive = ANGLES_SET_VECTORS_COMPUTED;
-#endif
- continue;
- default:
- interface_unlock_exclusive(thiz);
- assert(SL_BOOLEAN_FALSE);
- pFront->x = 0;
- pFront->y = 0;
- pFront->z = 0;
- pUp->x = 0;
- pUp->y = 0;
- pUp->z = 0;
- break;
- }
- break;
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SL3DMacroscopicItf_ I3DMacroscopic_Itf = {
- I3DMacroscopic_SetSize,
- I3DMacroscopic_GetSize,
- I3DMacroscopic_SetOrientationAngles,
- I3DMacroscopic_SetOrientationVectors,
- I3DMacroscopic_Rotate,
- I3DMacroscopic_GetOrientationVectors
-};
-
-void I3DMacroscopic_init(void *self)
-{
- I3DMacroscopic *thiz = (I3DMacroscopic *) self;
- thiz->mItf = &I3DMacroscopic_Itf;
- thiz->mSize.mWidth = 0;
- thiz->mSize.mHeight = 0;
- thiz->mSize.mDepth = 0;
- thiz->mOrientationAngles.mHeading = 0;
- thiz->mOrientationAngles.mPitch = 0;
- thiz->mOrientationAngles.mRoll = 0;
- memset(&thiz->mOrientationVectors, 0x55, sizeof(thiz->mOrientationVectors));
- thiz->mOrientationVectors.mFront.x = 0;
- thiz->mOrientationVectors.mFront.y = 0;
- thiz->mOrientationVectors.mFront.z = -1000;
- thiz->mOrientationVectors.mUp.x = 0;
- thiz->mOrientationVectors.mUp.y = 1000;
- thiz->mOrientationVectors.mUp.z = 0;
- thiz->mOrientationVectors.mAbove.x = 0;
- thiz->mOrientationVectors.mAbove.y = 0;
- thiz->mOrientationVectors.mAbove.z = 0;
- thiz->mOrientationActive = ANGLES_SET_VECTORS_COMPUTED;
- thiz->mTheta = 0x55555555;
- thiz->mAxis.x = 0x55555555;
- thiz->mAxis.y = 0x55555555;
- thiz->mAxis.z = 0x55555555;
- thiz->mRotatePending = SL_BOOLEAN_FALSE;
-}
diff --git a/wilhelm/src/itf/I3DSource.c b/wilhelm/src/itf/I3DSource.c
deleted file mode 100644
index fdc7d36..0000000
--- a/wilhelm/src/itf/I3DSource.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* 3DSource implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult I3DSource_SetHeadRelative(SL3DSourceItf self, SLboolean headRelative)
-{
- SL_ENTER_INTERFACE
-
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_poke(thiz);
- thiz->mHeadRelative = SL_BOOLEAN_FALSE != headRelative; // normalize
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_GetHeadRelative(SL3DSourceItf self, SLboolean *pHeadRelative)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pHeadRelative) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_peek(thiz);
- SLboolean headRelative = thiz->mHeadRelative;
- interface_unlock_peek(thiz);
- *pHeadRelative = headRelative;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_SetRolloffDistances(SL3DSourceItf self,
- SLmillimeter minDistance, SLmillimeter maxDistance)
-{
- SL_ENTER_INTERFACE
-
- if (!((0 < minDistance) && (minDistance <= SL_MILLIMETER_MAX) &&
- (minDistance <= maxDistance) && (maxDistance <= SL_MILLIMETER_MAX))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_exclusive(thiz);
- thiz->mMinDistance = minDistance;
- thiz->mMaxDistance = maxDistance;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_GetRolloffDistances(SL3DSourceItf self,
- SLmillimeter *pMinDistance, SLmillimeter *pMaxDistance)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMinDistance || NULL == pMaxDistance) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self; interface_lock_shared(thiz);
- SLmillimeter minDistance = thiz->mMinDistance;
- SLmillimeter maxDistance = thiz->mMaxDistance;
- interface_unlock_shared(thiz);
- *pMinDistance = minDistance;
- *pMaxDistance = maxDistance;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_SetRolloffMaxDistanceMute(SL3DSourceItf self, SLboolean mute)
-{
- SL_ENTER_INTERFACE
-
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_poke(thiz);
- thiz->mRolloffMaxDistanceMute = SL_BOOLEAN_FALSE != mute; // normalize
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_GetRolloffMaxDistanceMute(SL3DSourceItf self, SLboolean *pMute)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMute) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_peek(thiz);
- SLboolean mute = thiz->mRolloffMaxDistanceMute;
- interface_unlock_peek(thiz);
- *pMute = mute;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_SetRolloffFactor(SL3DSourceItf self, SLpermille rolloffFactor)
-{
- SL_ENTER_INTERFACE
-
- if (!((0 <= rolloffFactor) && (rolloffFactor <= 10000))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_poke(thiz);
- thiz->mRolloffFactor = rolloffFactor;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_GetRolloffFactor(SL3DSourceItf self, SLpermille *pRolloffFactor)
-{
- SL_ENTER_INTERFACE
-
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_peek(thiz);
- SLpermille rolloffFactor = thiz->mRolloffFactor;
- interface_unlock_peek(thiz);
- *pRolloffFactor = rolloffFactor;
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_SetRoomRolloffFactor(SL3DSourceItf self, SLpermille roomRolloffFactor)
-{
- SL_ENTER_INTERFACE
-
- if (!((0 <= roomRolloffFactor) && (roomRolloffFactor <= 10000))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_poke(thiz);
- thiz->mRoomRolloffFactor = roomRolloffFactor;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_GetRoomRolloffFactor(SL3DSourceItf self, SLpermille *pRoomRolloffFactor)
-{
- SL_ENTER_INTERFACE
-
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_peek(thiz);
- SLpermille roomRolloffFactor = thiz->mRoomRolloffFactor;
- interface_unlock_peek(thiz);
- *pRoomRolloffFactor = roomRolloffFactor;
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_SetRolloffModel(SL3DSourceItf self, SLuint8 model)
-{
- SL_ENTER_INTERFACE
-
- switch (model) {
- case SL_ROLLOFFMODEL_LINEAR:
- case SL_ROLLOFFMODEL_EXPONENTIAL:
- {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_poke(thiz);
- thiz->mDistanceModel = model;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_GetRolloffModel(SL3DSourceItf self, SLuint8 *pModel)
-{
- SL_ENTER_INTERFACE
-
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_peek(thiz);
- SLuint8 model = thiz->mDistanceModel;
- interface_unlock_peek(thiz);
- *pModel = model;
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_SetCone(SL3DSourceItf self, SLmillidegree innerAngle,
- SLmillidegree outerAngle, SLmillibel outerLevel)
-{
- SL_ENTER_INTERFACE
-
- if (!((0 <= innerAngle) && (innerAngle <= 360000) &&
- (0 <= outerAngle) && (outerAngle <= 360000) &&
- (SL_MILLIBEL_MIN <= outerLevel) && (outerLevel <= 0))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_exclusive(thiz);
- thiz->mConeInnerAngle = innerAngle;
- thiz->mConeOuterAngle = outerAngle;
- thiz->mConeOuterLevel = outerLevel;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult I3DSource_GetCone(SL3DSourceItf self, SLmillidegree *pInnerAngle,
- SLmillidegree *pOuterAngle, SLmillibel *pOuterLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pInnerAngle || NULL == pOuterAngle || NULL == pOuterLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- I3DSource *thiz = (I3DSource *) self;
- interface_lock_shared(thiz);
- SLmillidegree innerAngle = thiz->mConeInnerAngle;
- SLmillidegree outerAngle = thiz->mConeOuterAngle;
- SLmillibel outerLevel = thiz->mConeOuterLevel;
- interface_unlock_shared(thiz);
- *pInnerAngle = innerAngle;
- *pOuterAngle = outerAngle;
- *pOuterLevel = outerLevel;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SL3DSourceItf_ I3DSource_Itf = {
- I3DSource_SetHeadRelative,
- I3DSource_GetHeadRelative,
- I3DSource_SetRolloffDistances,
- I3DSource_GetRolloffDistances,
- I3DSource_SetRolloffMaxDistanceMute,
- I3DSource_GetRolloffMaxDistanceMute,
- I3DSource_SetRolloffFactor,
- I3DSource_GetRolloffFactor,
- I3DSource_SetRoomRolloffFactor,
- I3DSource_GetRoomRolloffFactor,
- I3DSource_SetRolloffModel,
- I3DSource_GetRolloffModel,
- I3DSource_SetCone,
- I3DSource_GetCone
-};
-
-void I3DSource_init(void *self)
-{
- I3DSource *thiz = (I3DSource *) self;
- thiz->mItf = &I3DSource_Itf;
- thiz->mHeadRelative = SL_BOOLEAN_FALSE;
- thiz->mRolloffMaxDistanceMute = SL_BOOLEAN_FALSE;
- thiz->mMaxDistance = SL_MILLIMETER_MAX;
- thiz->mMinDistance = 1000;
- thiz->mConeInnerAngle = 360000;
- thiz->mConeOuterAngle = 360000;
- thiz->mConeOuterLevel = 0;
- thiz->mRolloffFactor = 1000;
- thiz->mRoomRolloffFactor = 0;
- thiz->mDistanceModel = SL_ROLLOFFMODEL_EXPONENTIAL;
-}
diff --git a/wilhelm/src/itf/IAndroidBufferQueue.c b/wilhelm/src/itf/IAndroidBufferQueue.c
deleted file mode 100644
index 884f637..0000000
--- a/wilhelm/src/itf/IAndroidBufferQueue.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* AndroidBufferQueue implementation */
-
-//#define USE_LOG SLAndroidLogLevel_Verbose
-
-#include "sles_allinclusive.h"
-// for AAC ADTS verification on enqueue:
-#include "android/include/AacBqToPcmCbRenderer.h"
-
-/**
- * Determine the state of the audio player or audio recorder associated with a buffer queue.
- * Note that PLAYSTATE and RECORDSTATE values are equivalent (where PLAYING == RECORDING).
- */
-
-static SLuint32 getAssociatedState(IAndroidBufferQueue *thiz)
-{
- SLuint32 state;
- switch (InterfaceToObjectID(thiz)) {
- case XA_OBJECTID_MEDIAPLAYER:
- state = ((CMediaPlayer *) thiz->mThis)->mPlay.mState;
- break;
- case SL_OBJECTID_AUDIOPLAYER:
- state = ((CAudioPlayer *) thiz->mThis)->mPlay.mState;
- break;
- default:
- // unreachable, but just in case we will assume it is stopped
- assert(SL_BOOLEAN_FALSE);
- state = SL_PLAYSTATE_STOPPED;
- break;
- }
- return state;
-}
-
-
-/**
- * parse and set the items associated with the given buffer, based on the buffer type,
- * which determines the set of authorized items and format
- */
-static void setItems(const SLAndroidBufferItem *pItems, SLuint32 itemsLength,
- SLuint16 bufferType, AdvancedBufferHeader *pBuff)
-{
- // reset item structure based on type
- switch (bufferType) {
- case kAndroidBufferTypeMpeg2Ts:
- pBuff->mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE;
- pBuff->mItems.mTsCmdData.mPts = 0;
- break;
- case kAndroidBufferTypeAacadts:
- pBuff->mItems.mAdtsCmdData.mAdtsCmdCode = ANDROID_ADTSEVENT_NONE;
- break;
- case kAndroidBufferTypeInvalid:
- default:
- // shouldn't happen, but just in case clear out the item structure
- memset(&pBuff->mItems, 0, sizeof(AdvancedBufferItems));
- return;
- }
-
- // process all items in the array; if no items then we break out of loop immediately
- while (itemsLength > 0) {
-
- // remaining length must be large enough for one full item without any associated data
- if (itemsLength < sizeof(SLAndroidBufferItem)) {
- SL_LOGE("Partial item at end of array ignored");
- break;
- }
- itemsLength -= sizeof(SLAndroidBufferItem);
-
- // remaining length must be large enough for data with current item and alignment padding
- SLuint32 itemDataSizeWithAlignmentPadding = (pItems->itemSize + 3) & ~3;
- if (itemsLength < itemDataSizeWithAlignmentPadding) {
- SL_LOGE("Partial item data at end of array ignored");
- break;
- }
- itemsLength -= itemDataSizeWithAlignmentPadding;
-
- // parse item data based on type
- switch (bufferType) {
-
- case kAndroidBufferTypeMpeg2Ts: {
- switch (pItems->itemKey) {
-
- case SL_ANDROID_ITEMKEY_EOS:
- pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_EOS;
- //SL_LOGD("Found EOS event=%d", pBuff->mItems.mTsCmdData.mTsCmdCode);
- if (pItems->itemSize != 0) {
- SL_LOGE("Invalid item parameter size %u for EOS, ignoring value",
- pItems->itemSize);
- }
- break;
-
- case SL_ANDROID_ITEMKEY_DISCONTINUITY:
- if (pItems->itemSize == 0) {
- pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_DISCONTINUITY;
- //SL_LOGD("Found DISCONTINUITYevent=%d", pBuff->mItems.mTsCmdData.mTsCmdCode);
- } else if (pItems->itemSize == sizeof(SLAuint64)) {
- pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_DISCON_NEWPTS;
- pBuff->mItems.mTsCmdData.mPts = *((SLAuint64*)pItems->itemData);
- //SL_LOGD("Found PTS=%lld", pBuff->mItems.mTsCmdData.mPts);
- } else {
- SL_LOGE("Invalid item parameter size %u for MPEG-2 PTS, ignoring value",
- pItems->itemSize);
- pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_DISCONTINUITY;
- }
- break;
-
- case SL_ANDROID_ITEMKEY_FORMAT_CHANGE:
- // distinguish between a "full" format change and one where it says what changed
- if (pItems->itemSize == 0) {
- SL_LOGV("Received format change with no data == full format change");
- pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL;
- } else if (pItems->itemSize == sizeof(SLuint32)) {
- XAuint32 formatData = *((XAuint32*)pItems->itemData);
- // intentionally only supporting video change when reading which specific
- // stream has changed, interpret other changes as full change
- if (formatData == XA_ANDROID_FORMATCHANGE_ITEMDATA_VIDEO) {
- pBuff->mItems.mTsCmdData.mTsCmdCode |=
- ANDROID_MP2TSEVENT_FORMAT_CHANGE_VIDEO;
- SL_LOGV("Received video format change");
- } else {
- // note that we don't support specifying
- // ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL by having all bits of
- // the data mask set, we default to it with unsupported masks
- SL_LOGE("Received format change with unsupported data, ignoring data");
- pBuff->mItems.mTsCmdData.mTsCmdCode |=
- ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL;
- }
- } else {
- SL_LOGE("Received format change with invalid data size, ignoring data");
- pBuff->mItems.mTsCmdData.mTsCmdCode |= ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL;
- }
- break;
-
- default:
- // unknown item key
- SL_LOGE("Unknown item key %u with size %u ignored", pItems->itemKey,
- pItems->itemSize);
- break;
-
- }// switch (pItems->itemKey)
- } break;
-
- case kAndroidBufferTypeAacadts: {
- switch (pItems->itemKey) {
-
- case SL_ANDROID_ITEMKEY_EOS:
- pBuff->mItems.mAdtsCmdData.mAdtsCmdCode |= ANDROID_ADTSEVENT_EOS;
- if (pItems->itemSize != 0) {
- SL_LOGE("Invalid item parameter size %u for EOS, ignoring value",
- pItems->itemSize);
- }
- break;
-
- default:
- // unknown item key
- SL_LOGE("Unknown item key %u with size %u ignored", pItems->itemKey,
- pItems->itemSize);
- break;
-
- }// switch (pItems->itemKey)
- } break;
-
- case kAndroidBufferTypeInvalid:
- default:
- // not reachable as we checked this earlier
- return;
-
- }// switch (bufferType)
-
- // skip past this item, including data with alignment padding
- pItems = (SLAndroidBufferItem *) ((char *) pItems +
- sizeof(SLAndroidBufferItem) + itemDataSizeWithAlignmentPadding);
- }
-
- // now check for invalid combinations of items
- switch (bufferType) {
-
- case kAndroidBufferTypeMpeg2Ts: {
- // supported Mpeg2Ts commands are mutually exclusive
- switch (pBuff->mItems.mTsCmdData.mTsCmdCode) {
- // single items are allowed
- case ANDROID_MP2TSEVENT_NONE:
- case ANDROID_MP2TSEVENT_EOS:
- case ANDROID_MP2TSEVENT_DISCONTINUITY:
- case ANDROID_MP2TSEVENT_DISCON_NEWPTS:
- case ANDROID_MP2TSEVENT_FORMAT_CHANGE_FULL:
- case ANDROID_MP2TSEVENT_FORMAT_CHANGE_VIDEO:
- break;
- // no combinations are allowed
- default:
- SL_LOGE("Invalid combination of items; all ignored");
- pBuff->mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE;
- break;
- }
- } break;
-
- case kAndroidBufferTypeAacadts: {
- // only one item supported, and thus no combination check needed
- } break;
-
- case kAndroidBufferTypeInvalid:
- default:
- // not reachable as we checked this earlier
- return;
- }
-
-}
-
-
-static SLresult IAndroidBufferQueue_RegisterCallback(SLAndroidBufferQueueItf self,
- slAndroidBufferQueueCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
-
- interface_lock_exclusive(thiz);
-
- // verify pre-condition that media object is in the SL_PLAYSTATE_STOPPED state
- if (SL_PLAYSTATE_STOPPED == getAssociatedState(thiz)) {
- thiz->mCallback = callback;
- thiz->mContext = pContext;
-
- // FIXME investigate why these two cases are not handled symmetrically any more
- switch (InterfaceToObjectID(thiz)) {
- case SL_OBJECTID_AUDIOPLAYER:
- result = android_audioPlayer_androidBufferQueue_registerCallback_l(
- (CAudioPlayer*) thiz->mThis);
- break;
- case XA_OBJECTID_MEDIAPLAYER:
- result = SL_RESULT_SUCCESS;
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- } else {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- }
-
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidBufferQueue_Clear(SLAndroidBufferQueueItf self)
-{
- SL_ENTER_INTERFACE
- result = SL_RESULT_SUCCESS;
-
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
-
- interface_lock_exclusive(thiz);
-
- // reset the queue pointers
- thiz->mFront = &thiz->mBufferArray[0];
- thiz->mRear = &thiz->mBufferArray[0];
- // reset the queue state
- thiz->mState.count = 0;
- thiz->mState.index = 0;
- // reset the individual buffers
- for (XAuint16 i=0 ; i<(thiz->mNumBuffers + 1) ; i++) {
- thiz->mBufferArray[i].mDataBuffer = NULL;
- thiz->mBufferArray[i].mDataSize = 0;
- thiz->mBufferArray[i].mDataSizeConsumed = 0;
- thiz->mBufferArray[i].mBufferContext = NULL;
- thiz->mBufferArray[i].mBufferState = SL_ANDROIDBUFFERQUEUEEVENT_NONE;
- switch (thiz->mBufferType) {
- case kAndroidBufferTypeMpeg2Ts:
- thiz->mBufferArray[i].mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE;
- thiz->mBufferArray[i].mItems.mTsCmdData.mPts = 0;
- break;
- case kAndroidBufferTypeAacadts:
- thiz->mBufferArray[i].mItems.mAdtsCmdData.mAdtsCmdCode = ANDROID_ADTSEVENT_NONE;
- break;
- default:
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- }
- }
-
- if (SL_RESULT_SUCCESS == result) {
- // object-specific behavior for a clear
- switch (InterfaceToObjectID(thiz)) {
- case SL_OBJECTID_AUDIOPLAYER:
- result = SL_RESULT_SUCCESS;
- android_audioPlayer_androidBufferQueue_clear_l((CAudioPlayer*) thiz->mThis);
- break;
- case XA_OBJECTID_MEDIAPLAYER:
- result = SL_RESULT_SUCCESS;
- android_Player_androidBufferQueue_clear_l((CMediaPlayer*) thiz->mThis);
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidBufferQueue_Enqueue(SLAndroidBufferQueueItf self,
- void *pBufferContext,
- void *pData,
- SLuint32 dataLength,
- const SLAndroidBufferItem *pItems,
- SLuint32 itemsLength)
-{
- SL_ENTER_INTERFACE
- SL_LOGD("IAndroidBufferQueue_Enqueue pData=%p dataLength=%d", pData, dataLength);
-
- if ((dataLength > 0) && (NULL == pData)) {
- SL_LOGE("Enqueue failure: non-zero data length %u but NULL data pointer", dataLength);
- result = SL_RESULT_PARAMETER_INVALID;
- } else if ((itemsLength > 0) && (NULL == pItems)) {
- SL_LOGE("Enqueue failure: non-zero items length %u but NULL items pointer", itemsLength);
- result = SL_RESULT_PARAMETER_INVALID;
- } else if ((0 == dataLength) && (0 == itemsLength)) {
- // no data and no msg
- SL_LOGE("Enqueue failure: trying to enqueue buffer with no data and no items.");
- result = SL_RESULT_PARAMETER_INVALID;
- // Note that a non-NULL data pointer with zero data length is allowed.
- // We track that data pointer as it moves through the queue
- // to assist the application in accounting for data buffers.
- // A non-NULL items pointer with zero items length is also allowed, but has no value.
- } else {
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
-
- // buffer size check, can be done outside of lock because buffer type can't change
- switch (thiz->mBufferType) {
- case kAndroidBufferTypeMpeg2Ts:
- if (dataLength % MPEG2_TS_BLOCK_SIZE == 0) {
- break;
- }
- SL_LOGE("Error enqueueing MPEG-2 TS data: size must be a multiple of %d (block size)",
- MPEG2_TS_BLOCK_SIZE);
- result = SL_RESULT_PARAMETER_INVALID;
- SL_LEAVE_INTERFACE
- break;
- case kAndroidBufferTypeAacadts:
- // non-zero dataLength is permitted in case of EOS command only
- if (dataLength > 0) {
- result = android::AacBqToPcmCbRenderer::validateBufferStartEndOnFrameBoundaries(
- pData, dataLength);
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("Error enqueueing ADTS data: data must start and end on frame "
- "boundaries");
- SL_LEAVE_INTERFACE
- }
- }
- break;
- case kAndroidBufferTypeInvalid:
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- SL_LEAVE_INTERFACE
- }
-
- interface_lock_exclusive(thiz);
-
- AdvancedBufferHeader *oldRear = thiz->mRear, *newRear;
- if ((newRear = oldRear + 1) == &thiz->mBufferArray[thiz->mNumBuffers + 1]) {
- newRear = thiz->mBufferArray;
- }
- if (newRear == thiz->mFront) {
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- oldRear->mDataBuffer = pData;
- oldRear->mDataSize = dataLength;
- oldRear->mDataSizeConsumed = 0;
- oldRear->mBufferContext = pBufferContext;
- oldRear->mBufferState = SL_ANDROIDBUFFERQUEUEEVENT_NONE;
- thiz->mRear = newRear;
- ++thiz->mState.count;
- // set oldRear->mItems based on items
- setItems(pItems, itemsLength, thiz->mBufferType, oldRear);
- result = SL_RESULT_SUCCESS;
- }
- // set enqueue attribute if state is PLAYING and the first buffer is enqueued
- interface_unlock_exclusive_attributes(thiz, ((SL_RESULT_SUCCESS == result) &&
- (1 == thiz->mState.count) && (SL_PLAYSTATE_PLAYING == getAssociatedState(thiz))) ?
- ATTR_ABQ_ENQUEUE : ATTR_NONE);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidBufferQueue_GetState(SLAndroidBufferQueueItf self,
- SLAndroidBufferQueueState *pState)
-{
- SL_ENTER_INTERFACE
-
- // Note that GetState while a Clear is pending is equivalent to GetState before the Clear
-
- if (NULL == pState) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
-
- interface_lock_shared(thiz);
-
- pState->count = thiz->mState.count;
- pState->index = thiz->mState.index;
-
- interface_unlock_shared(thiz);
-
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidBufferQueue_SetCallbackEventsMask(SLAndroidBufferQueueItf self,
- SLuint32 eventFlags)
-{
- SL_ENTER_INTERFACE
-
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
- interface_lock_exclusive(thiz);
- // FIXME only supporting SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED in this implementation
- if ((SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED == eventFlags) ||
- (SL_ANDROIDBUFFERQUEUEEVENT_NONE == eventFlags)) {
- thiz->mCallbackEventsMask = eventFlags;
- result = SL_RESULT_SUCCESS;
- } else {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidBufferQueue_GetCallbackEventsMask(SLAndroidBufferQueueItf self,
- SLuint32 *pEventFlags)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEventFlags) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
- interface_lock_shared(thiz);
- SLuint32 callbackEventsMask = thiz->mCallbackEventsMask;
- interface_unlock_shared(thiz);
- *pEventFlags = callbackEventsMask;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAndroidBufferQueueItf_ IAndroidBufferQueue_Itf = {
- IAndroidBufferQueue_RegisterCallback,
- IAndroidBufferQueue_Clear,
- IAndroidBufferQueue_Enqueue,
- IAndroidBufferQueue_GetState,
- IAndroidBufferQueue_SetCallbackEventsMask,
- IAndroidBufferQueue_GetCallbackEventsMask
-};
-
-
-void IAndroidBufferQueue_init(void *self)
-{
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
- thiz->mItf = &IAndroidBufferQueue_Itf;
-
- thiz->mState.count = 0;
- thiz->mState.index = 0;
-
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
- thiz->mCallbackEventsMask = SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED;
-
- thiz->mBufferType = kAndroidBufferTypeInvalid;
- thiz->mBufferArray = NULL;
- thiz->mFront = NULL;
- thiz->mRear = NULL;
-}
-
-
-void IAndroidBufferQueue_deinit(void *self)
-{
- IAndroidBufferQueue *thiz = (IAndroidBufferQueue *) self;
- if (NULL != thiz->mBufferArray) {
- free(thiz->mBufferArray);
- thiz->mBufferArray = NULL;
- }
-}
diff --git a/wilhelm/src/itf/IAndroidConfiguration.c b/wilhelm/src/itf/IAndroidConfiguration.c
deleted file mode 100644
index bd4ed54..0000000
--- a/wilhelm/src/itf/IAndroidConfiguration.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* AndroidConfiguration implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IAndroidConfiguration_SetConfiguration(SLAndroidConfigurationItf self,
- const SLchar *configKey,
- const void *pConfigValue,
- SLuint32 valueSize)
-{
- SL_ENTER_INTERFACE
-
- // object-specific code will check that valueSize is large enough for the key
- if (NULL == configKey || NULL == pConfigValue || valueSize == 0) {
- result = SL_RESULT_PARAMETER_INVALID;
-
- } else {
- IAndroidConfiguration *thiz = (IAndroidConfiguration *) self;
- interface_lock_exclusive(thiz);
-
- // route configuration to the appropriate object
- switch (IObjectToObjectID((thiz)->mThis)) {
- case SL_OBJECTID_AUDIORECORDER:
- SL_LOGV("SetConfiguration issued for AudioRecorder key=%s valueSize=%u",
- configKey, valueSize);
- result = android_audioRecorder_setConfig((CAudioRecorder *) thiz->mThis, configKey,
- pConfigValue, valueSize);
- break;
- case SL_OBJECTID_AUDIOPLAYER:
- SL_LOGV("SetConfiguration issued for AudioPlayer key=%s valueSize=%u",
- configKey, valueSize);
- result = android_audioPlayer_setConfig((CAudioPlayer *) thiz->mThis, configKey,
- pConfigValue, valueSize);
- break;
- default:
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- break;
- }
-
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidConfiguration_GetConfiguration(SLAndroidConfigurationItf self,
- const SLchar *configKey,
- SLuint32 *pValueSize,
- void *pConfigValue)
-{
- SL_ENTER_INTERFACE
-
- // non-NULL pValueSize is required, but a NULL pConfigValue is allowed, so
- // that we can report the actual value size without returning the value itself
- if (NULL == configKey || NULL == pValueSize) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidConfiguration *thiz = (IAndroidConfiguration *) self;
- interface_lock_exclusive(thiz);
-
- // route configuration request to the appropriate object
- switch (IObjectToObjectID((thiz)->mThis)) {
- case SL_OBJECTID_AUDIORECORDER:
- result = android_audioRecorder_getConfig((CAudioRecorder *) thiz->mThis, configKey,
- pValueSize, pConfigValue);
- break;
- case SL_OBJECTID_AUDIOPLAYER:
- result = android_audioPlayer_getConfig((CAudioPlayer *) thiz->mThis, configKey,
- pValueSize, pConfigValue);
- default:
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- break;
- }
-
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAndroidConfigurationItf_ IAndroidConfiguration_Itf = {
- IAndroidConfiguration_SetConfiguration,
- IAndroidConfiguration_GetConfiguration
-};
-
-void IAndroidConfiguration_init(void *self)
-{
- IAndroidConfiguration *thiz = (IAndroidConfiguration *) self;
- thiz->mItf = &IAndroidConfiguration_Itf;
-}
diff --git a/wilhelm/src/itf/IAndroidEffect.cpp b/wilhelm/src/itf/IAndroidEffect.cpp
deleted file mode 100644
index f34cabd..0000000
--- a/wilhelm/src/itf/IAndroidEffect.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Android Effect implementation */
-
-#include "sles_allinclusive.h"
-
-#include <system/audio.h>
-
-static SLresult IAndroidEffect_CreateEffect(SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId) {
-
- SL_ENTER_INTERFACE
-
- IAndroidEffect *thiz = (IAndroidEffect *) self;
- if (SL_OBJECTID_AUDIOPLAYER == IObjectToObjectID(thiz->mThis)) {
- CAudioPlayer *ap = (CAudioPlayer *)thiz->mThis;
- if (ap->mAudioTrack != 0) {
- result = android_genericFx_createEffect(thiz, effectImplementationId, ap->mSessionId);
- } else {
- result = SL_RESULT_RESOURCE_ERROR;
- }
- } else if (SL_OBJECTID_OUTPUTMIX == IObjectToObjectID(thiz->mThis)) {
- result = android_genericFx_createEffect(thiz, effectImplementationId,
- AUDIO_SESSION_OUTPUT_MIX);
- } else {
- // the interface itself is invalid because it is not attached to an AudioPlayer or
- // an OutputMix
- result = SL_RESULT_PARAMETER_INVALID;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffect_ReleaseEffect(SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId) {
-
- SL_ENTER_INTERFACE
-
- IAndroidEffect *thiz = (IAndroidEffect *) self;
- result = android_genericFx_releaseEffect(thiz, effectImplementationId);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffect_SetEnabled(SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId, SLboolean enabled) {
-
- SL_ENTER_INTERFACE
-
- IAndroidEffect *thiz = (IAndroidEffect *) self;
- result = android_genericFx_setEnabled(thiz, effectImplementationId, enabled);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffect_IsEnabled(SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId, SLboolean * pEnabled) {
-
- SL_ENTER_INTERFACE
-
- IAndroidEffect *thiz = (IAndroidEffect *) self;
- result = android_genericFx_isEnabled(thiz, effectImplementationId, pEnabled);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffect_SendCommand(SLAndroidEffectItf self,
- SLInterfaceID effectImplementationId, SLuint32 command, SLuint32 commandSize,
- void* pCommand, SLuint32 *replySize, void *pReply) {
-
- SL_ENTER_INTERFACE
-
- IAndroidEffect *thiz = (IAndroidEffect *) self;
- result = android_genericFx_sendCommand(thiz, effectImplementationId, command, commandSize,
- pCommand, replySize, pReply);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAndroidEffectItf_ IAndroidEffect_Itf = {
- IAndroidEffect_CreateEffect,
- IAndroidEffect_ReleaseEffect,
- IAndroidEffect_SetEnabled,
- IAndroidEffect_IsEnabled,
- IAndroidEffect_SendCommand
-};
-
-void IAndroidEffect_init(void *self)
-{
- IAndroidEffect *thiz = (IAndroidEffect *) self;
- thiz->mItf = &IAndroidEffect_Itf;
- thiz->mEffects = new android::KeyedVector<SLuint32, android::AudioEffect* >();
-}
-
-void IAndroidEffect_deinit(void *self)
-{
- IAndroidEffect *thiz = (IAndroidEffect *) self;
- if (NULL != thiz->mEffects) {
- if (!thiz->mEffects->isEmpty()) {
- for (size_t i = 0 ; i < thiz->mEffects->size() ; i++) {
- delete thiz->mEffects->valueAt(i);
- }
- thiz->mEffects->clear();
- }
- delete thiz->mEffects;
- thiz->mEffects = NULL;
- }
-}
diff --git a/wilhelm/src/itf/IAndroidEffectCapabilities.c b/wilhelm/src/itf/IAndroidEffectCapabilities.c
deleted file mode 100644
index 923b6a7..0000000
--- a/wilhelm/src/itf/IAndroidEffectCapabilities.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Android Effect Capabilities implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IAndroidEffectCapabilities_QueryNumEffects(SLAndroidEffectCapabilitiesItf self,
- SLuint32 * pNumSupportedAudioEffects) {
-
- SL_ENTER_INTERFACE
-
- if (NULL == pNumSupportedAudioEffects) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidEffectCapabilities *thiz = (IAndroidEffectCapabilities *) self;
- interface_lock_shared(thiz);
-
- *pNumSupportedAudioEffects = thiz->mNumFx;
- result = SL_RESULT_SUCCESS;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffectCapabilities_QueryEffect(SLAndroidEffectCapabilitiesItf self,
- SLuint32 index, SLInterfaceID *pEffectType, SLInterfaceID *pEffectImplementation,
- SLchar * pName, SLuint16 *pNameSize) {
-
- SL_ENTER_INTERFACE
-
- IAndroidEffectCapabilities *thiz = (IAndroidEffectCapabilities *) self;
- if (index > thiz->mNumFx) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_shared(thiz);
- if (NULL != pEffectType) {
- *pEffectType = (SLInterfaceID) &thiz->mFxDescriptors[index].type;
- }
- if (NULL != pEffectImplementation) {
- *pEffectImplementation = (SLInterfaceID) &thiz->mFxDescriptors[index].uuid;
- }
- if ((NULL != pName) && (0 < *pNameSize)) {
- int len = strlen(thiz->mFxDescriptors[index].name);
- strncpy((char*)pName, thiz->mFxDescriptors[index].name,
- *pNameSize > len ? len : *pNameSize );
- *pNameSize = len;
- }
- interface_unlock_shared(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAndroidEffectCapabilitiesItf_ IAndroidEffectCapabilities_Itf = {
- IAndroidEffectCapabilities_QueryNumEffects,
- IAndroidEffectCapabilities_QueryEffect
-};
-
-void IAndroidEffectCapabilities_init(void *self)
-{
- IAndroidEffectCapabilities *thiz = (IAndroidEffectCapabilities *) self;
- thiz->mItf = &IAndroidEffectCapabilities_Itf;
-
- // This is the default initialization; fields will be updated when interface is exposed
- thiz->mNumFx = 0;
- thiz->mFxDescriptors = NULL;
-}
-
-bool IAndroidEffectCapabilities_Expose(void *self)
-{
- IAndroidEffectCapabilities *thiz = (IAndroidEffectCapabilities *) self;
- SLuint32 numEffects = 0;
- SLresult result = android_genericFx_queryNumEffects(&numEffects);
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("android_genericFx_queryNumEffects %u", result);
- return false;
- }
- thiz->mNumFx = numEffects;
- SL_LOGV("Effect Capabilities has %d effects", thiz->mNumFx);
- if (thiz->mNumFx > 0) {
- thiz->mFxDescriptors = (effect_descriptor_t*) new effect_descriptor_t[thiz->mNumFx];
- for (SLuint32 i = 0 ; i < thiz->mNumFx ; i++) {
- SLresult result2;
- result2 = android_genericFx_queryEffect(i, &thiz->mFxDescriptors[i]);
- if (SL_RESULT_SUCCESS != result2) {
- SL_LOGE("Error (SLresult is %d) querying effect %d", result2, i);
- // Remember the first failing result code, but keep going
- if (SL_RESULT_SUCCESS == result) {
- result = result2;
- }
- } else {
- SL_LOGV("effect %d: type=%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x name=%s",
- i,
- thiz->mFxDescriptors[i].type.timeLow,
- thiz->mFxDescriptors[i].type.timeMid,
- thiz->mFxDescriptors[i].type.timeHiAndVersion,
- thiz->mFxDescriptors[i].type.clockSeq,
- thiz->mFxDescriptors[i].type.node[0],
- thiz->mFxDescriptors[i].type.node[1],
- thiz->mFxDescriptors[i].type.node[2],
- thiz->mFxDescriptors[i].type.node[3],
- thiz->mFxDescriptors[i].type.node[4],
- thiz->mFxDescriptors[i].type.node[5],
- thiz->mFxDescriptors[i].name);
- }
- }
- }
- return SL_RESULT_SUCCESS == result;
-}
-
-void IAndroidEffectCapabilities_deinit(void *self)
-{
- IAndroidEffectCapabilities *thiz = (IAndroidEffectCapabilities *) self;
- // free effect library data
- if (NULL != thiz->mFxDescriptors) {
- delete[] thiz->mFxDescriptors;
- thiz->mFxDescriptors = NULL;
- }
-}
diff --git a/wilhelm/src/itf/IAndroidEffectSend.c b/wilhelm/src/itf/IAndroidEffectSend.c
deleted file mode 100644
index b075753..0000000
--- a/wilhelm/src/itf/IAndroidEffectSend.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* AndroidEffectSend implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IAndroidEffectSend_EnableEffectSend(SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId, SLboolean enable, SLmillibel initialLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!((SL_MILLIBEL_MIN <= initialLevel) && (initialLevel <= 0))) {
- // comparison (SL_MILLIBEL_MIN <= initialLevel) is always true due to range of SLmillibel
- if (!(initialLevel <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidEffectSend *thiz = (IAndroidEffectSend *) self;
- interface_lock_exclusive(thiz);
- // is SLAndroidEffectSendItf on an AudioPlayer?
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL == ap) {
- SL_LOGE("invalid interface: not attached to an AudioPlayer");
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- COutputMix *outputMix = CAudioPlayer_GetOutputMix(ap);
- // the initial send level set here is the total energy on the aux bus,
- // so it must take into account the player volume level
- result = android_fxSend_attachToAux(ap, effectImplementationId, enable,
- initialLevel + ap->mVolume.mLevel);
- if (SL_RESULT_SUCCESS == result) {
- // there currently is support for only one send bus, so there is a single send
- // level and a single enable flag
- thiz->mSendLevel = initialLevel;
- thiz->mEnabled = enable;
- }
- }
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffectSend_IsEnabled(SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId, SLboolean *pEnable)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEnable) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidEffectSend *thiz = (IAndroidEffectSend *) self;
- interface_lock_shared(thiz);
- // there currently is support for only one send bus, so there is a single enable flag
- SLboolean enable = thiz->mEnabled;
- interface_unlock_shared(thiz);
- *pEnable = enable;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffectSend_SetDirectLevel(SLAndroidEffectSendItf self,
- SLmillibel directLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!((SL_MILLIBEL_MIN <= directLevel) && (directLevel <= 0))) {
- // comparison (SL_MILLIBEL_MIN <= directLevel) is always true due to range of SLmillibel
- if (!(directLevel <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidEffectSend *thiz = (IAndroidEffectSend *) self;
- interface_lock_exclusive(thiz);
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL != ap) {
- SLmillibel oldDirectLevel = ap->mDirectLevel;
- if (oldDirectLevel != directLevel) {
- ap->mDirectLevel = directLevel;
- ap->mAmplFromDirectLevel = sles_to_android_amplification(directLevel);
- interface_unlock_exclusive_attributes(thiz, ATTR_GAIN);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- } else {
- interface_unlock_exclusive(thiz);
- SL_LOGE("invalid interface: not attached to an AudioPlayer");
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffectSend_GetDirectLevel(SLAndroidEffectSendItf self,
- SLmillibel *pDirectLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDirectLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidEffectSend *thiz = (IAndroidEffectSend *) self;
- interface_lock_shared(thiz);
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL != ap) {
- *pDirectLevel = ap->mDirectLevel;
- result = SL_RESULT_SUCCESS;
- } else {
- SL_LOGE("invalid interface: not attached to an AudioPlayer");
- result = SL_RESULT_PARAMETER_INVALID;
- }
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffectSend_SetSendLevel(SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId, SLmillibel sendLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!((SL_MILLIBEL_MIN <= sendLevel) && (sendLevel <= 0))) {
- // comparison (SL_MILLIBEL_MIN <= sendLevel) is always true due to range of SLmillibel
- if (!(sendLevel <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidEffectSend *thiz = (IAndroidEffectSend *) self;
- interface_lock_exclusive(thiz);
- // is SLAndroidEffectSendItf on an AudioPlayer?
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL == ap) {
- SL_LOGE("invalid interface: not attached to an AudioPlayer");
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- COutputMix *outputMix = CAudioPlayer_GetOutputMix(ap);
- if (android_genericFx_hasEffect(&outputMix->mAndroidEffect, effectImplementationId)) {
- // the send level set here is the total energy on the aux bus, so it must take
- // into account the player volume level
- result = android_fxSend_setSendLevel(ap, sendLevel + ap->mVolume.mLevel);
- } else {
- SL_LOGE("trying to send to an effect not on this AudioPlayer's OutputMix");
- result = SL_RESULT_PARAMETER_INVALID;
- }
- if (SL_RESULT_SUCCESS == result) {
- // there currently is support for only one send bus, so there is a single send
- // level
- thiz->mSendLevel = sendLevel;
- }
- }
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAndroidEffectSend_GetSendLevel(SLAndroidEffectSendItf self,
- SLInterfaceID effectImplementationId, SLmillibel *pSendLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSendLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAndroidEffectSend *thiz = (IAndroidEffectSend *) self;
- interface_lock_exclusive(thiz);
- // is SLAndroidEffectSendItf on an AudioPlayer?
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL == ap) {
- SL_LOGE("invalid interface: not attached to an AudioPlayer");
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- COutputMix *outputMix = CAudioPlayer_GetOutputMix(ap);
- if (android_genericFx_hasEffect(&outputMix->mAndroidEffect, effectImplementationId)) {
- result = SL_RESULT_SUCCESS;
- } else {
- SL_LOGE("trying to retrieve send level on an effect not on this AudioPlayer's \
-OutputMix");
- result = SL_RESULT_PARAMETER_INVALID;
- }
- if (SL_RESULT_SUCCESS == result) {
- // there currently is support for only one send bus, so there is a single send
- // level
- *pSendLevel = thiz->mSendLevel;
- }
- }
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAndroidEffectSendItf_ IAndroidEffectSend_Itf = {
- IAndroidEffectSend_EnableEffectSend,
- IAndroidEffectSend_IsEnabled,
- IAndroidEffectSend_SetDirectLevel,
- IAndroidEffectSend_GetDirectLevel,
- IAndroidEffectSend_SetSendLevel,
- IAndroidEffectSend_GetSendLevel
-};
-
-void IAndroidEffectSend_init(void *self)
-{
- IAndroidEffectSend *thiz = (IAndroidEffectSend *) self;
- thiz->mItf = &IAndroidEffectSend_Itf;
- thiz->mEnabled = SL_BOOLEAN_FALSE;
- thiz->mSendLevel = SL_MILLIBEL_MIN;
-}
diff --git a/wilhelm/src/itf/IAudioDecoderCapabilities.c b/wilhelm/src/itf/IAudioDecoderCapabilities.c
deleted file mode 100644
index c332a65..0000000
--- a/wilhelm/src/itf/IAudioDecoderCapabilities.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* AudioDecoderCapabilities implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IAudioDecoderCapabilities_GetAudioDecoders(SLAudioDecoderCapabilitiesItf self,
- SLuint32 *pNumDecoders, SLuint32 *pDecoderIds)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumDecoders) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- if (NULL != pDecoderIds) {
- SLuint32 numDecoders = *pNumDecoders;
- if (numDecoders > MAX_DECODERS) {
- numDecoders = MAX_DECODERS;
- } else if (numDecoders < MAX_DECODERS) {
- // FIXME starting in 1.1 this will be SL_RESULT_BUFFER_INSUFFICIENT
- result = SL_RESULT_PARAMETER_INVALID;
- }
- memcpy(pDecoderIds, Decoder_IDs, numDecoders * sizeof(SLuint32));
- }
- *pNumDecoders = MAX_DECODERS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioDecoderCapabilities_GetAudioDecoderCapabilities(
- SLAudioDecoderCapabilitiesItf self, SLuint32 decoderId, SLuint32 *pIndex,
- SLAudioCodecDescriptor *pDescriptor)
-{
- SL_ENTER_INTERFACE
-
- result = GetCodecCapabilities(decoderId, pIndex, pDescriptor, DecoderDescriptors);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAudioDecoderCapabilitiesItf_ IAudioDecoderCapabilities_Itf = {
- IAudioDecoderCapabilities_GetAudioDecoders,
- IAudioDecoderCapabilities_GetAudioDecoderCapabilities
-};
-
-void IAudioDecoderCapabilities_init(void *self)
-{
- IAudioDecoderCapabilities *thiz = (IAudioDecoderCapabilities *) self;
- thiz->mItf = &IAudioDecoderCapabilities_Itf;
-}
diff --git a/wilhelm/src/itf/IAudioEncoder.c b/wilhelm/src/itf/IAudioEncoder.c
deleted file mode 100644
index 511a008..0000000
--- a/wilhelm/src/itf/IAudioEncoder.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* AudioEncoder implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IAudioEncoder_SetEncoderSettings(SLAudioEncoderItf self,
- SLAudioEncoderSettings *pSettings)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSettings) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAudioEncoder *thiz = (IAudioEncoder *) self;
- SLAudioEncoderSettings settings = *pSettings;
- interface_lock_exclusive(thiz);
- thiz->mSettings = settings;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioEncoder_GetEncoderSettings(SLAudioEncoderItf self,
- SLAudioEncoderSettings *pSettings)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSettings) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IAudioEncoder *thiz = (IAudioEncoder *) self;
- interface_lock_shared(thiz);
- SLAudioEncoderSettings settings = thiz->mSettings;
- interface_unlock_shared(thiz);
- *pSettings = settings;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAudioEncoderItf_ IAudioEncoder_Itf = {
- IAudioEncoder_SetEncoderSettings,
- IAudioEncoder_GetEncoderSettings
-};
-
-void IAudioEncoder_init(void *self)
-{
- IAudioEncoder *thiz = (IAudioEncoder *) self;
- thiz->mItf = &IAudioEncoder_Itf;
- memset(&thiz->mSettings, 0, sizeof(SLAudioEncoderSettings));
-}
diff --git a/wilhelm/src/itf/IAudioEncoderCapabilities.c b/wilhelm/src/itf/IAudioEncoderCapabilities.c
deleted file mode 100644
index 3f45118..0000000
--- a/wilhelm/src/itf/IAudioEncoderCapabilities.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* AudioEncoderCapabilities implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IAudioEncoderCapabilities_GetAudioEncoders(SLAudioEncoderCapabilitiesItf self,
- SLuint32 *pNumEncoders, SLuint32 *pEncoderIds)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumEncoders) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- if (NULL != pEncoderIds) {
- SLuint32 numEncoders = *pNumEncoders;
- if (numEncoders > MAX_ENCODERS) {
- numEncoders = MAX_ENCODERS;
- } else if (numEncoders < MAX_ENCODERS) {
- // FIXME starting in 1.1 this will be SL_RESULT_BUFFER_INSUFFICIENT
- result = SL_RESULT_PARAMETER_INVALID;
- }
- memcpy(pEncoderIds, Encoder_IDs, numEncoders * sizeof(SLuint32));
- }
- *pNumEncoders = MAX_ENCODERS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioEncoderCapabilities_GetAudioEncoderCapabilities(
- SLAudioEncoderCapabilitiesItf self, SLuint32 encoderId, SLuint32 *pIndex,
- SLAudioCodecDescriptor *pDescriptor)
-{
- SL_ENTER_INTERFACE
-
- result = GetCodecCapabilities(encoderId, pIndex, pDescriptor,
- EncoderDescriptors);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAudioEncoderCapabilitiesItf_ IAudioEncoderCapabilities_Itf = {
- IAudioEncoderCapabilities_GetAudioEncoders,
- IAudioEncoderCapabilities_GetAudioEncoderCapabilities
-};
-
-void IAudioEncoderCapabilities_init(void *self)
-{
- IAudioEncoderCapabilities *thiz = (IAudioEncoderCapabilities *) self;
- thiz->mItf = &IAudioEncoderCapabilities_Itf;
-}
diff --git a/wilhelm/src/itf/IAudioIODeviceCapabilities.c b/wilhelm/src/itf/IAudioIODeviceCapabilities.c
deleted file mode 100644
index f667e98..0000000
--- a/wilhelm/src/itf/IAudioIODeviceCapabilities.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-/* AudioIODeviceCapabilities implementation */
-
-// NTH make it platform-configurable
-
-
-static SLresult IAudioIODeviceCapabilities_GetAvailableAudioInputs(
- SLAudioIODeviceCapabilitiesItf self, SLint32 *pNumInputs, SLuint32 *pInputDeviceIDs)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumInputs) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- if (NULL != pInputDeviceIDs) {
- if (1 > *pNumInputs) {
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- pInputDeviceIDs[0] = SL_DEFAULTDEVICEID_AUDIOINPUT;
- }
- }
- *pNumInputs = 1;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_QueryAudioInputCapabilities(
- SLAudioIODeviceCapabilitiesItf self, SLuint32 deviceID, SLAudioInputDescriptor *pDescriptor)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDescriptor) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- switch (deviceID) {
- case SL_DEFAULTDEVICEID_AUDIOINPUT:
- *pDescriptor = *AudioInput_id_descriptors[0].descriptor;
- break;
- default:
- result = SL_RESULT_IO_ERROR;
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_RegisterAvailableAudioInputsChangedCallback(
- SLAudioIODeviceCapabilitiesItf self, slAvailableAudioInputsChangedCallback callback,
- void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IAudioIODeviceCapabilities * thiz = (IAudioIODeviceCapabilities *) self;
- interface_lock_exclusive(thiz);
- thiz->mAvailableAudioInputsChangedCallback = callback;
- thiz->mAvailableAudioInputsChangedContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_GetAvailableAudioOutputs(
- SLAudioIODeviceCapabilitiesItf self, SLint32 *pNumOutputs, SLuint32 *pOutputDeviceIDs)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumOutputs) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- if (NULL != pOutputDeviceIDs) {
- if (2 > *pNumOutputs) {
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- // if 1 slot available, should still fill that
- } else {
- pOutputDeviceIDs[0] = DEVICE_ID_HEADSET;
- pOutputDeviceIDs[1] = DEVICE_ID_HANDSFREE;
- // SL_DEFAULTDEVICEID_AUDIOOUTPUT?
- }
- }
- *pNumOutputs = 2;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_QueryAudioOutputCapabilities(
- SLAudioIODeviceCapabilitiesItf self, SLuint32 deviceID, SLAudioOutputDescriptor *pDescriptor)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDescriptor) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- switch (deviceID) {
- case DEVICE_ID_HEADSET:
- *pDescriptor = *AudioOutput_id_descriptors[1].descriptor;
- break;
- case DEVICE_ID_HANDSFREE:
- *pDescriptor = *AudioOutput_id_descriptors[2].descriptor;
- break;
- // SL_DEFAULTDEVICEID_AUDIOOUTPUT?
- default:
- result = SL_RESULT_IO_ERROR;
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_RegisterAvailableAudioOutputsChangedCallback(
- SLAudioIODeviceCapabilitiesItf self, slAvailableAudioOutputsChangedCallback callback,
- void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IAudioIODeviceCapabilities * thiz = (IAudioIODeviceCapabilities *) self;
- interface_lock_exclusive(thiz);
- thiz->mAvailableAudioOutputsChangedCallback = callback;
- thiz->mAvailableAudioOutputsChangedContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_RegisterDefaultDeviceIDMapChangedCallback(
- SLAudioIODeviceCapabilitiesItf self, slDefaultDeviceIDMapChangedCallback callback,
- void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IAudioIODeviceCapabilities * thiz = (IAudioIODeviceCapabilities *) self;
- interface_lock_exclusive(thiz);
- thiz->mDefaultDeviceIDMapChangedCallback = callback;
- thiz->mDefaultDeviceIDMapChangedContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_GetAssociatedAudioInputs(
- SLAudioIODeviceCapabilitiesItf self, SLuint32 deviceID,
- SLint32 *pNumAudioInputs, SLuint32 *pAudioInputDeviceIDs)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumAudioInputs) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- // Incomplete
- *pNumAudioInputs = 0;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_GetAssociatedAudioOutputs(
- SLAudioIODeviceCapabilitiesItf self, SLuint32 deviceID,
- SLint32 *pNumAudioOutputs, SLuint32 *pAudioOutputDeviceIDs)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumAudioOutputs) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- // Incomplete
- *pNumAudioOutputs = 0;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_GetDefaultAudioDevices(
- SLAudioIODeviceCapabilitiesItf self, SLuint32 defaultDeviceID,
- SLint32 *pNumAudioDevices, SLuint32 *pAudioDeviceIDs)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumAudioDevices) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- switch (defaultDeviceID) {
- case SL_DEFAULTDEVICEID_AUDIOINPUT:
- case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
- result = SL_RESULT_SUCCESS;
- if (NULL != pAudioDeviceIDs) {
- switch (defaultDeviceID) {
- case SL_DEFAULTDEVICEID_AUDIOINPUT:
- if (1 > *pNumAudioDevices) {
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- pAudioDeviceIDs[0] = SL_DEFAULTDEVICEID_AUDIOINPUT;
- }
- *pNumAudioDevices = 1;
- break;
- case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
- if (2 > *pNumAudioDevices) {
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- pAudioDeviceIDs[0] = DEVICE_ID_HEADSET;
- pAudioDeviceIDs[1] = DEVICE_ID_HANDSFREE;
- // should be capable of returning first item if 1 slot
- }
- *pNumAudioDevices = 2;
- break;
- default:
- assert(SL_BOOLEAN_FALSE);
- *pNumAudioDevices = 0;
- break;
- }
- }
- break;
- default:
- result = SL_RESULT_IO_ERROR;
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IAudioIODeviceCapabilities_QuerySampleFormatsSupported(
- SLAudioIODeviceCapabilitiesItf self, SLuint32 deviceID, SLmilliHertz samplingRate,
- SLint32 *pSampleFormats, SLint32 *pNumOfSampleFormats)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumOfSampleFormats) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- switch (deviceID) {
- case SL_DEFAULTDEVICEID_AUDIOINPUT:
- case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
- result = SL_RESULT_SUCCESS;
- // incomplete
- switch (samplingRate) {
- case SL_SAMPLINGRATE_44_1:
- break;
- default:
- result = SL_RESULT_IO_ERROR;
- break;
- }
- if (NULL != pSampleFormats) {
- if (1 > *pNumOfSampleFormats)
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- // incomplete
- pSampleFormats[0] = SL_PCMSAMPLEFORMAT_FIXED_16;
- }
- *pNumOfSampleFormats = 1;
- break;
- default:
- result = SL_RESULT_IO_ERROR;
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLAudioIODeviceCapabilitiesItf_ IAudioIODeviceCapabilities_Itf = {
- IAudioIODeviceCapabilities_GetAvailableAudioInputs,
- IAudioIODeviceCapabilities_QueryAudioInputCapabilities,
- IAudioIODeviceCapabilities_RegisterAvailableAudioInputsChangedCallback,
- IAudioIODeviceCapabilities_GetAvailableAudioOutputs,
- IAudioIODeviceCapabilities_QueryAudioOutputCapabilities,
- IAudioIODeviceCapabilities_RegisterAvailableAudioOutputsChangedCallback,
- IAudioIODeviceCapabilities_RegisterDefaultDeviceIDMapChangedCallback,
- IAudioIODeviceCapabilities_GetAssociatedAudioInputs,
- IAudioIODeviceCapabilities_GetAssociatedAudioOutputs,
- IAudioIODeviceCapabilities_GetDefaultAudioDevices,
- IAudioIODeviceCapabilities_QuerySampleFormatsSupported
-};
-
-void IAudioIODeviceCapabilities_init(void *self)
-{
- IAudioIODeviceCapabilities *thiz = (IAudioIODeviceCapabilities *) self;
- thiz->mItf = &IAudioIODeviceCapabilities_Itf;
- thiz->mAvailableAudioInputsChangedCallback = NULL;
- thiz->mAvailableAudioInputsChangedContext = NULL;
- thiz->mAvailableAudioOutputsChangedCallback = NULL;
- thiz->mAvailableAudioOutputsChangedContext = NULL;
- thiz->mDefaultDeviceIDMapChangedCallback = NULL;
- thiz->mDefaultDeviceIDMapChangedContext = NULL;
-}
diff --git a/wilhelm/src/itf/IBassBoost.c b/wilhelm/src/itf/IBassBoost.c
deleted file mode 100644
index fcf2fc9..0000000
--- a/wilhelm/src/itf/IBassBoost.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* BassBoost implementation */
-
-#include "sles_allinclusive.h"
-#ifdef ANDROID
-#include <audio_effects/effect_bassboost.h>
-#endif
-
-#define BASSBOOST_STRENGTH_MIN 0
-#define BASSBOOST_STRENGTH_MAX 1000
-
-
-#if defined(ANDROID)
-/**
- * returns true if this interface is not associated with an initialized BassBoost effect
- */
-static inline bool NO_BASSBOOST(IBassBoost* v) {
- return (v->mBassBoostEffect == 0);
-}
-#endif
-
-
-static SLresult IBassBoost_SetEnabled(SLBassBoostItf self, SLboolean enabled)
-{
- SL_ENTER_INTERFACE
-
- IBassBoost *thiz = (IBassBoost *) self;
- interface_lock_exclusive(thiz);
- thiz->mEnabled = (SLboolean) enabled;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_BASSBOOST(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = thiz->mBassBoostEffect->setEnabled((bool) thiz->mEnabled);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IBassBoost_IsEnabled(SLBassBoostItf self, SLboolean *pEnabled)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEnabled) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IBassBoost *thiz = (IBassBoost *) self;
- interface_lock_exclusive(thiz);
- SLboolean enabled = thiz->mEnabled;
-#if !defined(ANDROID)
- *pEnabled = enabled;
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_BASSBOOST(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- *pEnabled = (SLboolean) thiz->mBassBoostEffect->getEnabled();
- result = SL_RESULT_SUCCESS;
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IBassBoost_SetStrength(SLBassBoostItf self, SLpermille strength)
-{
- SL_ENTER_INTERFACE
-
- if ((BASSBOOST_STRENGTH_MIN > strength) || (BASSBOOST_STRENGTH_MAX < strength)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IBassBoost *thiz = (IBassBoost *) self;
- interface_lock_exclusive(thiz);
-#if !defined(ANDROID)
- thiz->mStrength = strength;
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_BASSBOOST(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_bb_setParam(thiz->mBassBoostEffect, BASSBOOST_PARAM_STRENGTH, &strength);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IBassBoost_GetRoundedStrength(SLBassBoostItf self, SLpermille *pStrength)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pStrength) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IBassBoost *thiz = (IBassBoost *) self;
- interface_lock_exclusive(thiz);
- SLpermille strength = thiz->mStrength;;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_BASSBOOST(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_bb_getParam(thiz->mBassBoostEffect, BASSBOOST_PARAM_STRENGTH, &strength);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- *pStrength = strength;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IBassBoost_IsStrengthSupported(SLBassBoostItf self, SLboolean *pSupported)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSupported) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
-#if !defined(ANDROID)
- *pSupported = SL_BOOLEAN_TRUE;
- result = SL_RESULT_SUCCESS;
-#else
- IBassBoost *thiz = (IBassBoost *) self;
- int32_t supported = 0;
- interface_lock_exclusive(thiz);
- if (NO_BASSBOOST(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_bb_getParam(thiz->mBassBoostEffect, BASSBOOST_PARAM_STRENGTH_SUPPORTED,
- &supported);
- result = android_fx_statusToResult(status);
- }
- interface_unlock_exclusive(thiz);
- *pSupported = (SLboolean) (supported != 0);
-#endif
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLBassBoostItf_ IBassBoost_Itf = {
- IBassBoost_SetEnabled,
- IBassBoost_IsEnabled,
- IBassBoost_SetStrength,
- IBassBoost_GetRoundedStrength,
- IBassBoost_IsStrengthSupported
-};
-
-void IBassBoost_init(void *self)
-{
- IBassBoost *thiz = (IBassBoost *) self;
- thiz->mItf = &IBassBoost_Itf;
- thiz->mEnabled = SL_BOOLEAN_FALSE;
- thiz->mStrength = 0;
-#if defined(ANDROID)
- memset(&thiz->mBassBoostDescriptor, 0, sizeof(effect_descriptor_t));
- // placement new (explicit constructor)
- (void) new (&thiz->mBassBoostEffect) android::sp<android::AudioEffect>();
-#endif
-}
-
-void IBassBoost_deinit(void *self)
-{
-#if defined(ANDROID)
- IBassBoost *thiz = (IBassBoost *) self;
- // explicit destructor
- thiz->mBassBoostEffect.~sp();
-#endif
-}
-
-bool IBassBoost_Expose(void *self)
-{
-#if defined(ANDROID)
- IBassBoost *thiz = (IBassBoost *) self;
- if (!android_fx_initEffectDescriptor(SL_IID_BASSBOOST, &thiz->mBassBoostDescriptor)) {
- SL_LOGE("BassBoost initialization failed.");
- return false;
- }
-#endif
- return true;
-}
diff --git a/wilhelm/src/itf/IBufferQueue.c b/wilhelm/src/itf/IBufferQueue.c
deleted file mode 100644
index 9503694..0000000
--- a/wilhelm/src/itf/IBufferQueue.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* BufferQueue implementation */
-
-#include "sles_allinclusive.h"
-
-
-/** Determine the state of the audio player or audio recorder associated with a buffer queue.
- * Note that PLAYSTATE and RECORDSTATE values are equivalent (where PLAYING == RECORDING).
- */
-
-static SLuint32 getAssociatedState(IBufferQueue *thiz)
-{
- SLuint32 state;
- switch (InterfaceToObjectID(thiz)) {
- case SL_OBJECTID_AUDIOPLAYER:
- state = ((CAudioPlayer *) thiz->mThis)->mPlay.mState;
- break;
- case SL_OBJECTID_AUDIORECORDER:
- state = ((CAudioRecorder *) thiz->mThis)->mRecord.mState;
- break;
- default:
- // unreachable, but just in case we will assume it is stopped
- assert(SL_BOOLEAN_FALSE);
- state = SL_PLAYSTATE_STOPPED;
- break;
- }
- return state;
-}
-
-
-SLresult IBufferQueue_Enqueue(SLBufferQueueItf self, const void *pBuffer, SLuint32 size)
-{
- SL_ENTER_INTERFACE
- //SL_LOGV("IBufferQueue_Enqueue(%p, %p, %u)", self, pBuffer, size);
-
- // Note that Enqueue while a Clear is pending is equivalent to Enqueue followed by Clear
-
- if (NULL == pBuffer || 0 == size) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IBufferQueue *thiz = (IBufferQueue *) self;
- interface_lock_exclusive(thiz);
- BufferHeader *oldRear = thiz->mRear, *newRear;
- if ((newRear = oldRear + 1) == &thiz->mArray[thiz->mNumBuffers + 1]) {
- newRear = thiz->mArray;
- }
- if (newRear == thiz->mFront) {
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- oldRear->mBuffer = pBuffer;
- oldRear->mSize = size;
- thiz->mRear = newRear;
- ++thiz->mState.count;
- result = SL_RESULT_SUCCESS;
- }
- // set enqueue attribute if state is PLAYING and the first buffer is enqueued
- interface_unlock_exclusive_attributes(thiz, ((SL_RESULT_SUCCESS == result) &&
- (1 == thiz->mState.count) && (SL_PLAYSTATE_PLAYING == getAssociatedState(thiz))) ?
- ATTR_BQ_ENQUEUE : ATTR_NONE);
- }
- SL_LEAVE_INTERFACE
-}
-
-
-SLresult IBufferQueue_Clear(SLBufferQueueItf self)
-{
- SL_ENTER_INTERFACE
-
- result = SL_RESULT_SUCCESS;
- IBufferQueue *thiz = (IBufferQueue *) self;
- interface_lock_exclusive(thiz);
-
-#ifdef ANDROID
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- CAudioPlayer *audioPlayer = (CAudioPlayer *) thiz->mThis;
- // flush associated audio player
- result = android_audioPlayer_bufferQueue_onClear(audioPlayer);
- if (SL_RESULT_SUCCESS == result) {
- thiz->mFront = &thiz->mArray[0];
- thiz->mRear = &thiz->mArray[0];
- thiz->mState.count = 0;
- thiz->mState.playIndex = 0;
- thiz->mSizeConsumed = 0;
- }
- }
-#endif
-
-#ifdef USE_OUTPUTMIXEXT
- // mixer might be reading from the front buffer, so tread carefully here
- // NTH asynchronous cancel instead of blocking until mixer acknowledges
- thiz->mClearRequested = SL_BOOLEAN_TRUE;
- do {
- interface_cond_wait(thiz);
- } while (thiz->mClearRequested);
-#endif
-
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IBufferQueue_GetState(SLBufferQueueItf self, SLBufferQueueState *pState)
-{
- SL_ENTER_INTERFACE
-
- // Note that GetState while a Clear is pending is equivalent to GetState before the Clear
-
- if (NULL == pState) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IBufferQueue *thiz = (IBufferQueue *) self;
- SLBufferQueueState state;
- interface_lock_shared(thiz);
-#ifdef __cplusplus // FIXME Is this a compiler bug?
- state.count = thiz->mState.count;
- state.playIndex = thiz->mState.playIndex;
-#else
- state = thiz->mState;
-#endif
- interface_unlock_shared(thiz);
- *pState = state;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-SLresult IBufferQueue_RegisterCallback(SLBufferQueueItf self,
- slBufferQueueCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IBufferQueue *thiz = (IBufferQueue *) self;
- interface_lock_exclusive(thiz);
- // verify pre-condition that media object is in the SL_PLAYSTATE_STOPPED state
- if (SL_PLAYSTATE_STOPPED == getAssociatedState(thiz)) {
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- result = SL_RESULT_SUCCESS;
- } else {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- }
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLBufferQueueItf_ IBufferQueue_Itf = {
- IBufferQueue_Enqueue,
- IBufferQueue_Clear,
- IBufferQueue_GetState,
- IBufferQueue_RegisterCallback
-};
-
-void IBufferQueue_init(void *self)
-{
- IBufferQueue *thiz = (IBufferQueue *) self;
- thiz->mItf = &IBufferQueue_Itf;
- thiz->mState.count = 0;
- thiz->mState.playIndex = 0;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
- thiz->mNumBuffers = 0;
- thiz->mClearRequested = SL_BOOLEAN_FALSE;
- thiz->mArray = NULL;
- thiz->mFront = NULL;
- thiz->mRear = NULL;
-#ifdef ANDROID
- thiz->mSizeConsumed = 0;
-#endif
- BufferHeader *bufferHeader = thiz->mTypical;
- unsigned i;
- for (i = 0; i < BUFFER_HEADER_TYPICAL+1; ++i, ++bufferHeader) {
- bufferHeader->mBuffer = NULL;
- bufferHeader->mSize = 0;
- }
-}
-
-
-/** \brief Interface deinitialization hook called by IObject::Destroy.
- * Free the buffer queue, if it was larger than typical.
- */
-
-void IBufferQueue_deinit(void *self)
-{
- IBufferQueue *thiz = (IBufferQueue *) self;
- if ((NULL != thiz->mArray) && (thiz->mArray != thiz->mTypical)) {
- free(thiz->mArray);
- thiz->mArray = NULL;
- }
-}
diff --git a/wilhelm/src/itf/IDeviceVolume.c b/wilhelm/src/itf/IDeviceVolume.c
deleted file mode 100644
index bd9f0be..0000000
--- a/wilhelm/src/itf/IDeviceVolume.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* DeviceVolume implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IDeviceVolume_GetVolumeScale(SLDeviceVolumeItf self, SLuint32 deviceID,
- SLint32 *pMinValue, SLint32 *pMaxValue, SLboolean *pIsMillibelScale)
-{
- SL_ENTER_INTERFACE
-
- switch (deviceID) {
- case SL_DEFAULTDEVICEID_AUDIOINPUT:
- case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
- case DEVICE_ID_HEADSET:
- case DEVICE_ID_HANDSFREE:
- if (NULL != pMinValue)
- *pMinValue = 0;
- if (NULL != pMaxValue)
- *pMaxValue = 10;
- if (NULL != pIsMillibelScale)
- *pIsMillibelScale = SL_BOOLEAN_FALSE;
- result = SL_RESULT_SUCCESS;
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IDeviceVolume_SetVolume(SLDeviceVolumeItf self, SLuint32 deviceID, SLint32 volume)
-{
- SL_ENTER_INTERFACE
-
- switch (deviceID) {
- // These are treated same as generic audio output for now
- case DEVICE_ID_HEADSET:
- case DEVICE_ID_HANDSFREE:
- deviceID = SL_DEFAULTDEVICEID_AUDIOOUTPUT;
- // fall through
- case SL_DEFAULTDEVICEID_AUDIOINPUT:
- case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
- {
- IDeviceVolume *thiz = (IDeviceVolume *) self;
- interface_lock_poke(thiz);
- thiz->mVolume[~deviceID] = volume;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IDeviceVolume_GetVolume(SLDeviceVolumeItf self, SLuint32 deviceID, SLint32 *pVolume)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pVolume) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- switch (deviceID) {
- // These are treated same as generic audio output for now
- case DEVICE_ID_HEADSET:
- case DEVICE_ID_HANDSFREE:
- deviceID = SL_DEFAULTDEVICEID_AUDIOOUTPUT;
- // fall through
- case SL_DEFAULTDEVICEID_AUDIOINPUT:
- case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
- {
- IDeviceVolume *thiz = (IDeviceVolume *) self;
- interface_lock_peek(thiz);
- SLint32 volume = thiz->mVolume[~deviceID];
- interface_unlock_peek(thiz);
- *pVolume = volume;
- result = SL_RESULT_SUCCESS;
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLDeviceVolumeItf_ IDeviceVolume_Itf = {
- IDeviceVolume_GetVolumeScale,
- IDeviceVolume_SetVolume,
- IDeviceVolume_GetVolume
-};
-
-void IDeviceVolume_init(void *self)
-{
- IDeviceVolume *thiz = (IDeviceVolume *) self;
- thiz->mItf = &IDeviceVolume_Itf;
- unsigned i;
- for (i = 0; i < MAX_DEVICE; ++i) {
- thiz->mVolume[i] = 10;
- }
-}
diff --git a/wilhelm/src/itf/IDynamicInterfaceManagement.c b/wilhelm/src/itf/IDynamicInterfaceManagement.c
deleted file mode 100644
index e810c85..0000000
--- a/wilhelm/src/itf/IDynamicInterfaceManagement.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* DynamicInterfaceManagement implementation */
-
-#include "sles_allinclusive.h"
-
-
-// Called by a worker thread to handle an asynchronous AddInterface.
-// Parameter self is the DynamicInterface, and MPH specifies which interface to add.
-
-static void HandleAdd(void *self, void *ignored, int MPH)
-{
-
- // validate input parameters
- IDynamicInterfaceManagement *thiz = (IDynamicInterfaceManagement *) self;
- assert(NULL != thiz);
- IObject *thisObject = InterfaceToIObject(thiz);
- assert(NULL != thisObject);
- assert(0 <= MPH && MPH < MPH_MAX);
- const ClassTable *clazz = thisObject->mClass;
- assert(NULL != clazz);
- int index = clazz->mMPH_to_index[MPH];
- assert(0 <= index && index < (int) clazz->mInterfaceCount);
- SLuint8 *interfaceStateP = &thisObject->mInterfaceStates[index];
- SLresult result;
-
- // check interface state
- object_lock_exclusive(thisObject);
- SLuint8 state = *interfaceStateP;
- switch (state) {
-
- case INTERFACE_ADDING_1: // normal case
- {
- // change state to indicate we are now adding the interface
- *interfaceStateP = INTERFACE_ADDING_2;
- object_unlock_exclusive(thisObject);
-
- // this section runs with mutex unlocked
- const struct iid_vtable *x = &clazz->mInterfaces[index];
- size_t offset = x->mOffset;
- void *thisItf = (char *) thisObject + offset;
- BoolHook expose = MPH_init_table[MPH].mExpose;
- // call the optional expose hook
- if ((NULL == expose) || (*expose)(thisItf)) {
- result = SL_RESULT_SUCCESS;
- } else {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
-
- // re-lock mutex to update state
- object_lock_exclusive(thisObject);
- assert(INTERFACE_ADDING_2 == *interfaceStateP);
- if (SL_RESULT_SUCCESS == result) {
- ((size_t *) thisItf)[0] ^= ~0;
- state = INTERFACE_ADDED;
- } else {
- state = INTERFACE_INITIALIZED;
- }
- }
- break;
-
- case INTERFACE_ADDING_1A: // operation was aborted while on work queue
- result = SL_RESULT_OPERATION_ABORTED;
- state = INTERFACE_INITIALIZED;
- break;
-
- default: // impossible
- assert(SL_BOOLEAN_FALSE);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
-
- }
-
- // mutex is locked, update state
- *interfaceStateP = state;
-
- // Make a copy of these, so we can call the callback with mutex unlocked
- slDynamicInterfaceManagementCallback callback = thiz->mCallback;
- void *context = thiz->mContext;
- object_unlock_exclusive(thisObject);
-
- // Note that the mutex is unlocked during the callback
- if (NULL != callback) {
- const SLInterfaceID iid = &SL_IID_array[MPH]; // equal but not == to the original IID
- (*callback)(&thiz->mItf, context, SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, result, iid);
- }
-
-}
-
-
-static SLresult IDynamicInterfaceManagement_AddInterface(SLDynamicInterfaceManagementItf self,
- const SLInterfaceID iid, SLboolean async)
-{
- SL_ENTER_INTERFACE
-
- // validate input parameters
- if (NULL == iid) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IDynamicInterfaceManagement *thiz = (IDynamicInterfaceManagement *) self;
- IObject *thisObject = InterfaceToIObject(thiz);
- const ClassTable *clazz = thisObject->mClass;
- int MPH, index;
- if ((0 > (MPH = IID_to_MPH(iid))) ||
- // no need to check for an initialization hook
- // (NULL == MPH_init_table[MPH].mInit) ||
- (0 > (index = clazz->mMPH_to_index[MPH]))) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- assert(index < (int) clazz->mInterfaceCount);
- SLuint8 *interfaceStateP = &thisObject->mInterfaceStates[index];
-
- // check interface state
- object_lock_exclusive(thisObject);
- switch (*interfaceStateP) {
-
- case INTERFACE_INITIALIZED: // normal case
- if (async) {
- // Asynchronous: mark operation pending and cancellable
- *interfaceStateP = INTERFACE_ADDING_1;
- object_unlock_exclusive(thisObject);
-
- // this section runs with mutex unlocked
- result = ThreadPool_add_ppi(&thisObject->mEngine->mThreadPool, HandleAdd, thiz,
- NULL, MPH);
- if (SL_RESULT_SUCCESS != result) {
- // Engine was destroyed during add, or insufficient memory,
- // so restore mInterfaceStates state to prior value
- object_lock_exclusive(thisObject);
- switch (*interfaceStateP) {
- case INTERFACE_ADDING_1: // normal
- case INTERFACE_ADDING_1A: // operation aborted while mutex unlocked
- *interfaceStateP = INTERFACE_INITIALIZED;
- break;
- default: // unexpected
- // leave state alone
- break;
- }
- }
-
- } else {
- // Synchronous: mark operation pending to prevent duplication
- *interfaceStateP = INTERFACE_ADDING_2;
- object_unlock_exclusive(thisObject);
-
- // this section runs with mutex unlocked
- const struct iid_vtable *x = &clazz->mInterfaces[index];
- size_t offset = x->mOffset;
- void *thisItf = (char *) thisObject + offset;
- // call the optional expose hook
- BoolHook expose = MPH_init_table[MPH].mExpose;
- if ((NULL == expose) || (*expose)(thisItf)) {
- result = SL_RESULT_SUCCESS;
- } else {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
-
- // re-lock mutex to update state
- object_lock_exclusive(thisObject);
- assert(INTERFACE_ADDING_2 == *interfaceStateP);
- if (SL_RESULT_SUCCESS == result) {
- *interfaceStateP = INTERFACE_ADDED;
- } else {
- *interfaceStateP = INTERFACE_INITIALIZED;
- }
- }
-
- // mutex is still locked
- break;
-
- default: // disallow adding of (partially) initialized interfaces
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- break;
-
- }
-
- object_unlock_exclusive(thisObject);
-
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IDynamicInterfaceManagement_RemoveInterface(
- SLDynamicInterfaceManagementItf self, const SLInterfaceID iid)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_BASE
- // validate input parameters
- if (NULL == iid) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IDynamicInterfaceManagement *thiz = (IDynamicInterfaceManagement *) self;
- IObject *thisObject = InterfaceToIObject(thiz);
- const ClassTable *clazz = thisObject->mClass;
- int MPH, index;
- if ((0 > (MPH = IID_to_MPH(iid))) ||
- // no need to check for an initialization hook
- // (NULL == MPH_init_table[MPH].mInit) ||
- (0 > (index = clazz->mMPH_to_index[MPH]))) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- SLuint8 *interfaceStateP = &thisObject->mInterfaceStates[index];
-
- // check interface state
- object_lock_exclusive(thisObject);
- switch (*interfaceStateP) {
-
- case INTERFACE_ADDED: // normal cases
- case INTERFACE_SUSPENDED:
- {
- // Compute address of the interface
- const struct iid_vtable *x = &clazz->mInterfaces[index];
- size_t offset = x->mOffset;
- void *thisItf = (char *) thisObject + offset;
-
- // Mark operation pending (not necessary; remove is synchronous with mutex locked)
- *interfaceStateP = INTERFACE_REMOVING;
-
- // Check if application ever called Object::GetInterface
- unsigned mask = 1 << index;
- if (thisObject->mGottenMask & mask) {
- thisObject->mGottenMask &= ~mask;
- // This trickery invalidates the v-table
- ((size_t *) thisItf)[0] ^= ~0;
- }
-
- // The remove hook is called with mutex locked
- VoidHook remove = MPH_init_table[MPH].mRemove;
- if (NULL != remove) {
- (*remove)(thisItf);
- }
- result = SL_RESULT_SUCCESS;
-
- assert(INTERFACE_REMOVING == *interfaceStateP);
- *interfaceStateP = INTERFACE_INITIALIZED;
- }
-
- // mutex is still locked
- break;
-
- default:
- // disallow removal of non-dynamic interfaces, or interfaces which are
- // currently being resumed (will not auto-cancel an asynchronous resume)
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- break;
-
- }
-
- object_unlock_exclusive(thisObject);
- }
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-// Called by a worker thread to handle an asynchronous ResumeInterface.
-// Parameter self is the DynamicInterface, and MPH specifies which interface to resume.
-
-static void HandleResume(void *self, void *ignored, int MPH)
-{
-
- // validate input parameters
- IDynamicInterfaceManagement *thiz = (IDynamicInterfaceManagement *) self;
- assert(NULL != thiz);
- IObject *thisObject = InterfaceToIObject(thiz);
- assert(NULL != thisObject);
- assert(0 <= MPH && MPH < MPH_MAX);
- const ClassTable *clazz = thisObject->mClass;
- assert(NULL != clazz);
- int index = clazz->mMPH_to_index[MPH];
- assert(0 <= index && index < (int) clazz->mInterfaceCount);
- SLuint8 *interfaceStateP = &thisObject->mInterfaceStates[index];
- SLresult result;
-
- // check interface state
- object_lock_exclusive(thisObject);
- SLuint8 state = *interfaceStateP;
- switch (state) {
-
- case INTERFACE_RESUMING_1: // normal case
- {
- // change state to indicate we are now resuming the interface
- *interfaceStateP = INTERFACE_RESUMING_2;
- object_unlock_exclusive(thisObject);
-
- // this section runs with mutex unlocked
- const struct iid_vtable *x = &clazz->mInterfaces[index];
- size_t offset = x->mOffset;
- void *thisItf = (char *) thisObject + offset;
- VoidHook resume = MPH_init_table[MPH].mResume;
- if (NULL != resume) {
- (*resume)(thisItf);
- }
- result = SL_RESULT_SUCCESS;
-
- // re-lock mutex to update state
- object_lock_exclusive(thisObject);
- assert(INTERFACE_RESUMING_2 == *interfaceStateP);
- state = INTERFACE_ADDED;
- }
- break;
-
- case INTERFACE_RESUMING_1A: // operation was aborted while on work queue
- result = SL_RESULT_OPERATION_ABORTED;
- state = INTERFACE_SUSPENDED;
- break;
-
- default: // impossible
- assert(SL_BOOLEAN_FALSE);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
-
- }
-
- // mutex is locked, update state
- *interfaceStateP = state;
-
- // Make a copy of these, so we can call the callback with mutex unlocked
- slDynamicInterfaceManagementCallback callback = thiz->mCallback;
- void *context = thiz->mContext;
- object_unlock_exclusive(thisObject);
-
- // Note that the mutex is unlocked during the callback
- if (NULL != callback) {
- const SLInterfaceID iid = &SL_IID_array[MPH]; // equal but not == to the original IID
- (*callback)(&thiz->mItf, context, SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, result, iid);
- }
-}
-
-
-static SLresult IDynamicInterfaceManagement_ResumeInterface(SLDynamicInterfaceManagementItf self,
- const SLInterfaceID iid, SLboolean async)
-{
- SL_ENTER_INTERFACE
-
- // validate input parameters
- if (NULL == iid) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IDynamicInterfaceManagement *thiz = (IDynamicInterfaceManagement *) self;
- IObject *thisObject = InterfaceToIObject(thiz);
- const ClassTable *clazz = thisObject->mClass;
- int MPH, index;
- if ((0 > (MPH = IID_to_MPH(iid))) ||
- // no need to check for an initialization hook
- // (NULL == MPH_init_table[MPH].mInit) ||
- (0 > (index = clazz->mMPH_to_index[MPH]))) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- assert(index < (int) clazz->mInterfaceCount);
- SLuint8 *interfaceStateP = &thisObject->mInterfaceStates[index];
-
- // check interface state
- object_lock_exclusive(thisObject);
- switch (*interfaceStateP) {
-
- case INTERFACE_SUSPENDED: // normal case
- if (async) {
- // Asynchronous: mark operation pending and cancellable
- *interfaceStateP = INTERFACE_RESUMING_1;
- object_unlock_exclusive(thisObject);
-
- // this section runs with mutex unlocked
- result = ThreadPool_add_ppi(&thisObject->mEngine->mThreadPool, HandleResume,
- thiz, NULL, MPH);
- if (SL_RESULT_SUCCESS != result) {
- // Engine was destroyed during resume, or insufficient memory,
- // so restore mInterfaceStates state to prior value
- object_lock_exclusive(thisObject);
- switch (*interfaceStateP) {
- case INTERFACE_RESUMING_1: // normal
- case INTERFACE_RESUMING_1A: // operation aborted while mutex unlocked
- *interfaceStateP = INTERFACE_SUSPENDED;
- break;
- default: // unexpected
- // leave state alone
- break;
- }
- }
-
- } else {
- // Synchronous: mark operation pending to prevent duplication
- *interfaceStateP = INTERFACE_RESUMING_2;
- object_unlock_exclusive(thisObject);
-
- // this section runs with mutex unlocked
- const struct iid_vtable *x = &clazz->mInterfaces[index];
- size_t offset = x->mOffset;
- void *thisItf = (char *) thiz + offset;
- VoidHook resume = MPH_init_table[MPH].mResume;
- if (NULL != resume) {
- (*resume)(thisItf);
- }
- result = SL_RESULT_SUCCESS;
-
- // re-lock mutex to update state
- object_lock_exclusive(thisObject);
- assert(INTERFACE_RESUMING_2 == *interfaceStateP);
- *interfaceStateP = INTERFACE_ADDED;
- }
-
- // mutex is now locked
- break;
-
- default: // disallow resumption of non-suspended interfaces
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- break;
- }
-
- object_unlock_exclusive(thisObject);
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IDynamicInterfaceManagement_RegisterCallback(SLDynamicInterfaceManagementItf self,
- slDynamicInterfaceManagementCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IDynamicInterfaceManagement *thiz = (IDynamicInterfaceManagement *) self;
- IObject *thisObject = InterfaceToIObject(thiz);
- object_lock_exclusive(thisObject);
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- object_unlock_exclusive(thisObject);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLDynamicInterfaceManagementItf_ IDynamicInterfaceManagement_Itf = {
- IDynamicInterfaceManagement_AddInterface,
- IDynamicInterfaceManagement_RemoveInterface,
- IDynamicInterfaceManagement_ResumeInterface,
- IDynamicInterfaceManagement_RegisterCallback
-};
-
-void IDynamicInterfaceManagement_init(void *self)
-{
- IDynamicInterfaceManagement *thiz = (IDynamicInterfaceManagement *) self;
- thiz->mItf = &IDynamicInterfaceManagement_Itf;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
-}
diff --git a/wilhelm/src/itf/IDynamicSource.c b/wilhelm/src/itf/IDynamicSource.c
deleted file mode 100644
index 8a97e52..0000000
--- a/wilhelm/src/itf/IDynamicSource.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* DynamicSource implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IDynamicSource_SetSource(SLDynamicSourceItf self, SLDataSource *pDataSource)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDataSource) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IDynamicSource *thiz = (IDynamicSource *) self;
-#if 0
- DataLocatorFormat myDataSource;
- SLresult result;
- result = checkDataSource("pDataSource", pDataSource, &myDataSource, DATALOCATOR_MASK_ALL,
- DATAFORMAT_MASK_ALL);
- // handle result here
-#endif
- // need to lock the object, as a change to source can impact most of object
- IObject *thisObject = InterfaceToIObject(thiz);
- object_lock_exclusive(thisObject);
- // a bit of a simplification to say the least! (see Khronos bug 6728)
- thiz->mDataSource = pDataSource;
- object_unlock_exclusive(thisObject);
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLDynamicSourceItf_ IDynamicSource_Itf = {
- IDynamicSource_SetSource
-};
-
-void IDynamicSource_init(void *self)
-{
- IDynamicSource *thiz = (IDynamicSource *) self;
- thiz->mItf = &IDynamicSource_Itf;
- // mDataSource will be re-initialized later in the containing object constructor
- thiz->mDataSource = NULL;
-}
diff --git a/wilhelm/src/itf/IEffectSend.c b/wilhelm/src/itf/IEffectSend.c
deleted file mode 100644
index 9d88efa..0000000
--- a/wilhelm/src/itf/IEffectSend.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* EffectSend implementation */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Maps AUX index to OutputMix interface index */
-
-static const unsigned char AUX_to_MPH[AUX_MAX] = {
- MPH_ENVIRONMENTALREVERB,
- MPH_PRESETREVERB
-};
-
-
-/** \brief This is a private function that validates the effect interface specified by the
- * application when it calls EnableEffectSend, IsEnabled, SetSendLevel, or GetSendLevel.
- * For the interface to be valid, it has to satisfy these requirements:
- * - object is an audio player (MIDI player is not supported yet)
- * - audio sink is an output mix
- * - interface was exposed at object creation time or by DynamicInterface::AddInterface
- * - interface was "gotten" with Object::GetInterface
- */
-
-static struct EnableLevel *getEnableLevel(IEffectSend *thiz, const void *pAuxEffect)
-{
- // Make sure this effect send is on an audio player, not a MIDI player
- CAudioPlayer *audioPlayer = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL == audioPlayer) {
- return NULL;
- }
- // Get the output mix for this player
- COutputMix *outputMix = CAudioPlayer_GetOutputMix(audioPlayer);
- unsigned aux;
- if (pAuxEffect == &outputMix->mEnvironmentalReverb.mItf) {
- aux = AUX_ENVIRONMENTALREVERB;
- } else if (pAuxEffect == &outputMix->mPresetReverb.mItf) {
- aux = AUX_PRESETREVERB;
- } else {
- SL_LOGE("EffectSend on unknown aux effect %p", pAuxEffect);
- return NULL;
- }
- assert(aux < AUX_MAX);
- // Validate that the application has a valid interface for the effect. The interface must have
- // been exposed at object creation time or by DynamicInterface::AddInterface, and it also must
- // have been "gotten" with Object::GetInterface.
- unsigned MPH = AUX_to_MPH[aux];
- int index = MPH_to_OutputMix[MPH];
- if (0 > index) {
- SL_LOGE("EffectSend aux=%u MPH=%u", aux, MPH);
- return NULL;
- }
- unsigned mask = 1 << index;
- object_lock_shared(&outputMix->mObject);
- SLuint32 state = outputMix->mObject.mInterfaceStates[index];
- mask &= outputMix->mObject.mGottenMask;
- object_unlock_shared(&outputMix->mObject);
- switch (state) {
- case INTERFACE_EXPOSED:
- case INTERFACE_ADDED:
- case INTERFACE_SUSPENDED:
- case INTERFACE_SUSPENDING:
- case INTERFACE_RESUMING_1:
- case INTERFACE_RESUMING_2:
- if (mask) {
- return &thiz->mEnableLevels[aux];
- }
- SL_LOGE("EffectSend no GetInterface yet");
- break;
- default:
- SL_LOGE("EffectSend invalid interface state %u", state);
- break;
- }
- return NULL;
-}
-
-#if defined(ANDROID)
-/** \brief This is a private function that translates an Android effect framework status code
- * to the SL ES result code used in the EnableEffectSend() function of the SLEffectSendItf
- * interface.
- */
-static SLresult translateEnableFxSendError(android::status_t status) {
- switch (status) {
- case android::NO_ERROR:
- return SL_RESULT_SUCCESS;
- case android::INVALID_OPERATION:
- case android::BAD_VALUE:
- default:
- SL_LOGE("EffectSend status %u", status);
- return SL_RESULT_RESOURCE_ERROR;
- }
-}
-#endif
-
-
-static SLresult IEffectSend_EnableEffectSend(SLEffectSendItf self,
- const void *pAuxEffect, SLboolean enable, SLmillibel initialLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!((SL_MILLIBEL_MIN <= initialLevel) && (initialLevel <= 0))) {
- // comparison (SL_MILLIBEL_MIN <= initialLevel) is always true due to range of SLmillibel
- if (!(initialLevel <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEffectSend *thiz = (IEffectSend *) self;
- struct EnableLevel *enableLevel = getEnableLevel(thiz, pAuxEffect);
- if (NULL == enableLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_exclusive(thiz);
- enableLevel->mEnable = SL_BOOLEAN_FALSE != enable; // normalize
- enableLevel->mSendLevel = initialLevel;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- // TODO do not repeat querying of CAudioPlayer, done inside getEnableLevel()
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- // note that if this was a MIDI player, getEnableLevel would have returned NULL
- assert(NULL != ap);
- // check which effect the send is attached to, attach and set level
- COutputMix *outputMix = CAudioPlayer_GetOutputMix(ap);
- // the initial send level set here is the total energy on the aux bus,
- // so it must take into account the player volume level
- if (pAuxEffect == &outputMix->mPresetReverb.mItf) {
- result = translateEnableFxSendError(android_fxSend_attach(ap, (bool) enable,
- outputMix->mPresetReverb.mPresetReverbEffect,
- initialLevel + ap->mVolume.mLevel));
- } else if (pAuxEffect == &outputMix->mEnvironmentalReverb.mItf) {
- result = translateEnableFxSendError(android_fxSend_attach(ap, (bool) enable,
- outputMix->mEnvironmentalReverb.mEnvironmentalReverbEffect,
- initialLevel + ap->mVolume.mLevel));
- } else {
- SL_LOGE("EffectSend unknown aux effect %p", pAuxEffect);
- result = SL_RESULT_PARAMETER_INVALID;
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEffectSend_IsEnabled(SLEffectSendItf self,
- const void *pAuxEffect, SLboolean *pEnable)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEnable) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEffectSend *thiz = (IEffectSend *) self;
- struct EnableLevel *enableLevel = getEnableLevel(thiz, pAuxEffect);
- if (NULL == enableLevel) {
- *pEnable = SL_BOOLEAN_FALSE;
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_shared(thiz);
- SLboolean enable = enableLevel->mEnable;
- interface_unlock_shared(thiz);
- *pEnable = enable;
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEffectSend_SetDirectLevel(SLEffectSendItf self, SLmillibel directLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!((SL_MILLIBEL_MIN <= directLevel) && (directLevel <= 0))) {
- // comparison (SL_MILLIBEL_MIN <= directLevel) is always true due to range of SLmillibel
- if (!(directLevel <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEffectSend *thiz = (IEffectSend *) self;
- interface_lock_exclusive(thiz);
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL != ap) {
- SLmillibel oldDirectLevel = ap->mDirectLevel;
- if (oldDirectLevel != directLevel) {
- ap->mDirectLevel = directLevel;
-#if defined(ANDROID)
- ap->mAmplFromDirectLevel = sles_to_android_amplification(directLevel);
- interface_unlock_exclusive_attributes(thiz, ATTR_GAIN);
-#else
- interface_unlock_exclusive(thiz);
-#endif
- } else {
- interface_unlock_exclusive(thiz);
- }
- } else {
- // MIDI player is silently not supported
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEffectSend_GetDirectLevel(SLEffectSendItf self, SLmillibel *pDirectLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDirectLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEffectSend *thiz = (IEffectSend *) self;
- interface_lock_shared(thiz);
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL != ap) {
- *pDirectLevel = ap->mDirectLevel;
- } else {
- // MIDI player is silently not supported
- *pDirectLevel = 0;
- }
- interface_unlock_shared(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEffectSend_SetSendLevel(SLEffectSendItf self, const void *pAuxEffect,
- SLmillibel sendLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!((SL_MILLIBEL_MIN <= sendLevel) && (sendLevel <= 0))) {
- // comparison (SL_MILLIBEL_MIN <= sendLevel) is always true due to range of SLmillibel
- if (!(sendLevel <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEffectSend *thiz = (IEffectSend *) self;
- struct EnableLevel *enableLevel = getEnableLevel(thiz, pAuxEffect);
- if (NULL == enableLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- // EnableEffectSend is exclusive, so this has to be also
- interface_lock_exclusive(thiz);
- enableLevel->mSendLevel = sendLevel;
-#if defined(ANDROID)
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL != ap) {
- // the send level set here is the total energy on the aux bus, so it must take
- // into account the player volume level
- result = android_fxSend_setSendLevel(ap, sendLevel + ap->mVolume.mLevel);
- }
-#endif
- interface_unlock_exclusive(thiz);
-
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEffectSend_GetSendLevel(SLEffectSendItf self, const void *pAuxEffect,
- SLmillibel *pSendLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSendLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEffectSend *thiz = (IEffectSend *) self;
- struct EnableLevel *enableLevel = getEnableLevel(thiz, pAuxEffect);
- if (NULL == enableLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_shared(thiz);
- SLmillibel sendLevel = enableLevel->mSendLevel;
- interface_unlock_shared(thiz);
- *pSendLevel = sendLevel;
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLEffectSendItf_ IEffectSend_Itf = {
- IEffectSend_EnableEffectSend,
- IEffectSend_IsEnabled,
- IEffectSend_SetDirectLevel,
- IEffectSend_GetDirectLevel,
- IEffectSend_SetSendLevel,
- IEffectSend_GetSendLevel
-};
-
-void IEffectSend_init(void *self)
-{
- IEffectSend *thiz = (IEffectSend *) self;
- thiz->mItf = &IEffectSend_Itf;
- struct EnableLevel *enableLevel = thiz->mEnableLevels;
- unsigned aux;
- for (aux = 0; aux < AUX_MAX; ++aux, ++enableLevel) {
- enableLevel->mEnable = SL_BOOLEAN_FALSE;
- enableLevel->mSendLevel = SL_MILLIBEL_MIN;
- }
-}
diff --git a/wilhelm/src/itf/IEngine.c b/wilhelm/src/itf/IEngine.c
deleted file mode 100644
index 41de0a1..0000000
--- a/wilhelm/src/itf/IEngine.c
+++ /dev/null
@@ -1,1476 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Engine implementation */
-
-#include "sles_allinclusive.h"
-
-
-/* Utility functions */
-
-static SLresult initializeBufferQueueMembers(CAudioPlayer *ap) {
- // inline allocation of circular mArray, up to a typical max
- if (BUFFER_HEADER_TYPICAL >= ap->mBufferQueue.mNumBuffers) {
- ap->mBufferQueue.mArray = ap->mBufferQueue.mTypical;
- } else {
- // Avoid possible integer overflow during multiplication; this arbitrary
- // maximum is big enough to not interfere with real applications, but
- // small enough to not overflow.
- if (ap->mBufferQueue.mNumBuffers >= 256) {
- return SL_RESULT_MEMORY_FAILURE;
- }
- ap->mBufferQueue.mArray = (BufferHeader *)
- malloc((ap->mBufferQueue.mNumBuffers + 1) * sizeof(BufferHeader));
- if (NULL == ap->mBufferQueue.mArray) {
- return SL_RESULT_MEMORY_FAILURE;
- }
- }
- ap->mBufferQueue.mFront = ap->mBufferQueue.mArray;
- ap->mBufferQueue.mRear = ap->mBufferQueue.mArray;
- return SL_RESULT_SUCCESS;
-}
-
-#ifdef ANDROID
-static SLresult initializeAndroidBufferQueueMembers(CAudioPlayer *ap) {
- // Avoid possible integer overflow during multiplication; this arbitrary
- // maximum is big enough to not interfere with real applications, but
- // small enough to not overflow.
- if (ap->mAndroidBufferQueue.mNumBuffers >= 256) {
- return SL_RESULT_MEMORY_FAILURE;
- }
- ap->mAndroidBufferQueue.mBufferArray = (AdvancedBufferHeader *)
- malloc( (ap->mAndroidBufferQueue.mNumBuffers + 1) * sizeof(AdvancedBufferHeader));
- if (NULL == ap->mAndroidBufferQueue.mBufferArray) {
- return SL_RESULT_MEMORY_FAILURE;
- } else {
-
- // initialize ABQ buffer type
- // assert below has been checked in android_audioPlayer_checkSourceSink
- assert(SL_DATAFORMAT_MIME == ap->mDataSource.mFormat.mFormatType);
- switch(ap->mDataSource.mFormat.mMIME.containerType) {
- case SL_CONTAINERTYPE_MPEG_TS:
- ap->mAndroidBufferQueue.mBufferType = kAndroidBufferTypeMpeg2Ts;
- break;
- case SL_CONTAINERTYPE_AAC:
- case SL_CONTAINERTYPE_RAW: {
- const char* mime = (char*)ap->mDataSource.mFormat.mMIME.mimeType;
- if ((mime != NULL) && !(strcasecmp(mime, (const char *)SL_ANDROID_MIME_AACADTS) &&
- strcasecmp(mime, ANDROID_MIME_AACADTS_ANDROID_FRAMEWORK))) {
- ap->mAndroidBufferQueue.mBufferType = kAndroidBufferTypeAacadts;
- } else {
- ap->mAndroidBufferQueue.mBufferType = kAndroidBufferTypeInvalid;
- SL_LOGE("CreateAudioPlayer: Invalid buffer type in Android Buffer Queue");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- } break;
- default:
- ap->mAndroidBufferQueue.mBufferType = kAndroidBufferTypeInvalid;
- SL_LOGE("CreateAudioPlayer: Invalid buffer type in Android Buffer Queue");
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
-
- // initialize ABQ memory
- for (SLuint16 i=0 ; i<(ap->mAndroidBufferQueue.mNumBuffers + 1) ; i++) {
- AdvancedBufferHeader *pBuf = &ap->mAndroidBufferQueue.mBufferArray[i];
- pBuf->mDataBuffer = NULL;
- pBuf->mDataSize = 0;
- pBuf->mDataSizeConsumed = 0;
- pBuf->mBufferContext = NULL;
- pBuf->mBufferState = SL_ANDROIDBUFFERQUEUEEVENT_NONE;
- switch (ap->mAndroidBufferQueue.mBufferType) {
- case kAndroidBufferTypeMpeg2Ts:
- pBuf->mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE;
- pBuf->mItems.mTsCmdData.mPts = 0;
- break;
- case kAndroidBufferTypeAacadts:
- pBuf->mItems.mAdtsCmdData.mAdtsCmdCode = ANDROID_ADTSEVENT_NONE;
- break;
- default:
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
- }
- ap->mAndroidBufferQueue.mFront = ap->mAndroidBufferQueue.mBufferArray;
- ap->mAndroidBufferQueue.mRear = ap->mAndroidBufferQueue.mBufferArray;
- }
-
- return SL_RESULT_SUCCESS;
-}
-#endif
-
-
-static SLresult IEngine_CreateLEDDevice(SLEngineItf self, SLObjectItf *pDevice, SLuint32 deviceID,
- SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_OPTIONAL
- if ((NULL == pDevice) || (SL_DEFAULTDEVICEID_LED != deviceID)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pDevice = NULL;
- unsigned exposedMask;
- const ClassTable *pCLEDDevice_class = objectIDtoClass(SL_OBJECTID_LEDDEVICE);
- if (NULL == pCLEDDevice_class) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = checkInterfaces(pCLEDDevice_class, numInterfaces, pInterfaceIds,
- pInterfaceRequired, &exposedMask, NULL);
- }
- if (SL_RESULT_SUCCESS == result) {
- CLEDDevice *thiz = (CLEDDevice *) construct(pCLEDDevice_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
- thiz->mDeviceID = deviceID;
- IObject_Publish(&thiz->mObject);
- // return the new LED object
- *pDevice = &thiz->mObject.mItf;
- }
- }
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateVibraDevice(SLEngineItf self, SLObjectItf *pDevice, SLuint32 deviceID,
- SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_OPTIONAL
- if ((NULL == pDevice) || (SL_DEFAULTDEVICEID_VIBRA != deviceID)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pDevice = NULL;
- unsigned exposedMask;
- const ClassTable *pCVibraDevice_class = objectIDtoClass(SL_OBJECTID_VIBRADEVICE);
- if (NULL == pCVibraDevice_class) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = checkInterfaces(pCVibraDevice_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- }
- if (SL_RESULT_SUCCESS == result) {
- CVibraDevice *thiz = (CVibraDevice *) construct(pCVibraDevice_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
- thiz->mDeviceID = deviceID;
- IObject_Publish(&thiz->mObject);
- // return the new vibra object
- *pDevice = &thiz->mObject.mItf;
- }
- }
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer,
- SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pPlayer) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pPlayer = NULL;
- unsigned exposedMask, requiredMask;
- const ClassTable *pCAudioPlayer_class = objectIDtoClass(SL_OBJECTID_AUDIOPLAYER);
- assert(NULL != pCAudioPlayer_class);
- result = checkInterfaces(pCAudioPlayer_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, &requiredMask);
- if (SL_RESULT_SUCCESS == result) {
-
- // Construct our new AudioPlayer instance
- CAudioPlayer *thiz = (CAudioPlayer *) construct(pCAudioPlayer_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
-
- do {
-
- // Initialize private fields not associated with an interface
-
- // Default data source in case of failure in checkDataSource
- thiz->mDataSource.mLocator.mLocatorType = SL_DATALOCATOR_NULL;
- thiz->mDataSource.mFormat.mFormatType = SL_DATAFORMAT_NULL;
-
- // Default data sink in case of failure in checkDataSink
- thiz->mDataSink.mLocator.mLocatorType = SL_DATALOCATOR_NULL;
- thiz->mDataSink.mFormat.mFormatType = SL_DATAFORMAT_NULL;
-
- // Default is no per-channel mute or solo
- thiz->mMuteMask = 0;
- thiz->mSoloMask = 0;
-
- // Will be set soon for PCM buffer queues, or later by platform-specific code
- // during Realize or Prefetch
- thiz->mNumChannels = UNKNOWN_NUMCHANNELS;
- thiz->mSampleRateMilliHz = UNKNOWN_SAMPLERATE;
-
- // More default values, in case destructor needs to be called early
- thiz->mDirectLevel = 0;
-#ifdef USE_OUTPUTMIXEXT
- thiz->mTrack = NULL;
- thiz->mGains[0] = 1.0f;
- thiz->mGains[1] = 1.0f;
- thiz->mDestroyRequested = SL_BOOLEAN_FALSE;
-#endif
-#ifdef USE_SNDFILE
- thiz->mSndFile.mPathname = NULL;
- thiz->mSndFile.mSNDFILE = NULL;
- memset(&thiz->mSndFile.mSfInfo, 0, sizeof(SF_INFO));
- memset(&thiz->mSndFile.mMutex, 0, sizeof(pthread_mutex_t));
- thiz->mSndFile.mEOF = SL_BOOLEAN_FALSE;
- thiz->mSndFile.mWhich = 0;
- memset(thiz->mSndFile.mBuffer, 0, sizeof(thiz->mSndFile.mBuffer));
-#endif
-#ifdef ANDROID
- // placement new (explicit constructor)
- // FIXME unnecessary once those fields are encapsulated in one class, rather
- // than a structure
- (void) new (&thiz->mAudioTrack) android::sp<android::AudioTrackProxy>();
- (void) new (&thiz->mCallbackProtector)
- android::sp<android::CallbackProtector>();
- (void) new (&thiz->mAuxEffect) android::sp<android::AudioEffect>();
- (void) new (&thiz->mAPlayer) android::sp<android::GenericPlayer>();
-#endif
-
- // Check the source and sink parameters against generic constraints,
- // and make a local copy of all parameters in case other application threads
- // change memory concurrently.
-
- result = checkDataSource("pAudioSrc", pAudioSrc, &thiz->mDataSource,
- DATALOCATOR_MASK_URI | DATALOCATOR_MASK_ADDRESS |
- DATALOCATOR_MASK_BUFFERQUEUE
-#ifdef ANDROID
- | DATALOCATOR_MASK_ANDROIDFD | DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE
- | DATALOCATOR_MASK_ANDROIDBUFFERQUEUE
-#endif
- , DATAFORMAT_MASK_MIME | DATAFORMAT_MASK_PCM);
-
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-
- result = checkDataSink("pAudioSnk", pAudioSnk, &thiz->mDataSink,
- DATALOCATOR_MASK_OUTPUTMIX // for playback
-#ifdef ANDROID
- | DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE // for decode to a BQ
- | DATALOCATOR_MASK_BUFFERQUEUE // for decode to a BQ
-#endif
- , DATAFORMAT_MASK_NULL
-#ifdef ANDROID
- | DATAFORMAT_MASK_PCM // for decode to PCM
-#endif
- );
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-
- // It would be unsafe to ever refer to the application pointers again
- pAudioSrc = NULL;
- pAudioSnk = NULL;
-
- // Check that the requested interfaces are compatible with data source and sink
- result = checkSourceSinkVsInterfacesCompatibility(&thiz->mDataSource,
- &thiz->mDataSink, pCAudioPlayer_class, requiredMask);
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-
- // copy the buffer queue count from source locator (for playback) / from the
- // sink locator (for decode on ANDROID build) to the buffer queue interface
- // we have already range-checked the value down to a smaller width
- SLuint16 nbBuffers = 0;
- bool usesAdvancedBufferHeaders = false;
- bool usesSimpleBufferQueue = false;
- // creating an AudioPlayer which decodes AAC ADTS buffers to a PCM buffer queue
- // will cause usesAdvancedBufferHeaders and usesSimpleBufferQueue to be true
- switch (thiz->mDataSource.mLocator.mLocatorType) {
- case SL_DATALOCATOR_BUFFERQUEUE:
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
-#endif
- usesSimpleBufferQueue = true;
- nbBuffers = (SLuint16) thiz->mDataSource.mLocator.mBufferQueue.numBuffers;
- assert(SL_DATAFORMAT_PCM == thiz->mDataSource.mFormat.mFormatType);
- thiz->mNumChannels = thiz->mDataSource.mFormat.mPCM.numChannels;
- thiz->mSampleRateMilliHz = thiz->mDataSource.mFormat.mPCM.samplesPerSec;
- break;
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDBUFFERQUEUE:
- usesAdvancedBufferHeaders = true;
- nbBuffers = (SLuint16) thiz->mDataSource.mLocator.mABQ.numBuffers;
- thiz->mAndroidBufferQueue.mNumBuffers = nbBuffers;
- break;
-#endif
- default:
- nbBuffers = 0;
- break;
- }
-#ifdef ANDROID
- switch(thiz->mDataSink.mLocator.mLocatorType) {
- case SL_DATALOCATOR_BUFFERQUEUE:
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
- usesSimpleBufferQueue = true;
- nbBuffers = thiz->mDataSink.mLocator.mBufferQueue.numBuffers;
- assert(SL_DATAFORMAT_PCM == thiz->mDataSink.mFormat.mFormatType);
- // FIXME The values specified by the app are meaningless. We get the
- // real values from the decoder. But the data sink checks currently require
- // that the app specify these useless values. Needs doc/fix.
- // Instead use the "unknown" values, as needed by prepare completion.
- // thiz->mNumChannels = thiz->mDataSink.mFormat.mPCM.numChannels;
- // thiz->mSampleRateMilliHz = thiz->mDataSink.mFormat.mPCM.samplesPerSec;
- thiz->mNumChannels = UNKNOWN_NUMCHANNELS;
- thiz->mSampleRateMilliHz = UNKNOWN_SAMPLERATE;
- break;
- default:
- // leave nbBuffers unchanged
- break;
- }
-#endif
- thiz->mBufferQueue.mNumBuffers = nbBuffers;
-
- // check the audio source and sink parameters against platform support
-#ifdef ANDROID
- result = android_audioPlayer_checkSourceSink(thiz);
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-#endif
-
-#ifdef USE_SNDFILE
- result = SndFile_checkAudioPlayerSourceSink(thiz);
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-#endif
-
-#ifdef USE_OUTPUTMIXEXT
- result = IOutputMixExt_checkAudioPlayerSourceSink(thiz);
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-#endif
-
- // Allocate memory for buffer queue
- if (usesAdvancedBufferHeaders) {
-#ifdef ANDROID
- // locator is SL_DATALOCATOR_ANDROIDBUFFERQUEUE
- result = initializeAndroidBufferQueueMembers(thiz);
-#else
- assert(false);
-#endif
- }
-
- if (usesSimpleBufferQueue) {
- // locator is SL_DATALOCATOR_BUFFERQUEUE
- // or SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE
- result = initializeBufferQueueMembers(thiz);
- }
-
- // used to store the data source of our audio player
- thiz->mDynamicSource.mDataSource = &thiz->mDataSource.u.mSource;
-
- // platform-specific initialization
-#ifdef ANDROID
- android_audioPlayer_create(thiz);
-#endif
-
- } while (0);
-
- if (SL_RESULT_SUCCESS != result) {
- IObject_Destroy(&thiz->mObject.mItf);
- } else {
- IObject_Publish(&thiz->mObject);
- // return the new audio player object
- *pPlayer = &thiz->mObject.mItf;
- }
-
- }
- }
-
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateAudioRecorder(SLEngineItf self, SLObjectItf *pRecorder,
- SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
-#if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
- if (NULL == pRecorder) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pRecorder = NULL;
- unsigned exposedMask;
- const ClassTable *pCAudioRecorder_class = objectIDtoClass(SL_OBJECTID_AUDIORECORDER);
- if (NULL == pCAudioRecorder_class) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = checkInterfaces(pCAudioRecorder_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- }
-
- if (SL_RESULT_SUCCESS == result) {
-
- // Construct our new AudioRecorder instance
- CAudioRecorder *thiz = (CAudioRecorder *) construct(pCAudioRecorder_class, exposedMask,
- self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
-
- do {
-
- // Initialize fields not associated with any interface
-
- // Default data source in case of failure in checkDataSource
- thiz->mDataSource.mLocator.mLocatorType = SL_DATALOCATOR_NULL;
- thiz->mDataSource.mFormat.mFormatType = SL_DATAFORMAT_NULL;
-
- // Default data sink in case of failure in checkDataSink
- thiz->mDataSink.mLocator.mLocatorType = SL_DATALOCATOR_NULL;
- thiz->mDataSink.mFormat.mFormatType = SL_DATAFORMAT_NULL;
-
- // These fields are set to real values by
- // android_audioRecorder_checkSourceSinkSupport. Note that the data sink is
- // always PCM buffer queue, so we know the channel count and sample rate early.
- thiz->mNumChannels = UNKNOWN_NUMCHANNELS;
- thiz->mSampleRateMilliHz = UNKNOWN_SAMPLERATE;
-#ifdef ANDROID
- thiz->mAudioRecord = NULL;
- thiz->mRecordSource = AUDIO_SOURCE_DEFAULT;
-#endif
-
- // Check the source and sink parameters, and make a local copy of all parameters
- result = checkDataSource("pAudioSrc", pAudioSrc, &thiz->mDataSource,
- DATALOCATOR_MASK_IODEVICE, DATAFORMAT_MASK_NULL);
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
- result = checkDataSink("pAudioSnk", pAudioSnk, &thiz->mDataSink,
- DATALOCATOR_MASK_URI
-#ifdef ANDROID
- | DATALOCATOR_MASK_ANDROIDSIMPLEBUFFERQUEUE
-#endif
- , DATAFORMAT_MASK_MIME | DATAFORMAT_MASK_PCM
- );
- if (SL_RESULT_SUCCESS != result) {
- break;
- }
-
- // It would be unsafe to ever refer to the application pointers again
- pAudioSrc = NULL;
- pAudioSnk = NULL;
-
- // check the audio source and sink parameters against platform support
-#ifdef ANDROID
- result = android_audioRecorder_checkSourceSinkSupport(thiz);
- if (SL_RESULT_SUCCESS != result) {
- SL_LOGE("Cannot create AudioRecorder: invalid source or sink");
- break;
- }
-#endif
-
-#ifdef ANDROID
- // Allocate memory for buffer queue
- SLuint32 locatorType = thiz->mDataSink.mLocator.mLocatorType;
- if (locatorType == SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE) {
- thiz->mBufferQueue.mNumBuffers =
- thiz->mDataSink.mLocator.mBufferQueue.numBuffers;
- // inline allocation of circular Buffer Queue mArray, up to a typical max
- if (BUFFER_HEADER_TYPICAL >= thiz->mBufferQueue.mNumBuffers) {
- thiz->mBufferQueue.mArray = thiz->mBufferQueue.mTypical;
- } else {
- // Avoid possible integer overflow during multiplication; this arbitrary
- // maximum is big enough to not interfere with real applications, but
- // small enough to not overflow.
- if (thiz->mBufferQueue.mNumBuffers >= 256) {
- result = SL_RESULT_MEMORY_FAILURE;
- break;
- }
- thiz->mBufferQueue.mArray = (BufferHeader *) malloc((thiz->mBufferQueue.
- mNumBuffers + 1) * sizeof(BufferHeader));
- if (NULL == thiz->mBufferQueue.mArray) {
- result = SL_RESULT_MEMORY_FAILURE;
- break;
- }
- }
- thiz->mBufferQueue.mFront = thiz->mBufferQueue.mArray;
- thiz->mBufferQueue.mRear = thiz->mBufferQueue.mArray;
- }
-#endif
-
- // platform-specific initialization
-#ifdef ANDROID
- android_audioRecorder_create(thiz);
-#endif
-
- } while (0);
-
- if (SL_RESULT_SUCCESS != result) {
- IObject_Destroy(&thiz->mObject.mItf);
- } else {
- IObject_Publish(&thiz->mObject);
- // return the new audio recorder object
- *pRecorder = &thiz->mObject.mItf;
- }
- }
-
- }
-
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateMidiPlayer(SLEngineItf self, SLObjectItf *pPlayer,
- SLDataSource *pMIDISrc, SLDataSource *pBankSrc, SLDataSink *pAudioOutput,
- SLDataSink *pVibra, SLDataSink *pLEDArray, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_PHONE)
- if ((NULL == pPlayer) || (NULL == pMIDISrc) || (NULL == pAudioOutput)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pPlayer = NULL;
- unsigned exposedMask;
- const ClassTable *pCMidiPlayer_class = objectIDtoClass(SL_OBJECTID_MIDIPLAYER);
- if (NULL == pCMidiPlayer_class) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = checkInterfaces(pCMidiPlayer_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- }
- if (SL_RESULT_SUCCESS == result) {
- CMidiPlayer *thiz = (CMidiPlayer *) construct(pCMidiPlayer_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
-#if 0
- "pMIDISrc", pMIDISrc, URI | MIDIBUFFERQUEUE, NONE
- "pBankSrc", pBanksrc, NULL | URI | ADDRESS, NULL
- "pAudioOutput", pAudioOutput, OUTPUTMIX, NULL
- "pVibra", pVibra, NULL | IODEVICE, NULL
- "pLEDArray", pLEDArray, NULL | IODEVICE, NULL
-#endif
- // a fake value - why not use value from IPlay_init? what does CT check for?
- thiz->mPlay.mDuration = 0;
- IObject_Publish(&thiz->mObject);
- // return the new MIDI player object
- *pPlayer = &thiz->mObject.mItf;
- }
- }
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateListener(SLEngineItf self, SLObjectItf *pListener,
- SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_GAME
- if (NULL == pListener) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pListener = NULL;
- unsigned exposedMask;
- const ClassTable *pCListener_class = objectIDtoClass(SL_OBJECTID_LISTENER);
- if (NULL == pCListener_class) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = checkInterfaces(pCListener_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- }
- if (SL_RESULT_SUCCESS == result) {
- CListener *thiz = (CListener *) construct(pCListener_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
- IObject_Publish(&thiz->mObject);
- // return the new 3D listener object
- *pListener = &thiz->mObject.mItf;
- }
- }
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_Create3DGroup(SLEngineItf self, SLObjectItf *pGroup, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_GAME
- if (NULL == pGroup) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pGroup = NULL;
- unsigned exposedMask;
- const ClassTable *pC3DGroup_class = objectIDtoClass(SL_OBJECTID_3DGROUP);
- if (NULL == pC3DGroup_class) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = checkInterfaces(pC3DGroup_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- }
- if (SL_RESULT_SUCCESS == result) {
- C3DGroup *thiz = (C3DGroup *) construct(pC3DGroup_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
- thiz->mMemberMask = 0;
- IObject_Publish(&thiz->mObject);
- // return the new 3D group object
- *pGroup = &thiz->mObject.mItf;
- }
- }
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateOutputMix(SLEngineItf self, SLObjectItf *pMix, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMix) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pMix = NULL;
- unsigned exposedMask;
- const ClassTable *pCOutputMix_class = objectIDtoClass(SL_OBJECTID_OUTPUTMIX);
- assert(NULL != pCOutputMix_class);
- result = checkInterfaces(pCOutputMix_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- if (SL_RESULT_SUCCESS == result) {
- COutputMix *thiz = (COutputMix *) construct(pCOutputMix_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
-#ifdef ANDROID
- android_outputMix_create(thiz);
-#endif
-#ifdef USE_SDL
- IEngine *thisEngine = &thiz->mObject.mEngine->mEngine;
- interface_lock_exclusive(thisEngine);
- bool unpause = false;
- if (NULL == thisEngine->mOutputMix) {
- thisEngine->mOutputMix = thiz;
- unpause = true;
- }
- interface_unlock_exclusive(thisEngine);
-#endif
- IObject_Publish(&thiz->mObject);
-#ifdef USE_SDL
- if (unpause) {
- // Enable SDL_callback to be called periodically by SDL's internal thread
- SDL_PauseAudio(0);
- }
-#endif
- // return the new output mix object
- *pMix = &thiz->mObject.mItf;
- }
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateMetadataExtractor(SLEngineItf self, SLObjectItf *pMetadataExtractor,
- SLDataSource *pDataSource, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds,
- const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
- if (NULL == pMetadataExtractor) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pMetadataExtractor = NULL;
- unsigned exposedMask;
- const ClassTable *pCMetadataExtractor_class =
- objectIDtoClass(SL_OBJECTID_METADATAEXTRACTOR);
- if (NULL == pCMetadataExtractor_class) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = checkInterfaces(pCMetadataExtractor_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- }
- if (SL_RESULT_SUCCESS == result) {
- CMetadataExtractor *thiz = (CMetadataExtractor *)
- construct(pCMetadataExtractor_class, exposedMask, self);
- if (NULL == thiz) {
- result = SL_RESULT_MEMORY_FAILURE;
- } else {
-#if 0
- "pDataSource", pDataSource, NONE, NONE
-#endif
- IObject_Publish(&thiz->mObject);
- // return the new metadata extractor object
- *pMetadataExtractor = &thiz->mObject.mItf;
- result = SL_RESULT_SUCCESS;
- }
- }
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_CreateExtensionObject(SLEngineItf self, SLObjectItf *pObject,
- void *pParameters, SLuint32 objectID, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pObject) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pObject = NULL;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_QueryNumSupportedInterfaces(SLEngineItf self,
- SLuint32 objectID, SLuint32 *pNumSupportedInterfaces)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumSupportedInterfaces) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- const ClassTable *clazz = objectIDtoClass(objectID);
- if (NULL == clazz) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- SLuint32 count = 0;
- SLuint32 i;
- for (i = 0; i < clazz->mInterfaceCount; ++i) {
- switch (clazz->mInterfaces[i].mInterface) {
- case INTERFACE_IMPLICIT:
- case INTERFACE_IMPLICIT_PREREALIZE:
- case INTERFACE_EXPLICIT:
- case INTERFACE_EXPLICIT_PREREALIZE:
- case INTERFACE_DYNAMIC:
- ++count;
- break;
- case INTERFACE_UNAVAILABLE:
- break;
- default:
- assert(false);
- break;
- }
- }
- *pNumSupportedInterfaces = count;
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE;
-}
-
-
-static SLresult IEngine_QuerySupportedInterfaces(SLEngineItf self,
- SLuint32 objectID, SLuint32 index, SLInterfaceID *pInterfaceId)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pInterfaceId) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pInterfaceId = NULL;
- const ClassTable *clazz = objectIDtoClass(objectID);
- if (NULL == clazz) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- result = SL_RESULT_PARAMETER_INVALID; // will be reset later
- SLuint32 i;
- for (i = 0; i < clazz->mInterfaceCount; ++i) {
- switch (clazz->mInterfaces[i].mInterface) {
- case INTERFACE_IMPLICIT:
- case INTERFACE_IMPLICIT_PREREALIZE:
- case INTERFACE_EXPLICIT:
- case INTERFACE_EXPLICIT_PREREALIZE:
- case INTERFACE_DYNAMIC:
- break;
- case INTERFACE_UNAVAILABLE:
- continue;
- default:
- assert(false);
- break;
- }
- if (index == 0) {
- *pInterfaceId = &SL_IID_array[clazz->mInterfaces[i].mMPH];
- result = SL_RESULT_SUCCESS;
- break;
- }
- --index;
- }
- }
- }
-
- SL_LEAVE_INTERFACE
-};
-
-
-static const char * const extensionNames[] = {
-#ifdef ANDROID
-#define _(n) #n
-#define __(n) _(n)
- "ANDROID_SDK_LEVEL_" __(PLATFORM_SDK_VERSION),
-#undef _
-#undef __
-#else
- "WILHELM_DESKTOP",
-#endif
-};
-
-
-static SLresult IEngine_QueryNumSupportedExtensions(SLEngineItf self, SLuint32 *pNumExtensions)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumExtensions) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pNumExtensions = sizeof(extensionNames) / sizeof(extensionNames[0]);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_QuerySupportedExtension(SLEngineItf self,
- SLuint32 index, SLchar *pExtensionName, SLint16 *pNameLength)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNameLength) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- size_t actualNameLength;
- unsigned numExtensions = sizeof(extensionNames) / sizeof(extensionNames[0]);
- if (index >= numExtensions) {
- actualNameLength = 0;
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- const char *extensionName = extensionNames[index];
- actualNameLength = strlen(extensionName) + 1;
- if (NULL == pExtensionName) {
- // application is querying the name length in order to allocate a buffer
- result = SL_RESULT_SUCCESS;
- } else {
- SLint16 availableNameLength = *pNameLength;
- if (0 >= availableNameLength) {
- // there is not even room for the terminating NUL
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else if (actualNameLength > (size_t) availableNameLength) {
- // "no invalid strings are written. That is, the null-terminator always exists"
- memcpy(pExtensionName, extensionName, (size_t) availableNameLength - 1);
- pExtensionName[(size_t) availableNameLength - 1] = '\0';
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- memcpy(pExtensionName, extensionName, actualNameLength);
- result = SL_RESULT_SUCCESS;
- }
- }
- }
- *pNameLength = actualNameLength;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngine_IsExtensionSupported(SLEngineItf self,
- const SLchar *pExtensionName, SLboolean *pSupported)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSupported) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLboolean isSupported = SL_BOOLEAN_FALSE;
- if (NULL == pExtensionName) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- unsigned numExtensions = sizeof(extensionNames) / sizeof(extensionNames[0]);
- unsigned i;
- for (i = 0; i < numExtensions; ++i) {
- if (!strcmp((const char *) pExtensionName, extensionNames[i])) {
- isSupported = SL_BOOLEAN_TRUE;
- break;
- }
- }
- result = SL_RESULT_SUCCESS;
- }
- *pSupported = isSupported;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLEngineItf_ IEngine_Itf = {
- IEngine_CreateLEDDevice,
- IEngine_CreateVibraDevice,
- IEngine_CreateAudioPlayer,
- IEngine_CreateAudioRecorder,
- IEngine_CreateMidiPlayer,
- IEngine_CreateListener,
- IEngine_Create3DGroup,
- IEngine_CreateOutputMix,
- IEngine_CreateMetadataExtractor,
- IEngine_CreateExtensionObject,
- IEngine_QueryNumSupportedInterfaces,
- IEngine_QuerySupportedInterfaces,
- IEngine_QueryNumSupportedExtensions,
- IEngine_QuerySupportedExtension,
- IEngine_IsExtensionSupported
-};
-
-void IEngine_init(void *self)
-{
- IEngine *thiz = (IEngine *) self;
- thiz->mItf = &IEngine_Itf;
- // mLossOfControlGlobal is initialized in slCreateEngine
-#ifdef USE_SDL
- thiz->mOutputMix = NULL;
-#endif
- thiz->mInstanceCount = 1; // ourself
- thiz->mInstanceMask = 0;
- thiz->mChangedMask = 0;
- unsigned i;
- for (i = 0; i < MAX_INSTANCE; ++i) {
- thiz->mInstances[i] = NULL;
- }
- thiz->mShutdown = SL_BOOLEAN_FALSE;
- thiz->mShutdownAck = SL_BOOLEAN_FALSE;
-}
-
-void IEngine_deinit(void *self)
-{
-}
-
-
-// OpenMAX AL Engine
-
-
-static XAresult IEngine_CreateCameraDevice(XAEngineItf self, XAObjectItf *pDevice,
- XAuint32 deviceID, XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds,
- const XAboolean *pInterfaceRequired)
-{
- XA_ENTER_INTERFACE
-
- //IXAEngine *thiz = (IXAEngine *) self;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IEngine_CreateRadioDevice(XAEngineItf self, XAObjectItf *pDevice,
- XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds,
- const XAboolean *pInterfaceRequired)
-{
- XA_ENTER_INTERFACE
-
- //IXAEngine *thiz = (IXAEngine *) self;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IXAEngine_CreateLEDDevice(XAEngineItf self, XAObjectItf *pDevice, XAuint32 deviceID,
- XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds,
- const XAboolean *pInterfaceRequired)
-{
- // forward to OpenSL ES
- return IEngine_CreateLEDDevice(&((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf,
- (SLObjectItf *) pDevice, deviceID, numInterfaces, (const SLInterfaceID *) pInterfaceIds,
- (const SLboolean *) pInterfaceRequired);
-}
-
-
-static XAresult IXAEngine_CreateVibraDevice(XAEngineItf self, XAObjectItf *pDevice,
- XAuint32 deviceID, XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds,
- const XAboolean *pInterfaceRequired)
-{
- // forward to OpenSL ES
- return IEngine_CreateVibraDevice(&((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf,
- (SLObjectItf *) pDevice, deviceID, numInterfaces, (const SLInterfaceID *) pInterfaceIds,
- (const SLboolean *) pInterfaceRequired);
-}
-
-
-static XAresult IEngine_CreateMediaPlayer(XAEngineItf self, XAObjectItf *pPlayer,
- XADataSource *pDataSrc, XADataSource *pBankSrc, XADataSink *pAudioSnk,
- XADataSink *pImageVideoSnk, XADataSink *pVibra, XADataSink *pLEDArray,
- XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds,
- const XAboolean *pInterfaceRequired)
-{
- XA_ENTER_INTERFACE
-
- if (NULL == pPlayer) {
- result = XA_RESULT_PARAMETER_INVALID;
- } else {
- *pPlayer = NULL;
- unsigned exposedMask;
- const ClassTable *pCMediaPlayer_class = objectIDtoClass(XA_OBJECTID_MEDIAPLAYER);
- assert(NULL != pCMediaPlayer_class);
- result = checkInterfaces(pCMediaPlayer_class, numInterfaces,
- (const SLInterfaceID *) pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
- if (XA_RESULT_SUCCESS == result) {
-
- // Construct our new MediaPlayer instance
- CMediaPlayer *thiz = (CMediaPlayer *) construct(pCMediaPlayer_class, exposedMask,
- &((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf);
- if (NULL == thiz) {
- result = XA_RESULT_MEMORY_FAILURE;
- } else {
-
- do {
-
- // Initialize private fields not associated with an interface
-
- // Default data source in case of failure in checkDataSource
- thiz->mDataSource.mLocator.mLocatorType = SL_DATALOCATOR_NULL;
- thiz->mDataSource.mFormat.mFormatType = XA_DATAFORMAT_NULL;
-
- // Default andio and image sink in case of failure in checkDataSink
- thiz->mAudioSink.mLocator.mLocatorType = XA_DATALOCATOR_NULL;
- thiz->mAudioSink.mFormat.mFormatType = XA_DATAFORMAT_NULL;
- thiz->mImageVideoSink.mLocator.mLocatorType = XA_DATALOCATOR_NULL;
- thiz->mImageVideoSink.mFormat.mFormatType = XA_DATAFORMAT_NULL;
-
- // More default values, in case destructor needs to be called early
- thiz->mNumChannels = UNKNOWN_NUMCHANNELS;
-
- // (assume calloc or memset 0 during allocation)
- // placement new
-#ifdef ANDROID
- // placement new (explicit constructor)
- // FIXME unnecessary once those fields are encapsulated in one class, rather
- // than a structure
- (void) new (&thiz->mAVPlayer) android::sp<android::GenericPlayer>();
- (void) new (&thiz->mCallbackProtector)
- android::sp<android::CallbackProtector>();
-#endif
-
- // Check the source and sink parameters against generic constraints
-
- result = checkDataSource("pDataSrc", (const SLDataSource *) pDataSrc,
- &thiz->mDataSource, DATALOCATOR_MASK_URI
-#ifdef ANDROID
- | DATALOCATOR_MASK_ANDROIDFD
- | DATALOCATOR_MASK_ANDROIDBUFFERQUEUE
-#endif
- , DATAFORMAT_MASK_MIME);
- if (XA_RESULT_SUCCESS != result) {
- break;
- }
-
- result = checkDataSource("pBankSrc", (const SLDataSource *) pBankSrc,
- &thiz->mBankSource, DATALOCATOR_MASK_NULL | DATALOCATOR_MASK_URI |
- DATALOCATOR_MASK_ADDRESS, DATAFORMAT_MASK_NULL);
- if (XA_RESULT_SUCCESS != result) {
- break;
- }
-
- result = checkDataSink("pAudioSnk", (const SLDataSink *) pAudioSnk,
- &thiz->mAudioSink, DATALOCATOR_MASK_OUTPUTMIX, DATAFORMAT_MASK_NULL);
- if (XA_RESULT_SUCCESS != result) {
- break;
- }
-
- result = checkDataSink("pImageVideoSnk", (const SLDataSink *) pImageVideoSnk,
- &thiz->mImageVideoSink,
- DATALOCATOR_MASK_NULL | DATALOCATOR_MASK_NATIVEDISPLAY,
- DATAFORMAT_MASK_NULL);
- if (XA_RESULT_SUCCESS != result) {
- break;
- }
-
- result = checkDataSink("pVibra", (const SLDataSink *) pVibra, &thiz->mVibraSink,
- DATALOCATOR_MASK_NULL | DATALOCATOR_MASK_IODEVICE,
- DATAFORMAT_MASK_NULL);
- if (XA_RESULT_SUCCESS != result) {
- break;
- }
-
- result = checkDataSink("pLEDArray", (const SLDataSink *) pLEDArray,
- &thiz->mLEDArraySink, DATALOCATOR_MASK_NULL | DATALOCATOR_MASK_IODEVICE,
- DATAFORMAT_MASK_NULL);
- if (XA_RESULT_SUCCESS != result) {
- break;
- }
-
- // Unsafe to ever refer to application pointers again
- pDataSrc = NULL;
- pBankSrc = NULL;
- pAudioSnk = NULL;
- pImageVideoSnk = NULL;
- pVibra = NULL;
- pLEDArray = NULL;
-
- // Check that the requested interfaces are compatible with the data source
- // FIXME implement
-
- // check the source and sink parameters against platform support
-#ifdef ANDROID
- result = android_Player_checkSourceSink(thiz);
- if (XA_RESULT_SUCCESS != result) {
- break;
- }
-#endif
-
-#ifdef ANDROID
- // AndroidBufferQueue-specific initialization
- if (XA_DATALOCATOR_ANDROIDBUFFERQUEUE ==
- thiz->mDataSource.mLocator.mLocatorType) {
- XAuint16 nbBuffers = (XAuint16) thiz->mDataSource.mLocator.mABQ.numBuffers;
-
- // Avoid possible integer overflow during multiplication; this arbitrary
- // maximum is big enough to not interfere with real applications, but
- // small enough to not overflow.
- if (nbBuffers >= 256) {
- result = SL_RESULT_MEMORY_FAILURE;
- break;
- }
-
- // initialize ABQ buffer type
- // assert below has been checked in android_audioPlayer_checkSourceSink
- assert(XA_DATAFORMAT_MIME == thiz->mDataSource.mFormat.mFormatType);
- if (XA_CONTAINERTYPE_MPEG_TS ==
- thiz->mDataSource.mFormat.mMIME.containerType) {
- thiz->mAndroidBufferQueue.mBufferType = kAndroidBufferTypeMpeg2Ts;
-
- // Set the container type for the StreamInformation interface
- XAMediaContainerInformation *containerInfo =
- (XAMediaContainerInformation*)
- // always storing container info at index 0, as per spec
- &(thiz->mStreamInfo.mStreamInfoTable.itemAt(0).
- containerInfo);
- containerInfo->containerType = XA_CONTAINERTYPE_MPEG_TS;
- // there are no streams at this stage
- containerInfo->numStreams = 0;
-
- } else {
- thiz->mAndroidBufferQueue.mBufferType = kAndroidBufferTypeInvalid;
- SL_LOGE("Invalid buffer type in Android Buffer Queue");
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- }
-
- // initialize ABQ memory
- thiz->mAndroidBufferQueue.mBufferArray = (AdvancedBufferHeader *)
- malloc( (nbBuffers + 1) * sizeof(AdvancedBufferHeader));
- if (NULL == thiz->mAndroidBufferQueue.mBufferArray) {
- result = SL_RESULT_MEMORY_FAILURE;
- break;
- } else {
- for (XAuint16 i=0 ; i<(nbBuffers + 1) ; i++) {
- thiz->mAndroidBufferQueue.mBufferArray[i].mDataBuffer = NULL;
- thiz->mAndroidBufferQueue.mBufferArray[i].mDataSize = 0;
- thiz->mAndroidBufferQueue.mBufferArray[i].mDataSizeConsumed = 0;
- thiz->mAndroidBufferQueue.mBufferArray[i].mBufferContext = NULL;
- thiz->mAndroidBufferQueue.mBufferArray[i].mBufferState =
- XA_ANDROIDBUFFERQUEUEEVENT_NONE;
- switch (thiz->mAndroidBufferQueue.mBufferType) {
- case kAndroidBufferTypeMpeg2Ts:
- thiz->mAndroidBufferQueue.mBufferArray[i].mItems.mTsCmdData.
- mTsCmdCode = ANDROID_MP2TSEVENT_NONE;
- thiz->mAndroidBufferQueue.mBufferArray[i].mItems.mTsCmdData.
- mPts = 0;
- break;
- default:
- result = SL_RESULT_CONTENT_UNSUPPORTED;
- break;
- }
- }
- thiz->mAndroidBufferQueue.mFront =
- thiz->mAndroidBufferQueue.mBufferArray;
- thiz->mAndroidBufferQueue.mRear =
- thiz->mAndroidBufferQueue.mBufferArray;
- }
-
- thiz->mAndroidBufferQueue.mNumBuffers = nbBuffers;
-
- }
-#endif
-
- // used to store the data source of our audio player
- thiz->mDynamicSource.mDataSource = &thiz->mDataSource.u.mSource;
-
- // platform-specific initialization
-#ifdef ANDROID
- android_Player_create(thiz);
-#endif
-
- } while (0);
-
- if (XA_RESULT_SUCCESS != result) {
- IObject_Destroy(&thiz->mObject.mItf);
- } else {
- IObject_Publish(&thiz->mObject);
- // return the new media player object
- *pPlayer = (XAObjectItf) &thiz->mObject.mItf;
- }
-
- }
- }
-
- }
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IEngine_CreateMediaRecorder(XAEngineItf self, XAObjectItf *pRecorder,
- XADataSource *pAudioSrc, XADataSource *pImageVideoSrc,
- XADataSink *pDataSnk, XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds,
- const XAboolean *pInterfaceRequired)
-{
- XA_ENTER_INTERFACE
-
- //IXAEngine *thiz = (IXAEngine *) self;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-
-#if 0
- "pAudioSrc", pAudioSrc,
- "pImageVideoSrc", pImageVideoSrc,
- "pDataSink", pDataSnk,
-#endif
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IXAEngine_CreateOutputMix(XAEngineItf self, XAObjectItf *pMix,
- XAuint32 numInterfaces, const XAInterfaceID *pInterfaceIds,
- const XAboolean *pInterfaceRequired)
-{
- // forward to OpenSL ES
- return IEngine_CreateOutputMix(&((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf,
- (SLObjectItf *) pMix, numInterfaces, (const SLInterfaceID *) pInterfaceIds,
- (const SLboolean *) pInterfaceRequired);
-}
-
-
-static XAresult IXAEngine_CreateMetadataExtractor(XAEngineItf self, XAObjectItf *pMetadataExtractor,
- XADataSource *pDataSource, XAuint32 numInterfaces,
- const XAInterfaceID *pInterfaceIds, const XAboolean *pInterfaceRequired)
-{
- // forward to OpenSL ES
- return IEngine_CreateMetadataExtractor(&((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf,
- (SLObjectItf *) pMetadataExtractor, (SLDataSource *) pDataSource, numInterfaces,
- (const SLInterfaceID *) pInterfaceIds, (const SLboolean *) pInterfaceRequired);
-}
-
-
-static XAresult IXAEngine_CreateExtensionObject(XAEngineItf self, XAObjectItf *pObject,
- void *pParameters, XAuint32 objectID, XAuint32 numInterfaces,
- const XAInterfaceID *pInterfaceIds, const XAboolean *pInterfaceRequired)
-{
- // forward to OpenSL ES
- return IEngine_CreateExtensionObject(&((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf,
- (SLObjectItf *) pObject, pParameters, objectID, numInterfaces,
- (const SLInterfaceID *) pInterfaceIds, (const SLboolean *) pInterfaceRequired);
-}
-
-
-static XAresult IEngine_GetImplementationInfo(XAEngineItf self, XAuint32 *pMajor, XAuint32 *pMinor,
- XAuint32 *pStep, /* XAuint32 nImplementationTextSize, */ const XAchar *pImplementationText)
-{
- XA_ENTER_INTERFACE
-
- //IXAEngine *thiz = (IXAEngine *) self;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IXAEngine_QuerySupportedProfiles(XAEngineItf self, XAint16 *pProfilesSupported)
-{
- XA_ENTER_INTERFACE
-
- if (NULL == pProfilesSupported) {
- result = XA_RESULT_PARAMETER_INVALID;
- } else {
-#if 1
- *pProfilesSupported = 0;
- // the code below was copied from OpenSL ES and needs to be adapted for OpenMAX AL.
-#else
- // The generic implementation doesn't implement any of the profiles, they shouldn't be
- // declared as supported. Also exclude the fake profiles BASE and OPTIONAL.
- *pProfilesSupported = USE_PROFILES &
- (USE_PROFILES_GAME | USE_PROFILES_MUSIC | USE_PROFILES_PHONE);
-#endif
- result = XA_RESULT_SUCCESS;
- }
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IXAEngine_QueryNumSupportedInterfaces(XAEngineItf self, XAuint32 objectID,
- XAuint32 *pNumSupportedInterfaces)
-{
- // forward to OpenSL ES
- return IEngine_QueryNumSupportedInterfaces(
- &((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf, objectID,
- pNumSupportedInterfaces);
-}
-
-
-static XAresult IXAEngine_QuerySupportedInterfaces(XAEngineItf self, XAuint32 objectID,
- XAuint32 index, XAInterfaceID *pInterfaceId)
-{
- // forward to OpenSL ES
- return IEngine_QuerySupportedInterfaces(
- &((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf, objectID, index,
- (SLInterfaceID *) pInterfaceId);
-}
-
-
-static XAresult IXAEngine_QueryNumSupportedExtensions(XAEngineItf self, XAuint32 *pNumExtensions)
-{
- // forward to OpenSL ES
- return IEngine_QueryNumSupportedExtensions(
- &((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf, pNumExtensions);
-}
-
-
-static XAresult IXAEngine_QuerySupportedExtension(XAEngineItf self, XAuint32 index,
- XAchar *pExtensionName, XAint16 *pNameLength)
-{
- // forward to OpenSL ES
- return IEngine_QuerySupportedExtension(&((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf,
- index, pExtensionName, (SLint16 *) pNameLength);
-}
-
-
-static XAresult IXAEngine_IsExtensionSupported(XAEngineItf self, const XAchar *pExtensionName,
- XAboolean *pSupported)
-{
- // forward to OpenSL ES
- return IEngine_IsExtensionSupported(&((CEngine *) ((IXAEngine *) self)->mThis)->mEngine.mItf,
- pExtensionName, pSupported);
-}
-
-
-static XAresult IXAEngine_QueryLEDCapabilities(XAEngineItf self, XAuint32 *pIndex,
- XAuint32 *pLEDDeviceID, XALEDDescriptor *pDescriptor)
-{
- // forward to OpenSL ES EngineCapabilities
- return (XAresult) IEngineCapabilities_QueryLEDCapabilities(
- &((CEngine *) ((IXAEngine *) self)->mThis)->mEngineCapabilities.mItf, pIndex,
- pLEDDeviceID, (SLLEDDescriptor *) pDescriptor);
-}
-
-
-static XAresult IXAEngine_QueryVibraCapabilities(XAEngineItf self, XAuint32 *pIndex,
- XAuint32 *pVibraDeviceID, XAVibraDescriptor *pDescriptor)
-{
- // forward to OpenSL ES EngineCapabilities
- return (XAresult) IEngineCapabilities_QueryVibraCapabilities(
- &((CEngine *) ((IXAEngine *) self)->mThis)->mEngineCapabilities.mItf, pIndex,
- pVibraDeviceID, (SLVibraDescriptor *) pDescriptor);
-}
-
-
-// OpenMAX AL engine v-table
-
-static const struct XAEngineItf_ IXAEngine_Itf = {
- IEngine_CreateCameraDevice,
- IEngine_CreateRadioDevice,
- IXAEngine_CreateLEDDevice,
- IXAEngine_CreateVibraDevice,
- IEngine_CreateMediaPlayer,
- IEngine_CreateMediaRecorder,
- IXAEngine_CreateOutputMix,
- IXAEngine_CreateMetadataExtractor,
- IXAEngine_CreateExtensionObject,
- IEngine_GetImplementationInfo,
- IXAEngine_QuerySupportedProfiles,
- IXAEngine_QueryNumSupportedInterfaces,
- IXAEngine_QuerySupportedInterfaces,
- IXAEngine_QueryNumSupportedExtensions,
- IXAEngine_QuerySupportedExtension,
- IXAEngine_IsExtensionSupported,
- IXAEngine_QueryLEDCapabilities,
- IXAEngine_QueryVibraCapabilities
-};
-
-
-void IXAEngine_init(void *self)
-{
- IXAEngine *thiz = (IXAEngine *) self;
- thiz->mItf = &IXAEngine_Itf;
-}
-
-
-void IXAEngine_deinit(void *self)
-{
-}
diff --git a/wilhelm/src/itf/IEngineCapabilities.c b/wilhelm/src/itf/IEngineCapabilities.c
deleted file mode 100644
index 681d82d..0000000
--- a/wilhelm/src/itf/IEngineCapabilities.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* EngineCapabilities implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IEngineCapabilities_QuerySupportedProfiles(
- SLEngineCapabilitiesItf self, SLuint16 *pProfilesSupported)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pProfilesSupported) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- // The generic implementation doesn't implement any of the profiles, they shouldn't be
- // declared as supported. Also exclude the fake profiles BASE and OPTIONAL.
- *pProfilesSupported = USE_PROFILES &
- (USE_PROFILES_GAME | USE_PROFILES_MUSIC | USE_PROFILES_PHONE);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngineCapabilities_QueryAvailableVoices(SLEngineCapabilitiesItf self,
- SLuint16 voiceType, SLint16 *pNumMaxVoices, SLboolean *pIsAbsoluteMax, SLint16 *pNumFreeVoices)
-{
- SL_ENTER_INTERFACE
-
- switch (voiceType) {
- case SL_VOICETYPE_2D_AUDIO:
- case SL_VOICETYPE_MIDI:
- case SL_VOICETYPE_3D_AUDIO:
- case SL_VOICETYPE_3D_MIDIOUTPUT:
- if (NULL != pNumMaxVoices)
- *pNumMaxVoices = MAX_INSTANCE - 2;
- if (NULL != pIsAbsoluteMax)
- *pIsAbsoluteMax = SL_BOOLEAN_TRUE;
- if (NULL != pNumFreeVoices)
- *pNumFreeVoices = MAX_INSTANCE - 2;
- result = SL_RESULT_SUCCESS;
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngineCapabilities_QueryNumberOfMIDISynthesizers(
- SLEngineCapabilitiesItf self, SLint16 *pNum)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNum) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pNum = 1;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngineCapabilities_QueryAPIVersion(SLEngineCapabilitiesItf self,
- SLint16 *pMajor, SLint16 *pMinor, SLint16 *pStep)
-{
- SL_ENTER_INTERFACE
-
- if (!(NULL != pMajor && NULL != pMinor && NULL != pStep)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pMajor = 1;
- *pMinor = 0;
- *pStep = 1;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-SLresult IEngineCapabilities_QueryLEDCapabilities(SLEngineCapabilitiesItf self,
- SLuint32 *pIndex, SLuint32 *pLEDDeviceID, SLLEDDescriptor *pDescriptor)
-{
- SL_ENTER_INTERFACE
-
- IEngineCapabilities *thiz = (IEngineCapabilities *) self;
- const struct LED_id_descriptor *id_descriptor;
- SLuint32 index;
- if (NULL != pIndex) {
- result = SL_RESULT_SUCCESS;
- if (NULL != pLEDDeviceID || NULL != pDescriptor) {
- index = *pIndex;
- if (index >= thiz->mMaxIndexLED) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- id_descriptor = &LED_id_descriptors[index];
- if (NULL != pLEDDeviceID)
- *pLEDDeviceID = id_descriptor->id;
- if (NULL != pDescriptor)
- *pDescriptor = *id_descriptor->descriptor;
- }
- }
- *pIndex = thiz->mMaxIndexLED;
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- if (NULL != pLEDDeviceID && NULL != pDescriptor) {
- SLuint32 id = *pLEDDeviceID;
- for (index = 0; index < thiz->mMaxIndexLED; ++index) {
- id_descriptor = &LED_id_descriptors[index];
- if (id == id_descriptor->id) {
- *pDescriptor = *id_descriptor->descriptor;
- result = SL_RESULT_SUCCESS;
- break;
- }
- }
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-SLresult IEngineCapabilities_QueryVibraCapabilities(SLEngineCapabilitiesItf self,
- SLuint32 *pIndex, SLuint32 *pVibraDeviceID, SLVibraDescriptor *pDescriptor)
-{
- SL_ENTER_INTERFACE
-
- IEngineCapabilities *thiz = (IEngineCapabilities *) self;
- const struct Vibra_id_descriptor *id_descriptor;
- SLuint32 index;
- if (NULL != pIndex) {
- result = SL_RESULT_SUCCESS;
- if (NULL != pVibraDeviceID || NULL != pDescriptor) {
- index = *pIndex;
- if (index >= thiz->mMaxIndexVibra) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- id_descriptor = &Vibra_id_descriptors[index];
- if (NULL != pVibraDeviceID)
- *pVibraDeviceID = id_descriptor->id;
- if (NULL != pDescriptor)
- *pDescriptor = *id_descriptor->descriptor;
- }
- }
- *pIndex = thiz->mMaxIndexVibra;
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- if (NULL != pVibraDeviceID && NULL != pDescriptor) {
- SLuint32 id = *pVibraDeviceID;
- for (index = 0; index < thiz->mMaxIndexVibra; ++index) {
- id_descriptor = &Vibra_id_descriptors[index];
- if (id == id_descriptor->id) {
- *pDescriptor = *id_descriptor->descriptor;
- result = SL_RESULT_SUCCESS;
- break;
- }
- }
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEngineCapabilities_IsThreadSafe(SLEngineCapabilitiesItf self,
- SLboolean *pIsThreadSafe)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pIsThreadSafe) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEngineCapabilities *thiz = (IEngineCapabilities *) self;
- *pIsThreadSafe = thiz->mThreadSafe;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLEngineCapabilitiesItf_ IEngineCapabilities_Itf = {
- IEngineCapabilities_QuerySupportedProfiles,
- IEngineCapabilities_QueryAvailableVoices,
- IEngineCapabilities_QueryNumberOfMIDISynthesizers,
- IEngineCapabilities_QueryAPIVersion,
- IEngineCapabilities_QueryLEDCapabilities,
- IEngineCapabilities_QueryVibraCapabilities,
- IEngineCapabilities_IsThreadSafe
-};
-
-void IEngineCapabilities_init(void *self)
-{
- IEngineCapabilities *thiz = (IEngineCapabilities *) self;
- thiz->mItf = &IEngineCapabilities_Itf;
- // mThreadSafe is initialized in slCreateEngine
- const struct LED_id_descriptor *id_descriptor_LED = LED_id_descriptors;
- while (NULL != id_descriptor_LED->descriptor)
- ++id_descriptor_LED;
- thiz->mMaxIndexLED = id_descriptor_LED - LED_id_descriptors;
- const struct Vibra_id_descriptor *id_descriptor_Vibra = Vibra_id_descriptors;
- while (NULL != id_descriptor_Vibra->descriptor)
- ++id_descriptor_Vibra;
- thiz->mMaxIndexVibra = id_descriptor_Vibra - Vibra_id_descriptors;
-}
diff --git a/wilhelm/src/itf/IEnvironmentalReverb.c b/wilhelm/src/itf/IEnvironmentalReverb.c
deleted file mode 100644
index adf1a8d..0000000
--- a/wilhelm/src/itf/IEnvironmentalReverb.c
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* EnvironmentalReverb implementation */
-
-#include "sles_allinclusive.h"
-#ifdef ANDROID
-#include <audio_effects/effect_environmentalreverb.h>
-#endif
-
-// Note: all Set operations use exclusive not poke,
-// because SetEnvironmentalReverbProperties is exclusive.
-// It is safe for the Get operations to use peek,
-// on the assumption that the block copy will atomically
-// replace each word of the block.
-
-
-#if defined(ANDROID)
-/**
- * returns true if this interface is not associated with an initialized EnvironmentalReverb effect
- */
-static inline bool NO_ENVREVERB(IEnvironmentalReverb* ier) {
- return (ier->mEnvironmentalReverbEffect == 0);
-}
-#endif
-
-
-static SLresult IEnvironmentalReverb_SetRoomLevel(SLEnvironmentalReverbItf self, SLmillibel room)
-{
- SL_ENTER_INTERFACE
-
- //if (!(SL_MILLIBEL_MIN <= room && room <= 0)) {
- // comparison (SL_MILLIBEL_MIN <= room) is always true due to range of SLmillibel
- if (!(room <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.roomLevel = room;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_ROOM_LEVEL, &room);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetRoomLevel(SLEnvironmentalReverbItf self, SLmillibel *pRoom)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pRoom) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_ROOM_LEVEL, &thiz->mProperties.roomLevel);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pRoom = thiz->mProperties.roomLevel;
-
- interface_unlock_shared(thiz);
-
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetRoomHFLevel(
- SLEnvironmentalReverbItf self, SLmillibel roomHF)
-{
- SL_ENTER_INTERFACE
-
- //if (!(SL_MILLIBEL_MIN <= roomHF && roomHF <= 0)) {
- // comparison (SL_MILLIBEL_MIN <= roomHF) is always true due to range of SLmillibel
- if (!(roomHF <= 0)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.roomHFLevel = roomHF;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_ROOM_HF_LEVEL, &roomHF);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetRoomHFLevel(
- SLEnvironmentalReverbItf self, SLmillibel *pRoomHF)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pRoomHF) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_ROOM_HF_LEVEL, &thiz->mProperties.roomHFLevel);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pRoomHF = thiz->mProperties.roomHFLevel;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetDecayTime(
- SLEnvironmentalReverbItf self, SLmillisecond decayTime)
-{
- SL_ENTER_INTERFACE
-
- if (!(100 <= decayTime && decayTime <= 20000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.decayTime = decayTime;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DECAY_TIME, &decayTime);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetDecayTime(
- SLEnvironmentalReverbItf self, SLmillisecond *pDecayTime)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDecayTime) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DECAY_TIME, &thiz->mProperties.decayTime);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pDecayTime = thiz->mProperties.decayTime;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetDecayHFRatio(
- SLEnvironmentalReverbItf self, SLpermille decayHFRatio)
-{
- SL_ENTER_INTERFACE
-
- if (!(100 <= decayHFRatio && decayHFRatio <= 2000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.decayHFRatio = decayHFRatio;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DECAY_HF_RATIO, &decayHFRatio);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetDecayHFRatio(
- SLEnvironmentalReverbItf self, SLpermille *pDecayHFRatio)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDecayHFRatio) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DECAY_HF_RATIO, &thiz->mProperties.decayHFRatio);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pDecayHFRatio = thiz->mProperties.decayHFRatio;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetReflectionsLevel(
- SLEnvironmentalReverbItf self, SLmillibel reflectionsLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!(SL_MILLIBEL_MIN <= reflectionsLevel && reflectionsLevel <= 1000)) {
- // comparison (SL_MILLIBEL_MIN <= reflectionsLevel) is always true due to range of SLmillibel
- if (!(reflectionsLevel <= 1000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.reflectionsLevel = reflectionsLevel;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REFLECTIONS_LEVEL, &reflectionsLevel);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetReflectionsLevel(
- SLEnvironmentalReverbItf self, SLmillibel *pReflectionsLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pReflectionsLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REFLECTIONS_LEVEL, &thiz->mProperties.reflectionsLevel);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pReflectionsLevel = thiz->mProperties.reflectionsLevel;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetReflectionsDelay(
- SLEnvironmentalReverbItf self, SLmillisecond reflectionsDelay)
-{
- SL_ENTER_INTERFACE
-
- if (!(/* 0 <= reflectionsDelay && */ reflectionsDelay <= 300)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.reflectionsDelay = reflectionsDelay;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REFLECTIONS_DELAY, &reflectionsDelay);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetReflectionsDelay(
- SLEnvironmentalReverbItf self, SLmillisecond *pReflectionsDelay)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pReflectionsDelay) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REFLECTIONS_DELAY, &thiz->mProperties.reflectionsDelay);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pReflectionsDelay = thiz->mProperties.reflectionsDelay;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetReverbLevel(
- SLEnvironmentalReverbItf self, SLmillibel reverbLevel)
-{
- SL_ENTER_INTERFACE
-
- //if (!(SL_MILLIBEL_MIN <= reverbLevel && reverbLevel <= 2000)) {
- // comparison (SL_MILLIBEL_MIN <= reverbLevel) is always true due to range of SLmillibel
- if (!(reverbLevel <= 2000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.reverbLevel = reverbLevel;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REVERB_LEVEL, &reverbLevel);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetReverbLevel(
- SLEnvironmentalReverbItf self, SLmillibel *pReverbLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pReverbLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REVERB_LEVEL, &thiz->mProperties.reverbLevel);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pReverbLevel = thiz->mProperties.reverbLevel;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetReverbDelay(
- SLEnvironmentalReverbItf self, SLmillisecond reverbDelay)
-{
- SL_ENTER_INTERFACE
-
- if (!(/* 0 <= reverbDelay && */ reverbDelay <= 100)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.reverbDelay = reverbDelay;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REVERB_DELAY, &reverbDelay);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetReverbDelay(
- SLEnvironmentalReverbItf self, SLmillisecond *pReverbDelay)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pReverbDelay) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_REVERB_DELAY, &thiz->mProperties.reverbDelay);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pReverbDelay = thiz->mProperties.reverbDelay;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetDiffusion(
- SLEnvironmentalReverbItf self, SLpermille diffusion)
-{
- SL_ENTER_INTERFACE
-
- if (!(0 <= diffusion && diffusion <= 1000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.diffusion = diffusion;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DIFFUSION, &diffusion);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetDiffusion(SLEnvironmentalReverbItf self,
- SLpermille *pDiffusion)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDiffusion) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DIFFUSION, &thiz->mProperties.diffusion);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pDiffusion = thiz->mProperties.diffusion;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetDensity(SLEnvironmentalReverbItf self,
- SLpermille density)
-{
- SL_ENTER_INTERFACE
-
- if (!(0 <= density && density <= 1000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties.density = density;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DENSITY, &density);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetDensity(SLEnvironmentalReverbItf self,
- SLpermille *pDensity)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDensity) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_DENSITY, &thiz->mProperties.density);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pDensity = thiz->mProperties.density;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_SetEnvironmentalReverbProperties(SLEnvironmentalReverbItf self,
- const SLEnvironmentalReverbSettings *pProperties)
-{
- SL_ENTER_INTERFACE
-
- // note that it's unnecessary to verify that any level stored inside the "properties" struct
- // is >= SL_MILLIBEL_MIN before using it, due to range of SLmillibel
-
- result = SL_RESULT_PARAMETER_INVALID;
- do {
- if (NULL == pProperties)
- break;
- SLEnvironmentalReverbSettings properties = *pProperties;
- if (!(properties.roomLevel <= 0))
- break;
- if (!(properties.roomHFLevel <= 0))
- break;
- if (!(100 <= properties.decayTime && properties.decayTime <= 20000))
- break;
- if (!(100 <= properties.decayHFRatio && properties.decayHFRatio <= 2000))
- break;
- if (!(properties.reflectionsLevel <= 1000))
- break;
- if (!(/* 0 <= properties.reflectionsDelay && */ properties.reflectionsDelay <= 300))
- break;
- if (!(properties.reverbLevel <= 2000))
- break;
- if (!(/* 0 <= properties.reverbDelay && */ properties.reverbDelay <= 100))
- break;
- if (!(0 <= properties.diffusion && properties.diffusion <= 1000))
- break;
- if (!(0 <= properties.density && properties.density <= 1000))
- break;
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_exclusive(thiz);
- thiz->mProperties = properties;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_setParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_PROPERTIES, &properties);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- } while (0);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEnvironmentalReverb_GetEnvironmentalReverbProperties(
- SLEnvironmentalReverbItf self, SLEnvironmentalReverbSettings *pProperties)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pProperties) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_ENVREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_erev_getParam(thiz->mEnvironmentalReverbEffect,
- REVERB_PARAM_PROPERTIES, &thiz->mProperties);
- result = android_fx_statusToResult(status);
- }
-#endif
- *pProperties = thiz->mProperties;
-
- interface_unlock_shared(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLEnvironmentalReverbItf_ IEnvironmentalReverb_Itf = {
- IEnvironmentalReverb_SetRoomLevel,
- IEnvironmentalReverb_GetRoomLevel,
- IEnvironmentalReverb_SetRoomHFLevel,
- IEnvironmentalReverb_GetRoomHFLevel,
- IEnvironmentalReverb_SetDecayTime,
- IEnvironmentalReverb_GetDecayTime,
- IEnvironmentalReverb_SetDecayHFRatio,
- IEnvironmentalReverb_GetDecayHFRatio,
- IEnvironmentalReverb_SetReflectionsLevel,
- IEnvironmentalReverb_GetReflectionsLevel,
- IEnvironmentalReverb_SetReflectionsDelay,
- IEnvironmentalReverb_GetReflectionsDelay,
- IEnvironmentalReverb_SetReverbLevel,
- IEnvironmentalReverb_GetReverbLevel,
- IEnvironmentalReverb_SetReverbDelay,
- IEnvironmentalReverb_GetReverbDelay,
- IEnvironmentalReverb_SetDiffusion,
- IEnvironmentalReverb_GetDiffusion,
- IEnvironmentalReverb_SetDensity,
- IEnvironmentalReverb_GetDensity,
- IEnvironmentalReverb_SetEnvironmentalReverbProperties,
- IEnvironmentalReverb_GetEnvironmentalReverbProperties
-};
-
-static const SLEnvironmentalReverbSettings IEnvironmentalReverb_default = {
- SL_MILLIBEL_MIN, // roomLevel
- 0, // roomHFLevel
- 1000, // decayTime
- 500, // decayHFRatio
- SL_MILLIBEL_MIN, // reflectionsLevel
- 20, // reflectionsDelay
- SL_MILLIBEL_MIN, // reverbLevel
- 40, // reverbDelay
- 1000, // diffusion
- 1000 // density
-};
-
-void IEnvironmentalReverb_init(void *self)
-{
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- thiz->mItf = &IEnvironmentalReverb_Itf;
- thiz->mProperties = IEnvironmentalReverb_default;
-#if defined(ANDROID)
- memset(&thiz->mEnvironmentalReverbDescriptor, 0, sizeof(effect_descriptor_t));
- // placement new (explicit constructor)
- (void) new (&thiz->mEnvironmentalReverbEffect) android::sp<android::AudioEffect>();
-#endif
-}
-
-void IEnvironmentalReverb_deinit(void *self)
-{
-#if defined(ANDROID)
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- // explicit destructor
- thiz->mEnvironmentalReverbEffect.~sp();
-#endif
-}
-
-bool IEnvironmentalReverb_Expose(void *self)
-{
-#if defined(ANDROID)
- IEnvironmentalReverb *thiz = (IEnvironmentalReverb *) self;
- if (!android_fx_initEffectDescriptor(SL_IID_ENVIRONMENTALREVERB,
- &thiz->mEnvironmentalReverbDescriptor)) {
- SL_LOGE("EnvironmentalReverb initialization failed.");
- return false;
- }
-#endif
- return true;
-}
diff --git a/wilhelm/src/itf/IEqualizer.c b/wilhelm/src/itf/IEqualizer.c
deleted file mode 100644
index e50bdb7..0000000
--- a/wilhelm/src/itf/IEqualizer.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Equalizer implementation */
-
-#include "sles_allinclusive.h"
-#ifdef ANDROID
-#include <audio_effects/effect_equalizer.h>
-#endif
-
-#define MAX_EQ_PRESETS 3
-
-#if !defined(ANDROID)
-static const struct EqualizerBand EqualizerBands[MAX_EQ_BANDS] = {
- {1000, 1500, 2000},
- {2000, 3000, 4000},
- {4000, 5500, 7000},
- {7000, 8000, 9000}
-};
-
-static const struct EqualizerPreset {
- const char *mName;
- SLmillibel mLevels[MAX_EQ_BANDS];
-} EqualizerPresets[MAX_EQ_PRESETS] = {
- {"Default", {0, 0, 0, 0}},
- {"Bass", {500, 200, 100, 0}},
- {"Treble", {0, 100, 200, 500}}
-};
-#endif
-
-
-#if defined(ANDROID)
-/**
- * returns true if this interface is not associated with an initialized Equalizer effect
- */
-static inline bool NO_EQ(IEqualizer* v) {
- return (v->mEqEffect == 0);
-}
-#endif
-
-
-static SLresult IEqualizer_SetEnabled(SLEqualizerItf self, SLboolean enabled)
-{
- SL_ENTER_INTERFACE
-
- IEqualizer *thiz = (IEqualizer *) self;
- interface_lock_exclusive(thiz);
- thiz->mEnabled = (SLboolean) enabled;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- thiz->mEqEffect->setEnabled((bool) thiz->mEnabled);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_IsEnabled(SLEqualizerItf self, SLboolean *pEnabled)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEnabled) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- interface_lock_exclusive(thiz);
- SLboolean enabled = thiz->mEnabled;
- #if !defined(ANDROID)
- *pEnabled = enabled;
- result = SL_RESULT_SUCCESS;
- #else
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- *pEnabled = (SLboolean) thiz->mEqEffect->getEnabled();
- result = SL_RESULT_SUCCESS;
- }
- #endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetNumberOfBands(SLEqualizerItf self, SLuint16 *pNumBands)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumBands) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- // Note: no lock, but OK because it is const
- *pNumBands = thiz->mNumBands;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetBandLevelRange(SLEqualizerItf self, SLmillibel *pMin,
- SLmillibel *pMax)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMin && NULL == pMax) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- // Note: no lock, but OK because it is const
- if (NULL != pMin)
- *pMin = thiz->mBandLevelRangeMin;
- if (NULL != pMax)
- *pMax = thiz->mBandLevelRangeMax;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_SetBandLevel(SLEqualizerItf self, SLuint16 band, SLmillibel level)
-{
- SL_ENTER_INTERFACE
-
- IEqualizer *thiz = (IEqualizer *) self;
- if (!(thiz->mBandLevelRangeMin <= level && level <= thiz->mBandLevelRangeMax) ||
- (band >= thiz->mNumBands)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_exclusive(thiz);
-#if !defined(ANDROID)
- thiz->mLevels[band] = level;
- thiz->mPreset = SL_EQUALIZER_UNDEFINED;
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_eq_setParam(thiz->mEqEffect, EQ_PARAM_BAND_LEVEL, band, &level);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetBandLevel(SLEqualizerItf self, SLuint16 band, SLmillibel *pLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- // const, no lock needed
- if (band >= thiz->mNumBands) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLmillibel level = 0;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- level = thiz->mLevels[band];
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_eq_getParam(thiz->mEqEffect, EQ_PARAM_BAND_LEVEL, band, &level);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_shared(thiz);
- *pLevel = level;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetCenterFreq(SLEqualizerItf self, SLuint16 band, SLmilliHertz *pCenter)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pCenter) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- if (band >= thiz->mNumBands) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
-#if !defined(ANDROID)
- // Note: no lock, but OK because it is const
- *pCenter = thiz->mBands[band].mCenter;
- result = SL_RESULT_SUCCESS;
-#else
- SLmilliHertz center = 0;
- interface_lock_shared(thiz);
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_eq_getParam(thiz->mEqEffect, EQ_PARAM_CENTER_FREQ, band, ¢er);
- result = android_fx_statusToResult(status);
- }
- interface_unlock_shared(thiz);
- *pCenter = center;
-#endif
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetBandFreqRange(SLEqualizerItf self, SLuint16 band,
- SLmilliHertz *pMin, SLmilliHertz *pMax)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMin && NULL == pMax) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- if (band >= thiz->mNumBands) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
-#if !defined(ANDROID)
- // Note: no lock, but OK because it is const
- if (NULL != pMin)
- *pMin = thiz->mBands[band].mMin;
- if (NULL != pMax)
- *pMax = thiz->mBands[band].mMax;
- result = SL_RESULT_SUCCESS;
-#else
- SLmilliHertz range[2] = {0, 0}; // SLmilliHertz is SLuint32
- interface_lock_shared(thiz);
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_eq_getParam(thiz->mEqEffect, EQ_PARAM_BAND_FREQ_RANGE, band, range);
- result = android_fx_statusToResult(status);
- }
- interface_unlock_shared(thiz);
- if (NULL != pMin) {
- *pMin = range[0];
- }
- if (NULL != pMax) {
- *pMax = range[1];
- }
-#endif
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetBand(SLEqualizerItf self, SLmilliHertz frequency, SLuint16 *pBand)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pBand) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
-#if !defined(ANDROID)
- // search for band whose center frequency has the closest ratio to 1.0
- // assumes bands are unsorted (a pessimistic assumption)
- // assumes bands can overlap (a pessimistic assumption)
- // assumes a small number of bands, so no need for a fancier algorithm
- const struct EqualizerBand *band;
- float floatFreq = (float) frequency;
- float bestRatio = 0.0;
- SLuint16 bestBand = SL_EQUALIZER_UNDEFINED;
- for (band = thiz->mBands; band < &thiz->mBands[thiz->mNumBands]; ++band) {
- if (!(band->mMin <= frequency && frequency <= band->mMax))
- continue;
- assert(band->mMin <= band->mCenter && band->mCenter <= band->mMax);
- assert(band->mCenter != 0);
- float ratio = frequency <= band->mCenter ?
- floatFreq / band->mCenter : band->mCenter / floatFreq;
- if (ratio > bestRatio) {
- bestRatio = ratio;
- bestBand = band - thiz->mBands;
- }
- }
- *pBand = bestBand;
- result = SL_RESULT_SUCCESS;
-#else
- uint16_t band = 0;
- interface_lock_shared(thiz);
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_eq_getParam(thiz->mEqEffect, EQ_PARAM_GET_BAND, frequency, &band);
- result = android_fx_statusToResult(status);
- }
- interface_unlock_shared(thiz);
- *pBand = (SLuint16)band;
-#endif
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetCurrentPreset(SLEqualizerItf self, SLuint16 *pPreset)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pPreset) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- interface_lock_shared(thiz);
-#if !defined(ANDROID)
- SLuint16 preset = thiz->mPreset;
- interface_unlock_shared(thiz);
- *pPreset = preset;
- result = SL_RESULT_SUCCESS;
-#else
- uint16_t preset = 0;
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_eq_getParam(thiz->mEqEffect, EQ_PARAM_CUR_PRESET, 0, &preset);
- result = android_fx_statusToResult(status);
- }
- interface_unlock_shared(thiz);
-
- if (preset < 0) {
- *pPreset = SL_EQUALIZER_UNDEFINED;
- } else {
- *pPreset = (SLuint16) preset;
- }
-#endif
-
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_UsePreset(SLEqualizerItf self, SLuint16 index)
-{
- SL_ENTER_INTERFACE
- SL_LOGV("Equalizer::UsePreset index=%u", index);
-
- IEqualizer *thiz = (IEqualizer *) self;
- if (index >= thiz->mNumPresets) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_exclusive(thiz);
-#if !defined(ANDROID)
- SLuint16 band;
- for (band = 0; band < thiz->mNumBands; ++band)
- thiz->mLevels[band] = EqualizerPresets[index].mLevels[band];
- thiz->mPreset = index;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_EQ(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_eq_setParam(thiz->mEqEffect, EQ_PARAM_CUR_PRESET, 0, &index);
- result = android_fx_statusToResult(status);
- }
- interface_unlock_shared(thiz);
-#endif
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetNumberOfPresets(SLEqualizerItf self, SLuint16 *pNumPresets)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumPresets) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
- // Note: no lock, but OK because it is const
- *pNumPresets = thiz->mNumPresets;
-
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IEqualizer_GetPresetName(SLEqualizerItf self, SLuint16 index, const SLchar **ppName)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == ppName) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IEqualizer *thiz = (IEqualizer *) self;
-#if !defined(ANDROID)
- if (index >= thiz->mNumPresets) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *ppName = (SLchar *) thiz->mPresets[index].mName;
- result = SL_RESULT_SUCCESS;
- }
-#else
- if (index >= thiz->mNumPresets) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- // FIXME query preset name rather than retrieve it from the engine.
- // In SL ES 1.0.1, the strings must exist for the lifetime of the engine.
- // Starting in 1.1, this will change and we don't need to hold onto the strings
- // for so long as they will copied into application space.
- *ppName = (SLchar *) thiz->mThis->mEngine->mEqPresetNames[index];
- result = SL_RESULT_SUCCESS;
- }
-#endif
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLEqualizerItf_ IEqualizer_Itf = {
- IEqualizer_SetEnabled,
- IEqualizer_IsEnabled,
- IEqualizer_GetNumberOfBands,
- IEqualizer_GetBandLevelRange,
- IEqualizer_SetBandLevel,
- IEqualizer_GetBandLevel,
- IEqualizer_GetCenterFreq,
- IEqualizer_GetBandFreqRange,
- IEqualizer_GetBand,
- IEqualizer_GetCurrentPreset,
- IEqualizer_UsePreset,
- IEqualizer_GetNumberOfPresets,
- IEqualizer_GetPresetName
-};
-
-void IEqualizer_init(void *self)
-{
- IEqualizer *thiz = (IEqualizer *) self;
- thiz->mItf = &IEqualizer_Itf;
- thiz->mEnabled = SL_BOOLEAN_FALSE;
- thiz->mPreset = SL_EQUALIZER_UNDEFINED;
-#if 0 < MAX_EQ_BANDS
- unsigned band;
- for (band = 0; band < MAX_EQ_BANDS; ++band)
- thiz->mLevels[band] = 0;
-#endif
- // const fields
- thiz->mNumPresets = 0;
- thiz->mNumBands = 0;
-#if !defined(ANDROID)
- thiz->mBands = EqualizerBands;
- thiz->mPresets = EqualizerPresets;
-#endif
- thiz->mBandLevelRangeMin = 0;
- thiz->mBandLevelRangeMax = 0;
-#if defined(ANDROID)
- memset(&thiz->mEqDescriptor, 0, sizeof(effect_descriptor_t));
- // placement new (explicit constructor)
- (void) new (&thiz->mEqEffect) android::sp<android::AudioEffect>();
-#endif
-}
-
-void IEqualizer_deinit(void *self)
-{
-#if defined(ANDROID)
- IEqualizer *thiz = (IEqualizer *) self;
- // explicit destructor
- thiz->mEqEffect.~sp();
-#endif
-}
-
-bool IEqualizer_Expose(void *self)
-{
-#if defined(ANDROID)
- IEqualizer *thiz = (IEqualizer *) self;
- if (!android_fx_initEffectDescriptor(SL_IID_EQUALIZER, &thiz->mEqDescriptor)) {
- SL_LOGE("Equalizer initialization failed");
- thiz->mNumPresets = 0;
- thiz->mNumBands = 0;
- thiz->mBandLevelRangeMin = 0;
- thiz->mBandLevelRangeMax = 0;
- return false;
- }
-#endif
- return true;
-}
diff --git a/wilhelm/src/itf/ILEDArray.c b/wilhelm/src/itf/ILEDArray.c
deleted file mode 100644
index 57938cc..0000000
--- a/wilhelm/src/itf/ILEDArray.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* LEDArray implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult ILEDArray_ActivateLEDArray(SLLEDArrayItf self, SLuint32 lightMask)
-{
- SL_ENTER_INTERFACE
-
- ILEDArray *thiz = (ILEDArray *) self;
- interface_lock_poke(thiz);
- thiz->mLightMask = lightMask;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult ILEDArray_IsLEDArrayActivated(SLLEDArrayItf self, SLuint32 *pLightMask)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pLightMask) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- ILEDArray *thiz = (ILEDArray *) self;
- interface_lock_peek(thiz);
- SLuint32 lightMask = thiz->mLightMask;
- interface_unlock_peek(thiz);
- *pLightMask = lightMask;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult ILEDArray_SetColor(SLLEDArrayItf self, SLuint8 index, const SLHSL *pColor)
-{
- SL_ENTER_INTERFACE
-
- result = SL_RESULT_PARAMETER_INVALID;
- do {
- if (!(index < MAX_LED_COUNT) || NULL == pColor)
- break;
- SLHSL color = *pColor;
- if (!(0 <= color.hue && color.hue <= 360000))
- break;
- if (!(0 <= color.saturation && color.saturation <= 1000))
- break;
- if (!(0 <= color.lightness && color.lightness <= 1000))
- break;
- ILEDArray *thiz = (ILEDArray *) self;
- // can't use poke because struct copy might not be atomic
- interface_lock_exclusive(thiz);
- thiz->mColors[index] = color;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- } while (0);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult ILEDArray_GetColor(SLLEDArrayItf self, SLuint8 index, SLHSL *pColor)
-{
- SL_ENTER_INTERFACE
-
- if (!(index < MAX_LED_COUNT) || NULL == pColor) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- ILEDArray *thiz = (ILEDArray *) self;
- // can't use peek because struct copy might not be atomic
- interface_lock_shared(thiz);
- SLHSL color = thiz->mColors[index];
- interface_unlock_shared(thiz);
- *pColor = color;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLLEDArrayItf_ ILEDArray_Itf = {
- ILEDArray_ActivateLEDArray,
- ILEDArray_IsLEDArrayActivated,
- ILEDArray_SetColor,
- ILEDArray_GetColor
-};
-
-void ILEDArray_init(void *self)
-{
- ILEDArray *thiz = (ILEDArray *) self;
- thiz->mItf = &ILEDArray_Itf;
- thiz->mLightMask = 0;
- SLHSL *color = thiz->mColors;
- SLuint8 index;
- for (index = 0; index < MAX_LED_COUNT; ++index, ++color) {
- color->hue = 0; // red, but per specification 1.0.1 pg. 259: "Default color is undefined."
- color->saturation = 1000;
- color->lightness = 1000;
- }
- // const
- thiz->mCount = MAX_LED_COUNT;
-}
diff --git a/wilhelm/src/itf/IMIDIMessage.c b/wilhelm/src/itf/IMIDIMessage.c
deleted file mode 100644
index 1657bc3..0000000
--- a/wilhelm/src/itf/IMIDIMessage.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* MIDIMessage implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IMIDIMessage_SendMessage(SLMIDIMessageItf self, const SLuint8 *data,
- SLuint32 length)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == data) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- //IMIDIMessage *thiz = (IMIDIMessage *) self;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMessage_RegisterMetaEventCallback(SLMIDIMessageItf self,
- slMetaEventCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IMIDIMessage *thiz = (IMIDIMessage *) self;
- interface_lock_exclusive(thiz);
- thiz->mMetaEventCallback = callback;
- thiz->mMetaEventContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMessage_RegisterMIDIMessageCallback(SLMIDIMessageItf self,
- slMIDIMessageCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IMIDIMessage *thiz = (IMIDIMessage *) self;
- interface_lock_exclusive(thiz);
- thiz->mMessageCallback = callback;
- thiz->mMessageContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMessage_AddMIDIMessageCallbackFilter(SLMIDIMessageItf self,
- SLuint32 messageType)
-{
- SL_ENTER_INTERFACE
-
- switch (messageType) {
- case SL_MIDIMESSAGETYPE_NOTE_ON_OFF:
- case SL_MIDIMESSAGETYPE_POLY_PRESSURE:
- case SL_MIDIMESSAGETYPE_CONTROL_CHANGE:
- case SL_MIDIMESSAGETYPE_PROGRAM_CHANGE:
- case SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE:
- case SL_MIDIMESSAGETYPE_PITCH_BEND:
- case SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE:
- {
- SLuint8 messageTypeMask = 1 << messageType;
- IMIDIMessage *thiz = (IMIDIMessage *) self;
- interface_lock_exclusive(thiz);
- thiz->mMessageTypes |= messageTypeMask;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMessage_ClearMIDIMessageCallbackFilter(SLMIDIMessageItf self)
-{
- SL_ENTER_INTERFACE
-
- IMIDIMessage *thiz = (IMIDIMessage *) self;
- interface_lock_exclusive(thiz);
- thiz->mMessageTypes = 0;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLMIDIMessageItf_ IMIDIMessage_Itf = {
- IMIDIMessage_SendMessage,
- IMIDIMessage_RegisterMetaEventCallback,
- IMIDIMessage_RegisterMIDIMessageCallback,
- IMIDIMessage_AddMIDIMessageCallbackFilter,
- IMIDIMessage_ClearMIDIMessageCallbackFilter
-};
-
-void IMIDIMessage_init(void *self)
-{
- IMIDIMessage *thiz = (IMIDIMessage *) self;
- thiz->mItf = &IMIDIMessage_Itf;
- thiz->mMetaEventCallback = NULL;
- thiz->mMetaEventContext = NULL;
- thiz->mMessageCallback = NULL;
- thiz->mMessageContext = NULL;
- thiz->mMessageTypes = 0;
-}
diff --git a/wilhelm/src/itf/IMIDIMuteSolo.c b/wilhelm/src/itf/IMIDIMuteSolo.c
deleted file mode 100644
index ceb7d76..0000000
--- a/wilhelm/src/itf/IMIDIMuteSolo.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* MIDIMuteSolo implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IMIDIMuteSolo_SetChannelMute(SLMIDIMuteSoloItf self, SLuint8 channel,
- SLboolean mute)
-{
- SL_ENTER_INTERFACE
-
- if (channel > 15) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- SLuint16 mask = 1 << channel;
- interface_lock_exclusive(thiz);
- if (mute)
- thiz->mChannelMuteMask |= mask;
- else
- thiz->mChannelMuteMask &= ~mask;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_GetChannelMute(SLMIDIMuteSoloItf self, SLuint8 channel,
- SLboolean *pMute)
-{
- SL_ENTER_INTERFACE
-
- if (channel > 15 || (NULL == pMute)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- interface_lock_peek(thiz);
- SLuint16 mask = thiz->mChannelMuteMask;
- interface_unlock_peek(thiz);
- *pMute = (mask >> channel) & 1;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_SetChannelSolo(SLMIDIMuteSoloItf self, SLuint8 channel,
- SLboolean solo)
-{
- SL_ENTER_INTERFACE
-
- if (channel > 15) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- SLuint16 mask = 1 << channel;
- interface_lock_exclusive(thiz);
- if (solo)
- thiz->mChannelSoloMask |= mask;
- else
- thiz->mChannelSoloMask &= ~mask;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_GetChannelSolo(SLMIDIMuteSoloItf self, SLuint8 channel,
- SLboolean *pSolo)
-{
- SL_ENTER_INTERFACE
-
- if (channel > 15 || (NULL == pSolo)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- interface_lock_peek(thiz);
- SLuint16 mask = thiz->mChannelSoloMask;
- interface_unlock_peek(thiz);
- *pSolo = (mask >> channel) & 1;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_GetTrackCount(SLMIDIMuteSoloItf self, SLuint16 *pCount)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pCount) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- // const, so no lock needed
- SLuint16 trackCount = thiz->mTrackCount;
- *pCount = trackCount;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_SetTrackMute(SLMIDIMuteSoloItf self, SLuint16 track, SLboolean mute)
-{
- SL_ENTER_INTERFACE
-
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- // const
- if (!(track < thiz->mTrackCount)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLuint32 mask = 1 << track;
- interface_lock_exclusive(thiz);
- if (mute)
- thiz->mTrackMuteMask |= mask;
- else
- thiz->mTrackMuteMask &= ~mask;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_GetTrackMute(SLMIDIMuteSoloItf self, SLuint16 track, SLboolean *pMute)
-{
- SL_ENTER_INTERFACE
-
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- // const, no lock needed
- if (!(track < thiz->mTrackCount) || NULL == pMute) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_peek(thiz);
- SLuint32 mask = thiz->mTrackMuteMask;
- interface_unlock_peek(thiz);
- *pMute = (mask >> track) & 1;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_SetTrackSolo(SLMIDIMuteSoloItf self, SLuint16 track, SLboolean solo)
-{
- SL_ENTER_INTERFACE
-
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- // const
- if (!(track < thiz->mTrackCount)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLuint32 mask = 1 << track; interface_lock_exclusive(thiz);
- if (solo)
- thiz->mTrackSoloMask |= mask;
- else
- thiz->mTrackSoloMask &= ~mask;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDIMuteSolo_GetTrackSolo(SLMIDIMuteSoloItf self, SLuint16 track, SLboolean *pSolo)
-{
- SL_ENTER_INTERFACE
-
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- // const, no lock needed
- if (!(track < thiz->mTrackCount) || NULL == pSolo) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_peek(thiz);
- SLuint32 mask = thiz->mTrackSoloMask;
- interface_unlock_peek(thiz);
- *pSolo = (mask >> track) & 1;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLMIDIMuteSoloItf_ IMIDIMuteSolo_Itf = {
- IMIDIMuteSolo_SetChannelMute,
- IMIDIMuteSolo_GetChannelMute,
- IMIDIMuteSolo_SetChannelSolo,
- IMIDIMuteSolo_GetChannelSolo,
- IMIDIMuteSolo_GetTrackCount,
- IMIDIMuteSolo_SetTrackMute,
- IMIDIMuteSolo_GetTrackMute,
- IMIDIMuteSolo_SetTrackSolo,
- IMIDIMuteSolo_GetTrackSolo
-};
-
-void IMIDIMuteSolo_init(void *self)
-{
- IMIDIMuteSolo *thiz = (IMIDIMuteSolo *) self;
- thiz->mItf = &IMIDIMuteSolo_Itf;
- thiz->mChannelMuteMask = 0;
- thiz->mChannelSoloMask = 0;
- thiz->mTrackMuteMask = 0;
- thiz->mTrackSoloMask = 0;
- // const
- thiz->mTrackCount = 32; // wrong
-}
diff --git a/wilhelm/src/itf/IMIDITempo.c b/wilhelm/src/itf/IMIDITempo.c
deleted file mode 100644
index 831fda9..0000000
--- a/wilhelm/src/itf/IMIDITempo.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* MIDITempo implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IMIDITempo_SetTicksPerQuarterNote(SLMIDITempoItf self, SLuint32 tpqn)
-{
- SL_ENTER_INTERFACE
-
- if (!(1 <= tpqn && tpqn <= 32767)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDITempo *thiz = (IMIDITempo *) self;
- interface_lock_poke(thiz);
- thiz->mTicksPerQuarterNote = tpqn;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDITempo_GetTicksPerQuarterNote(SLMIDITempoItf self, SLuint32 *pTpqn)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pTpqn) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDITempo *thiz = (IMIDITempo *) self;
- interface_lock_peek(thiz);
- SLuint32 ticksPerQuarterNote = thiz->mTicksPerQuarterNote;
- interface_unlock_peek(thiz);
- *pTpqn = ticksPerQuarterNote;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDITempo_SetMicrosecondsPerQuarterNote(SLMIDITempoItf self, SLmicrosecond uspqn)
-{
- SL_ENTER_INTERFACE
-
- // spec says zero, is that correct?
- if (!(1 <= uspqn && uspqn <= 16777215)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDITempo *thiz = (IMIDITempo *) self;
- interface_lock_poke(thiz);
- thiz->mMicrosecondsPerQuarterNote = uspqn;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDITempo_GetMicrosecondsPerQuarterNote(SLMIDITempoItf self, SLmicrosecond *uspqn)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == uspqn) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDITempo *thiz = (IMIDITempo *) self;
- interface_lock_peek(thiz);
- SLuint32 microsecondsPerQuarterNote = thiz->mMicrosecondsPerQuarterNote;
- interface_unlock_peek(thiz);
- *uspqn = microsecondsPerQuarterNote;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLMIDITempoItf_ IMIDITempo_Itf = {
- IMIDITempo_SetTicksPerQuarterNote,
- IMIDITempo_GetTicksPerQuarterNote,
- IMIDITempo_SetMicrosecondsPerQuarterNote,
- IMIDITempo_GetMicrosecondsPerQuarterNote
-};
-
-void IMIDITempo_init(void *self)
-{
- IMIDITempo *thiz = (IMIDITempo *) self;
- thiz->mItf = &IMIDITempo_Itf;
- thiz->mTicksPerQuarterNote = 32; // wrong
- thiz->mMicrosecondsPerQuarterNote = 100; // wrong
-}
diff --git a/wilhelm/src/itf/IMIDITime.c b/wilhelm/src/itf/IMIDITime.c
deleted file mode 100644
index 312e4bc..0000000
--- a/wilhelm/src/itf/IMIDITime.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* MIDITime implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IMIDITime_GetDuration(SLMIDITimeItf self, SLuint32 *pDuration)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pDuration) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDITime *thiz = (IMIDITime *) self;
- SLuint32 duration = thiz->mDuration;
- *pDuration = duration;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDITime_SetPosition(SLMIDITimeItf self, SLuint32 position)
-{
- SL_ENTER_INTERFACE
-
- IMIDITime *thiz = (IMIDITime *) self;
- // const, no lock needed
- if (!(position < thiz->mDuration)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_poke(thiz);
- thiz->mPosition = position;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDITime_GetPosition(SLMIDITimeItf self, SLuint32 *pPosition)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pPosition) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDITime *thiz = (IMIDITime *) self;
- interface_lock_peek(thiz);
- SLuint32 position = thiz->mPosition;
- interface_unlock_peek(thiz);
- *pPosition = position;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDITime_SetLoopPoints(SLMIDITimeItf self, SLuint32 startTick, SLuint32 numTicks)
-{
- SL_ENTER_INTERFACE
-
- IMIDITime *thiz = (IMIDITime *) self;
- // const, no lock needed
- SLuint32 duration = thiz->mDuration;
- if (!((startTick < duration) && (numTicks <= duration - startTick))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_exclusive(thiz);
- thiz->mStartTick = startTick;
- thiz->mNumTicks = numTicks;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMIDITime_GetLoopPoints(SLMIDITimeItf self, SLuint32 *pStartTick,
- SLuint32 *pNumTicks)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pStartTick || NULL == pNumTicks) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMIDITime *thiz = (IMIDITime *) self;
- interface_lock_shared(thiz);
- SLuint32 startTick = thiz->mStartTick;
- SLuint32 numTicks = thiz->mNumTicks;
- interface_unlock_shared(thiz);
- *pStartTick = startTick;
- *pNumTicks = numTicks;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLMIDITimeItf_ IMIDITime_Itf = {
- IMIDITime_GetDuration,
- IMIDITime_SetPosition,
- IMIDITime_GetPosition,
- IMIDITime_SetLoopPoints,
- IMIDITime_GetLoopPoints
-};
-
-void IMIDITime_init(void *self)
-{
- IMIDITime *thiz = (IMIDITime *) self;
- thiz->mItf = &IMIDITime_Itf;
- thiz->mDuration = 0;
- thiz->mPosition = 0;
- thiz->mStartTick = 0;
- thiz->mNumTicks = 0;
-}
diff --git a/wilhelm/src/itf/IMetadataExtraction.c b/wilhelm/src/itf/IMetadataExtraction.c
deleted file mode 100644
index 6692c20..0000000
--- a/wilhelm/src/itf/IMetadataExtraction.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* MetadataExtraction implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IMetadataExtraction_GetItemCount(SLMetadataExtractionItf self, SLuint32 *pItemCount)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pItemCount) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- result = android_audioPlayer_metadata_getItemCount((CAudioPlayer *)thiz->mThis,
- pItemCount);
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataExtraction_GetKeySize(SLMetadataExtractionItf self,
- SLuint32 index, SLuint32 *pKeySize)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pKeySize) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- result = android_audioPlayer_metadata_getKeySize((CAudioPlayer *)thiz->mThis,
- index, pKeySize);
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataExtraction_GetKey(SLMetadataExtractionItf self,
- SLuint32 index, SLuint32 keySize, SLMetadataInfo *pKey)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pKey) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- result = android_audioPlayer_metadata_getKey((CAudioPlayer *)thiz->mThis,
- index, keySize, pKey);
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataExtraction_GetValueSize(SLMetadataExtractionItf self,
- SLuint32 index, SLuint32 *pValueSize)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pValueSize) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- result = android_audioPlayer_metadata_getValueSize((CAudioPlayer *)thiz->mThis,
- index, pValueSize);
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataExtraction_GetValue(SLMetadataExtractionItf self,
- SLuint32 index, SLuint32 valueSize, SLMetadataInfo *pValue)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pValue) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- result = android_audioPlayer_metadata_getValue((CAudioPlayer *)thiz->mThis,
- index, valueSize, pValue);
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataExtraction_AddKeyFilter(SLMetadataExtractionItf self,
- SLuint32 keySize, const void *pKey, SLuint32 keyEncoding,
- const SLchar *pValueLangCountry, SLuint32 valueEncoding, SLuint8 filterMask)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pKey || NULL == pValueLangCountry || (filterMask & ~(SL_METADATA_FILTER_KEY |
- SL_METADATA_FILTER_KEY | SL_METADATA_FILTER_KEY))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- interface_lock_exclusive(thiz);
- thiz->mKeySize = keySize;
- thiz->mKey = pKey;
- thiz->mKeyEncoding = keyEncoding;
- thiz->mValueLangCountry = pValueLangCountry; // should make a local copy
- thiz->mValueEncoding = valueEncoding;
- thiz->mFilterMask = filterMask;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataExtraction_ClearKeyFilter(SLMetadataExtractionItf self)
-{
- SL_ENTER_INTERFACE
-
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- thiz->mKeyFilter = 0;
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLMetadataExtractionItf_ IMetadataExtraction_Itf = {
- IMetadataExtraction_GetItemCount,
- IMetadataExtraction_GetKeySize,
- IMetadataExtraction_GetKey,
- IMetadataExtraction_GetValueSize,
- IMetadataExtraction_GetValue,
- IMetadataExtraction_AddKeyFilter,
- IMetadataExtraction_ClearKeyFilter
-};
-
-void IMetadataExtraction_init(void *self)
-{
- IMetadataExtraction *thiz = (IMetadataExtraction *) self;
- thiz->mItf = &IMetadataExtraction_Itf;
- thiz->mKeySize = 0;
- thiz->mKey = NULL;
- thiz->mKeyEncoding = 0 /*TBD*/;
- thiz->mValueLangCountry = 0 /*TBD*/;
- thiz->mValueEncoding = 0 /*TBD*/;
- thiz->mFilterMask = 0 /*TBD*/;
- thiz->mKeyFilter = 0;
-}
diff --git a/wilhelm/src/itf/IMetadataTraversal.c b/wilhelm/src/itf/IMetadataTraversal.c
deleted file mode 100644
index 2432b9a..0000000
--- a/wilhelm/src/itf/IMetadataTraversal.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* MetadataTraversal implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IMetadataTraversal_SetMode(SLMetadataTraversalItf self, SLuint32 mode)
-{
- SL_ENTER_INTERFACE
-
- switch (mode) {
- case SL_METADATATRAVERSALMODE_ALL:
- case SL_METADATATRAVERSALMODE_NODE:
- {
- IMetadataTraversal *thiz = (IMetadataTraversal *) self;
- interface_lock_poke(thiz);
- thiz->mMode = mode;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataTraversal_GetChildCount(SLMetadataTraversalItf self, SLuint32 *pCount)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pCount) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataTraversal *thiz = (IMetadataTraversal *) self;
- interface_lock_peek(thiz);
- SLuint32 count = thiz->mCount;
- interface_unlock_peek(thiz);
- *pCount = count;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataTraversal_GetChildMIMETypeSize(
- SLMetadataTraversalItf self, SLuint32 index, SLuint32 *pSize)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSize) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMetadataTraversal *thiz = (IMetadataTraversal *) self;
- interface_lock_peek(thiz);
- SLuint32 size = thiz->mSize;
- interface_unlock_peek(thiz);
- *pSize = size;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataTraversal_GetChildInfo(SLMetadataTraversalItf self, SLuint32 index,
- SLint32 *pNodeID, SLuint32 *pType, SLuint32 size, SLchar *pMimeType)
-{
- SL_ENTER_INTERFACE
-
- //IMetadataTraversal *thiz = (IMetadataTraversal *) self;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMetadataTraversal_SetActiveNode(SLMetadataTraversalItf self, SLuint32 index)
-{
- SL_ENTER_INTERFACE
-
- if (SL_NODE_PARENT == index) {
- ;
- }
- IMetadataTraversal *thiz = (IMetadataTraversal *) self;
- thiz->mIndex = index;
- result = SL_RESULT_PARAMETER_INVALID;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLMetadataTraversalItf_ IMetadataTraversal_Itf = {
- IMetadataTraversal_SetMode,
- IMetadataTraversal_GetChildCount,
- IMetadataTraversal_GetChildMIMETypeSize,
- IMetadataTraversal_GetChildInfo,
- IMetadataTraversal_SetActiveNode
-};
-
-void IMetadataTraversal_init(void *self)
-{
- IMetadataTraversal *thiz = (IMetadataTraversal *) self;
- thiz->mItf = &IMetadataTraversal_Itf;
- thiz->mIndex = 0;
- thiz->mMode = SL_METADATATRAVERSALMODE_NODE;
- thiz->mCount = 0;
- thiz->mSize = 0;
-}
diff --git a/wilhelm/src/itf/IMuteSolo.c b/wilhelm/src/itf/IMuteSolo.c
deleted file mode 100644
index dcf5879..0000000
--- a/wilhelm/src/itf/IMuteSolo.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* MuteSolo implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IMuteSolo_SetChannelMute(SLMuteSoloItf self, SLuint8 chan, SLboolean mute)
-{
- SL_ENTER_INTERFACE
-
- IMuteSolo *thiz = (IMuteSolo *) self;
- IObject *thisObject = thiz->mThis;
- if (SL_OBJECTID_AUDIOPLAYER != IObjectToObjectID(thisObject)) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- CAudioPlayer *ap = (CAudioPlayer *) thisObject;
- interface_lock_exclusive(thiz);
- SLuint8 numChannels = ap->mNumChannels;
- if (1 >= numChannels) {
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else if (numChannels <= chan) {
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLuint8 mask = 1 << chan;
- SLuint8 oldMuteMask = ap->mMuteMask;
- if (mute) {
- ap->mMuteMask |= mask;
- } else {
- ap->mMuteMask &= ~mask;
- }
- interface_unlock_exclusive_attributes(thiz, oldMuteMask != ap->mMuteMask ? ATTR_GAIN :
- ATTR_NONE);
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMuteSolo_GetChannelMute(SLMuteSoloItf self, SLuint8 chan, SLboolean *pMute)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMute) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMuteSolo *thiz = (IMuteSolo *) self;
- IObject *thisObject = thiz->mThis;
- if (SL_OBJECTID_AUDIOPLAYER != IObjectToObjectID(thisObject)) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- CAudioPlayer *ap = (CAudioPlayer *) thisObject;
- SLboolean mute;
- interface_lock_shared(thiz);
- SLuint8 numChannels = ap->mNumChannels;
- if (1 >= numChannels) {
- mute = SL_BOOLEAN_FALSE;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else if (numChannels <= chan) {
- mute = SL_BOOLEAN_FALSE;
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLuint8 mask = ap->mMuteMask;
- mute = (SLboolean) ((mask >> chan) & 1);
- result = SL_RESULT_SUCCESS;
- }
- interface_unlock_shared(thiz);
- *pMute = mute;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMuteSolo_SetChannelSolo(SLMuteSoloItf self, SLuint8 chan, SLboolean solo)
-{
- SL_ENTER_INTERFACE
-
- IMuteSolo *thiz = (IMuteSolo *) self;
- IObject *thisObject = thiz->mThis;
- if (SL_OBJECTID_AUDIOPLAYER != IObjectToObjectID(thisObject)) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- CAudioPlayer *ap = (CAudioPlayer *) thisObject;
- interface_lock_exclusive(thiz);
- SLuint8 numChannels = ap->mNumChannels;
- if (1 >= numChannels) {
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else if (numChannels <= chan) {
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLuint8 mask = 1 << chan;
- SLuint8 oldSoloMask = ap->mSoloMask;
- if (solo) {
- ap->mSoloMask |= mask;
- } else {
- ap->mSoloMask &= ~mask;
- }
- interface_unlock_exclusive_attributes(thiz, oldSoloMask != ap->mSoloMask ? ATTR_GAIN :
- ATTR_NONE);
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMuteSolo_GetChannelSolo(SLMuteSoloItf self, SLuint8 chan, SLboolean *pSolo)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSolo) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMuteSolo *thiz = (IMuteSolo *) self;
- IObject *thisObject = thiz->mThis;
- if (SL_OBJECTID_AUDIOPLAYER != IObjectToObjectID(thisObject)) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- CAudioPlayer *ap = (CAudioPlayer *) thisObject;
- SLboolean solo;
- interface_lock_shared(thiz);
- SLuint8 numChannels = ap->mNumChannels;
- if (1 >= numChannels) {
- solo = SL_BOOLEAN_FALSE;
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else if (numChannels <= chan) {
- solo = SL_BOOLEAN_FALSE;
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- SLuint8 mask = ap->mSoloMask;
- solo = (SLboolean) ((mask >> chan) & 1);
- result = SL_RESULT_SUCCESS;
- }
- interface_unlock_shared(thiz);
- *pSolo = solo;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IMuteSolo_GetNumChannels(SLMuteSoloItf self, SLuint8 *pNumChannels)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumChannels) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IMuteSolo *thiz = (IMuteSolo *) self;
- IObject *thisObject = thiz->mThis;
- if (SL_OBJECTID_AUDIOPLAYER != IObjectToObjectID(thisObject)) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- CAudioPlayer *ap = (CAudioPlayer *) thisObject;
- object_lock_shared(thisObject);
- SLuint8 numChannels = ap->mNumChannels;
- object_unlock_shared(thisObject);
- *pNumChannels = numChannels;
- result = 0 < numChannels ? SL_RESULT_SUCCESS : SL_RESULT_PRECONDITIONS_VIOLATED;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLMuteSoloItf_ IMuteSolo_Itf = {
- IMuteSolo_SetChannelMute,
- IMuteSolo_GetChannelMute,
- IMuteSolo_SetChannelSolo,
- IMuteSolo_GetChannelSolo,
- IMuteSolo_GetNumChannels
-};
-
-void IMuteSolo_init(void *self)
-{
- IMuteSolo *thiz = (IMuteSolo *) self;
- thiz->mItf = &IMuteSolo_Itf;
-}
diff --git a/wilhelm/src/itf/IObject.c b/wilhelm/src/itf/IObject.c
deleted file mode 100644
index befe939..0000000
--- a/wilhelm/src/itf/IObject.c
+++ /dev/null
@@ -1,825 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Object implementation */
-
-#include "sles_allinclusive.h"
-
-
-// Called by a worker thread to handle an asynchronous Object.Realize.
-// Parameter self is the Object.
-
-static void HandleRealize(void *self, void *ignored, int unused)
-{
-
- // validate input parameters
- IObject *thiz = (IObject *) self;
- assert(NULL != thiz);
- const ClassTable *clazz = thiz->mClass;
- assert(NULL != clazz);
- AsyncHook realize = clazz->mRealize;
- SLresult result;
- SLuint8 state;
-
- // check object state
- object_lock_exclusive(thiz);
- state = thiz->mState;
- switch (state) {
-
- case SL_OBJECT_STATE_REALIZING_1: // normal case
- if (NULL != realize) {
- thiz->mState = SL_OBJECT_STATE_REALIZING_2;
- // Note that the mutex is locked on entry to and exit from the realize hook,
- // but the hook is permitted to temporarily unlock the mutex (e.g. for async).
- result = (*realize)(thiz, SL_BOOLEAN_TRUE);
- assert(SL_OBJECT_STATE_REALIZING_2 == thiz->mState);
- state = SL_RESULT_SUCCESS == result ? SL_OBJECT_STATE_REALIZED :
- SL_OBJECT_STATE_UNREALIZED;
- } else {
- result = SL_RESULT_SUCCESS;
- state = SL_OBJECT_STATE_REALIZED;
- }
- break;
-
- case SL_OBJECT_STATE_REALIZING_1A: // operation was aborted while on work queue
- result = SL_RESULT_OPERATION_ABORTED;
- state = SL_OBJECT_STATE_UNREALIZED;
- break;
-
- default: // impossible
- assert(SL_BOOLEAN_FALSE);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
-
- }
-
- // mutex is locked, update state
- thiz->mState = state;
-
- // Make a copy of these, so we can call the callback with mutex unlocked
- slObjectCallback callback = thiz->mCallback;
- void *context = thiz->mContext;
- object_unlock_exclusive(thiz);
-
- // Note that the mutex is unlocked during the callback
- if (NULL != callback) {
- (*callback)(&thiz->mItf, context, SL_OBJECT_EVENT_ASYNC_TERMINATION, result, state, NULL);
- }
-}
-
-
-static SLresult IObject_Realize(SLObjectItf self, SLboolean async)
-{
- SL_ENTER_INTERFACE
-
- IObject *thiz = (IObject *) self;
- SLuint8 state;
- const ClassTable *clazz = thiz->mClass;
- bool isSharedEngine = false;
- object_lock_exclusive(thiz);
- // note that SL_OBJECTID_ENGINE and XA_OBJECTID_ENGINE map to same class
- if (clazz == objectIDtoClass(SL_OBJECTID_ENGINE)) {
- // important: the lock order is engine followed by theOneTrueMutex
- int ok = pthread_mutex_lock(&theOneTrueMutex);
- assert(0 == ok);
- isSharedEngine = 1 < theOneTrueRefCount;
- ok = pthread_mutex_unlock(&theOneTrueMutex);
- assert(0 == ok);
- }
- state = thiz->mState;
- // Reject redundant calls to Realize, except on a shared engine
- if (SL_OBJECT_STATE_UNREALIZED != state) {
- object_unlock_exclusive(thiz);
- // redundant realize on the shared engine is permitted
- if (isSharedEngine && (SL_OBJECT_STATE_REALIZED == state)) {
- result = SL_RESULT_SUCCESS;
- } else {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- }
- } else {
- // Asynchronous: mark operation pending and cancellable
- if (async && (SL_OBJECTID_ENGINE != clazz->mSLObjectID)) {
- state = SL_OBJECT_STATE_REALIZING_1;
- // Synchronous: mark operation pending and non-cancellable
- } else {
- state = SL_OBJECT_STATE_REALIZING_2;
- }
- thiz->mState = state;
- switch (state) {
- case SL_OBJECT_STATE_REALIZING_1: // asynchronous on non-Engine
- object_unlock_exclusive(thiz);
- assert(async);
- result = ThreadPool_add_ppi(&thiz->mEngine->mThreadPool, HandleRealize, thiz, NULL, 0);
- if (SL_RESULT_SUCCESS != result) {
- // Engine was destroyed during realize, or insufficient memory
- object_lock_exclusive(thiz);
- thiz->mState = SL_OBJECT_STATE_UNREALIZED;
- object_unlock_exclusive(thiz);
- }
- break;
- case SL_OBJECT_STATE_REALIZING_2: // synchronous, or asynchronous on Engine
- {
- AsyncHook realize = clazz->mRealize;
- // Note that the mutex is locked on entry to and exit from the realize hook,
- // but the hook is permitted to temporarily unlock the mutex (e.g. for async).
- result = (NULL != realize) ? (*realize)(thiz, async) : SL_RESULT_SUCCESS;
- assert(SL_OBJECT_STATE_REALIZING_2 == thiz->mState);
- state = (SL_RESULT_SUCCESS == result) ? SL_OBJECT_STATE_REALIZED :
- SL_OBJECT_STATE_UNREALIZED;
- thiz->mState = state;
- slObjectCallback callback = thiz->mCallback;
- void *context = thiz->mContext;
- object_unlock_exclusive(thiz);
- // asynchronous Realize on an Engine is actually done synchronously, but still has
- // callback because there is no thread pool yet to do it asynchronously.
- if (async && (NULL != callback)) {
- (*callback)(&thiz->mItf, context, SL_OBJECT_EVENT_ASYNC_TERMINATION, result, state,
- NULL);
- }
- }
- break;
- default: // impossible
- object_unlock_exclusive(thiz);
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-// Called by a worker thread to handle an asynchronous Object.Resume.
-// Parameter self is the Object.
-
-static void HandleResume(void *self, void *ignored, int unused)
-{
-
- // valid input parameters
- IObject *thiz = (IObject *) self;
- assert(NULL != thiz);
- const ClassTable *clazz = thiz->mClass;
- assert(NULL != clazz);
- AsyncHook resume = clazz->mResume;
- SLresult result;
- SLuint8 state;
-
- // check object state
- object_lock_exclusive(thiz);
- state = thiz->mState;
- switch (state) {
-
- case SL_OBJECT_STATE_RESUMING_1: // normal case
- if (NULL != resume) {
- thiz->mState = SL_OBJECT_STATE_RESUMING_2;
- // Note that the mutex is locked on entry to and exit from the resume hook,
- // but the hook is permitted to temporarily unlock the mutex (e.g. for async).
- result = (*resume)(thiz, SL_BOOLEAN_TRUE);
- assert(SL_OBJECT_STATE_RESUMING_2 == thiz->mState);
- state = SL_RESULT_SUCCESS == result ? SL_OBJECT_STATE_REALIZED :
- SL_OBJECT_STATE_SUSPENDED;
- } else {
- result = SL_RESULT_SUCCESS;
- state = SL_OBJECT_STATE_REALIZED;
- }
- break;
-
- case SL_OBJECT_STATE_RESUMING_1A: // operation was aborted while on work queue
- result = SL_RESULT_OPERATION_ABORTED;
- state = SL_OBJECT_STATE_SUSPENDED;
- break;
-
- default: // impossible
- assert(SL_BOOLEAN_FALSE);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
-
- }
-
- // mutex is unlocked, update state
- thiz->mState = state;
-
- // Make a copy of these, so we can call the callback with mutex unlocked
- slObjectCallback callback = thiz->mCallback;
- void *context = thiz->mContext;
- object_unlock_exclusive(thiz);
-
- // Note that the mutex is unlocked during the callback
- if (NULL != callback) {
- (*callback)(&thiz->mItf, context, SL_OBJECT_EVENT_ASYNC_TERMINATION, result, state, NULL);
- }
-}
-
-
-static SLresult IObject_Resume(SLObjectItf self, SLboolean async)
-{
- SL_ENTER_INTERFACE
-
- IObject *thiz = (IObject *) self;
- const ClassTable *clazz = thiz->mClass;
- SLuint8 state;
- object_lock_exclusive(thiz);
- state = thiz->mState;
- // Reject redundant calls to Resume
- if (SL_OBJECT_STATE_SUSPENDED != state) {
- object_unlock_exclusive(thiz);
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- // Asynchronous: mark operation pending and cancellable
- if (async) {
- state = SL_OBJECT_STATE_RESUMING_1;
- // Synchronous: mark operatio pending and non-cancellable
- } else {
- state = SL_OBJECT_STATE_RESUMING_2;
- }
- thiz->mState = state;
- switch (state) {
- case SL_OBJECT_STATE_RESUMING_1: // asynchronous
- object_unlock_exclusive(thiz);
- assert(async);
- result = ThreadPool_add_ppi(&thiz->mEngine->mThreadPool, HandleResume, thiz, NULL, 0);
- if (SL_RESULT_SUCCESS != result) {
- // Engine was destroyed during resume, or insufficient memory
- object_lock_exclusive(thiz);
- thiz->mState = SL_OBJECT_STATE_SUSPENDED;
- object_unlock_exclusive(thiz);
- }
- break;
- case SL_OBJECT_STATE_RESUMING_2: // synchronous
- {
- AsyncHook resume = clazz->mResume;
- // Note that the mutex is locked on entry to and exit from the resume hook,
- // but the hook is permitted to temporarily unlock the mutex (e.g. for async).
- result = (NULL != resume) ? (*resume)(thiz, SL_BOOLEAN_FALSE) : SL_RESULT_SUCCESS;
- assert(SL_OBJECT_STATE_RESUMING_2 == thiz->mState);
- thiz->mState = (SL_RESULT_SUCCESS == result) ? SL_OBJECT_STATE_REALIZED :
- SL_OBJECT_STATE_SUSPENDED;
- object_unlock_exclusive(thiz);
- }
- break;
- default: // impossible
- object_unlock_exclusive(thiz);
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IObject_GetState(SLObjectItf self, SLuint32 *pState)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pState) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IObject *thiz = (IObject *) self;
- object_lock_shared(thiz);
- SLuint8 state = thiz->mState;
- object_unlock_shared(thiz);
- // Re-map the realizing, resuming, and suspending states
- switch (state) {
- case SL_OBJECT_STATE_REALIZING_1:
- case SL_OBJECT_STATE_REALIZING_1A:
- case SL_OBJECT_STATE_REALIZING_2:
- case SL_OBJECT_STATE_DESTROYING: // application shouldn't call GetState after Destroy
- state = SL_OBJECT_STATE_UNREALIZED;
- break;
- case SL_OBJECT_STATE_RESUMING_1:
- case SL_OBJECT_STATE_RESUMING_1A:
- case SL_OBJECT_STATE_RESUMING_2:
- case SL_OBJECT_STATE_SUSPENDING:
- state = SL_OBJECT_STATE_SUSPENDED;
- break;
- case SL_OBJECT_STATE_UNREALIZED:
- case SL_OBJECT_STATE_REALIZED:
- case SL_OBJECT_STATE_SUSPENDED:
- // These are the "official" object states, return them as is
- break;
- default:
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- *pState = state;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-static SLresult IObject_GetInterface(SLObjectItf self, const SLInterfaceID iid, void *pInterface)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pInterface) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- void *interface = NULL;
- if (NULL == iid) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IObject *thiz = (IObject *) self;
- const ClassTable *clazz = thiz->mClass;
- int MPH, index;
- if ((0 > (MPH = IID_to_MPH(iid))) ||
- // no need to check for an initialization hook
- // (NULL == MPH_init_table[MPH].mInit) ||
- (0 > (index = clazz->mMPH_to_index[MPH]))) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- unsigned mask = 1 << index;
- object_lock_exclusive(thiz);
- if ((SL_OBJECT_STATE_REALIZED != thiz->mState) &&
- !(INTERFACE_PREREALIZE & clazz->mInterfaces[index].mInterface)) {
- // Can't get interface on an unrealized object unless pre-realize is ok
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else if ((MPH_MUTESOLO == MPH) && (SL_OBJECTID_AUDIOPLAYER ==
- clazz->mSLObjectID) && (1 == ((CAudioPlayer *) thiz)->mNumChannels)) {
- // Can't get the MuteSolo interface of an audio player if the channel count is
- // mono, but _can_ get the MuteSolo interface if the channel count is unknown
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- switch (thiz->mInterfaceStates[index]) {
- case INTERFACE_EXPOSED:
- case INTERFACE_ADDED:
- interface = (char *) thiz + clazz->mInterfaces[index].mOffset;
- // Note that interface has been gotten,
- // for debugger and to detect incorrect use of interfaces
- if (!(thiz->mGottenMask & mask)) {
- thiz->mGottenMask |= mask;
- // This trickery validates the v-table
- ((size_t *) interface)[0] ^= ~0;
- }
- result = SL_RESULT_SUCCESS;
- break;
- // Can't get interface if uninitialized, initialized, suspended,
- // suspending, resuming, adding, or removing
- default:
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- break;
- }
- }
- object_unlock_exclusive(thiz);
- }
- }
- *(void **)pInterface = interface;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IObject_RegisterCallback(SLObjectItf self,
- slObjectCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IObject *thiz = (IObject *) self;
- object_lock_exclusive(thiz);
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- object_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-/** \brief This is internal common code for Abort and Destroy.
- * Note: called with mutex unlocked, and returns with mutex locked.
- */
-
-static void Abort_internal(IObject *thiz)
-{
- const ClassTable *clazz = thiz->mClass;
- bool anyAsync = false;
- object_lock_exclusive(thiz);
-
- // Abort asynchronous operations on the object
- switch (thiz->mState) {
- case SL_OBJECT_STATE_REALIZING_1: // Realize
- thiz->mState = SL_OBJECT_STATE_REALIZING_1A;
- anyAsync = true;
- break;
- case SL_OBJECT_STATE_RESUMING_1: // Resume
- thiz->mState = SL_OBJECT_STATE_RESUMING_1A;
- anyAsync = true;
- break;
- case SL_OBJECT_STATE_REALIZING_1A: // Realize
- case SL_OBJECT_STATE_REALIZING_2:
- case SL_OBJECT_STATE_RESUMING_1A: // Resume
- case SL_OBJECT_STATE_RESUMING_2:
- anyAsync = true;
- break;
- case SL_OBJECT_STATE_DESTROYING:
- assert(false);
- break;
- default:
- break;
- }
-
- // Abort asynchronous operations on interfaces
- SLuint8 *interfaceStateP = thiz->mInterfaceStates;
- unsigned index;
- for (index = 0; index < clazz->mInterfaceCount; ++index, ++interfaceStateP) {
- switch (*interfaceStateP) {
- case INTERFACE_ADDING_1: // AddInterface
- *interfaceStateP = INTERFACE_ADDING_1A;
- anyAsync = true;
- break;
- case INTERFACE_RESUMING_1: // ResumeInterface
- *interfaceStateP = INTERFACE_RESUMING_1A;
- anyAsync = true;
- break;
- case INTERFACE_ADDING_1A: // AddInterface
- case INTERFACE_ADDING_2:
- case INTERFACE_RESUMING_1A: // ResumeInterface
- case INTERFACE_RESUMING_2:
- case INTERFACE_REMOVING: // not observable: RemoveInterface is synchronous & mutex locked
- anyAsync = true;
- break;
- default:
- break;
- }
- }
-
- // Wait until all asynchronous operations either complete normally or recognize the abort
- while (anyAsync) {
- object_unlock_exclusive(thiz);
- // FIXME should use condition variable instead of polling
- usleep(20000);
- anyAsync = false;
- object_lock_exclusive(thiz);
- switch (thiz->mState) {
- case SL_OBJECT_STATE_REALIZING_1: // state 1 means it cycled during the usleep window
- case SL_OBJECT_STATE_RESUMING_1:
- case SL_OBJECT_STATE_REALIZING_1A:
- case SL_OBJECT_STATE_REALIZING_2:
- case SL_OBJECT_STATE_RESUMING_1A:
- case SL_OBJECT_STATE_RESUMING_2:
- anyAsync = true;
- break;
- case SL_OBJECT_STATE_DESTROYING:
- assert(false);
- break;
- default:
- break;
- }
- interfaceStateP = thiz->mInterfaceStates;
- for (index = 0; index < clazz->mInterfaceCount; ++index, ++interfaceStateP) {
- switch (*interfaceStateP) {
- case INTERFACE_ADDING_1: // state 1 means it cycled during the usleep window
- case INTERFACE_RESUMING_1:
- case INTERFACE_ADDING_1A:
- case INTERFACE_ADDING_2:
- case INTERFACE_RESUMING_1A:
- case INTERFACE_RESUMING_2:
- case INTERFACE_REMOVING:
- anyAsync = true;
- break;
- default:
- break;
- }
- }
- }
-
- // At this point there are no pending asynchronous operations
-}
-
-
-static void IObject_AbortAsyncOperation(SLObjectItf self)
-{
- SL_ENTER_INTERFACE_VOID
-
- IObject *thiz = (IObject *) self;
- Abort_internal(thiz);
- object_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE_VOID
-}
-
-
-void IObject_Destroy(SLObjectItf self)
-{
- SL_ENTER_INTERFACE_VOID
-
- IObject *thiz = (IObject *) self;
- // mutex is unlocked
- Abort_internal(thiz);
- // mutex is locked
- const ClassTable *clazz = thiz->mClass;
- PreDestroyHook preDestroy = clazz->mPreDestroy;
- // The pre-destroy hook is called with mutex locked, and should block until it is safe to
- // destroy. It is OK to unlock the mutex temporarily, as it long as it re-locks the mutex
- // before returning.
- if (NULL != preDestroy) {
- predestroy_t okToDestroy = (*preDestroy)(thiz);
- switch (okToDestroy) {
- case predestroy_ok:
- break;
- case predestroy_error:
- SL_LOGE("Object::Destroy(%p) not allowed", thiz);
- // fall through
- case predestroy_again:
- object_unlock_exclusive(thiz);
- // unfortunately Destroy doesn't return a result
- SL_LEAVE_INTERFACE_VOID
- // unreachable
- default:
- assert(false);
- break;
- }
- }
- thiz->mState = SL_OBJECT_STATE_DESTROYING;
- VoidHook destroy = clazz->mDestroy;
- // const, no lock needed
- IEngine *thisEngine = &thiz->mEngine->mEngine;
- unsigned i = thiz->mInstanceID;
- assert(MAX_INSTANCE >= i);
- // avoid a recursive lock on the engine when destroying the engine itself
- if (thisEngine->mThis != thiz) {
- interface_lock_exclusive(thisEngine);
- }
- // An unpublished object has a slot reserved, but the ID hasn't been chosen yet
- assert(0 < thisEngine->mInstanceCount);
- --thisEngine->mInstanceCount;
- // If object is published, then remove it from exposure to sync thread and debugger
- if (0 != i) {
- --i;
- unsigned mask = 1 << i;
- assert(thisEngine->mInstanceMask & mask);
- thisEngine->mInstanceMask &= ~mask;
- assert(thisEngine->mInstances[i] == thiz);
- thisEngine->mInstances[i] = NULL;
- }
- // avoid a recursive unlock on the engine when destroying the engine itself
- if (thisEngine->mThis != thiz) {
- interface_unlock_exclusive(thisEngine);
- }
- // The destroy hook is called with mutex locked
- if (NULL != destroy) {
- (*destroy)(thiz);
- }
- // Call the deinitializer for each currently initialized interface,
- // whether it is implicit, explicit, optional, or dynamically added.
- // The deinitializers are called in the reverse order that the
- // initializers were called, so that IObject_deinit is called last.
- unsigned index = clazz->mInterfaceCount;
- const struct iid_vtable *x = &clazz->mInterfaces[index];
- SLuint8 *interfaceStateP = &thiz->mInterfaceStates[index];
- for ( ; index > 0; --index) {
- --x;
- size_t offset = x->mOffset;
- void *thisItf = (char *) thiz + offset;
- SLuint32 state = *--interfaceStateP;
- switch (state) {
- case INTERFACE_UNINITIALIZED:
- break;
- case INTERFACE_EXPOSED: // quiescent states
- case INTERFACE_ADDED:
- case INTERFACE_SUSPENDED:
- // The remove hook is called with mutex locked
- {
- VoidHook remove = MPH_init_table[x->mMPH].mRemove;
- if (NULL != remove) {
- (*remove)(thisItf);
- }
- *interfaceStateP = INTERFACE_INITIALIZED;
- }
- // fall through
- case INTERFACE_INITIALIZED:
- {
- VoidHook deinit = MPH_init_table[x->mMPH].mDeinit;
- if (NULL != deinit) {
- (*deinit)(thisItf);
- }
- *interfaceStateP = INTERFACE_UNINITIALIZED;
- }
- break;
- case INTERFACE_ADDING_1: // active states indicate incorrect use of API
- case INTERFACE_ADDING_1A:
- case INTERFACE_ADDING_2:
- case INTERFACE_RESUMING_1:
- case INTERFACE_RESUMING_1A:
- case INTERFACE_RESUMING_2:
- case INTERFACE_REMOVING:
- case INTERFACE_SUSPENDING:
- SL_LOGE("Object::Destroy(%p) while interface %u active", thiz, index);
- break;
- default:
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- }
- // The mutex is unlocked and destroyed by IObject_deinit, which is the last deinitializer
- memset(thiz, 0x55, clazz->mSize); // catch broken applications that continue using interfaces
- // was ifdef USE_DEBUG but safer to do this unconditionally
- free(thiz);
-
- if (SL_OBJECTID_ENGINE == clazz->mSLObjectID) {
- CEngine_Destroyed((CEngine *) thiz);
- }
-
- SL_LEAVE_INTERFACE_VOID
-}
-
-
-static SLresult IObject_SetPriority(SLObjectItf self, SLint32 priority, SLboolean preemptable)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_BASE
- IObject *thiz = (IObject *) self;
- object_lock_exclusive(thiz);
- thiz->mPriority = priority;
- thiz->mPreemptable = SL_BOOLEAN_FALSE != preemptable; // normalize
- object_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IObject_GetPriority(SLObjectItf self, SLint32 *pPriority, SLboolean *pPreemptable)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_BASE
- if (NULL == pPriority || NULL == pPreemptable) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IObject *thiz = (IObject *) self;
- object_lock_shared(thiz);
- SLint32 priority = thiz->mPriority;
- SLboolean preemptable = thiz->mPreemptable;
- object_unlock_shared(thiz);
- *pPriority = priority;
- *pPreemptable = preemptable;
- result = SL_RESULT_SUCCESS;
- }
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IObject_SetLossOfControlInterfaces(SLObjectItf self,
- SLint16 numInterfaces, SLInterfaceID *pInterfaceIDs, SLboolean enabled)
-{
- SL_ENTER_INTERFACE
-
-#if USE_PROFILES & USE_PROFILES_BASE
- result = SL_RESULT_SUCCESS;
- if (0 < numInterfaces) {
- SLuint32 i;
- if (NULL == pInterfaceIDs) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IObject *thiz = (IObject *) self;
- const ClassTable *clazz = thiz->mClass;
- unsigned lossOfControlMask = 0;
- // The cast is due to a typo in the spec, bug 6482
- for (i = 0; i < (SLuint32) numInterfaces; ++i) {
- SLInterfaceID iid = pInterfaceIDs[i];
- if (NULL == iid) {
- result = SL_RESULT_PARAMETER_INVALID;
- goto out;
- }
- int MPH, index;
- // We ignore without error any invalid MPH or index, but spec is unclear
- if ((0 <= (MPH = IID_to_MPH(iid))) &&
- // no need to check for an initialization hook
- // (NULL == MPH_init_table[MPH].mInit) ||
- (0 <= (index = clazz->mMPH_to_index[MPH]))) {
- lossOfControlMask |= (1 << index);
- }
- }
- object_lock_exclusive(thiz);
- if (enabled) {
- thiz->mLossOfControlMask |= lossOfControlMask;
- } else {
- thiz->mLossOfControlMask &= ~lossOfControlMask;
- }
- object_unlock_exclusive(thiz);
- }
- }
-out:
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLObjectItf_ IObject_Itf = {
- IObject_Realize,
- IObject_Resume,
- IObject_GetState,
- IObject_GetInterface,
- IObject_RegisterCallback,
- IObject_AbortAsyncOperation,
- IObject_Destroy,
- IObject_SetPriority,
- IObject_GetPriority,
- IObject_SetLossOfControlInterfaces
-};
-
-
-/** \brief This must be the first initializer called for an object */
-
-void IObject_init(void *self)
-{
- IObject *thiz = (IObject *) self;
- thiz->mItf = &IObject_Itf;
- // initialized in construct:
- // mClass
- // mInstanceID
- // mLossOfControlMask
- // mEngine
- // mInterfaceStates
- thiz->mState = SL_OBJECT_STATE_UNREALIZED;
- thiz->mGottenMask = 1; // IObject
- thiz->mAttributesMask = 0;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
-#if USE_PROFILES & USE_PROFILES_BASE
- thiz->mPriority = SL_PRIORITY_NORMAL;
- thiz->mPreemptable = SL_BOOLEAN_FALSE;
-#endif
- thiz->mStrongRefCount = 0;
- int ok;
- ok = pthread_mutex_init(&thiz->mMutex, (const pthread_mutexattr_t *) NULL);
- assert(0 == ok);
-#ifdef USE_DEBUG
- memset(&thiz->mOwner, 0, sizeof(pthread_t));
- thiz->mFile = NULL;
- thiz->mLine = 0;
- thiz->mGeneration = 0;
-#endif
- ok = pthread_cond_init(&thiz->mCond, (const pthread_condattr_t *) NULL);
- assert(0 == ok);
-}
-
-
-/** \brief This must be the last deinitializer called for an object */
-
-void IObject_deinit(void *self)
-{
- IObject *thiz = (IObject *) self;
-#ifdef USE_DEBUG
- assert(pthread_equal(pthread_self(), thiz->mOwner));
-#endif
- int ok;
- ok = pthread_cond_destroy(&thiz->mCond);
- assert(0 == ok);
- // equivalent to object_unlock_exclusive, but without the rigmarole
- ok = pthread_mutex_unlock(&thiz->mMutex);
- assert(0 == ok);
- ok = pthread_mutex_destroy(&thiz->mMutex);
- assert(0 == ok);
- // redundant: thiz->mState = SL_OBJECT_STATE_UNREALIZED;
-}
-
-
-/** \brief Publish a new object after it is fully initialized.
- * Publishing will expose the object to sync thread and debugger,
- * and make it safe to return the SLObjectItf to the application.
- */
-
-void IObject_Publish(IObject *thiz)
-{
- IEngine *thisEngine = &thiz->mEngine->mEngine;
- interface_lock_exclusive(thisEngine);
- // construct earlier reserved a pending slot, but did not choose the actual slot number
- unsigned availMask = ~thisEngine->mInstanceMask;
- assert(availMask);
- unsigned i = ctz(availMask);
- assert(MAX_INSTANCE > i);
- assert(NULL == thisEngine->mInstances[i]);
- thisEngine->mInstances[i] = thiz;
- thisEngine->mInstanceMask |= 1 << i;
- // avoid zero as a valid instance ID
- thiz->mInstanceID = i + 1;
- interface_unlock_exclusive(thisEngine);
-}
diff --git a/wilhelm/src/itf/IOutputMix.c b/wilhelm/src/itf/IOutputMix.c
deleted file mode 100644
index 1594d7c..0000000
--- a/wilhelm/src/itf/IOutputMix.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* OutputMix implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IOutputMix_GetDestinationOutputDeviceIDs(SLOutputMixItf self,
- SLint32 *pNumDevices, SLuint32 *pDeviceIDs)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pNumDevices) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- // The application can set pDeviceIDs == NULL in order to find out number of devices.
- // Then the application can allocate a proper-sized device ID array and try again.
- if (NULL != pDeviceIDs) {
- if (1 > *pNumDevices) {
- result = SL_RESULT_BUFFER_INSUFFICIENT;
- } else {
- pDeviceIDs[0] = SL_DEFAULTDEVICEID_AUDIOOUTPUT;
- }
- }
- *pNumDevices = 1;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IOutputMix_RegisterDeviceChangeCallback(SLOutputMixItf self,
- slMixDeviceChangeCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IOutputMix *thiz = (IOutputMix *) self;
- interface_lock_exclusive(thiz);
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IOutputMix_ReRoute(SLOutputMixItf self, SLint32 numOutputDevices,
- SLuint32 *pOutputDeviceIDs)
-{
- SL_ENTER_INTERFACE
-
- if ((1 != numOutputDevices) || (NULL == pOutputDeviceIDs)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- switch (pOutputDeviceIDs[0]) {
- case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
- case DEVICE_ID_HEADSET:
- result = SL_RESULT_SUCCESS;
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLOutputMixItf_ IOutputMix_Itf = {
- IOutputMix_GetDestinationOutputDeviceIDs,
- IOutputMix_RegisterDeviceChangeCallback,
- IOutputMix_ReRoute
-};
-
-void IOutputMix_init(void *self)
-{
- IOutputMix *thiz = (IOutputMix *) self;
- thiz->mItf = &IOutputMix_Itf;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
-}
diff --git a/wilhelm/src/itf/IOutputMixExt.c b/wilhelm/src/itf/IOutputMixExt.c
deleted file mode 100644
index 7a72d28..0000000
--- a/wilhelm/src/itf/IOutputMixExt.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* OutputMixExt implementation */
-
-#include "sles_allinclusive.h"
-#include <math.h>
-
-
-// OutputMixExt is used by SDL, but is not specific to or dependent on SDL
-
-
-// stereo is a frame consisting of a pair of 16-bit PCM samples
-
-typedef struct {
- short left;
- short right;
-} stereo;
-
-
-/** \brief Summary of the gain, as an optimization for the mixer */
-
-typedef enum {
- GAIN_MUTE = 0, // mValue == 0.0f within epsilon
- GAIN_UNITY = 1, // mValue == 1.0f within epsilon
- GAIN_OTHER = 2 // 0.0f < mValue < 1.0f
-} Summary;
-
-
-/** \brief Check whether a track has any data for us to read */
-
-static SLboolean track_check(Track *track)
-{
- assert(NULL != track);
- SLboolean trackHasData = SL_BOOLEAN_FALSE;
-
- CAudioPlayer *audioPlayer = track->mAudioPlayer;
- if (NULL != audioPlayer) {
-
- // track is initialized
-
- // FIXME This lock could block and result in stuttering;
- // a trylock with retry or lockless solution would be ideal
- object_lock_exclusive(&audioPlayer->mObject);
- assert(audioPlayer->mTrack == track);
-
- SLuint32 framesMixed = track->mFramesMixed;
- if (0 != framesMixed) {
- track->mFramesMixed = 0;
- audioPlayer->mPlay.mFramesSinceLastSeek += framesMixed;
- audioPlayer->mPlay.mFramesSincePositionUpdate += framesMixed;
- }
-
- SLboolean doBroadcast = SL_BOOLEAN_FALSE;
- const BufferHeader *oldFront;
-
- if (audioPlayer->mBufferQueue.mClearRequested) {
- // application thread(s) that call BufferQueue::Clear while mixer is active
- // will block synchronously until mixer acknowledges the Clear request
- audioPlayer->mBufferQueue.mFront = &audioPlayer->mBufferQueue.mArray[0];
- audioPlayer->mBufferQueue.mRear = &audioPlayer->mBufferQueue.mArray[0];
- audioPlayer->mBufferQueue.mState.count = 0;
- audioPlayer->mBufferQueue.mState.playIndex = 0;
- audioPlayer->mBufferQueue.mClearRequested = SL_BOOLEAN_FALSE;
- track->mReader = NULL;
- track->mAvail = 0;
- doBroadcast = SL_BOOLEAN_TRUE;
- }
-
- if (audioPlayer->mDestroyRequested) {
- // an application thread that calls Object::Destroy while mixer is active will block
- // synchronously in the PreDestroy hook until mixer acknowledges the Destroy request
- COutputMix *outputMix = CAudioPlayer_GetOutputMix(audioPlayer);
- unsigned i = track - outputMix->mOutputMixExt.mTracks;
- assert( /* 0 <= i && */ i < MAX_TRACK);
- unsigned mask = 1 << i;
- track->mAudioPlayer = NULL;
- assert(outputMix->mOutputMixExt.mActiveMask & mask);
- outputMix->mOutputMixExt.mActiveMask &= ~mask;
- audioPlayer->mTrack = NULL;
- audioPlayer->mDestroyRequested = SL_BOOLEAN_FALSE;
- doBroadcast = SL_BOOLEAN_TRUE;
- goto broadcast;
- }
-
- switch (audioPlayer->mPlay.mState) {
-
- case SL_PLAYSTATE_PLAYING: // continue playing current track data
- if (0 < track->mAvail) {
- trackHasData = SL_BOOLEAN_TRUE;
- break;
- }
-
- // try to get another buffer from queue
- oldFront = audioPlayer->mBufferQueue.mFront;
- if (oldFront != audioPlayer->mBufferQueue.mRear) {
- assert(0 < audioPlayer->mBufferQueue.mState.count);
- track->mReader = oldFront->mBuffer;
- track->mAvail = oldFront->mSize;
- // note that the buffer stays on the queue while we are reading
- audioPlayer->mPlay.mState = SL_PLAYSTATE_PLAYING;
- trackHasData = SL_BOOLEAN_TRUE;
- } else {
- // no buffers on queue, so playable but not playing
- // NTH should be able to call a desperation callback when completely starved,
- // or call less often than every buffer based on high/low water-marks
- }
-
- // copy gains from audio player to track
- track->mGains[0] = audioPlayer->mGains[0];
- track->mGains[1] = audioPlayer->mGains[1];
- break;
-
- case SL_PLAYSTATE_STOPPING: // application thread(s) called Play::SetPlayState(STOPPED)
- audioPlayer->mPlay.mPosition = (SLmillisecond) 0;
- audioPlayer->mPlay.mFramesSinceLastSeek = 0;
- audioPlayer->mPlay.mFramesSincePositionUpdate = 0;
- audioPlayer->mPlay.mLastSeekPosition = 0;
- audioPlayer->mPlay.mState = SL_PLAYSTATE_STOPPED;
- // stop cancels a pending seek
- audioPlayer->mSeek.mPos = SL_TIME_UNKNOWN;
- oldFront = audioPlayer->mBufferQueue.mFront;
- if (oldFront != audioPlayer->mBufferQueue.mRear) {
- assert(0 < audioPlayer->mBufferQueue.mState.count);
- track->mReader = oldFront->mBuffer;
- track->mAvail = oldFront->mSize;
- }
- doBroadcast = SL_BOOLEAN_TRUE;
- break;
-
- case SL_PLAYSTATE_STOPPED: // idle
- case SL_PLAYSTATE_PAUSED: // idle
- break;
-
- default:
- assert(SL_BOOLEAN_FALSE);
- break;
- }
-
-broadcast:
- if (doBroadcast) {
- object_cond_broadcast(&audioPlayer->mObject);
- }
-
- object_unlock_exclusive(&audioPlayer->mObject);
-
- }
-
- return trackHasData;
-
-}
-
-
-/** \brief This is the track mixer: fill the specified 16-bit stereo PCM buffer */
-
-void IOutputMixExt_FillBuffer(SLOutputMixExtItf self, void *pBuffer, SLuint32 size)
-{
- SL_ENTER_INTERFACE_VOID
-
- // Force to be a multiple of a frame, assumes stereo 16-bit PCM
- size &= ~3;
- SLboolean mixBufferHasData = SL_BOOLEAN_FALSE;
- IOutputMixExt *thiz = (IOutputMixExt *) self;
- IObject *thisObject = thiz->mThis;
- // This lock should never block, except when the application destroys the output mix object
- object_lock_exclusive(thisObject);
- unsigned activeMask;
- // If the output mix is marked for destruction, then acknowledge the request
- if (thiz->mDestroyRequested) {
- IEngine *thisEngine = &thisObject->mEngine->mEngine;
- interface_lock_exclusive(thisEngine);
- assert(&thisEngine->mOutputMix->mObject == thisObject);
- thisEngine->mOutputMix = NULL;
- // Note we don't attempt to connect another output mix, even if there is one
- interface_unlock_exclusive(thisEngine);
- // Acknowledge the destroy request, and notify the pre-destroy hook
- thiz->mDestroyRequested = SL_BOOLEAN_FALSE;
- object_cond_broadcast(thisObject);
- activeMask = 0;
- } else {
- activeMask = thiz->mActiveMask;
- }
- while (activeMask) {
- unsigned i = ctz(activeMask);
- assert(MAX_TRACK > i);
- activeMask &= ~(1 << i);
- Track *track = &thiz->mTracks[i];
-
- // track is allocated
-
- if (!track_check(track)) {
- continue;
- }
-
- // track is playing
- void *dstWriter = pBuffer;
- unsigned desired = size;
- SLboolean trackContributedToMix = SL_BOOLEAN_FALSE;
- float gains[STEREO_CHANNELS];
- Summary summaries[STEREO_CHANNELS];
- unsigned channel;
- for (channel = 0; channel < STEREO_CHANNELS; ++channel) {
- float gain = track->mGains[channel];
- gains[channel] = gain;
- Summary summary;
- if (gain <= 0.001) {
- summary = GAIN_MUTE;
- } else if (gain >= 0.999) {
- summary = GAIN_UNITY;
- } else {
- summary = GAIN_OTHER;
- }
- summaries[channel] = summary;
- }
- while (desired > 0) {
- unsigned actual = desired;
- if (track->mAvail < actual) {
- actual = track->mAvail;
- }
- // force actual to be a frame multiple
- if (actual > 0) {
- assert(NULL != track->mReader);
- stereo *mixBuffer = (stereo *) dstWriter;
- const stereo *source = (const stereo *) track->mReader;
- unsigned j;
- if (GAIN_MUTE != summaries[0] || GAIN_MUTE != summaries[1]) {
- if (mixBufferHasData) {
- // apply gain during add
- if (GAIN_UNITY != summaries[0] || GAIN_UNITY != summaries[1]) {
- for (j = 0; j < actual; j += sizeof(stereo), ++mixBuffer, ++source) {
- mixBuffer->left += (short) (source->left * track->mGains[0]);
- mixBuffer->right += (short) (source->right * track->mGains[1]);
- }
- // no gain adjustment needed, so do a simple add
- } else {
- for (j = 0; j < actual; j += sizeof(stereo), ++mixBuffer, ++source) {
- mixBuffer->left += source->left;
- mixBuffer->right += source->right;
- }
- }
- } else {
- // apply gain during copy
- if (GAIN_UNITY != summaries[0] || GAIN_UNITY != summaries[1]) {
- for (j = 0; j < actual; j += sizeof(stereo), ++mixBuffer, ++source) {
- mixBuffer->left = (short) (source->left * track->mGains[0]);
- mixBuffer->right = (short) (source->right * track->mGains[1]);
- }
- // no gain adjustment needed, so do a simple copy
- } else {
- memcpy(dstWriter, track->mReader, actual);
- }
- }
- trackContributedToMix = SL_BOOLEAN_TRUE;
- }
- dstWriter = (char *) dstWriter + actual;
- desired -= actual;
- track->mReader = (char *) track->mReader + actual;
- track->mAvail -= actual;
- if (track->mAvail == 0) {
- IBufferQueue *bufferQueue = &track->mAudioPlayer->mBufferQueue;
- interface_lock_exclusive(bufferQueue);
- const BufferHeader *oldFront, *newFront, *rear;
- oldFront = bufferQueue->mFront;
- rear = bufferQueue->mRear;
- // a buffer stays on queue while playing, so it better still be there
- assert(oldFront != rear);
- newFront = oldFront;
- if (++newFront == &bufferQueue->mArray[bufferQueue->mNumBuffers + 1]) {
- newFront = bufferQueue->mArray;
- }
- bufferQueue->mFront = (BufferHeader *) newFront;
- assert(0 < bufferQueue->mState.count);
- --bufferQueue->mState.count;
- if (newFront != rear) {
- // we don't acknowledge application requests between buffers
- // within the same mixer frame
- assert(0 < bufferQueue->mState.count);
- track->mReader = newFront->mBuffer;
- track->mAvail = newFront->mSize;
- }
- // else we would set play state to playable but not playing during next mixer
- // frame if the queue is still empty at that time
- ++bufferQueue->mState.playIndex;
- slBufferQueueCallback callback = bufferQueue->mCallback;
- void *context = bufferQueue->mContext;
- interface_unlock_exclusive(bufferQueue);
- // The callback function is called on each buffer completion
- if (NULL != callback) {
- (*callback)((SLBufferQueueItf) bufferQueue, context);
- // Maybe it enqueued another buffer, or maybe it didn't.
- // We will find out later during the next mixer frame.
- }
- }
- // no lock, but safe because noone else updates this field
- track->mFramesMixed += actual >> 2; // sizeof(short) * STEREO_CHANNELS
- continue;
- }
- // we need more data: desired > 0 but actual == 0
- if (track_check(track)) {
- continue;
- }
- // underflow: clear out rest of partial buffer (NTH synthesize comfort noise)
- if (!mixBufferHasData && trackContributedToMix) {
- memset(dstWriter, 0, actual);
- }
- break;
- }
- if (trackContributedToMix) {
- mixBufferHasData = SL_BOOLEAN_TRUE;
- }
- }
- object_unlock_exclusive(thisObject);
- // No active tracks, so output silence
- if (!mixBufferHasData) {
- memset(pBuffer, 0, size);
- }
-
- SL_LEAVE_INTERFACE_VOID
-}
-
-
-static const struct SLOutputMixExtItf_ IOutputMixExt_Itf = {
- IOutputMixExt_FillBuffer
-};
-
-void IOutputMixExt_init(void *self)
-{
- IOutputMixExt *thiz = (IOutputMixExt *) self;
- thiz->mItf = &IOutputMixExt_Itf;
- thiz->mActiveMask = 0;
- Track *track = &thiz->mTracks[0];
- unsigned i;
- for (i = 0; i < MAX_TRACK; ++i, ++track) {
- track->mAudioPlayer = NULL;
- }
- thiz->mDestroyRequested = SL_BOOLEAN_FALSE;
-}
-
-
-/** \brief Called by Engine::CreateAudioPlayer to allocate a track */
-
-SLresult IOutputMixExt_checkAudioPlayerSourceSink(CAudioPlayer *thiz)
-{
- thiz->mTrack = NULL;
-
- // check the source for compatibility
- switch (thiz->mDataSource.mLocator.mLocatorType) {
- case SL_DATALOCATOR_BUFFERQUEUE:
-#ifdef ANDROID
- case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
-#endif
- switch (thiz->mDataSource.mFormat.mFormatType) {
- case SL_DATAFORMAT_PCM:
-#ifdef USE_SDL
- // SDL is hard-coded to 44.1 kHz, and there is no sample rate converter
- if (SL_SAMPLINGRATE_44_1 != thiz->mDataSource.mFormat.mPCM.samplesPerSec)
- return SL_RESULT_CONTENT_UNSUPPORTED;
-#endif
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- // check the sink for compatibility
- const SLDataSink *pAudioSnk = &thiz->mDataSink.u.mSink;
- Track *track = NULL;
- switch (*(SLuint32 *)pAudioSnk->pLocator) {
- case SL_DATALOCATOR_OUTPUTMIX:
- {
- // pAudioSnk->pFormat is ignored
- IOutputMixExt *omExt = &((COutputMix *) ((SLDataLocator_OutputMix *)
- pAudioSnk->pLocator)->outputMix)->mOutputMixExt;
- // allocate an entry within OutputMix for this track
- interface_lock_exclusive(omExt);
- unsigned availMask = ~omExt->mActiveMask;
- if (!availMask) {
- interface_unlock_exclusive(omExt);
- // All track slots full in output mix
- return SL_RESULT_MEMORY_FAILURE;
- }
- unsigned i = ctz(availMask);
- assert(MAX_TRACK > i);
- omExt->mActiveMask |= 1 << i;
- track = &omExt->mTracks[i];
- track->mAudioPlayer = NULL; // only field that is accessed before full initialization
- interface_unlock_exclusive(omExt);
- thiz->mTrack = track;
- thiz->mGains[0] = 1.0f;
- thiz->mGains[1] = 1.0f;
- thiz->mDestroyRequested = SL_BOOLEAN_FALSE;
- }
- break;
- default:
- return SL_RESULT_CONTENT_UNSUPPORTED;
- }
-
- assert(NULL != track);
- track->mBufferQueue = &thiz->mBufferQueue;
- track->mAudioPlayer = thiz;
- track->mReader = NULL;
- track->mAvail = 0;
- track->mGains[0] = 1.0f;
- track->mGains[1] = 1.0f;
- track->mFramesMixed = 0;
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Called when a gain-related field (mute, solo, volume, stereo position, etc.) updated */
-
-void audioPlayerGainUpdate(CAudioPlayer *audioPlayer)
-{
- SLboolean mute = audioPlayer->mVolume.mMute;
- SLuint8 muteMask = audioPlayer->mMuteMask;
- SLuint8 soloMask = audioPlayer->mSoloMask;
- SLmillibel level = audioPlayer->mVolume.mLevel;
- SLboolean enableStereoPosition = audioPlayer->mVolume.mEnableStereoPosition;
- SLpermille stereoPosition = audioPlayer->mVolume.mStereoPosition;
-
- if (soloMask) {
- muteMask |= ~soloMask;
- }
- if (mute || !(~muteMask & 3)) {
- audioPlayer->mGains[0] = 0.0f;
- audioPlayer->mGains[1] = 0.0f;
- } else {
- float playerGain = powf(10.0f, level / 2000.0f);
- unsigned channel;
- for (channel = 0; channel < STEREO_CHANNELS; ++channel) {
- float gain;
- if (muteMask & (1 << channel)) {
- gain = 0.0f;
- } else {
- gain = playerGain;
- if (enableStereoPosition) {
- switch (channel) {
- case 0:
- if (stereoPosition > 0) {
- gain *= (1000 - stereoPosition) / 1000.0f;
- }
- break;
- case 1:
- if (stereoPosition < 0) {
- gain *= (1000 + stereoPosition) / 1000.0f;
- }
- break;
- default:
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- }
- }
- audioPlayer->mGains[channel] = gain;
- }
- }
-}
diff --git a/wilhelm/src/itf/IPitch.c b/wilhelm/src/itf/IPitch.c
deleted file mode 100644
index 8672972..0000000
--- a/wilhelm/src/itf/IPitch.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Pitch implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IPitch_SetPitch(SLPitchItf self, SLpermille pitch)
-{
- SL_ENTER_INTERFACE
-
- IPitch *thiz = (IPitch *) self;
- // const, so no lock needed
- if (!(thiz->mMinPitch <= pitch && pitch <= thiz->mMaxPitch)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_poke(thiz);
- thiz->mPitch = pitch;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPitch_GetPitch(SLPitchItf self, SLpermille *pPitch)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pPitch) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPitch *thiz = (IPitch *) self;
- interface_lock_peek(thiz);
- SLpermille pitch = thiz->mPitch;
- interface_unlock_peek(thiz);
- *pPitch = pitch;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPitch_GetPitchCapabilities(SLPitchItf self,
- SLpermille *pMinPitch, SLpermille *pMaxPitch)
-{
- SL_ENTER_INTERFACE
-
- // per spec, each is optional, and does not require that at least one must be non-NULL
-#if 0
- if (NULL == pMinPitch && NULL == pMaxPitch)
- result = SL_RESULT_PARAMETER_INVALID;
-#endif
- IPitch *thiz = (IPitch *) self;
- // const, so no lock needed
- SLpermille minPitch = thiz->mMinPitch;
- SLpermille maxPitch = thiz->mMaxPitch;
- if (NULL != pMinPitch)
- *pMinPitch = minPitch;
- if (NULL != pMaxPitch)
- *pMaxPitch = maxPitch;
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLPitchItf_ IPitch_Itf = {
- IPitch_SetPitch,
- IPitch_GetPitch,
- IPitch_GetPitchCapabilities
-};
-
-void IPitch_init(void *self)
-{
- IPitch *thiz = (IPitch *) self;
- thiz->mItf = &IPitch_Itf;
- thiz->mPitch = 1000;
- // const
- thiz->mMinPitch = -500;
- thiz->mMaxPitch = 2000;
-}
diff --git a/wilhelm/src/itf/IPlay.c b/wilhelm/src/itf/IPlay.c
deleted file mode 100644
index 458ea30..0000000
--- a/wilhelm/src/itf/IPlay.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Play implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IPlay_SetPlayState(SLPlayItf self, SLuint32 state)
-{
- SL_ENTER_INTERFACE
-
- switch (state) {
- case SL_PLAYSTATE_STOPPED:
- case SL_PLAYSTATE_PAUSED:
- case SL_PLAYSTATE_PLAYING:
- {
- IPlay *thiz = (IPlay *) self;
- unsigned attr = ATTR_NONE;
- result = SL_RESULT_SUCCESS;
-#ifdef USE_OUTPUTMIXEXT
- CAudioPlayer *audioPlayer = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
-#endif
- interface_lock_exclusive(thiz);
- SLuint32 oldState = thiz->mState;
- if (state != oldState) {
-#ifdef USE_OUTPUTMIXEXT
- for (;; interface_cond_wait(thiz)) {
-
- // We are comparing the old state (left) vs. new state (right).
- // Note that the old state is 3 bits wide, but new state is only 2 bits wide.
- // That is why the old state is on the left and new state is on the right.
- switch ((oldState << 2) | state) {
-
- case (SL_PLAYSTATE_STOPPED << 2) | SL_PLAYSTATE_STOPPED:
- case (SL_PLAYSTATE_PAUSED << 2) | SL_PLAYSTATE_PAUSED:
- case (SL_PLAYSTATE_PLAYING << 2) | SL_PLAYSTATE_PLAYING:
- // no-op, and unreachable due to earlier "if (state != oldState)"
- break;
-
- case (SL_PLAYSTATE_STOPPED << 2) | SL_PLAYSTATE_PLAYING:
- case (SL_PLAYSTATE_PAUSED << 2) | SL_PLAYSTATE_PLAYING:
- attr = ATTR_PLAY_STATE;
- // set enqueue attribute if queue is non-empty and state becomes PLAYING
- if ((NULL != audioPlayer) && (audioPlayer->mBufferQueue.mFront !=
- audioPlayer->mBufferQueue.mRear)) {
- // note that USE_OUTPUTMIXEXT does not support ATTR_ABQ_ENQUEUE
- attr |= ATTR_BQ_ENQUEUE;
- }
- // fall through
-
- case (SL_PLAYSTATE_STOPPED << 2) | SL_PLAYSTATE_PAUSED:
- case (SL_PLAYSTATE_PLAYING << 2) | SL_PLAYSTATE_PAUSED:
- // easy
- thiz->mState = state;
- break;
-
- case (SL_PLAYSTATE_STOPPING << 2) | SL_PLAYSTATE_STOPPED:
- // either spurious wakeup, or someone else requested same transition
- continue;
-
- case (SL_PLAYSTATE_STOPPING << 2) | SL_PLAYSTATE_PAUSED:
- case (SL_PLAYSTATE_STOPPING << 2) | SL_PLAYSTATE_PLAYING:
- // wait for other guy to finish his transition, then retry ours
- continue;
-
- case (SL_PLAYSTATE_PAUSED << 2) | SL_PLAYSTATE_STOPPED:
- case (SL_PLAYSTATE_PLAYING << 2) | SL_PLAYSTATE_STOPPED:
- // tell mixer to stop, then wait for mixer to acknowledge the request to stop
- thiz->mState = SL_PLAYSTATE_STOPPING;
- continue;
-
- default:
- // unexpected state
- assert(SL_BOOLEAN_FALSE);
- result = SL_RESULT_INTERNAL_ERROR;
- break;
-
- }
-
- break;
- }
-#else
- // Here life looks easy for an Android, but there are other troubles in play land
- thiz->mState = state;
- attr = ATTR_PLAY_STATE;
- // no need to set ATTR_BQ_ENQUEUE or ATTR_ABQ_ENQUEUE
-#endif
- }
- // SL_LOGD("set play state %d", state);
- interface_unlock_exclusive_attributes(thiz, attr);
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_GetPlayState(SLPlayItf self, SLuint32 *pState)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pState) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- interface_lock_shared(thiz);
- SLuint32 state = thiz->mState;
- interface_unlock_shared(thiz);
- result = SL_RESULT_SUCCESS;
-#ifdef USE_OUTPUTMIXEXT
- switch (state) {
- case SL_PLAYSTATE_STOPPED: // as is
- case SL_PLAYSTATE_PAUSED:
- case SL_PLAYSTATE_PLAYING:
- break;
- case SL_PLAYSTATE_STOPPING: // these states require re-mapping
- state = SL_PLAYSTATE_STOPPED;
- break;
- default: // impossible
- assert(SL_BOOLEAN_FALSE);
- state = SL_PLAYSTATE_STOPPED;
- result = SL_RESULT_INTERNAL_ERROR;
- break;
- }
-#endif
- *pState = state;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_GetDuration(SLPlayItf self, SLmillisecond *pMsec)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMsec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- result = SL_RESULT_SUCCESS;
- IPlay *thiz = (IPlay *) self;
- // even though this is a getter, it can modify state due to caching
- interface_lock_exclusive(thiz);
- SLmillisecond duration = thiz->mDuration;
-#ifdef ANDROID
- if (SL_TIME_UNKNOWN == duration) {
- SLmillisecond temp;
- switch (InterfaceToObjectID(thiz)) {
- case SL_OBJECTID_AUDIOPLAYER:
- result = android_audioPlayer_getDuration(thiz, &temp);
- break;
- case XA_OBJECTID_MEDIAPLAYER:
- result = android_Player_getDuration(thiz, &temp);
- break;
- default:
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- break;
- }
- if (SL_RESULT_SUCCESS == result) {
- duration = temp;
- thiz->mDuration = duration;
- }
- }
-#else
- // will be set by containing AudioPlayer or MidiPlayer object at Realize, if known,
- // otherwise the duration will be updated each time a new maximum position is detected
-#endif
- interface_unlock_exclusive(thiz);
- *pMsec = duration;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_GetPosition(SLPlayItf self, SLmillisecond *pMsec)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMsec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- SLmillisecond position;
- interface_lock_shared(thiz);
-#ifdef ANDROID
- // Android does not use the mPosition field for audio and media players
- // and doesn't cache the position
- switch (IObjectToObjectID((thiz)->mThis)) {
- case SL_OBJECTID_AUDIOPLAYER:
- android_audioPlayer_getPosition(thiz, &position);
- break;
- case XA_OBJECTID_MEDIAPLAYER:
- android_Player_getPosition(thiz, &position);
- break;
- default:
- // we shouldn'be here
- assert(SL_BOOLEAN_FALSE);
- }
-#else
- // on other platforms we depend on periodic updates to the current position
- position = thiz->mPosition;
- // if a seek is pending, then lie about current position so the seek appears synchronous
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- CAudioPlayer *audioPlayer = (CAudioPlayer *) thiz->mThis;
- SLmillisecond pos = audioPlayer->mSeek.mPos;
- if (SL_TIME_UNKNOWN != pos) {
- position = pos;
- }
- }
-#endif
- interface_unlock_shared(thiz);
- *pMsec = position;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_RegisterCallback(SLPlayItf self, slPlayCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IPlay *thiz = (IPlay *) self;
- interface_lock_exclusive(thiz);
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- // omits _attributes b/c noone cares deeply enough about these fields to need quick notification
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_SetCallbackEventsMask(SLPlayItf self, SLuint32 eventFlags)
-{
- SL_ENTER_INTERFACE
-
- if (eventFlags & ~(SL_PLAYEVENT_HEADATEND | SL_PLAYEVENT_HEADATMARKER |
- SL_PLAYEVENT_HEADATNEWPOS | SL_PLAYEVENT_HEADMOVING | SL_PLAYEVENT_HEADSTALLED)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- interface_lock_exclusive(thiz);
- if (thiz->mEventFlags != eventFlags) {
-#ifdef USE_OUTPUTMIXEXT
- // enabling the "head at new position" play event will postpone the next update event
- if (!(thiz->mEventFlags & SL_PLAYEVENT_HEADATNEWPOS) &&
- (eventFlags & SL_PLAYEVENT_HEADATNEWPOS)) {
- thiz->mFramesSincePositionUpdate = 0;
- }
-#endif
- thiz->mEventFlags = eventFlags;
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_GetCallbackEventsMask(SLPlayItf self, SLuint32 *pEventFlags)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEventFlags) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- interface_lock_shared(thiz);
- SLuint32 eventFlags = thiz->mEventFlags;
- interface_unlock_shared(thiz);
- *pEventFlags = eventFlags;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_SetMarkerPosition(SLPlayItf self, SLmillisecond mSec)
-{
- SL_ENTER_INTERFACE
-
- if (SL_TIME_UNKNOWN == mSec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- bool significant = false;
- interface_lock_exclusive(thiz);
- if (thiz->mMarkerPosition != mSec) {
- thiz->mMarkerPosition = mSec;
- if (thiz->mEventFlags & SL_PLAYEVENT_HEADATMARKER) {
- significant = true;
- }
- }
- if (significant) {
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_ClearMarkerPosition(SLPlayItf self)
-{
- SL_ENTER_INTERFACE
-
- IPlay *thiz = (IPlay *) self;
- bool significant = false;
- interface_lock_exclusive(thiz);
- // clearing the marker position is equivalent to setting the marker to SL_TIME_UNKNOWN
- if (thiz->mMarkerPosition != SL_TIME_UNKNOWN) {
- thiz->mMarkerPosition = SL_TIME_UNKNOWN;
- if (thiz->mEventFlags & SL_PLAYEVENT_HEADATMARKER) {
- significant = true;
- }
- }
- if (significant) {
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_GetMarkerPosition(SLPlayItf self, SLmillisecond *pMsec)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMsec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- interface_lock_shared(thiz);
- SLmillisecond markerPosition = thiz->mMarkerPosition;
- interface_unlock_shared(thiz);
- *pMsec = markerPosition;
- if (SL_TIME_UNKNOWN == markerPosition) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_SetPositionUpdatePeriod(SLPlayItf self, SLmillisecond mSec)
-{
- SL_ENTER_INTERFACE
-
- if (0 == mSec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- bool significant = false;
- interface_lock_exclusive(thiz);
- if (thiz->mPositionUpdatePeriod != mSec) {
- thiz->mPositionUpdatePeriod = mSec;
-#ifdef USE_OUTPUTMIXEXT
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- CAudioPlayer *audioPlayer = (CAudioPlayer *) thiz->mThis;
- SLuint32 frameUpdatePeriod = ((long long) mSec *
- (long long) audioPlayer->mSampleRateMilliHz) / 1000000LL;
- if (0 == frameUpdatePeriod)
- frameUpdatePeriod = ~0;
- thiz->mFrameUpdatePeriod = frameUpdatePeriod;
- // setting a new update period postpones the next callback
- thiz->mFramesSincePositionUpdate = 0;
- }
-#endif
- if (thiz->mEventFlags & SL_PLAYEVENT_HEADATNEWPOS) {
- significant = true;
- }
- }
- if (significant) {
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlay_GetPositionUpdatePeriod(SLPlayItf self, SLmillisecond *pMsec)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMsec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlay *thiz = (IPlay *) self;
- interface_lock_shared(thiz);
- SLmillisecond positionUpdatePeriod = thiz->mPositionUpdatePeriod;
- interface_unlock_shared(thiz);
- *pMsec = positionUpdatePeriod;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLPlayItf_ IPlay_Itf = {
- IPlay_SetPlayState,
- IPlay_GetPlayState,
- IPlay_GetDuration,
- IPlay_GetPosition,
- IPlay_RegisterCallback,
- IPlay_SetCallbackEventsMask,
- IPlay_GetCallbackEventsMask,
- IPlay_SetMarkerPosition,
- IPlay_ClearMarkerPosition,
- IPlay_GetMarkerPosition,
- IPlay_SetPositionUpdatePeriod,
- IPlay_GetPositionUpdatePeriod
-};
-
-void IPlay_init(void *self)
-{
- IPlay *thiz = (IPlay *) self;
- thiz->mItf = &IPlay_Itf;
- thiz->mState = SL_PLAYSTATE_STOPPED;
- thiz->mDuration = SL_TIME_UNKNOWN; // will be set by containing player object
- thiz->mPosition = (SLmillisecond) 0;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
- thiz->mEventFlags = 0;
- thiz->mMarkerPosition = SL_TIME_UNKNOWN;
- thiz->mPositionUpdatePeriod = 1000; // per spec
-#ifdef USE_OUTPUTMIXEXT
- thiz->mFrameUpdatePeriod = 0; // because we don't know the sample rate yet
- thiz->mLastSeekPosition = 0;
- thiz->mFramesSinceLastSeek = 0;
- thiz->mFramesSincePositionUpdate = 0;
-#endif
-}
diff --git a/wilhelm/src/itf/IPlaybackRate.c b/wilhelm/src/itf/IPlaybackRate.c
deleted file mode 100644
index 092d13b..0000000
--- a/wilhelm/src/itf/IPlaybackRate.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* PlaybackRate implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IPlaybackRate_SetRate(SLPlaybackRateItf self, SLpermille rate)
-{
- SL_ENTER_INTERFACE
-
- IPlaybackRate *thiz = (IPlaybackRate *) self;
- // const, so no lock needed
- if (!(thiz->mMinRate <= rate && rate <= thiz->mMaxRate)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_exclusive(thiz);
-#ifdef ANDROID
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL != ap) {
- result = android_audioPlayer_setPlaybackRateAndConstraints(ap, rate, thiz->mProperties);
- } else {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
-#else
- result = SL_RESULT_SUCCESS;
-#endif
- if (SL_RESULT_SUCCESS == result) {
- thiz->mRate = rate;
- }
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlaybackRate_GetRate(SLPlaybackRateItf self, SLpermille *pRate)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pRate) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlaybackRate *thiz = (IPlaybackRate *) self;
- interface_lock_shared(thiz);
- SLpermille rate = thiz->mRate;
- interface_unlock_shared(thiz);
- *pRate = rate;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlaybackRate_SetPropertyConstraints(SLPlaybackRateItf self, SLuint32 constraints)
-{
- SL_ENTER_INTERFACE
-
- IPlaybackRate *thiz = (IPlaybackRate *) self;
- if (constraints & ~(SL_RATEPROP_SILENTAUDIO | SL_RATEPROP_STAGGEREDAUDIO |
- SL_RATEPROP_NOPITCHCORAUDIO | SL_RATEPROP_PITCHCORAUDIO)) {
- result = SL_RESULT_PARAMETER_INVALID;
- // const, so no lock needed
- } else if (!(thiz->mCapabilities & constraints)) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- interface_lock_exclusive(thiz);
-#ifdef ANDROID
- // verify property support before storing
- CAudioPlayer *ap = (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) ?
- (CAudioPlayer *) thiz->mThis : NULL;
- if (NULL != ap) {
- result = android_audioPlayer_setPlaybackRateAndConstraints(ap, thiz->mRate,
- constraints);
- } else {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- }
-#else
- result = SL_RESULT_SUCCESS;
-#endif
- if (result == SL_RESULT_SUCCESS) {
- thiz->mProperties = constraints;
- }
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlaybackRate_GetProperties(SLPlaybackRateItf self, SLuint32 *pProperties)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pProperties) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlaybackRate *thiz = (IPlaybackRate *) self;
- interface_lock_shared(thiz);
- SLuint32 properties = thiz->mProperties;
- interface_unlock_shared(thiz);
- *pProperties = properties;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlaybackRate_GetCapabilitiesOfRate(SLPlaybackRateItf self,
- SLpermille rate, SLuint32 *pCapabilities)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pCapabilities) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlaybackRate *thiz = (IPlaybackRate *) self;
- SLuint32 capabilities;
- // const, so no lock needed
- if (!(thiz->mMinRate <= rate && rate <= thiz->mMaxRate)) {
- capabilities = 0;
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- capabilities = thiz->mCapabilities;
- result = SL_RESULT_SUCCESS;
- }
- *pCapabilities = capabilities;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPlaybackRate_GetRateRange(SLPlaybackRateItf self, SLuint8 index,
- SLpermille *pMinRate, SLpermille *pMaxRate, SLpermille *pStepSize, SLuint32 *pCapabilities)
-{
- SL_ENTER_INTERFACE
-
- // only one range
- if (NULL == pMinRate || NULL == pMaxRate || NULL == pStepSize || NULL == pCapabilities ||
- (0 < index)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPlaybackRate *thiz = (IPlaybackRate *) self;
- // const, so no lock needed
- SLpermille minRate = thiz->mMinRate;
- SLpermille maxRate = thiz->mMaxRate;
- SLpermille stepSize = thiz->mStepSize;
- SLuint32 capabilities = thiz->mCapabilities;
- *pMinRate = minRate;
- *pMaxRate = maxRate;
- *pStepSize = stepSize;
- *pCapabilities = capabilities;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLPlaybackRateItf_ IPlaybackRate_Itf = {
- IPlaybackRate_SetRate,
- IPlaybackRate_GetRate,
- IPlaybackRate_SetPropertyConstraints,
- IPlaybackRate_GetProperties,
- IPlaybackRate_GetCapabilitiesOfRate,
- IPlaybackRate_GetRateRange
-};
-
-void IPlaybackRate_init(void *self)
-{
- IPlaybackRate *thiz = (IPlaybackRate *) self;
- thiz->mItf = &IPlaybackRate_Itf;
- thiz->mProperties = SL_RATEPROP_NOPITCHCORAUDIO;
- thiz->mRate = 1000;
- // const after initialization; these are default values which may be overwritten
- // during object creation but will not be modified after that
- // (e.g. for an Android AudioPlayer, see sles_to_android_audioPlayerCreate)
- thiz->mMinRate = 1000;
- thiz->mMaxRate = 1000;
- thiz->mStepSize = 0;
- thiz->mCapabilities = SL_RATEPROP_NOPITCHCORAUDIO;
-}
diff --git a/wilhelm/src/itf/IPrefetchStatus.c b/wilhelm/src/itf/IPrefetchStatus.c
deleted file mode 100644
index 906ba77..0000000
--- a/wilhelm/src/itf/IPrefetchStatus.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* PrefetchStatus implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IPrefetchStatus_GetPrefetchStatus(SLPrefetchStatusItf self, SLuint32 *pStatus)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pStatus) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- interface_lock_shared(thiz);
- SLuint32 status = thiz->mStatus;
- interface_unlock_shared(thiz);
- *pStatus = status;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPrefetchStatus_GetFillLevel(SLPrefetchStatusItf self, SLpermille *pLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- interface_lock_shared(thiz);
- SLpermille level = thiz->mLevel;
- interface_unlock_shared(thiz);
- *pLevel = level;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPrefetchStatus_RegisterCallback(SLPrefetchStatusItf self,
- slPrefetchCallback callback, void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- interface_lock_exclusive(thiz);
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPrefetchStatus_SetCallbackEventsMask(SLPrefetchStatusItf self, SLuint32 eventFlags)
-{
- SL_ENTER_INTERFACE
-
- if (eventFlags & ~(SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)) {
- result = SL_RESULT_PARAMETER_INVALID;
-
- } else {
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- interface_lock_exclusive(thiz);
- thiz->mCallbackEventsMask = eventFlags;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPrefetchStatus_GetCallbackEventsMask(SLPrefetchStatusItf self,
- SLuint32 *pEventFlags)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEventFlags) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- interface_lock_shared(thiz);
- SLuint32 callbackEventsMask = thiz->mCallbackEventsMask;
- interface_unlock_shared(thiz);
- *pEventFlags = callbackEventsMask;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPrefetchStatus_SetFillUpdatePeriod(SLPrefetchStatusItf self, SLpermille period)
-{
- SL_ENTER_INTERFACE
-
- if (0 == period) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- interface_lock_exclusive(thiz);
- thiz->mFillUpdatePeriod = period;
-#ifdef ANDROID
- if (SL_OBJECTID_AUDIOPLAYER == InterfaceToObjectID(thiz)) {
- CAudioPlayer *ap = (CAudioPlayer *) thiz->mThis;
- android_audioPlayer_setBufferingUpdateThresholdPerMille(ap, period);
- }
-#endif
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IPrefetchStatus_GetFillUpdatePeriod(SLPrefetchStatusItf self, SLpermille *pPeriod)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pPeriod) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- interface_lock_shared(thiz);
- SLpermille fillUpdatePeriod = thiz->mFillUpdatePeriod;
- interface_unlock_shared(thiz);
- *pPeriod = fillUpdatePeriod;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLPrefetchStatusItf_ IPrefetchStatus_Itf = {
- IPrefetchStatus_GetPrefetchStatus,
- IPrefetchStatus_GetFillLevel,
- IPrefetchStatus_RegisterCallback,
- IPrefetchStatus_SetCallbackEventsMask,
- IPrefetchStatus_GetCallbackEventsMask,
- IPrefetchStatus_SetFillUpdatePeriod,
- IPrefetchStatus_GetFillUpdatePeriod
-};
-
-void IPrefetchStatus_init(void *self)
-{
- IPrefetchStatus *thiz = (IPrefetchStatus *) self;
- thiz->mItf = &IPrefetchStatus_Itf;
- thiz->mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- thiz->mLevel = 0;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
- thiz->mCallbackEventsMask = 0;
- thiz->mFillUpdatePeriod = 100;
-#ifdef ANDROID
- thiz->mDeferredPrefetchCallback = NULL;
- thiz->mDeferredPrefetchContext = NULL;
- thiz->mDeferredPrefetchEvents = SL_PREFETCHEVENT_NONE;
-#endif
-}
diff --git a/wilhelm/src/itf/IPresetReverb.c b/wilhelm/src/itf/IPresetReverb.c
deleted file mode 100644
index e013cef..0000000
--- a/wilhelm/src/itf/IPresetReverb.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* PresetReverb implementation */
-
-#include "sles_allinclusive.h"
-
-#if defined(ANDROID)
-/**
- * returns true if this interface is not associated with an initialized PresetReverb effect
- */
-static inline bool NO_PRESETREVERB(IPresetReverb* ipr) {
- return (ipr->mPresetReverbEffect == 0);
-}
-#endif
-
-static SLresult IPresetReverb_SetPreset(SLPresetReverbItf self, SLuint16 preset)
-{
- SL_ENTER_INTERFACE
-
- IPresetReverb *thiz = (IPresetReverb *) self;
- switch (preset) {
- case SL_REVERBPRESET_NONE:
- case SL_REVERBPRESET_SMALLROOM:
- case SL_REVERBPRESET_MEDIUMROOM:
- case SL_REVERBPRESET_LARGEROOM:
- case SL_REVERBPRESET_MEDIUMHALL:
- case SL_REVERBPRESET_LARGEHALL:
- case SL_REVERBPRESET_PLATE:
- interface_lock_exclusive(thiz);
- thiz->mPreset = preset;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_PRESETREVERB(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_prev_setPreset(thiz->mPresetReverbEffect, preset);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-static SLresult IPresetReverb_GetPreset(SLPresetReverbItf self, SLuint16 *pPreset)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pPreset) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IPresetReverb *thiz = (IPresetReverb *) self;
- interface_lock_shared(thiz);
- SLuint16 preset = SL_REVERBPRESET_NONE;
-#if !defined(ANDROID)
- preset = thiz->mPreset;
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_PRESETREVERB(thiz)) {
- preset = thiz->mPreset;
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_prev_getPreset(thiz->mPresetReverbEffect, &preset);
- result = android_fx_statusToResult(status);
- }
- // OpenSL ES 1.0.1 spec and conformance test do not permit SL_RESULT_CONTROL_LOST
- if (SL_RESULT_CONTROL_LOST == result) {
- result = SL_RESULT_SUCCESS;
- }
-#endif
- interface_unlock_shared(thiz);
- *pPreset = preset;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-static const struct SLPresetReverbItf_ IPresetReverb_Itf = {
- IPresetReverb_SetPreset,
- IPresetReverb_GetPreset
-};
-
-void IPresetReverb_init(void *self)
-{
- IPresetReverb *thiz = (IPresetReverb *) self;
- thiz->mItf = &IPresetReverb_Itf;
- thiz->mPreset = SL_REVERBPRESET_NONE;
-#if defined(ANDROID)
- memset(&thiz->mPresetReverbDescriptor, 0, sizeof(effect_descriptor_t));
- // placement new (explicit constructor)
- (void) new (&thiz->mPresetReverbEffect) android::sp<android::AudioEffect>();
-#endif
-}
-
-void IPresetReverb_deinit(void *self)
-{
-#if defined(ANDROID)
- IPresetReverb *thiz = (IPresetReverb *) self;
- // explicit destructor
- thiz->mPresetReverbEffect.~sp();
-#endif
-}
-
-bool IPresetReverb_Expose(void *self)
-{
-#if defined(ANDROID)
- IPresetReverb *thiz = (IPresetReverb *) self;
- if (!android_fx_initEffectDescriptor(SL_IID_PRESETREVERB, &thiz->mPresetReverbDescriptor)) {
- SL_LOGE("PresetReverb initialization failed.");
- return false;
- }
-#endif
- return true;
-}
diff --git a/wilhelm/src/itf/IRatePitch.c b/wilhelm/src/itf/IRatePitch.c
deleted file mode 100644
index f83b5b4..0000000
--- a/wilhelm/src/itf/IRatePitch.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* RatePitch implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IRatePitch_SetRate(SLRatePitchItf self, SLpermille rate)
-{
- SL_ENTER_INTERFACE
-
- IRatePitch *thiz = (IRatePitch *) self;
- if (!(thiz->mMinRate <= rate && rate <= thiz->mMaxRate)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_poke(thiz);
- thiz->mRate = rate;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRatePitch_GetRate(SLRatePitchItf self, SLpermille *pRate)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pRate) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRatePitch *thiz = (IRatePitch *) self;
- interface_lock_peek(thiz);
- SLpermille rate = thiz->mRate;
- interface_unlock_peek(thiz);
- *pRate = rate;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRatePitch_GetRatePitchCapabilities(SLRatePitchItf self,
- SLpermille *pMinRate, SLpermille *pMaxRate)
-{
- SL_ENTER_INTERFACE
-
- // per spec, each is optional, and does not require that at least one must be non-NULL
-#if 0
- if (NULL == pMinRate && NULL == pMaxRate)
- result = SL_RESULT_PARAMETER_INVALID;
-#endif
- IRatePitch *thiz = (IRatePitch *) self;
- // const, so no lock required
- SLpermille minRate = thiz->mMinRate;
- SLpermille maxRate = thiz->mMaxRate;
- if (NULL != pMinRate)
- *pMinRate = minRate;
- if (NULL != pMaxRate)
- *pMaxRate = maxRate;
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLRatePitchItf_ IRatePitch_Itf = {
- IRatePitch_SetRate,
- IRatePitch_GetRate,
- IRatePitch_GetRatePitchCapabilities
-};
-
-void IRatePitch_init(void *self)
-{
- IRatePitch *thiz = (IRatePitch *) self;
- thiz->mItf = &IRatePitch_Itf;
- thiz->mRate = 1000;
- // const
- thiz->mMinRate = 500;
- thiz->mMaxRate = 2000;
-}
diff --git a/wilhelm/src/itf/IRecord.c b/wilhelm/src/itf/IRecord.c
deleted file mode 100644
index 3ac3f0c..0000000
--- a/wilhelm/src/itf/IRecord.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Record implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IRecord_SetRecordState(SLRecordItf self, SLuint32 state)
-{
- SL_ENTER_INTERFACE
-
- switch (state) {
- case SL_RECORDSTATE_STOPPED:
- case SL_RECORDSTATE_PAUSED:
- case SL_RECORDSTATE_RECORDING:
- {
- IRecord *thiz = (IRecord *) self;
- interface_lock_exclusive(thiz);
- thiz->mState = state;
-#ifdef ANDROID
- android_audioRecorder_setRecordState(InterfaceToCAudioRecorder(thiz), state);
-#endif
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_GetRecordState(SLRecordItf self, SLuint32 *pState)
-{
- SL_ENTER_INTERFACE
-
- IRecord *thiz = (IRecord *) self;
- if (NULL == pState) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- interface_lock_shared(thiz);
- SLuint32 state = thiz->mState;
- interface_unlock_shared(thiz);
- *pState = state;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_SetDurationLimit(SLRecordItf self, SLmillisecond msec)
-{
- SL_ENTER_INTERFACE
-
- IRecord *thiz = (IRecord *) self;
- interface_lock_exclusive(thiz);
- if (thiz->mDurationLimit != msec) {
- thiz->mDurationLimit = msec;
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_GetPosition(SLRecordItf self, SLmillisecond *pMsec)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMsec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRecord *thiz = (IRecord *) self;
- SLmillisecond position;
- interface_lock_shared(thiz);
-#ifdef ANDROID
- // Android does not use the mPosition field for audio recorders
- if (SL_OBJECTID_AUDIORECORDER == InterfaceToObjectID(thiz)) {
- android_audioRecorder_getPosition(InterfaceToCAudioRecorder(thiz), &position);
- } else {
- position = thiz->mPosition;
- }
-#else
- position = thiz->mPosition;
-#endif
- interface_unlock_shared(thiz);
- *pMsec = position;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_RegisterCallback(SLRecordItf self, slRecordCallback callback,
- void *pContext)
-{
- SL_ENTER_INTERFACE
-
- IRecord *thiz = (IRecord *) self;
- interface_lock_exclusive(thiz);
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_SetCallbackEventsMask(SLRecordItf self, SLuint32 eventFlags)
-{
- SL_ENTER_INTERFACE
-
- if (eventFlags & ~(
- SL_RECORDEVENT_HEADATLIMIT |
- SL_RECORDEVENT_HEADATMARKER |
- SL_RECORDEVENT_HEADATNEWPOS |
- SL_RECORDEVENT_HEADMOVING |
- SL_RECORDEVENT_HEADSTALLED |
- SL_RECORDEVENT_BUFFER_FULL)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRecord *thiz = (IRecord *) self;
- interface_lock_exclusive(thiz);
- if (thiz->mCallbackEventsMask != eventFlags) {
- thiz->mCallbackEventsMask = eventFlags;
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_GetCallbackEventsMask(SLRecordItf self, SLuint32 *pEventFlags)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEventFlags) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRecord *thiz = (IRecord *) self;
- interface_lock_shared(thiz);
- SLuint32 callbackEventsMask = thiz->mCallbackEventsMask;
- interface_unlock_shared(thiz);
- *pEventFlags = callbackEventsMask;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_SetMarkerPosition(SLRecordItf self, SLmillisecond mSec)
-{
- SL_ENTER_INTERFACE
-
- if (SL_TIME_UNKNOWN == mSec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRecord *thiz = (IRecord *) self;
- bool significant = false;
- interface_lock_exclusive(thiz);
- if (thiz->mMarkerPosition != mSec) {
- thiz->mMarkerPosition = mSec;
- if (thiz->mCallbackEventsMask & SL_PLAYEVENT_HEADATMARKER) {
- significant = true;
- }
- }
- if (significant) {
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_ClearMarkerPosition(SLRecordItf self)
-{
- SL_ENTER_INTERFACE
-
- IRecord *thiz = (IRecord *) self;
- bool significant = false;
- interface_lock_exclusive(thiz);
- // clearing the marker position is equivalent to setting the marker to SL_TIME_UNKNOWN
- if (thiz->mMarkerPosition != SL_TIME_UNKNOWN) {
- thiz->mMarkerPosition = SL_TIME_UNKNOWN;
- if (thiz->mCallbackEventsMask & SL_PLAYEVENT_HEADATMARKER) {
- significant = true;
- }
- }
- if (significant) {
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_GetMarkerPosition(SLRecordItf self, SLmillisecond *pMsec)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMsec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRecord *thiz = (IRecord *) self;
- interface_lock_shared(thiz);
- SLmillisecond markerPosition = thiz->mMarkerPosition;
- interface_unlock_shared(thiz);
- *pMsec = markerPosition;
- if (SL_TIME_UNKNOWN == markerPosition) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_SetPositionUpdatePeriod(SLRecordItf self, SLmillisecond mSec)
-{
- SL_ENTER_INTERFACE
-
- if (0 == mSec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRecord *thiz = (IRecord *) self;
- interface_lock_exclusive(thiz);
- if (thiz->mPositionUpdatePeriod != mSec) {
- thiz->mPositionUpdatePeriod = mSec;
- interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IRecord_GetPositionUpdatePeriod(SLRecordItf self, SLmillisecond *pMsec)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMsec) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IRecord *thiz = (IRecord *) self;
- interface_lock_shared(thiz);
- SLmillisecond positionUpdatePeriod = thiz->mPositionUpdatePeriod;
- interface_unlock_shared(thiz);
- *pMsec = positionUpdatePeriod;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLRecordItf_ IRecord_Itf = {
- IRecord_SetRecordState,
- IRecord_GetRecordState,
- IRecord_SetDurationLimit,
- IRecord_GetPosition,
- IRecord_RegisterCallback,
- IRecord_SetCallbackEventsMask,
- IRecord_GetCallbackEventsMask,
- IRecord_SetMarkerPosition,
- IRecord_ClearMarkerPosition,
- IRecord_GetMarkerPosition,
- IRecord_SetPositionUpdatePeriod,
- IRecord_GetPositionUpdatePeriod
-};
-
-void IRecord_init(void *self)
-{
- IRecord *thiz = (IRecord *) self;
- thiz->mItf = &IRecord_Itf;
- thiz->mState = SL_RECORDSTATE_STOPPED;
- thiz->mDurationLimit = 0;
- thiz->mPosition = (SLmillisecond) 0;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
- thiz->mCallbackEventsMask = 0;
- thiz->mMarkerPosition = SL_TIME_UNKNOWN;
- thiz->mPositionUpdatePeriod = 1000; // per spec
-}
diff --git a/wilhelm/src/itf/ISeek.c b/wilhelm/src/itf/ISeek.c
deleted file mode 100644
index 3422ae1..0000000
--- a/wilhelm/src/itf/ISeek.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Seek implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult ISeek_SetPosition(SLSeekItf self, SLmillisecond pos, SLuint32 seekMode)
-{
- SL_ENTER_INTERFACE
-
- switch (seekMode) {
- case SL_SEEKMODE_FAST:
- case SL_SEEKMODE_ACCURATE:
- {
- // maximum position is a special value that indicates a seek is not pending
- if (SL_TIME_UNKNOWN == pos) {
- pos = SL_TIME_UNKNOWN - 1;
- }
- ISeek *thiz = (ISeek *) self;
- interface_lock_exclusive(thiz);
- thiz->mPos = pos;
- // at this point the seek is merely pending, so do not yet update other fields
- interface_unlock_exclusive_attributes(thiz, ATTR_POSITION);
- result = SL_RESULT_SUCCESS;
- }
- break;
- default:
- result = SL_RESULT_PARAMETER_INVALID;
- break;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult ISeek_SetLoop(SLSeekItf self, SLboolean loopEnable,
- SLmillisecond startPos, SLmillisecond endPos)
-{
- SL_ENTER_INTERFACE
-
- if (!(startPos < endPos)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- ISeek *thiz = (ISeek *) self;
- interface_lock_exclusive(thiz);
-#ifdef ANDROID
- if ((startPos != 0) && (endPos != SL_TIME_UNKNOWN)) {
- result = SL_RESULT_FEATURE_UNSUPPORTED;
- } else {
- switch (IObjectToObjectID((thiz)->mThis)) {
- case SL_OBJECTID_AUDIOPLAYER: {
- CAudioPlayer *ap = InterfaceToCAudioPlayer(thiz);
- if (NULL != ap) {
- result = android_audioPlayer_loop(ap, loopEnable);
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- }
- case XA_OBJECTID_MEDIAPLAYER: {
- CMediaPlayer *mp = InterfaceToCMediaPlayer(thiz);
- if (NULL != mp) {
- result = android_Player_loop(mp, loopEnable);
- } else {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- break;
- }
- default: {
- result = SL_RESULT_PARAMETER_INVALID;
- }
- }
- if (SL_RESULT_SUCCESS == result) {
- thiz->mLoopEnabled = SL_BOOLEAN_FALSE != loopEnable; // normalize
- // start and end positions already initialized to [0, end of stream]
- /*thiz->mStartPos = 0;
- thiz->mEndPos = (SLmillisecond) SL_TIME_UNKNOWN;*/
- }
- }
-#else
- thiz->mLoopEnabled = SL_BOOLEAN_FALSE != loopEnable; // normalize
- thiz->mStartPos = startPos;
- thiz->mEndPos = endPos;
- result = SL_RESULT_SUCCESS;
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult ISeek_GetLoop(SLSeekItf self, SLboolean *pLoopEnabled,
- SLmillisecond *pStartPos, SLmillisecond *pEndPos)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pLoopEnabled || NULL == pStartPos || NULL == pEndPos) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- ISeek *thiz = (ISeek *) self;
- interface_lock_shared(thiz);
- SLboolean loopEnabled = thiz->mLoopEnabled;
- SLmillisecond startPos = thiz->mStartPos;
- SLmillisecond endPos = thiz->mEndPos;
- interface_unlock_shared(thiz);
- *pLoopEnabled = loopEnabled;
- *pStartPos = startPos;
- *pEndPos = endPos;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLSeekItf_ ISeek_Itf = {
- ISeek_SetPosition,
- ISeek_SetLoop,
- ISeek_GetLoop
-};
-
-void ISeek_init(void *self)
-{
- ISeek *thiz = (ISeek *) self;
- thiz->mItf = &ISeek_Itf;
- thiz->mPos = (SLmillisecond) SL_TIME_UNKNOWN;
- thiz->mStartPos = (SLmillisecond) 0;
- thiz->mEndPos = (SLmillisecond) SL_TIME_UNKNOWN;
- thiz->mLoopEnabled = SL_BOOLEAN_FALSE;
-}
diff --git a/wilhelm/src/itf/IStreamInformation.c b/wilhelm/src/itf/IStreamInformation.c
deleted file mode 100644
index 57da843..0000000
--- a/wilhelm/src/itf/IStreamInformation.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* StreamInformation implementation */
-
-#include "sles_allinclusive.h"
-
-static XAresult IStreamInformation_QueryMediaContainerInformation( XAStreamInformationItf self,
- XAMediaContainerInformation * info /* [out] */)
-{
- XA_ENTER_INTERFACE
-
- if (NULL == info) {
- result = XA_RESULT_PARAMETER_INVALID;
- XA_LEAVE_INTERFACE
- }
-
-#ifdef ANDROID
- IStreamInformation *thiz = (IStreamInformation *) self;
- interface_lock_exclusive(thiz);
- // always storing container info at index 0, as per spec
- *info = thiz->mStreamInfoTable.itemAt(0).containerInfo;
- interface_unlock_exclusive(thiz);
- // even though the pointer to the media container info is returned, the values aren't set
- // for the actual container in this version, they are simply initialized to defaults
- // (see IStreamInformation_init)
- result = XA_RESULT_SUCCESS;
-#else
- SL_LOGE("QueryMediaContainerInformation is unsupported");
- memset(info, 0, sizeof(XAMediaContainerInformation));
- result = XA_RESULT_CONTENT_UNSUPPORTED;
-#endif
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IStreamInformation_QueryStreamType( XAStreamInformationItf self,
- XAuint32 streamIndex, /* [in] */
- XAuint32 *domain) /* [out] */
-{
- XA_ENTER_INTERFACE
-
- if (NULL == domain) {
- result = XA_RESULT_PARAMETER_INVALID;
- XA_LEAVE_INTERFACE;
- }
-
-#ifndef ANDROID
- *domain = XA_DOMAINTYPE_UNKNOWN;
-#else
- if (0 == streamIndex) {
- // stream 0 is reserved for the container
- result = XA_RESULT_PARAMETER_INVALID;
- *domain = XA_DOMAINTYPE_UNKNOWN;
- } else {
- IStreamInformation *thiz = (IStreamInformation *) self;
-
- interface_lock_exclusive(thiz);
-
- XAuint32 nbStreams = thiz->mStreamInfoTable.itemAt(0).containerInfo.numStreams;
- // streams in the container are numbered 1..nbStreams
- if (streamIndex <= nbStreams) {
- result = XA_RESULT_SUCCESS;
- *domain = thiz->mStreamInfoTable.itemAt(streamIndex).domain;
- } else {
- SL_LOGE("Querying stream type for stream %d, only %d streams available",
- streamIndex, nbStreams);
- result = XA_RESULT_PARAMETER_INVALID;
- }
-
- interface_unlock_exclusive(thiz);
- }
-#endif
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IStreamInformation_QueryStreamInformation( XAStreamInformationItf self,
- XAuint32 streamIndex, /* [in] */
- void * info) /* [out] */
-{
- XA_ENTER_INTERFACE
-
- if (NULL == info) {
- result = XA_RESULT_PARAMETER_INVALID;
- } else {
-
-#ifndef ANDROID
- result = XA_RESULT_FEATURE_UNSUPPORTED;
-#else
-
- IStreamInformation *thiz = (IStreamInformation *) self;
-
- interface_lock_exclusive(thiz);
-
- XAuint32 nbStreams = thiz->mStreamInfoTable.itemAt(0).containerInfo.numStreams;
- // stream 0 is the container, and other streams in the container are numbered 1..nbStreams
- if (streamIndex <= nbStreams) {
- result = XA_RESULT_SUCCESS;
- const StreamInfo& streamInfo = thiz->mStreamInfoTable.itemAt((size_t)streamIndex);
-
- switch (streamInfo.domain) {
- case XA_DOMAINTYPE_CONTAINER:
- *(XAMediaContainerInformation *)info = streamInfo.containerInfo;
- break;
- case XA_DOMAINTYPE_AUDIO:
- *(XAAudioStreamInformation *)info = streamInfo.audioInfo;
- break;
- case XA_DOMAINTYPE_VIDEO:
- *(XAVideoStreamInformation *)info = streamInfo.videoInfo;
- break;
- case XA_DOMAINTYPE_IMAGE:
- *(XAImageStreamInformation *)info = streamInfo.imageInfo;
- break;
- case XA_DOMAINTYPE_TIMEDTEXT:
- *(XATimedTextStreamInformation *)info = streamInfo.textInfo;
- break;
- case XA_DOMAINTYPE_MIDI:
- *(XAMIDIStreamInformation *)info = streamInfo.midiInfo;
- break;
- case XA_DOMAINTYPE_VENDOR:
- *(XAVendorStreamInformation *)info = streamInfo.vendorInfo;
- break;
- default:
- SL_LOGE("StreamInformation::QueryStreamInformation index %u has "
- "unknown domain %u", streamIndex, streamInfo.domain);
- result = XA_RESULT_INTERNAL_ERROR;
- break;
- }
-
- } else {
- SL_LOGE("Querying stream type for stream %d, only %d streams available",
- streamIndex, nbStreams);
- result = XA_RESULT_PARAMETER_INVALID;
- }
-
- interface_unlock_exclusive(thiz);
-#endif
-
- }
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IStreamInformation_QueryStreamName( XAStreamInformationItf self,
- XAuint32 streamIndex, /* [in] */
- XAuint16 * pNameSize, /* [in/out] */
- XAchar * pName) /* [out] */
-{
- XA_ENTER_INTERFACE
-
- SL_LOGE("unsupported XAStreamInformationItf function");
- result = XA_RESULT_FEATURE_UNSUPPORTED;
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IStreamInformation_RegisterStreamChangeCallback( XAStreamInformationItf self,
- xaStreamEventChangeCallback callback, /* [in] */
- void * pContext) /* [in] */
-{
- XA_ENTER_INTERFACE
-
- IStreamInformation *thiz = (IStreamInformation *) self;
-
- interface_lock_exclusive(thiz);
-
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- result = SL_RESULT_SUCCESS;
-
- interface_unlock_exclusive(thiz);
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IStreamInformation_QueryActiveStreams( XAStreamInformationItf self,
- XAuint32 *numStreams, /* [in/out] */
- XAboolean *activeStreams) /* [out] */
-{
- XA_ENTER_INTERFACE
-
- if (NULL == numStreams) {
- result = XA_RESULT_PARAMETER_INVALID;
- XA_LEAVE_INTERFACE;
- }
-
- IStreamInformation *thiz = (IStreamInformation *) self;
-
- interface_lock_exclusive(thiz);
-
- result = XA_RESULT_SUCCESS;
- *numStreams = thiz->mStreamInfoTable.itemAt(0).containerInfo.numStreams;
- activeStreams = thiz->mActiveStreams;
-
- interface_unlock_exclusive(thiz);
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IStreamInformation_SetActiveStream( XAStreamInformationItf self,
- XAuint32 streamNum, /* [in] */
- XAboolean active, /* [in] */
- XAboolean commitNow) /* [in] */
-{
- XA_ENTER_INTERFACE
-
- SL_LOGE("unsupported XAStreamInformationItf function");
- result = XA_RESULT_FEATURE_UNSUPPORTED;
-
- XA_LEAVE_INTERFACE
-}
-
-
-static const struct XAStreamInformationItf_ IStreamInformation_Itf = {
- IStreamInformation_QueryMediaContainerInformation,
- IStreamInformation_QueryStreamType,
- IStreamInformation_QueryStreamInformation,
- IStreamInformation_QueryStreamName,
- IStreamInformation_RegisterStreamChangeCallback,
- IStreamInformation_QueryActiveStreams,
- IStreamInformation_SetActiveStream
-};
-
-
-void IStreamInformation_init(void *self)
-{
- SL_LOGV("IStreamInformation_init\n");
- IStreamInformation *thiz = (IStreamInformation *) self;
- thiz->mItf = &IStreamInformation_Itf;
-
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
-
- for (int i=0 ; i < NB_SUPPORTED_STREAMS ; i++) {
- thiz->mActiveStreams[i] = XA_BOOLEAN_FALSE;
- }
-
-#ifdef ANDROID
- // placement new constructor for C++ field within C struct
- (void) new (&thiz->mStreamInfoTable) android::Vector<StreamInfo>();
- // initialize container info
- StreamInfo contInf;
- contInf.domain = XA_DOMAINTYPE_CONTAINER;
- contInf.containerInfo.containerType = XA_CONTAINERTYPE_UNSPECIFIED;
- contInf.containerInfo.mediaDuration = XA_TIME_UNKNOWN;
- // FIXME shouldn't this be 1 ?
- contInf.containerInfo.numStreams = 0;
- // always storing container info at index 0, as per spec: here, the table was still empty
- thiz->mStreamInfoTable.add(contInf);
-#endif
-}
-
-
-void IStreamInformation_deinit(void *self) {
-#ifdef ANDROID
- IStreamInformation *thiz = (IStreamInformation *) self;
- // explicit destructor
- thiz->mStreamInfoTable.~Vector<StreamInfo>();
-#endif
-}
diff --git a/wilhelm/src/itf/IStreamInformation.cpp b/wilhelm/src/itf/IStreamInformation.cpp
deleted file mode 100644
index 2141533..0000000
--- a/wilhelm/src/itf/IStreamInformation.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Force compilation of code as C++
-#include "IStreamInformation.c"
diff --git a/wilhelm/src/itf/IThreadSync.c b/wilhelm/src/itf/IThreadSync.c
deleted file mode 100644
index 09d52df..0000000
--- a/wilhelm/src/itf/IThreadSync.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* ThreadSync implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IThreadSync_EnterCriticalSection(SLThreadSyncItf self)
-{
- SL_ENTER_INTERFACE
-
- IThreadSync *thiz = (IThreadSync *) self;
- interface_lock_exclusive(thiz);
- for (;;) {
- if (thiz->mInCriticalSection) {
- if (!pthread_equal(thiz->mOwner, pthread_self())) {
- ++thiz->mWaiting;
- interface_cond_wait(thiz);
- continue;
- }
- // nested locks are not allowed
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- break;
- }
- thiz->mInCriticalSection = SL_BOOLEAN_TRUE;
- thiz->mOwner = pthread_self();
- result = SL_RESULT_SUCCESS;
- break;
- }
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IThreadSync_ExitCriticalSection(SLThreadSyncItf self)
-{
- SL_ENTER_INTERFACE
-
- IThreadSync *thiz = (IThreadSync *) self;
- interface_lock_exclusive(thiz);
- if (!thiz->mInCriticalSection || !pthread_equal(thiz->mOwner, pthread_self())) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- thiz->mInCriticalSection = SL_BOOLEAN_FALSE;
- memset(&thiz->mOwner, 0, sizeof(pthread_t));
- if (thiz->mWaiting) {
- --thiz->mWaiting;
- interface_cond_signal(thiz);
- }
- result = SL_RESULT_SUCCESS;
- }
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLThreadSyncItf_ IThreadSync_Itf = {
- IThreadSync_EnterCriticalSection,
- IThreadSync_ExitCriticalSection
-};
-
-void IThreadSync_init(void *self)
-{
- IThreadSync *thiz = (IThreadSync *) self;
- thiz->mItf = &IThreadSync_Itf;
- thiz->mInCriticalSection = SL_BOOLEAN_FALSE;
- thiz->mWaiting = 0;
- memset(&thiz->mOwner, 0, sizeof(pthread_t));
-}
-
-void IThreadSync_deinit(void *self)
-{
- IThreadSync *thiz = (IThreadSync *) self;
- if (thiz->mInCriticalSection) {
- SL_LOGW("ThreadSync::EnterCriticalSection was active at Engine::Destroy");
- }
-}
diff --git a/wilhelm/src/itf/IVibra.c b/wilhelm/src/itf/IVibra.c
deleted file mode 100644
index 67b1016..0000000
--- a/wilhelm/src/itf/IVibra.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Vibra implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IVibra_Vibrate(SLVibraItf self, SLboolean vibrate)
-{
- SL_ENTER_INTERFACE
-
- IVibra *thiz = (IVibra *) self;
- interface_lock_poke(thiz);
- thiz->mVibrate = SL_BOOLEAN_FALSE != vibrate; // normalize
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVibra_IsVibrating(SLVibraItf self, SLboolean *pVibrating)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pVibrating) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVibra *thiz = (IVibra *) self;
- interface_lock_peek(thiz);
- SLboolean vibrate = thiz->mVibrate;
- interface_unlock_peek(thiz);
- *pVibrating = vibrate;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVibra_SetFrequency(SLVibraItf self, SLmilliHertz frequency)
-{
- SL_ENTER_INTERFACE
-
- const SLVibraDescriptor *d = Vibra_id_descriptors[0].descriptor;
- if (!d->supportsFrequency) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else if (!(d->minFrequency <= frequency && frequency <= d->maxFrequency)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVibra *thiz = (IVibra *) self;
- interface_lock_poke(thiz);
- thiz->mFrequency = frequency;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVibra_GetFrequency(SLVibraItf self, SLmilliHertz *pFrequency)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pFrequency) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVibra *thiz = (IVibra *) self;
- interface_lock_peek(thiz);
- SLmilliHertz frequency = thiz->mFrequency;
- interface_unlock_peek(thiz);
- *pFrequency = frequency;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVibra_SetIntensity(SLVibraItf self, SLpermille intensity)
-{
- SL_ENTER_INTERFACE
-
- const SLVibraDescriptor *d = Vibra_id_descriptors[0].descriptor;
- if (!d->supportsIntensity) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else if (!(0 <= intensity && intensity <= 1000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVibra *thiz = (IVibra *) self;
- interface_lock_poke(thiz);
- thiz->mIntensity = intensity;
- interface_unlock_poke(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVibra_GetIntensity(SLVibraItf self, SLpermille *pIntensity)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pIntensity) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- const SLVibraDescriptor *d = Vibra_id_descriptors[0].descriptor;
- if (!d->supportsIntensity) {
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- IVibra *thiz = (IVibra *) self;
- interface_lock_peek(thiz);
- SLpermille intensity = thiz->mIntensity;
- interface_unlock_peek(thiz);
- *pIntensity = intensity;
- result = SL_RESULT_SUCCESS;
- }
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLVibraItf_ IVibra_Itf = {
- IVibra_Vibrate,
- IVibra_IsVibrating,
- IVibra_SetFrequency,
- IVibra_GetFrequency,
- IVibra_SetIntensity,
- IVibra_GetIntensity
-};
-
-void IVibra_init(void *self)
-{
- IVibra *thiz = (IVibra *) self;
- thiz->mItf = &IVibra_Itf;
- thiz->mVibrate = SL_BOOLEAN_FALSE;
- // next 2 values are undefined per spec
- thiz->mFrequency = Vibra_id_descriptors[0].descriptor->minFrequency;
- thiz->mIntensity = 1000;
-}
diff --git a/wilhelm/src/itf/IVideoDecoderCapabilities.cpp b/wilhelm/src/itf/IVideoDecoderCapabilities.cpp
deleted file mode 100644
index 8f12cb2..0000000
--- a/wilhelm/src/itf/IVideoDecoderCapabilities.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* VideoDecoderCapabilities implementation */
-
-#include "sles_allinclusive.h"
-#ifdef ANDROID
-#include "android/VideoCodec_to_android.h"
-#endif
-
-
-static XAresult IVideoDecoderCapabilities_GetVideoDecoders(XAVideoDecoderCapabilitiesItf self,
- XAuint32 *pNumDecoders, XAuint32 *pDecoderIds)
-{
- XA_ENTER_INTERFACE
-
- if (NULL == pNumDecoders) {
- result = XA_RESULT_PARAMETER_INVALID;
- } else {
- if (NULL == pDecoderIds) {
- // If pDecoderIds is NULL, pNumDecoders returns the number of decoders available.
-#ifdef ANDROID
- *pNumDecoders = android::android_videoCodec_getNbDecoders();
-#else
- *pNumDecoders = kMaxVideoDecoders;
-#endif
-
- } else {
- // If pDecodersIds is non-NULL, as an input pNumDecoders specifies the size of the
- // pDecoderIds array and as an output it specifies the number of decoder IDs available
- // within the pDecoderIds array.
-#ifdef ANDROID
- XAuint32 numDecoders = *pNumDecoders;
- const XAuint32 androidNbDecoders = android::android_videoCodec_getNbDecoders();
- if (androidNbDecoders <= numDecoders) {
- *pNumDecoders = numDecoders = androidNbDecoders;
- }
- android::android_videoCodec_getDecoderIds(numDecoders, pDecoderIds);
-#else
- XAuint32 numDecoders = *pNumDecoders;
- if (kMaxVideoDecoders <= numDecoders) {
- *pNumDecoders = numDecoders = kMaxVideoDecoders;
- }
- memcpy(pDecoderIds, VideoDecoderIds, numDecoders * sizeof(XAuint32));
-#endif
- }
- result = XA_RESULT_SUCCESS;
- }
-
- XA_LEAVE_INTERFACE
-}
-
-
-static XAresult IVideoDecoderCapabilities_GetVideoDecoderCapabilities(
- XAVideoDecoderCapabilitiesItf self, XAuint32 decoderId, XAuint32 *pIndex,
- XAVideoCodecDescriptor *pDescriptor)
-{
- XA_ENTER_INTERFACE
-
- if (NULL == pIndex) {
- result = XA_RESULT_PARAMETER_INVALID;
- } else {
- if (NULL == pDescriptor) {
- // pIndex returns the number of video decoders capability descriptions.
-#ifdef ANDROID
- result = android::android_videoCodec_getProfileLevelCombinationNb(decoderId, pIndex);
-#else
- SL_LOGE("Generic implementation has no video decoder capabilities");
- result = XA_RESULT_PARAMETER_INVALID;
-#endif
- } else {
- // pIndex is an incrementing value used to enumerate capability descriptions.
-#ifdef ANDROID
- result = android::android_videoCodec_getProfileLevelCombination(decoderId, *pIndex,
- pDescriptor);
-#else
- pDescriptor->codecId = decoderId;
- SL_LOGE("Generic implementation has no video decoder capabilities");
- result = XA_RESULT_PARAMETER_INVALID;
-#endif
- }
- }
-
- XA_LEAVE_INTERFACE
-}
-
-
-static const struct XAVideoDecoderCapabilitiesItf_ IVideoDecoderCapabilities_Itf = {
- IVideoDecoderCapabilities_GetVideoDecoders,
- IVideoDecoderCapabilities_GetVideoDecoderCapabilities
-};
-
-void IVideoDecoderCapabilities_init(void *self)
-{
- IVideoDecoderCapabilities *thiz = (IVideoDecoderCapabilities *) self;
- thiz->mItf = &IVideoDecoderCapabilities_Itf;
-}
-
-
-bool IVideoDecoderCapabilities_expose(void *self)
-{
-#ifdef ANDROID
- // This is an Engine object interface, so we allocate the associated resources every time
- // the interface is exposed on the Engine object and free them when the object is about
- // to be destroyed (see IVideoDecoderCapabilities_deinit), not just once during the
- // lifetime of the process.
- return android::android_videoCodec_expose();
-#else
- return false;
-#endif
-}
-
-
-void IVideoDecoderCapabilities_deinit(void *self)
-{
- SL_LOGV("IVideoDecoderCapabilities_deinit()");
-#ifdef ANDROID
- android::android_videoCodec_deinit();
-#endif
-}
diff --git a/wilhelm/src/itf/IVirtualizer.c b/wilhelm/src/itf/IVirtualizer.c
deleted file mode 100644
index 70e2295..0000000
--- a/wilhelm/src/itf/IVirtualizer.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Virtualizer implementation */
-
-#include "sles_allinclusive.h"
-#ifdef ANDROID
-#include <audio_effects/effect_virtualizer.h>
-#endif
-
-#define VIRTUALIZER_STRENGTH_MIN 0
-#define VIRTUALIZER_STRENGTH_MAX 1000
-
-
-#if defined(ANDROID)
-/**
- * returns true if this interface is not associated with an initialized Virtualizer effect
- */
-static inline bool NO_VIRTUALIZER(IVirtualizer* v) {
- return (v->mVirtualizerEffect == 0);
-}
-#endif
-
-
-static SLresult IVirtualizer_SetEnabled(SLVirtualizerItf self, SLboolean enabled)
-{
- SL_ENTER_INTERFACE
-
- IVirtualizer *thiz = (IVirtualizer *) self;
- interface_lock_exclusive(thiz);
- thiz->mEnabled = (SLboolean) enabled;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_VIRTUALIZER(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- thiz->mVirtualizerEffect->setEnabled((bool) thiz->mEnabled);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
-
- SL_LEAVE_INTERFACE
-
-}
-
-
-static SLresult IVirtualizer_IsEnabled(SLVirtualizerItf self, SLboolean *pEnabled)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEnabled) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVirtualizer *thiz = (IVirtualizer *) self;
- interface_lock_exclusive(thiz);
- SLboolean enabled = thiz->mEnabled;
-#if !defined(ANDROID)
- *pEnabled = enabled;
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_VIRTUALIZER(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- *pEnabled = (SLboolean) thiz->mVirtualizerEffect->getEnabled();
- result = SL_RESULT_SUCCESS;
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVirtualizer_SetStrength(SLVirtualizerItf self, SLpermille strength)
-{
- SL_ENTER_INTERFACE
-
- if ((VIRTUALIZER_STRENGTH_MIN > strength) || (VIRTUALIZER_STRENGTH_MAX < strength)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVirtualizer *thiz = (IVirtualizer *) self;
- interface_lock_exclusive(thiz);
-#if !defined(ANDROID)
- thiz->mStrength = strength;
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_VIRTUALIZER(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_virt_setParam(thiz->mVirtualizerEffect,
- VIRTUALIZER_PARAM_STRENGTH, &strength);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVirtualizer_GetRoundedStrength(SLVirtualizerItf self, SLpermille *pStrength)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pStrength) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVirtualizer *thiz = (IVirtualizer *) self;
- interface_lock_exclusive(thiz);
- SLpermille strength = thiz->mStrength;;
-#if !defined(ANDROID)
- result = SL_RESULT_SUCCESS;
-#else
- if (NO_VIRTUALIZER(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status = android_virt_getParam(thiz->mVirtualizerEffect,
- VIRTUALIZER_PARAM_STRENGTH, &strength);
- result = android_fx_statusToResult(status);
- }
-#endif
- interface_unlock_exclusive(thiz);
- *pStrength = strength;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVirtualizer_IsStrengthSupported(SLVirtualizerItf self, SLboolean *pSupported)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pSupported) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
-#if !defined(ANDROID)
- *pSupported = SL_BOOLEAN_TRUE;
- result = SL_RESULT_SUCCESS;
-#else
- IVirtualizer *thiz = (IVirtualizer *) self;
- int32_t supported = 0;
- interface_lock_exclusive(thiz);
- if (NO_VIRTUALIZER(thiz)) {
- result = SL_RESULT_CONTROL_LOST;
- } else {
- android::status_t status =
- android_virt_getParam(thiz->mVirtualizerEffect,
- VIRTUALIZER_PARAM_STRENGTH_SUPPORTED, &supported);
- result = android_fx_statusToResult(status);
- }
- interface_unlock_exclusive(thiz);
- *pSupported = (SLboolean) (supported != 0);
-#endif
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLVirtualizerItf_ IVirtualizer_Itf = {
- IVirtualizer_SetEnabled,
- IVirtualizer_IsEnabled,
- IVirtualizer_SetStrength,
- IVirtualizer_GetRoundedStrength,
- IVirtualizer_IsStrengthSupported
-};
-
-void IVirtualizer_init(void *self)
-{
- IVirtualizer *thiz = (IVirtualizer *) self;
- thiz->mItf = &IVirtualizer_Itf;
- thiz->mEnabled = SL_BOOLEAN_FALSE;
- thiz->mStrength = 0;
-#if defined(ANDROID)
- memset(&thiz->mVirtualizerDescriptor, 0, sizeof(effect_descriptor_t));
- // placement new (explicit constructor)
- (void) new (&thiz->mVirtualizerEffect) android::sp<android::AudioEffect>();
-#endif
-}
-
-void IVirtualizer_deinit(void *self)
-{
-#if defined(ANDROID)
- IVirtualizer *thiz = (IVirtualizer *) self;
- // explicit destructor
- thiz->mVirtualizerEffect.~sp();
-#endif
-}
-
-bool IVirtualizer_Expose(void *self)
-{
-#if defined(ANDROID)
- IVirtualizer *thiz = (IVirtualizer *) self;
- if (!android_fx_initEffectDescriptor(SL_IID_VIRTUALIZER, &thiz->mVirtualizerDescriptor)) {
- SL_LOGE("Virtualizer initialization failed.");
- return false;
- }
-#endif
- return true;
-}
diff --git a/wilhelm/src/itf/IVisualization.c b/wilhelm/src/itf/IVisualization.c
deleted file mode 100644
index 6991d80..0000000
--- a/wilhelm/src/itf/IVisualization.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Visualization implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IVisualization_RegisterVisualizationCallback(SLVisualizationItf self,
- slVisualizationCallback callback, void *pContext, SLmilliHertz rate)
-{
- SL_ENTER_INTERFACE
-
- if (!(0 < rate && rate <= 20000)) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVisualization *thiz = (IVisualization *) self;
- interface_lock_exclusive(thiz);
- thiz->mCallback = callback;
- thiz->mContext = pContext;
- thiz->mRate = rate;
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVisualization_GetMaxRate(SLVisualizationItf self, SLmilliHertz *pRate)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pRate) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pRate = 20000;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLVisualizationItf_ IVisualization_Itf = {
- IVisualization_RegisterVisualizationCallback,
- IVisualization_GetMaxRate
-};
-
-void IVisualization_init(void *self)
-{
- IVisualization *thiz = (IVisualization *) self;
- thiz->mItf = &IVisualization_Itf;
- thiz->mCallback = NULL;
- thiz->mContext = NULL;
- thiz->mRate = 20000;
-}
diff --git a/wilhelm/src/itf/IVolume.c b/wilhelm/src/itf/IVolume.c
deleted file mode 100644
index 52f4da4..0000000
--- a/wilhelm/src/itf/IVolume.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Volume implementation */
-
-#include "sles_allinclusive.h"
-
-
-static SLresult IVolume_SetVolumeLevel(SLVolumeItf self, SLmillibel level)
-{
- SL_ENTER_INTERFACE
-
- if (!((SL_MILLIBEL_MIN <= level) && (level <= PLATFORM_MILLIBEL_MAX_VOLUME))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVolume *thiz = (IVolume *) self;
- interface_lock_exclusive(thiz);
- SLmillibel oldLevel = thiz->mLevel;
- if (oldLevel != level) {
- thiz->mLevel = level;
- interface_unlock_exclusive_attributes(thiz, ATTR_GAIN);
- } else
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_GetVolumeLevel(SLVolumeItf self, SLmillibel *pLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVolume *thiz = (IVolume *) self;
- interface_lock_shared(thiz);
- SLmillibel level = thiz->mLevel;
- interface_unlock_shared(thiz);
- *pLevel = level;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_GetMaxVolumeLevel(SLVolumeItf self, SLmillibel *pMaxLevel)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMaxLevel) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- *pMaxLevel = PLATFORM_MILLIBEL_MAX_VOLUME;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_SetMute(SLVolumeItf self, SLboolean mute)
-{
- SL_ENTER_INTERFACE
-
- IVolume *thiz = (IVolume *) self;
- mute = SL_BOOLEAN_FALSE != mute; // normalize
- interface_lock_exclusive(thiz);
- SLboolean oldMute = thiz->mMute;
- if (oldMute != mute) {
- thiz->mMute = (SLuint8) mute;
- interface_unlock_exclusive_attributes(thiz, ATTR_GAIN);
- } else
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_GetMute(SLVolumeItf self, SLboolean *pMute)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pMute) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVolume *thiz = (IVolume *) self;
- interface_lock_shared(thiz);
- SLboolean mute = thiz->mMute;
- interface_unlock_shared(thiz);
- *pMute = mute;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_EnableStereoPosition(SLVolumeItf self, SLboolean enable)
-{
- SL_ENTER_INTERFACE
-
- IVolume *thiz = (IVolume *) self;
- enable = SL_BOOLEAN_FALSE != enable; // normalize
- interface_lock_exclusive(thiz);
- SLboolean oldEnable = thiz->mEnableStereoPosition;
- if (oldEnable != enable) {
- thiz->mEnableStereoPosition = (SLuint8) enable;
- interface_unlock_exclusive_attributes(thiz, ATTR_GAIN);
- } else {
- interface_unlock_exclusive(thiz);
- }
- result = SL_RESULT_SUCCESS;
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_IsEnabledStereoPosition(SLVolumeItf self, SLboolean *pEnable)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pEnable) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVolume *thiz = (IVolume *) self;
- interface_lock_shared(thiz);
- SLboolean enable = thiz->mEnableStereoPosition;
- interface_unlock_shared(thiz);
- *pEnable = enable;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_SetStereoPosition(SLVolumeItf self, SLpermille stereoPosition)
-{
- SL_ENTER_INTERFACE
-
- if (!((-1000 <= stereoPosition) && (1000 >= stereoPosition))) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVolume *thiz = (IVolume *) self;
- interface_lock_exclusive(thiz);
- SLpermille oldStereoPosition = thiz->mStereoPosition;
- if (oldStereoPosition != stereoPosition) {
- thiz->mStereoPosition = stereoPosition;
- interface_unlock_exclusive_attributes(thiz, ATTR_GAIN);
- } else
- interface_unlock_exclusive(thiz);
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static SLresult IVolume_GetStereoPosition(SLVolumeItf self, SLpermille *pStereoPosition)
-{
- SL_ENTER_INTERFACE
-
- if (NULL == pStereoPosition) {
- result = SL_RESULT_PARAMETER_INVALID;
- } else {
- IVolume *thiz = (IVolume *) self;
- interface_lock_shared(thiz);
- SLpermille stereoPosition = thiz->mStereoPosition;
- interface_unlock_shared(thiz);
- *pStereoPosition = stereoPosition;
- result = SL_RESULT_SUCCESS;
- }
-
- SL_LEAVE_INTERFACE
-}
-
-
-static const struct SLVolumeItf_ IVolume_Itf = {
- IVolume_SetVolumeLevel,
- IVolume_GetVolumeLevel,
- IVolume_GetMaxVolumeLevel,
- IVolume_SetMute,
- IVolume_GetMute,
- IVolume_EnableStereoPosition,
- IVolume_IsEnabledStereoPosition,
- IVolume_SetStereoPosition,
- IVolume_GetStereoPosition
-};
-
-void IVolume_init(void *self)
-{
- IVolume *thiz = (IVolume *) self;
- thiz->mItf = &IVolume_Itf;
- thiz->mLevel = 0;
- thiz->mMute = SL_BOOLEAN_FALSE;
- thiz->mEnableStereoPosition = SL_BOOLEAN_FALSE;
- thiz->mStereoPosition = 0;
-}
diff --git a/wilhelm/src/itfstruct.h b/wilhelm/src/itfstruct.h
deleted file mode 100644
index 8391c96..0000000
--- a/wilhelm/src/itfstruct.h
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifdef ANDROID
-#include "media/AudioEffect.h"
-#include "hardware/audio_effect.h"
-#endif
-
-/* Interface structures */
-
-typedef struct Object_interface {
- const struct SLObjectItf_ *mItf; // const
- // field mThis would be redundant within an IObject, so we substitute mEngine
- CEngine *mEngine; // const
- const ClassTable *mClass; // const
- SLuint32 mInstanceID; // const for debugger and for RPC, 0 means unpublished
- slObjectCallback mCallback;
- void *mContext;
- unsigned mGottenMask; ///< bit-mask of interfaces exposed or added, then gotten
- unsigned mLossOfControlMask; // interfaces with loss of control enabled
- unsigned mAttributesMask; // attributes which have changed since last sync
-#if USE_PROFILES & USE_PROFILES_BASE
- SLint32 mPriority;
-#endif
- pthread_mutex_t mMutex;
-#ifdef USE_DEBUG
- // Only keep the pthread_t, not the kernel tid, because pthread_self() is very fast
- // (typically just arithmetic on the stack pointer). But a gettid() is a kernel call
- // and so too slow to do every time a mutex is acquired. However, we can determine
- // the kernel tid from the pthread_t.
- pthread_t mOwner;
- const char *mFile;
- int mLine;
- volatile int32_t mGeneration; // read without a lock, incremented with a lock
-#endif
- pthread_cond_t mCond;
- SLuint8 mState; // really SLuint32, but SLuint8 to save space
-#if USE_PROFILES & USE_PROFILES_BASE
- SLuint8 mPreemptable; // really SLboolean, but SLuint8 to save space
-#else
- SLuint8 mPadding;
-#endif
- SLuint8 mStrongRefCount; // number of strong references to this object
- // (object cannot be destroyed as long as > 0, and referrers _prefer_ it stay in Realized state)
- // for best alignment, do not add any fields here
-#define INTERFACES_Default 1
- SLuint8 mInterfaceStates[INTERFACES_Default]; // state of each of interface
- // do not add any fields here
-} IObject;
-
-#include "locks.h"
-
-typedef struct {
- const struct SL3DCommitItf_ *mItf;
- IObject *mThis;
- SLboolean mDeferred;
- SLuint32 mGeneration; // incremented each master clock cycle
- SLuint32 mWaiting; // number of threads waiting in Commit
-} I3DCommit;
-
-enum CartesianSphericalActive {
- CARTESIAN_COMPUTED_SPHERICAL_SET,
- CARTESIAN_REQUESTED_SPHERICAL_SET,
- CARTESIAN_UNKNOWN_SPHERICAL_SET,
- CARTESIAN_SET_SPHERICAL_COMPUTED, // not in 1.0.1
- CARTESIAN_SET_SPHERICAL_REQUESTED, // not in 1.0.1
- CARTESIAN_SET_SPHERICAL_UNKNOWN
-};
-
-typedef struct {
- const struct SL3DDopplerItf_ *mItf;
- IObject *mThis;
- // The API allows client to specify either Cartesian and spherical velocities.
- // But an implementation will likely prefer one or the other. So for
- // maximum portablity, we maintain both units and an indication of which
- // unit was set most recently. In addition, we keep a flag saying whether
- // the other unit has been derived yet. It can take significant time
- // to compute the other unit, so this may be deferred to another thread.
- // For this reason we also keep an indication of whether the secondary
- // has been computed yet, and its accuracy.
- // Though only one unit is primary at a time, a union is inappropriate:
- // the application might read in both units (not in 1.0.1),
- // and due to multi-threading concerns.
- SLVec3D mVelocityCartesian;
- struct {
- SLmillidegree mAzimuth;
- SLmillidegree mElevation;
- SLmillidegree mSpeed;
- } mVelocitySpherical;
- enum CartesianSphericalActive mVelocityActive;
- SLpermille mDopplerFactor;
-} I3DDoppler;
-
-typedef struct {
- const struct SL3DGroupingItf_ *mItf;
- IObject *mThis;
- C3DGroup *mGroup; // strong reference to associated group or NULL
-} I3DGrouping;
-
-enum AnglesVectorsActive {
- ANGLES_COMPUTED_VECTORS_SET, // not in 1.0.1
- ANGLES_REQUESTED_VECTORS_SET, // not in 1.0.1
- ANGLES_UNKNOWN_VECTORS_SET,
- ANGLES_SET_VECTORS_COMPUTED,
- ANGLES_SET_VECTORS_REQUESTED,
- ANGLES_SET_VECTORS_UNKNOWN
-};
-
-typedef struct {
- const struct SL3DLocationItf_ *mItf;
- IObject *mThis;
- SLVec3D mLocationCartesian;
- struct {
- SLmillidegree mAzimuth;
- SLmillidegree mElevation;
- SLmillimeter mDistance;
- } mLocationSpherical;
- enum CartesianSphericalActive mLocationActive;
- struct {
- SLmillidegree mHeading;
- SLmillidegree mPitch;
- SLmillidegree mRoll;
- } mOrientationAngles;
- struct {
- SLVec3D mFront;
- SLVec3D mAbove;
- SLVec3D mUp;
- } mOrientationVectors;
- enum AnglesVectorsActive mOrientationActive;
- // Rotations can be slow, so are deferred.
- SLmillidegree mTheta;
- SLVec3D mAxis;
- SLboolean mRotatePending;
-} I3DLocation;
-
-typedef struct {
- const struct SL3DMacroscopicItf_ *mItf;
- IObject *mThis;
- struct {
- SLmillimeter mWidth;
- SLmillimeter mHeight;
- SLmillimeter mDepth;
- } mSize;
- struct {
- SLmillimeter mHeading;
- SLmillimeter mPitch;
- SLmillimeter mRoll;
- } mOrientationAngles;
- struct {
- SLVec3D mFront;
- SLVec3D mAbove;
- SLVec3D mUp;
- } mOrientationVectors;
- enum AnglesVectorsActive mOrientationActive;
- // Rotations can be slow, so are deferred.
- SLmillidegree mTheta;
- SLVec3D mAxis;
- SLboolean mRotatePending;
-} I3DMacroscopic;
-
-typedef struct {
- const struct SL3DSourceItf_ *mItf;
- IObject *mThis;
- SLboolean mHeadRelative;
- SLboolean mRolloffMaxDistanceMute;
- SLmillimeter mMaxDistance;
- SLmillimeter mMinDistance;
- SLmillidegree mConeInnerAngle;
- SLmillidegree mConeOuterAngle;
- SLmillibel mConeOuterLevel;
- SLpermille mRolloffFactor;
- SLpermille mRoomRolloffFactor;
- SLuint8 mDistanceModel;
-} I3DSource;
-
-typedef struct {
- const struct SLAudioDecoderCapabilitiesItf_ *mItf;
- IObject *mThis;
-} IAudioDecoderCapabilities;
-
-typedef struct {
- const struct SLAudioEncoderItf_ *mItf;
- IObject *mThis;
- SLAudioEncoderSettings mSettings;
-} IAudioEncoder;
-
-typedef struct {
- const struct SLAudioEncoderCapabilitiesItf_ *mItf;
- IObject *mThis;
-} IAudioEncoderCapabilities;
-
-typedef struct {
- const struct SLAudioIODeviceCapabilitiesItf_ *mItf;
- IObject *mThis;
- slAvailableAudioInputsChangedCallback mAvailableAudioInputsChangedCallback;
- void *mAvailableAudioInputsChangedContext;
- slAvailableAudioOutputsChangedCallback mAvailableAudioOutputsChangedCallback;
- void *mAvailableAudioOutputsChangedContext;
- slDefaultDeviceIDMapChangedCallback mDefaultDeviceIDMapChangedCallback;
- void *mDefaultDeviceIDMapChangedContext;
-} IAudioIODeviceCapabilities;
-
-typedef struct {
- const struct SLBassBoostItf_ *mItf;
- IObject *mThis;
- SLboolean mEnabled;
- SLpermille mStrength;
-#if defined(ANDROID)
- effect_descriptor_t mBassBoostDescriptor;
- android::sp<android::AudioEffect> mBassBoostEffect;
-#endif
-} IBassBoost;
-
-typedef struct BufferQueue_interface {
- const struct SLBufferQueueItf_ *mItf;
- IObject *mThis;
- SLBufferQueueState mState;
- slBufferQueueCallback mCallback;
- void *mContext;
- // originally SLuint32, but range-checked down to SLuint16
- SLuint16 mNumBuffers;
- /*SLboolean*/ SLuint16 mClearRequested;
- BufferHeader *mArray;
- BufferHeader *mFront, *mRear;
-#ifdef ANDROID
- SLuint32 mSizeConsumed;
-#endif
- // saves a malloc in the typical case
-#define BUFFER_HEADER_TYPICAL 4
- BufferHeader mTypical[BUFFER_HEADER_TYPICAL+1];
-} IBufferQueue;
-
-#define MAX_DEVICE 2 // hard-coded array size for default in/out
-
-typedef struct {
- const struct SLDeviceVolumeItf_ *mItf;
- IObject *mThis;
- SLint32 mVolume[MAX_DEVICE];
-} IDeviceVolume;
-
-typedef struct {
- const struct SLDynamicInterfaceManagementItf_ *mItf;
- IObject *mThis;
- slDynamicInterfaceManagementCallback mCallback;
- void *mContext;
-} IDynamicInterfaceManagement;
-
-typedef struct {
- const struct SLDynamicSourceItf_ *mItf;
- IObject *mThis;
- SLDataSource *mDataSource;
-} IDynamicSource;
-
-// private
-
-struct EnableLevel {
- SLboolean mEnable;
- SLmillibel mSendLevel;
-};
-
-// indexes into IEffectSend.mEnableLevels
-
-#define AUX_ENVIRONMENTALREVERB 0
-#define AUX_PRESETREVERB 1
-#define AUX_MAX 2
-
-typedef struct {
- const struct SLEffectSendItf_ *mItf;
- IObject *mThis;
- struct EnableLevel mEnableLevels[AUX_MAX]; // wet enable and volume per effect type
-} IEffectSend;
-
-typedef struct Engine_interface {
- const struct SLEngineItf_ *mItf;
- IObject *mThis;
- SLboolean mLossOfControlGlobal;
-#ifdef USE_SDL
- COutputMix *mOutputMix; // SDL pulls PCM from an arbitrary IOutputMixExt
-#endif
- // Each engine is its own universe.
- SLuint32 mInstanceCount;
- unsigned mInstanceMask; // 1 bit per active object
- unsigned mChangedMask; // objects which have changed since last sync
-#define MAX_INSTANCE 32 // maximum active objects per engine, see mInstanceMask
- IObject *mInstances[MAX_INSTANCE];
- SLboolean mShutdown;
- SLboolean mShutdownAck;
- // SLuint32 mVersion; // 0xXXYYZZ where XX=major, YY=minor, ZZ=step
-} IEngine;
-
-typedef struct {
- const struct SLEngineCapabilitiesItf_ *mItf;
- IObject *mThis;
- SLboolean mThreadSafe;
- // const
- SLuint32 mMaxIndexLED;
- SLuint32 mMaxIndexVibra;
-} IEngineCapabilities;
-
-typedef struct {
- const struct SLEnvironmentalReverbItf_ *mItf;
- IObject *mThis;
- SLEnvironmentalReverbSettings mProperties;
-#if defined(ANDROID)
- effect_descriptor_t mEnvironmentalReverbDescriptor;
- android::sp<android::AudioEffect> mEnvironmentalReverbEffect;
-#endif
-} IEnvironmentalReverb;
-
-struct EqualizerBand {
- SLmilliHertz mMin;
- SLmilliHertz mCenter;
- SLmilliHertz mMax;
-};
-
-#if defined(ANDROID)
-#define MAX_EQ_BANDS 0
-#else
-#define MAX_EQ_BANDS 4 // compile-time limit, runtime limit may be smaller
-#endif
-
-typedef struct {
- const struct SLEqualizerItf_ *mItf;
- IObject *mThis;
- SLboolean mEnabled;
- SLuint16 mPreset;
-#if 0 < MAX_EQ_BANDS
- SLmillibel mLevels[MAX_EQ_BANDS];
-#endif
- // const to end of struct
- SLuint16 mNumPresets;
- SLuint16 mNumBands;
-#if !defined(ANDROID)
- const struct EqualizerBand *mBands;
- const struct EqualizerPreset *mPresets;
-#endif
- SLmillibel mBandLevelRangeMin;
- SLmillibel mBandLevelRangeMax;
-#if defined(ANDROID)
- effect_descriptor_t mEqDescriptor;
- android::sp<android::AudioEffect> mEqEffect;
-#endif
-} IEqualizer;
-
-#define MAX_LED_COUNT 32
-
-typedef struct {
- const struct SLLEDArrayItf_ *mItf;
- IObject *mThis;
- SLuint32 mLightMask;
- SLHSL mColors[MAX_LED_COUNT];
- // const
- SLuint8 mCount;
-} ILEDArray;
-
-typedef struct {
- const struct SLMetadataExtractionItf_ *mItf;
- IObject *mThis;
- SLuint32 mKeySize;
- const void *mKey;
- SLuint32 mKeyEncoding;
- const SLchar *mValueLangCountry;
- SLuint32 mValueEncoding;
- SLuint8 mFilterMask;
- int mKeyFilter;
-} IMetadataExtraction;
-
-typedef struct {
- const struct SLMetadataTraversalItf_ *mItf;
- IObject *mThis;
- SLuint32 mIndex;
- SLuint32 mMode;
- SLuint32 mCount;
- SLuint32 mSize;
-} IMetadataTraversal;
-
-typedef struct {
- const struct SLMIDIMessageItf_ *mItf;
- IObject *mThis;
- slMetaEventCallback mMetaEventCallback;
- void *mMetaEventContext;
- slMIDIMessageCallback mMessageCallback;
- void *mMessageContext;
- SLuint8 mMessageTypes;
-} IMIDIMessage;
-
-typedef struct {
- const struct SLMIDIMuteSoloItf_ *mItf;
- IObject *mThis;
- SLuint16 mChannelMuteMask;
- SLuint16 mChannelSoloMask;
- SLuint32 mTrackMuteMask;
- SLuint32 mTrackSoloMask;
- // const
- SLuint16 mTrackCount;
-} IMIDIMuteSolo;
-
-typedef struct {
- const struct SLMIDITempoItf_ *mItf;
- IObject *mThis;
- SLuint32 mTicksPerQuarterNote;
- SLuint32 mMicrosecondsPerQuarterNote;
-} IMIDITempo;
-
-typedef struct {
- const struct SLMIDITimeItf_ *mItf;
- IObject *mThis;
- SLuint32 mDuration;
- SLuint32 mPosition;
- SLuint32 mStartTick;
- SLuint32 mNumTicks;
-} IMIDITime;
-
-typedef struct {
- const struct SLMuteSoloItf_ *mItf;
- IObject *mThis;
- // fields that were formerly here are now at CAudioPlayer
-} IMuteSolo;
-
-#define MAX_TRACK 32 // see mActiveMask
-
-typedef struct {
- const struct SLOutputMixItf_ *mItf;
- IObject *mThis;
- slMixDeviceChangeCallback mCallback;
- void *mContext;
-} IOutputMix;
-
-#ifdef USE_OUTPUTMIXEXT
-typedef struct {
- const struct SLOutputMixExtItf_ *mItf;
- IObject *mThis;
- unsigned mActiveMask; // 1 bit per active track
- Track mTracks[MAX_TRACK];
- SLboolean mDestroyRequested; ///< Mixer to acknowledge application's call to Object::Destroy
-} IOutputMixExt;
-#endif
-
-typedef struct {
- const struct SLPitchItf_ *mItf;
- IObject *mThis;
- SLpermille mPitch;
- // const
- SLpermille mMinPitch;
- SLpermille mMaxPitch;
-} IPitch;
-
-typedef struct Play_interface {
- const struct SLPlayItf_ *mItf;
- IObject *mThis;
- SLuint32 mState;
- // next 2 fields are read-only to application
- SLmillisecond mDuration;
- SLmillisecond mPosition;
- slPlayCallback mCallback;
- void *mContext;
- SLuint32 mEventFlags;
- // the ISeek trick of using a distinct value doesn't work here because it's readable by app
- SLmillisecond mMarkerPosition;
- SLmillisecond mPositionUpdatePeriod; // Zero means do not do position updates (FIXME ~0)
-#ifdef USE_OUTPUTMIXEXT
- SLuint32 mFrameUpdatePeriod; // mPositionUpdatePeriod in frame units
- SLmillisecond mLastSeekPosition; // Last known accurate position, set at Seek
- SLuint32 mFramesSinceLastSeek; // Frames mixed since last known accurate position
- SLuint32 mFramesSincePositionUpdate; // Frames mixed since last position update callback
-#endif
-} IPlay;
-
-typedef struct {
- const struct SLPlaybackRateItf_ *mItf;
- IObject *mThis;
- SLpermille mRate;
- SLuint32 mProperties;
- // const after initialization
- SLpermille mMinRate;
- SLpermille mMaxRate;
- SLpermille mStepSize;
- SLuint32 mCapabilities;
-} IPlaybackRate;
-
-typedef struct {
- const struct SLPrefetchStatusItf_ *mItf;
- IObject *mThis;
- SLuint32 mStatus;
- SLpermille mLevel;
- slPrefetchCallback mCallback;
- void *mContext;
- SLuint32 mCallbackEventsMask;
- SLpermille mFillUpdatePeriod;
-#ifdef ANDROID
- /** FIXME used to call PrefetchStatus callback with object unlocked prior to return from API */
- slPrefetchCallback mDeferredPrefetchCallback;
- void *mDeferredPrefetchContext;
- SLuint32 mDeferredPrefetchEvents;
-#endif
-} IPrefetchStatus;
-
-typedef struct {
- const struct SLPresetReverbItf_ *mItf;
- IObject *mThis;
- SLuint16 mPreset;
-#if defined(ANDROID)
- effect_descriptor_t mPresetReverbDescriptor;
- android::sp<android::AudioEffect> mPresetReverbEffect;
-#endif
-} IPresetReverb;
-
-typedef struct {
- const struct SLRatePitchItf_ *mItf;
- IObject *mThis;
- SLpermille mRate;
- // const
- SLpermille mMinRate;
- SLpermille mMaxRate;
-} IRatePitch;
-
-typedef struct {
- const struct SLRecordItf_ *mItf;
- IObject *mThis;
- SLuint32 mState;
- SLmillisecond mDurationLimit;
- SLmillisecond mPosition;
- slRecordCallback mCallback;
- void *mContext;
- SLuint32 mCallbackEventsMask;
- SLmillisecond mMarkerPosition;
- SLmillisecond mPositionUpdatePeriod;
-} IRecord;
-
-typedef struct {
- const struct SLSeekItf_ *mItf;
- IObject *mThis;
- SLmillisecond mPos; // mPos != SL_TIME_UNKNOWN means pending seek request
- SLboolean mLoopEnabled;
- SLmillisecond mStartPos;
- SLmillisecond mEndPos;
-} ISeek;
-
-typedef struct {
- const struct SLThreadSyncItf_ *mItf;
- IObject *mThis;
- SLboolean mInCriticalSection;
- SLuint32 mWaiting; // number of threads waiting
- pthread_t mOwner;
-} IThreadSync;
-
-typedef struct {
- const struct SLVibraItf_ *mItf;
- IObject *mThis;
- SLboolean mVibrate;
- SLmilliHertz mFrequency;
- SLpermille mIntensity;
-} IVibra;
-
-typedef struct {
- const struct SLVirtualizerItf_ *mItf;
- IObject *mThis;
- SLboolean mEnabled;
- SLpermille mStrength;
-#if defined(ANDROID)
- effect_descriptor_t mVirtualizerDescriptor;
- android::sp<android::AudioEffect> mVirtualizerEffect;
-#endif
-} IVirtualizer;
-
-typedef struct {
- const struct SLVisualizationItf_ *mItf;
- IObject *mThis;
- slVisualizationCallback mCallback;
- void *mContext;
- SLmilliHertz mRate;
-} IVisualization;
-
-typedef struct /*Volume_interface*/ {
- const struct SLVolumeItf_ *mItf;
- IObject *mThis;
- // Values as specified by the application
- SLmillibel mLevel;
- SLpermille mStereoPosition;
- SLuint8 /*SLboolean*/ mMute;
- SLuint8 /*SLboolean*/ mEnableStereoPosition;
-} IVolume;
-
-typedef struct {
- const struct XAEngineItf_ *mItf;
- IObject *mThis;
-} IXAEngine;
-
-#define NB_SUPPORTED_STREAMS 1 // only one (video) stream supported in this implementation
-typedef struct {
- const struct XAStreamInformationItf_ *mItf;
- IObject *mThis;
- xaStreamEventChangeCallback mCallback;
- void *mContext;
- XAboolean mActiveStreams[NB_SUPPORTED_STREAMS];
-#ifdef ANDROID
- android::Vector<StreamInfo> mStreamInfoTable;
-#endif
-} IStreamInformation;
-
-typedef struct {
- const struct XAVideoDecoderCapabilitiesItf_ *mItf;
- IObject *mThis;
-} IVideoDecoderCapabilities;
-
-/* Class structures */
-
-/*typedef*/ struct C3DGroup_struct {
- IObject mObject;
-#define INTERFACES_3DGroup 6 // see MPH_to_3DGroup in MPH_to.c for list of interfaces
- SLuint8 mInterfaceStates2[INTERFACES_3DGroup - INTERFACES_Default];
- IDynamicInterfaceManagement mDynamicInterfaceManagement;
- I3DLocation m3DLocation;
- I3DDoppler m3DDoppler;
- I3DSource m3DSource;
- I3DMacroscopic m3DMacroscopic;
- // remaining are per-instance private fields not associated with an interface
- unsigned mMemberMask; // set of member objects
-} /*C3DGroup*/;
-
-#ifdef ANDROID
-
-// FIXME Move these into the I... section above
-
-typedef struct {
- const struct SLAndroidEffectItf_ *mItf;
- IObject *mThis;
- android::KeyedVector<SLuint32, android::AudioEffect* > *mEffects;
-} IAndroidEffect;
-
-typedef struct {
- const struct SLAndroidEffectCapabilitiesItf_ *mItf;
- IObject *mThis;
- SLuint32 mNumFx;
- effect_descriptor_t* mFxDescriptors;
-} IAndroidEffectCapabilities;
-
-typedef struct {
- const struct SLAndroidEffectSendItf_ *mItf;
- IObject *mThis;
- // only one send per interface for now (1 bus)
- SLboolean mEnabled;
- SLmillibel mSendLevel; //android::KeyedVector<SLuint32, SLmillibel> mSendLevels;
-} IAndroidEffectSend;
-
-typedef struct {
- const struct SLAndroidConfigurationItf_ *mItf;
- IObject *mThis;
-} IAndroidConfiguration;
-
-typedef struct {
- const struct SLAndroidBufferQueueItf_ *mItf;
- IObject *mThis;
- SLAndroidBufferQueueState mState;
- slAndroidBufferQueueCallback mCallback;
- SLuint32 mCallbackEventsMask;
- void *mContext;
- SLuint16 mNumBuffers;
- AndroidBufferType_type mBufferType;
- AdvancedBufferHeader *mBufferArray;
- AdvancedBufferHeader *mFront, *mRear;
-} IAndroidBufferQueue;
-
-#endif
diff --git a/wilhelm/src/locks.c b/wilhelm/src/locks.c
deleted file mode 100644
index 743d4a9..0000000
--- a/wilhelm/src/locks.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-#include <bionic_pthread.h>
-
-
-// Use this macro to validate a pthread_t before passing it into __pthread_gettid.
-// One of the common reasons for deadlock is trying to lock a mutex for an object
-// which has been destroyed (which does memset to 0x00 or 0x55 as the final step).
-// To avoid crashing with a SIGSEGV right before we're about to log a deadlock warning,
-// we check that the pthread_t is probably valid. Note that it is theoretically
-// possible for something to look like a valid pthread_t but not actually be valid.
-// So we might still crash, but only in the case where a deadlock was imminent anyway.
-#define LIKELY_VALID(ptr) (((ptr) != (pthread_t) 0) && ((((size_t) (ptr)) & 3) == 0))
-
-
-/** \brief Exclusively lock an object */
-
-#ifdef USE_DEBUG
-void object_lock_exclusive_(IObject *thiz, const char *file, int line)
-{
- int ok;
- ok = pthread_mutex_trylock(&thiz->mMutex);
- if (0 != ok) {
- // not android_atomic_acquire_load because we don't care about relative load/load ordering
- int32_t oldGeneration = thiz->mGeneration;
- // wait up to a total of 250 ms
- static const unsigned backoffs[] = {10, 20, 30, 40, 50, 100};
- unsigned i = 0;
- for (;;) {
- // the Android version is in ms not timespec, and isn't named pthread_mutex_timedlock_np
- ok = pthread_mutex_lock_timeout_np(&thiz->mMutex, backoffs[i]);
- if (0 == ok) {
- break;
- }
- if (EBUSY == ok) {
- // this is the expected return value for timeout, and will be handled below
- } else if (EDEADLK == ok) {
- // we don't use the kind of mutex that can return this error, but just in case
- SL_LOGE("%s:%d: recursive lock detected", file, line);
- } else {
- // some other return value
- SL_LOGE("%s:%d: pthread_mutex_lock_timeout_np returned %d", file, line, ok);
- }
- // is anyone else making forward progress?
- int32_t newGeneration = thiz->mGeneration;
- if (newGeneration != oldGeneration) {
- // if we ever see forward progress then lock without timeout (more efficient)
- goto forward_progress;
- }
- // no, then continue trying to lock but with increasing timeouts
- if (++i >= (sizeof(backoffs) / sizeof(backoffs[0]))) {
- // the extra block avoids a C++ compiler error about goto past initialization
- {
- pthread_t me = pthread_self();
- pthread_t owner = thiz->mOwner;
- // unlikely, but this could result in a memory fault if owner is corrupt
- pid_t ownerTid = LIKELY_VALID(owner) ? __pthread_gettid(owner) : -1;
- SL_LOGW("%s:%d: pthread %p (tid %d) sees object %p was locked by pthread %p"
- " (tid %d) at %s:%d\n", file, line, *(void **)&me, gettid(), thiz,
- *(void **)&owner, ownerTid, thiz->mFile, thiz->mLine);
- }
-forward_progress:
- // attempt one more time without timeout; maybe this time we will be successful
- ok = pthread_mutex_lock(&thiz->mMutex);
- assert(0 == ok);
- break;
- }
- }
- }
- // here if mutex was successfully locked
- pthread_t zero;
- memset(&zero, 0, sizeof(pthread_t));
- if (0 != memcmp(&zero, &thiz->mOwner, sizeof(pthread_t))) {
- pthread_t me = pthread_self();
- pthread_t owner = thiz->mOwner;
- pid_t ownerTid = LIKELY_VALID(owner) ? __pthread_gettid(owner) : -1;
- if (pthread_equal(pthread_self(), owner)) {
- SL_LOGE("%s:%d: pthread %p (tid %d) sees object %p was recursively locked by pthread"
- " %p (tid %d) at %s:%d\n", file, line, *(void **)&me, gettid(), thiz,
- *(void **)&owner, ownerTid, thiz->mFile, thiz->mLine);
- } else {
- SL_LOGE("%s:%d: pthread %p (tid %d) sees object %p was left unlocked in unexpected"
- " state by pthread %p (tid %d) at %s:%d\n", file, line, *(void **)&me, gettid(),
- thiz, *(void **)&owner, ownerTid, thiz->mFile, thiz->mLine);
- }
- assert(false);
- }
- thiz->mOwner = pthread_self();
- thiz->mFile = file;
- thiz->mLine = line;
- // not android_atomic_inc because we are already holding a mutex
- ++thiz->mGeneration;
-}
-#else
-void object_lock_exclusive(IObject *thiz)
-{
- int ok;
- ok = pthread_mutex_lock(&thiz->mMutex);
- assert(0 == ok);
-}
-#endif
-
-
-/** \brief Exclusively unlock an object and do not report any updates */
-
-#ifdef USE_DEBUG
-void object_unlock_exclusive_(IObject *thiz, const char *file, int line)
-{
- assert(pthread_equal(pthread_self(), thiz->mOwner));
- assert(NULL != thiz->mFile);
- assert(0 != thiz->mLine);
- memset(&thiz->mOwner, 0, sizeof(pthread_t));
- thiz->mFile = file;
- thiz->mLine = line;
- int ok;
- ok = pthread_mutex_unlock(&thiz->mMutex);
- assert(0 == ok);
-}
-#else
-void object_unlock_exclusive(IObject *thiz)
-{
- int ok;
- ok = pthread_mutex_unlock(&thiz->mMutex);
- assert(0 == ok);
-}
-#endif
-
-
-/** \brief Exclusively unlock an object and report updates to the specified bit-mask of
- * attributes
- */
-
-#ifdef USE_DEBUG
-void object_unlock_exclusive_attributes_(IObject *thiz, unsigned attributes,
- const char *file, int line)
-#else
-void object_unlock_exclusive_attributes(IObject *thiz, unsigned attributes)
-#endif
-{
-
-#ifdef USE_DEBUG
- assert(pthread_equal(pthread_self(), thiz->mOwner));
- assert(NULL != thiz->mFile);
- assert(0 != thiz->mLine);
-#endif
-
- int ok;
-
- // make SL object IDs be contiguous with XA object IDs
- SLuint32 objectID = IObjectToObjectID(thiz);
- SLuint32 index = objectID;
- if ((XA_OBJECTID_ENGINE <= index) && (index <= XA_OBJECTID_CAMERADEVICE)) {
- ;
- } else if ((SL_OBJECTID_ENGINE <= index) && (index <= SL_OBJECTID_METADATAEXTRACTOR)) {
- index -= SL_OBJECTID_ENGINE - XA_OBJECTID_CAMERADEVICE - 1;
- } else {
- assert(false);
- index = 0;
- }
-
- // first synchronously handle updates to attributes here, while object is still locked.
- // This appears to be a loop, but actually typically runs through the loop only once.
- unsigned asynchronous = attributes;
- while (attributes) {
- // this sequence is carefully crafted to be O(1); tread carefully when making changes
- unsigned bit = ctz(attributes);
- // ATTR_INDEX_MAX == next bit position after the last attribute
- assert(ATTR_INDEX_MAX > bit);
- // compute the entry in the handler table using object ID and bit number
- AttributeHandler handler = handlerTable[index][bit];
- if (NULL != handler) {
- asynchronous &= ~(*handler)(thiz);
- }
- attributes &= ~(1 << bit);
- }
-
- // any remaining attributes are handled asynchronously in the sync thread
- if (asynchronous) {
- unsigned oldAttributesMask = thiz->mAttributesMask;
- thiz->mAttributesMask = oldAttributesMask | asynchronous;
- if (oldAttributesMask) {
- asynchronous = ATTR_NONE;
- }
- }
-
-#ifdef ANDROID
- // FIXME hack to safely handle a post-unlock PrefetchStatus callback and/or AudioTrack::start()
- slPrefetchCallback prefetchCallback = NULL;
- void *prefetchContext = NULL;
- SLuint32 prefetchEvents = SL_PREFETCHEVENT_NONE;
- android::sp<android::AudioTrackProxy> audioTrack;
- if (SL_OBJECTID_AUDIOPLAYER == objectID) {
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- prefetchCallback = ap->mPrefetchStatus.mDeferredPrefetchCallback;
- prefetchContext = ap->mPrefetchStatus.mDeferredPrefetchContext;
- prefetchEvents = ap->mPrefetchStatus.mDeferredPrefetchEvents;
- ap->mPrefetchStatus.mDeferredPrefetchCallback = NULL;
- // clearing these next two fields is not required, but avoids stale data during debugging
- ap->mPrefetchStatus.mDeferredPrefetchContext = NULL;
- ap->mPrefetchStatus.mDeferredPrefetchEvents = SL_PREFETCHEVENT_NONE;
- if (ap->mDeferredStart) {
- audioTrack = ap->mAudioTrack;
- ap->mDeferredStart = false;
- }
- }
-#endif
-
-#ifdef USE_DEBUG
- memset(&thiz->mOwner, 0, sizeof(pthread_t));
- thiz->mFile = file;
- thiz->mLine = line;
-#endif
- ok = pthread_mutex_unlock(&thiz->mMutex);
- assert(0 == ok);
-
-#ifdef ANDROID
- // FIXME call the prefetch status callback while not holding the mutex on AudioPlayer
- if (NULL != prefetchCallback) {
- // note these are synchronous by the application's thread as it is about to return from API
- assert(prefetchEvents != SL_PREFETCHEVENT_NONE);
- CAudioPlayer *ap = (CAudioPlayer *) thiz;
- // spec requires separate callbacks for each event
- if (SL_PREFETCHEVENT_STATUSCHANGE & prefetchEvents) {
- (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
- SL_PREFETCHEVENT_STATUSCHANGE);
- }
- if (SL_PREFETCHEVENT_FILLLEVELCHANGE & prefetchEvents) {
- (*prefetchCallback)(&ap->mPrefetchStatus.mItf, prefetchContext,
- SL_PREFETCHEVENT_FILLLEVELCHANGE);
- }
- }
-
- // call AudioTrack::start() while not holding the mutex on AudioPlayer
- if (audioTrack != 0) {
- audioTrack->start();
- audioTrack.clear();
- }
-#endif
-
- // first update to this interface since previous sync
- if (ATTR_NONE != asynchronous) {
- unsigned id = thiz->mInstanceID;
- if (0 != id) {
- --id;
- assert(MAX_INSTANCE > id);
- IEngine *thisEngine = &thiz->mEngine->mEngine;
- // FIXME atomic or here
- interface_lock_exclusive(thisEngine);
- thisEngine->mChangedMask |= 1 << id;
- interface_unlock_exclusive(thisEngine);
- }
- }
-
-}
-
-
-/** \brief Wait on the condition variable associated with the object; see pthread_cond_wait */
-
-#ifdef USE_DEBUG
-void object_cond_wait_(IObject *thiz, const char *file, int line)
-{
- // note that this will unlock the mutex, so we have to clear the owner
- assert(pthread_equal(pthread_self(), thiz->mOwner));
- assert(NULL != thiz->mFile);
- assert(0 != thiz->mLine);
- memset(&thiz->mOwner, 0, sizeof(pthread_t));
- thiz->mFile = file;
- thiz->mLine = line;
- // alas we don't know the new owner's identity
- int ok;
- ok = pthread_cond_wait(&thiz->mCond, &thiz->mMutex);
- assert(0 == ok);
- // restore my ownership
- thiz->mOwner = pthread_self();
- thiz->mFile = file;
- thiz->mLine = line;
-}
-#else
-void object_cond_wait(IObject *thiz)
-{
- int ok;
- ok = pthread_cond_wait(&thiz->mCond, &thiz->mMutex);
- assert(0 == ok);
-}
-#endif
-
-
-/** \brief Signal the condition variable associated with the object; see pthread_cond_signal */
-
-void object_cond_signal(IObject *thiz)
-{
- int ok;
- ok = pthread_cond_signal(&thiz->mCond);
- assert(0 == ok);
-}
-
-
-/** \brief Broadcast the condition variable associated with the object;
- * see pthread_cond_broadcast
- */
-
-void object_cond_broadcast(IObject *thiz)
-{
- int ok;
- ok = pthread_cond_broadcast(&thiz->mCond);
- assert(0 == ok);
-}
diff --git a/wilhelm/src/locks.h b/wilhelm/src/locks.h
deleted file mode 100644
index eed3dcc..0000000
--- a/wilhelm/src/locks.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file locks.h Mutual exclusion and condition variables */
-
-#ifdef USE_DEBUG
-extern void object_lock_exclusive_(IObject *thiz, const char *file, int line);
-extern void object_unlock_exclusive_(IObject *thiz, const char *file, int line);
-extern void object_unlock_exclusive_attributes_(IObject *thiz, unsigned attr,
- const char *file, int line);
-extern void object_cond_wait_(IObject *thiz, const char *file, int line);
-#else
-extern void object_lock_exclusive(IObject *thiz);
-extern void object_unlock_exclusive(IObject *thiz);
-extern void object_unlock_exclusive_attributes(IObject *thiz, unsigned attr);
-extern void object_cond_wait(IObject *thiz);
-#endif
-extern void object_cond_signal(IObject *thiz);
-extern void object_cond_broadcast(IObject *thiz);
-
-#ifdef USE_DEBUG
-#define object_lock_exclusive(thiz) object_lock_exclusive_((thiz), __FILE__, __LINE__)
-#define object_unlock_exclusive(thiz) object_unlock_exclusive_((thiz), __FILE__, __LINE__)
-#define object_unlock_exclusive_attributes(thiz, attr) \
- object_unlock_exclusive_attributes_((thiz), (attr), __FILE__, __LINE__)
-#define object_cond_wait(thiz) object_cond_wait_((thiz), __FILE__, __LINE__)
-#endif
-
-// Currently shared locks are implemented as exclusive, but don't count on it
-
-#define object_lock_shared(thiz) object_lock_exclusive(thiz)
-#define object_unlock_shared(thiz) object_unlock_exclusive(thiz)
-
-// Currently interface locks are actually on whole object, but don't count on it.
-// These operations are undefined on IObject, as it lacks an mThis.
-// If you have an IObject, then use the object_ functions instead.
-
-#define interface_lock_exclusive(thiz) object_lock_exclusive(InterfaceToIObject(thiz))
-#define interface_unlock_exclusive(thiz) object_unlock_exclusive(InterfaceToIObject(thiz))
-#define interface_unlock_exclusive_attributes(thiz, attr) \
- object_unlock_exclusive_attributes(InterfaceToIObject(thiz), (attr))
-#define interface_lock_shared(thiz) object_lock_shared(InterfaceToIObject(thiz))
-#define interface_unlock_shared(thiz) object_unlock_shared(InterfaceToIObject(thiz))
-#define interface_cond_wait(thiz) object_cond_wait(InterfaceToIObject(thiz))
-#define interface_cond_signal(thiz) object_cond_signal(InterfaceToIObject(thiz))
-#define interface_cond_broadcast(thiz) object_cond_broadcast(InterfaceToIObject(thiz))
-
-// Peek and poke are an optimization for small atomic fields that don't "matter".
-// Don't use for struct, as struct copy might not be atomic.
-// On uniprocessor they can be no-ops, on SMP they could be memory barriers but locks are easier.
-
-#define object_lock_peek(thiz) object_lock_shared(thiz)
-#define object_unlock_peek(thiz) object_unlock_shared(thiz)
-#define interface_lock_poke(thiz) interface_lock_exclusive(thiz)
-#define interface_unlock_poke(thiz) interface_unlock_exclusive(thiz)
-#define interface_lock_peek(thiz) interface_lock_shared(thiz)
-#define interface_unlock_peek(thiz) interface_unlock_shared(thiz)
diff --git a/wilhelm/src/objects/C3DGroup.c b/wilhelm/src/objects/C3DGroup.c
deleted file mode 100644
index ad3afee..0000000
--- a/wilhelm/src/objects/C3DGroup.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file C3DGroup.c C3DGroup class */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Hook called by Object::Destroy before a 3D group is about to be destroyed */
-
-predestroy_t C3DGroup_PreDestroy(void *self)
-{
- C3DGroup *thiz = (C3DGroup *) self;
- // See design document for explanation
- if (0 == thiz->mMemberMask) {
- return predestroy_ok;
- }
- SL_LOGE("Object::Destroy(%p) for 3DGroup ignored; mMemberMask=0x%x", thiz, thiz->mMemberMask);
- return predestroy_error;
-}
diff --git a/wilhelm/src/objects/CAudioPlayer.c b/wilhelm/src/objects/CAudioPlayer.c
deleted file mode 100644
index dcad95a..0000000
--- a/wilhelm/src/objects/CAudioPlayer.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file CAudioPlayer.c AudioPlayer class */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Hook called by Object::Realize when an audio player is realized */
-
-SLresult CAudioPlayer_Realize(void *self, SLboolean async)
-{
- CAudioPlayer *thiz = (CAudioPlayer *) self;
- SLresult result = SL_RESULT_SUCCESS;
-
-#ifdef ANDROID
- result = android_audioPlayer_realize(thiz, async);
-#endif
-
-#ifdef USE_SNDFILE
- result = SndFile_Realize(thiz);
-#endif
-
- // At this point the channel count and sample rate might still be unknown,
- // depending on the data source and the platform implementation.
- // If they are unknown here, then they will be determined during prefetch.
-
- return result;
-}
-
-
-/** \brief Hook called by Object::Resume when an audio player is resumed */
-
-SLresult CAudioPlayer_Resume(void *self, SLboolean async)
-{
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Hook called by Object::Destroy when an audio player is destroyed */
-
-void CAudioPlayer_Destroy(void *self)
-{
- CAudioPlayer *thiz = (CAudioPlayer *) self;
-#ifdef ANDROID
- android_audioPlayer_destroy(thiz);
-#endif
- freeDataLocatorFormat(&thiz->mDataSource);
- freeDataLocatorFormat(&thiz->mDataSink);
-#ifdef USE_SNDFILE
- SndFile_Destroy(thiz);
-#endif
-}
-
-
-/** \brief Hook called by Object::Destroy before an audio player is about to be destroyed */
-
-predestroy_t CAudioPlayer_PreDestroy(void *self)
-{
- CAudioPlayer *thiz = (CAudioPlayer *) self;
-#ifdef ANDROID
- android_audioPlayer_preDestroy(thiz);
-#endif
-
-#ifdef USE_OUTPUTMIXEXT
- // Safe to proceed immediately if a track has not yet been assigned
- Track *track = thiz->mTrack;
- if (NULL == track) {
- return predestroy_ok;
- }
- CAudioPlayer *audioPlayer = track->mAudioPlayer;
- if (NULL == audioPlayer) {
- return predestroy_ok;
- }
- assert(audioPlayer == thiz);
- // Request the mixer thread to unlink this audio player's track
- thiz->mDestroyRequested = true;
- while (thiz->mDestroyRequested) {
- object_cond_wait(self);
- }
- // Mixer thread has acknowledged the request
-#endif
- return predestroy_ok;
-}
-
-
-/** \brief Given an audio player, return its data sink, which is guaranteed to be a non-NULL output
- * mix. This function is used by effect send.
- */
-
-COutputMix *CAudioPlayer_GetOutputMix(CAudioPlayer *audioPlayer)
-{
- assert(NULL != audioPlayer);
- assert(SL_DATALOCATOR_OUTPUTMIX == audioPlayer->mDataSink.mLocator.mLocatorType);
- SLObjectItf outputMix = audioPlayer->mDataSink.mLocator.mOutputMix.outputMix;
- assert(NULL != outputMix);
- return (COutputMix *) outputMix;
-}
diff --git a/wilhelm/src/objects/CAudioRecorder.c b/wilhelm/src/objects/CAudioRecorder.c
deleted file mode 100644
index 956e987..0000000
--- a/wilhelm/src/objects/CAudioRecorder.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* \file CAudioRecorder.c AudioRecorder class */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Hook called by Object::Realize when an audio recorder is realized */
-
-SLresult CAudioRecorder_Realize(void *self, SLboolean async)
-{
- SLresult result = SL_RESULT_SUCCESS;
-
-#ifdef ANDROID
- CAudioRecorder *thiz = (CAudioRecorder *) self;
- result = android_audioRecorder_realize(thiz, async);
-#endif
-
- return result;
-}
-
-
-/** \brief Hook called by Object::Resume when an audio recorder is resumed */
-
-SLresult CAudioRecorder_Resume(void *self, SLboolean async)
-{
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Hook called by Object::Destroy when an audio recorder is destroyed */
-
-void CAudioRecorder_Destroy(void *self)
-{
- CAudioRecorder *thiz = (CAudioRecorder *) self;
- freeDataLocatorFormat(&thiz->mDataSource);
- freeDataLocatorFormat(&thiz->mDataSink);
-#ifdef ANDROID
- android_audioRecorder_destroy(thiz);
-#endif
-}
-
-
-/** \brief Hook called by Object::Destroy before an audio recorder is about to be destroyed */
-
-predestroy_t CAudioRecorder_PreDestroy(void *self)
-{
- return predestroy_ok;
-}
diff --git a/wilhelm/src/objects/CEngine.c b/wilhelm/src/objects/CEngine.c
deleted file mode 100644
index c7c5b42..0000000
--- a/wilhelm/src/objects/CEngine.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file CEngine.c Engine class */
-
-#include "sles_allinclusive.h"
-
-
-/* This implementation supports at most one engine, identical for both OpenSL ES and OpenMAX AL */
-
-CEngine *theOneTrueEngine = NULL;
-pthread_mutex_t theOneTrueMutex = PTHREAD_MUTEX_INITIALIZER;
-unsigned theOneTrueRefCount = 0;
-// incremented by slCreateEngine or xaCreateEngine, decremented by Object::Destroy on engine
-
-
-/** \brief Called by dlopen when .so is loaded */
-
-__attribute__((constructor)) static void onDlOpen(void)
-{
-}
-
-
-/** \brief Called by dlclose when .so is unloaded */
-
-__attribute__((destructor)) static void onDlClose(void)
-{
- // a memory barrier would be sufficient, but the mutex is easier
- (void) pthread_mutex_lock(&theOneTrueMutex);
- if ((NULL != theOneTrueEngine) || (0 < theOneTrueRefCount)) {
- SL_LOGE("Object::Destroy omitted for engine %p", theOneTrueEngine);
- }
- (void) pthread_mutex_unlock(&theOneTrueMutex);
-}
-
-
-/** \brief Hook called by Object::Realize when an engine is realized */
-
-SLresult CEngine_Realize(void *self, SLboolean async)
-{
- CEngine *thiz = (CEngine *) self;
- SLresult result;
-#ifndef ANDROID
- // create the sync thread
- int err = pthread_create(&thiz->mSyncThread, (const pthread_attr_t *) NULL, sync_start, thiz);
- result = err_to_result(err);
- if (SL_RESULT_SUCCESS != result)
- return result;
-#endif
- // initialize the thread pool for asynchronous operations
- result = ThreadPool_init(&thiz->mThreadPool, 0, 0);
- if (SL_RESULT_SUCCESS != result) {
- thiz->mEngine.mShutdown = SL_BOOLEAN_TRUE;
- (void) pthread_join(thiz->mSyncThread, (void **) NULL);
- return result;
- }
-#ifdef USE_SDL
- SDL_open(&thiz->mEngine);
-#endif
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Hook called by Object::Resume when an engine is resumed */
-
-SLresult CEngine_Resume(void *self, SLboolean async)
-{
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Hook called by Object::Destroy when an engine is destroyed */
-
-void CEngine_Destroy(void *self)
-{
- CEngine *thiz = (CEngine *) self;
-
- // Verify that there are no extant objects
- unsigned instanceCount = thiz->mEngine.mInstanceCount;
- unsigned instanceMask = thiz->mEngine.mInstanceMask;
- if ((0 < instanceCount) || (0 != instanceMask)) {
- SL_LOGE("Object::Destroy(%p) for engine ignored; %u total active objects",
- thiz, instanceCount);
- while (0 != instanceMask) {
- unsigned i = ctz(instanceMask);
- assert(MAX_INSTANCE > i);
- SL_LOGE("Object::Destroy(%p) for engine ignored; active object ID %u at %p",
- thiz, i + 1, thiz->mEngine.mInstances[i]);
- instanceMask &= ~(1 << i);
- }
- }
-
- // If engine was created but not realized, there will be no sync thread yet
- pthread_t zero;
- memset(&zero, 0, sizeof(pthread_t));
- if (0 != memcmp(&zero, &thiz->mSyncThread, sizeof(pthread_t))) {
-
- // Announce to the sync thread that engine is shutting down; it polls so should see it soon
- thiz->mEngine.mShutdown = SL_BOOLEAN_TRUE;
- // Wait for the sync thread to acknowledge the shutdown
- while (!thiz->mEngine.mShutdownAck) {
- object_cond_wait(&thiz->mObject);
- }
- // The sync thread should have exited by now, so collect it by joining
- (void) pthread_join(thiz->mSyncThread, (void **) NULL);
-
- }
-
- // Shutdown the thread pool used for asynchronous operations (there should not be any)
- ThreadPool_deinit(&thiz->mThreadPool);
-
-#if defined(ANDROID)
- // free equalizer preset names
- if (NULL != thiz->mEqPresetNames) {
- for (unsigned i = 0; i < thiz->mEqNumPresets; ++i) {
- if (NULL != thiz->mEqPresetNames[i]) {
- delete[] thiz->mEqPresetNames[i];
- thiz->mEqPresetNames[i] = NULL;
- }
- }
- delete[] thiz->mEqPresetNames;
- thiz->mEqPresetNames = NULL;
- }
- thiz->mEqNumPresets = 0;
-#endif
-
-#ifdef USE_SDL
- SDL_close();
-#endif
-
-}
-
-
-/** \brief Hook called by Object::Destroy before an engine is about to be destroyed */
-
-predestroy_t CEngine_PreDestroy(void *self)
-{
- predestroy_t ret;
- (void) pthread_mutex_lock(&theOneTrueMutex);
- assert(self == theOneTrueEngine);
- switch (theOneTrueRefCount) {
- case 0:
- assert(false);
- ret = predestroy_error;
- break;
- case 1:
- ret = predestroy_ok;
- break;
- default:
- --theOneTrueRefCount;
- ret = predestroy_again;
- break;
- }
- (void) pthread_mutex_unlock(&theOneTrueMutex);
- return ret;
-}
-
-
-/** \brief Called by IObject::Destroy after engine is destroyed. The parameter refers to the
- * previous engine, which is now undefined memory.
- */
-
-void CEngine_Destroyed(CEngine *self)
-{
- int ok;
- ok = pthread_mutex_lock(&theOneTrueMutex);
- assert(0 == ok);
- assert(self == theOneTrueEngine);
- theOneTrueEngine = NULL;
- assert(1 == theOneTrueRefCount);
- theOneTrueRefCount = 0;
- ok = pthread_mutex_unlock(&theOneTrueMutex);
- assert(0 == ok);
-}
diff --git a/wilhelm/src/objects/CMediaPlayer.c b/wilhelm/src/objects/CMediaPlayer.c
deleted file mode 100644
index 63285d8..0000000
--- a/wilhelm/src/objects/CMediaPlayer.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file CMediaPlayer.c MediaPlayer class */
-
-#include "sles_allinclusive.h"
-
-#ifdef ANDROID
-#include <gui/SurfaceTextureClient.h>
-#include "android/android_GenericMediaPlayer.h"
-using namespace android;
-#endif
-
-
-XAresult CMediaPlayer_Realize(void *self, XAboolean async)
-{
- XAresult result = XA_RESULT_SUCCESS;
-
-#ifdef ANDROID
- CMediaPlayer *thiz = (CMediaPlayer *) self;
-
- // realize player
- result = android_Player_realize(thiz, async);
-#endif
-
- return result;
-}
-
-XAresult CMediaPlayer_Resume(void *self, XAboolean async)
-{
- return XA_RESULT_SUCCESS;
-}
-
-
-/** \brief Hook called by Object::Destroy when a media player is destroyed */
-
-void CMediaPlayer_Destroy(void *self)
-{
- CMediaPlayer *thiz = (CMediaPlayer *) self;
- freeDataLocatorFormat(&thiz->mDataSource);
- freeDataLocatorFormat(&thiz->mBankSource);
- freeDataLocatorFormat(&thiz->mAudioSink);
- freeDataLocatorFormat(&thiz->mImageVideoSink);
- freeDataLocatorFormat(&thiz->mVibraSink);
- freeDataLocatorFormat(&thiz->mLEDArraySink);
-#ifdef ANDROID
- android_Player_destroy(thiz);
-#endif
-}
-
-
-predestroy_t CMediaPlayer_PreDestroy(void *self)
-{
- CMediaPlayer *thiz = (CMediaPlayer *) self;
-#ifdef ANDROID
- android_Player_preDestroy(thiz);
-#endif
- return predestroy_ok;
-}
diff --git a/wilhelm/src/objects/COutputMix.c b/wilhelm/src/objects/COutputMix.c
deleted file mode 100644
index 340da0b..0000000
--- a/wilhelm/src/objects/COutputMix.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* \file COutputMix.c OutputMix class */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Hook called by Object::Realize when an output mix is realized */
-
-SLresult COutputMix_Realize(void *self, SLboolean async)
-{
- SLresult result = SL_RESULT_SUCCESS;
-
-#ifdef ANDROID
- COutputMix *thiz = (COutputMix *) self;
- result = android_outputMix_realize(thiz, async);
-#endif
-
- return result;
-}
-
-
-/** \brief Hook called by Object::Resume when an output mix is resumed */
-
-SLresult COutputMix_Resume(void *self, SLboolean async)
-{
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Hook called by Object::Destroy when an output mix is destroyed */
-
-void COutputMix_Destroy(void *self)
-{
-#ifdef ANDROID
- COutputMix *thiz = (COutputMix *) self;
- android_outputMix_destroy(thiz);
-#endif
-}
-
-
-/** \brief Hook called by Object::Destroy before an output mix is about to be destroyed */
-
-predestroy_t COutputMix_PreDestroy(void *self)
-{
- // Ignore destroy requests if there are any players attached to this output mix
- COutputMix *outputMix = (COutputMix *) self;
- // See design document for explanation
- if (0 == outputMix->mObject.mStrongRefCount) {
-#ifdef USE_OUTPUTMIXEXT
- // We only support a single active output mix per engine, so check if this is the active mix
- IEngine *thisEngine = &outputMix->mObject.mEngine->mEngine;
- interface_lock_exclusive(thisEngine);
- bool thisIsTheActiveOutputMix = false;
- if (outputMix == thisEngine->mOutputMix) {
- thisIsTheActiveOutputMix = true;
- }
- interface_unlock_exclusive(thisEngine);
- if (thisIsTheActiveOutputMix) {
- // Tell the asynchronous mixer callback that we want to destroy the output mix
- outputMix->mOutputMixExt.mDestroyRequested = true;
- while (outputMix->mOutputMixExt.mDestroyRequested) {
- object_cond_wait(&outputMix->mObject);
- }
-#ifdef USE_SDL
- // Mixer callback has acknowledged our request and unlinked output mix from engine.
- // Disable SDL_callback from being called periodically by SDL's internal thread.
- SDL_PauseAudio(1);
-#endif
- }
-#endif
- return predestroy_ok;
- }
- SL_LOGE("Object::Destroy(%p) for OutputMix ignored; %u players attached", outputMix,
- outputMix->mObject.mStrongRefCount);
- return predestroy_error;
-}
diff --git a/wilhelm/src/platform.h b/wilhelm/src/platform.h
deleted file mode 100644
index 1a2b5b4..0000000
--- a/wilhelm/src/platform.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file platform.h Platform-specific configuration constants */
-
-#if defined(ANDROID) || defined(USE_SDL)
-#define PLATFORM_MILLIBEL_MAX_VOLUME 0 // No more than unity gain
-#else
-#define PLATFORM_MILLIBEL_MAX_VOLUME SL_MILLIBEL_MAX
-#endif
diff --git a/wilhelm/src/sl_entry.c b/wilhelm/src/sl_entry.c
deleted file mode 100644
index 41f33f7..0000000
--- a/wilhelm/src/sl_entry.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-/** \brief slCreateEngine Function */
-
-SL_API SLresult SLAPIENTRY slCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions,
- const SLEngineOption *pEngineOptions, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
-{
- SL_ENTER_GLOBAL
-
- result = liCreateEngine(pEngine, numOptions, pEngineOptions, numInterfaces, pInterfaceIds,
- pInterfaceRequired, objectIDtoClass(SL_OBJECTID_ENGINE));
-
- SL_LEAVE_GLOBAL
-}
-
-
-
-/** \brief slQueryNumSupportedEngineInterfaces Function */
-
-SL_API SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces(SLuint32 *pNumSupportedInterfaces)
-{
- SL_ENTER_GLOBAL
-
- result = liQueryNumSupportedInterfaces(pNumSupportedInterfaces,
- objectIDtoClass(SL_OBJECTID_ENGINE));
-
- SL_LEAVE_GLOBAL
-}
-
-
-
-
-/** \brief slQuerySupportedEngineInterfaces Function */
-
-SL_API SLresult SLAPIENTRY slQuerySupportedEngineInterfaces(SLuint32 index,
- SLInterfaceID *pInterfaceId)
-{
- SL_ENTER_GLOBAL
-
- result = liQuerySupportedInterfaces(index, pInterfaceId, objectIDtoClass(SL_OBJECTID_ENGINE));
-
- SL_LEAVE_GLOBAL
-}
diff --git a/wilhelm/src/sl_iid.c b/wilhelm/src/sl_iid.c
deleted file mode 100644
index 0207899..0000000
--- a/wilhelm/src/sl_iid.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// OpenSL ES 1.0.1 interfaces
-const SLInterfaceID SL_IID_3DCOMMIT = &SL_IID_array[MPH_3DCOMMIT];
-const SLInterfaceID SL_IID_3DDOPPLER = &SL_IID_array[MPH_3DDOPPLER];
-const SLInterfaceID SL_IID_3DGROUPING = &SL_IID_array[MPH_3DGROUPING];
-const SLInterfaceID SL_IID_3DLOCATION = &SL_IID_array[MPH_3DLOCATION];
-const SLInterfaceID SL_IID_3DMACROSCOPIC = &SL_IID_array[MPH_3DMACROSCOPIC];
-const SLInterfaceID SL_IID_3DSOURCE = &SL_IID_array[MPH_3DSOURCE];
-const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES = &SL_IID_array[MPH_AUDIODECODERCAPABILITIES];
-const SLInterfaceID SL_IID_AUDIOENCODER = &SL_IID_array[MPH_AUDIOENCODER];
-const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES = &SL_IID_array[MPH_AUDIOENCODERCAPABILITIES];
-const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES = &SL_IID_array[MPH_AUDIOIODEVICECAPABILITIES];
-const SLInterfaceID SL_IID_BASSBOOST = &SL_IID_array[MPH_BASSBOOST];
-const SLInterfaceID SL_IID_BUFFERQUEUE = &SL_IID_array[MPH_BUFFERQUEUE];
-const SLInterfaceID SL_IID_DEVICEVOLUME = &SL_IID_array[MPH_DEVICEVOLUME];
-const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT =
- &SL_IID_array[MPH_DYNAMICINTERFACEMANAGEMENT];
-const SLInterfaceID SL_IID_DYNAMICSOURCE = &SL_IID_array[MPH_DYNAMICSOURCE];
-const SLInterfaceID SL_IID_EFFECTSEND = &SL_IID_array[MPH_EFFECTSEND];
-const SLInterfaceID SL_IID_ENGINE = &SL_IID_array[MPH_ENGINE];
-const SLInterfaceID SL_IID_ENGINECAPABILITIES = &SL_IID_array[MPH_ENGINECAPABILITIES];
-const SLInterfaceID SL_IID_ENVIRONMENTALREVERB = &SL_IID_array[MPH_ENVIRONMENTALREVERB];
-const SLInterfaceID SL_IID_EQUALIZER = &SL_IID_array[MPH_EQUALIZER];
-const SLInterfaceID SL_IID_LED = &SL_IID_array[MPH_LED];
-const SLInterfaceID SL_IID_METADATAEXTRACTION = &SL_IID_array[MPH_METADATAEXTRACTION];
-const SLInterfaceID SL_IID_METADATATRAVERSAL = &SL_IID_array[MPH_METADATATRAVERSAL];
-const SLInterfaceID SL_IID_MIDIMESSAGE = &SL_IID_array[MPH_MIDIMESSAGE];
-const SLInterfaceID SL_IID_MIDIMUTESOLO = &SL_IID_array[MPH_MIDIMUTESOLO];
-const SLInterfaceID SL_IID_MIDITEMPO = &SL_IID_array[MPH_MIDITEMPO];
-const SLInterfaceID SL_IID_MIDITIME = &SL_IID_array[MPH_MIDITIME];
-const SLInterfaceID SL_IID_MUTESOLO = &SL_IID_array[MPH_MUTESOLO];
-const SLInterfaceID SL_IID_NULL = &SL_IID_array[MPH_NULL];
-const SLInterfaceID SL_IID_OBJECT = &SL_IID_array[MPH_OBJECT];
-const SLInterfaceID SL_IID_OUTPUTMIX = &SL_IID_array[MPH_OUTPUTMIX];
-const SLInterfaceID SL_IID_PITCH = &SL_IID_array[MPH_PITCH];
-const SLInterfaceID SL_IID_PLAY = &SL_IID_array[MPH_PLAY];
-const SLInterfaceID SL_IID_PLAYBACKRATE = &SL_IID_array[MPH_PLAYBACKRATE];
-const SLInterfaceID SL_IID_PREFETCHSTATUS = &SL_IID_array[MPH_PREFETCHSTATUS];
-const SLInterfaceID SL_IID_PRESETREVERB = &SL_IID_array[MPH_PRESETREVERB];
-const SLInterfaceID SL_IID_RATEPITCH = &SL_IID_array[MPH_RATEPITCH];
-const SLInterfaceID SL_IID_RECORD = &SL_IID_array[MPH_RECORD];
-const SLInterfaceID SL_IID_SEEK = &SL_IID_array[MPH_SEEK];
-const SLInterfaceID SL_IID_THREADSYNC = &SL_IID_array[MPH_THREADSYNC];
-const SLInterfaceID SL_IID_VIBRA = &SL_IID_array[MPH_VIBRA];
-const SLInterfaceID SL_IID_VIRTUALIZER = &SL_IID_array[MPH_VIRTUALIZER];
-const SLInterfaceID SL_IID_VISUALIZATION = &SL_IID_array[MPH_VISUALIZATION];
-const SLInterfaceID SL_IID_VOLUME = &SL_IID_array[MPH_VOLUME];
-
-// Wilhelm desktop extended interfaces
-extern const SLInterfaceID SL_IID_OUTPUTMIXEXT;
-const SLInterfaceID SL_IID_OUTPUTMIXEXT = &SL_IID_array[MPH_OUTPUTMIXEXT];
-
-// Android API level 9 extended interfaces
-const SLInterfaceID SL_IID_ANDROIDEFFECT = &SL_IID_array[MPH_ANDROIDEFFECT];
-const SLInterfaceID SL_IID_ANDROIDEFFECTCAPABILITIES = &SL_IID_array[MPH_ANDROIDEFFECTCAPABILITIES];
-const SLInterfaceID SL_IID_ANDROIDEFFECTSEND = &SL_IID_array[MPH_ANDROIDEFFECTSEND];
-const SLInterfaceID SL_IID_ANDROIDCONFIGURATION = &SL_IID_array[MPH_ANDROIDCONFIGURATION];
-const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE = &SL_IID_array[MPH_ANDROIDSIMPLEBUFFERQUEUE];
-
-// Android API level 12 extended interfaces
-// GUID and MPH are shared by SL and XA
-const SLInterfaceID SL_IID_ANDROIDBUFFERQUEUESOURCE = &SL_IID_array[MPH_ANDROIDBUFFERQUEUESOURCE];
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/wilhelm/src/sles.c b/wilhelm/src/sles.c
deleted file mode 100644
index 270d01a..0000000
--- a/wilhelm/src/sles.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* OpenSL ES private and global functions not associated with an interface or class */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Return true if the specified interface exists and has been initialized for this object.
- * Returns false if the class does not support this kind of interface, or the class supports the
- * interface but this particular object has not had the interface exposed at object creation time
- * or by DynamicInterface::AddInterface. Note that the return value is not affected by whether
- * the application has requested access to the interface with Object::GetInterface. Assumes on
- * entry that the object is locked for either shared or exclusive access.
- */
-
-bool IsInterfaceInitialized(IObject *thiz, unsigned MPH)
-{
- assert(NULL != thiz);
- assert( /* (MPH_MIN <= MPH) && */ (MPH < (unsigned) MPH_MAX));
- const ClassTable *clazz = thiz->mClass;
- assert(NULL != clazz);
- int index;
- if (0 > (index = clazz->mMPH_to_index[MPH])) {
- return false;
- }
- assert(MAX_INDEX >= clazz->mInterfaceCount);
- assert(clazz->mInterfaceCount > (unsigned) index);
- switch (thiz->mInterfaceStates[index]) {
- case INTERFACE_EXPOSED:
- case INTERFACE_ADDED:
- return true;
- default:
- return false;
- }
-}
-
-
-/** \brief Map an IObject to it's "object ID" (which is really a class ID) */
-
-SLuint32 IObjectToObjectID(IObject *thiz)
-{
- assert(NULL != thiz);
- // Note this returns the OpenSL ES object ID in preference to the OpenMAX AL if both available
- const ClassTable *clazz = thiz->mClass;
- assert(NULL != clazz);
- SLuint32 id = clazz->mSLObjectID;
- if (!id)
- id = clazz->mXAObjectID;
- return id;
-}
-
-
-/** \brief Acquire a strong reference to an object.
- * Check that object has the specified "object ID" (which is really a class ID) and is in the
- * realized state. If so, then acquire a strong reference to it and return true.
- * Otherwise return false.
- */
-
-SLresult AcquireStrongRef(IObject *object, SLuint32 expectedObjectID)
-{
- if (NULL == object) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- // NTH additional validity checks on address here
- SLresult result;
- object_lock_exclusive(object);
- SLuint32 actualObjectID = IObjectToObjectID(object);
- if (expectedObjectID != actualObjectID) {
- SL_LOGE("object %p has object ID %u but expected %u", object, actualObjectID,
- expectedObjectID);
- result = SL_RESULT_PARAMETER_INVALID;
- } else if (SL_OBJECT_STATE_REALIZED != object->mState) {
- SL_LOGE("object %p with object ID %u is not realized", object, actualObjectID);
- result = SL_RESULT_PRECONDITIONS_VIOLATED;
- } else {
- ++object->mStrongRefCount;
- result = SL_RESULT_SUCCESS;
- }
- object_unlock_exclusive(object);
- return result;
-}
-
-
-/** \brief Release a strong reference to an object.
- * Entry condition: the object is locked.
- * Exit condition: the object is unlocked.
- * Finishes the destroy if needed.
- */
-
-void ReleaseStrongRefAndUnlockExclusive(IObject *object)
-{
-#ifdef USE_DEBUG
- assert(pthread_equal(pthread_self(), object->mOwner));
-#endif
- assert(0 < object->mStrongRefCount);
- if ((0 == --object->mStrongRefCount) && (SL_OBJECT_STATE_DESTROYING == object->mState)) {
- // FIXME do the destroy here - merge with IDestroy
- // but can't do this until we move Destroy to the sync thread
- // as Destroy is now a blocking operation, and to avoid a race
- } else {
- object_unlock_exclusive(object);
- }
-}
-
-
-/** \brief Release a strong reference to an object.
- * Entry condition: the object is unlocked.
- * Exit condition: the object is unlocked.
- * Finishes the destroy if needed.
- */
-
-void ReleaseStrongRef(IObject *object)
-{
- assert(NULL != object);
- object_lock_exclusive(object);
- ReleaseStrongRefAndUnlockExclusive(object);
-}
-
-
-/** \brief Convert POSIX pthread error code to OpenSL ES result code */
-
-SLresult err_to_result(int err)
-{
- if (EAGAIN == err || ENOMEM == err) {
- return SL_RESULT_RESOURCE_ERROR;
- }
- if (0 != err) {
- return SL_RESULT_INTERNAL_ERROR;
- }
- return SL_RESULT_SUCCESS;
-}
-
-
-/** \brief Check the interface IDs passed into a Create operation */
-
-SLresult checkInterfaces(const ClassTable *clazz, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired,
- unsigned *pExposedMask, unsigned *pRequiredMask)
-{
- assert(NULL != clazz && NULL != pExposedMask);
- // Initially no interfaces are exposed
- unsigned exposedMask = 0;
- unsigned requiredMask = 0;
- const struct iid_vtable *interfaces = clazz->mInterfaces;
- SLuint32 interfaceCount = clazz->mInterfaceCount;
- SLuint32 i;
- // Expose all implicit interfaces
- for (i = 0; i < interfaceCount; ++i) {
- switch (interfaces[i].mInterface) {
- case INTERFACE_IMPLICIT:
- case INTERFACE_IMPLICIT_PREREALIZE:
- // there must be an initialization hook present
- if (NULL != MPH_init_table[interfaces[i].mMPH].mInit) {
- exposedMask |= 1 << i;
- }
- break;
- case INTERFACE_EXPLICIT:
- case INTERFACE_DYNAMIC:
- case INTERFACE_UNAVAILABLE:
- case INTERFACE_EXPLICIT_PREREALIZE:
- break;
- default:
- assert(false);
- break;
- }
- }
- if (0 < numInterfaces) {
- if (NULL == pInterfaceIds || NULL == pInterfaceRequired) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- bool anyRequiredButUnsupported = false;
- // Loop for each requested interface
- for (i = 0; i < numInterfaces; ++i) {
- SLInterfaceID iid = pInterfaceIds[i];
- if (NULL == iid) {
- return SL_RESULT_PARAMETER_INVALID;
- }
- SLboolean isRequired = pInterfaceRequired[i];
- int MPH, index;
- if ((0 > (MPH = IID_to_MPH(iid))) ||
- // there must be an initialization hook present
- (NULL == MPH_init_table[MPH].mInit) ||
- (0 > (index = clazz->mMPH_to_index[MPH])) ||
- (INTERFACE_UNAVAILABLE == interfaces[index].mInterface)) {
- // Here if interface was not found, or is not available for this object type
- if (isRequired) {
- // Application said it required the interface, so give up
- SL_LOGE("class %s interface %u required but unavailable MPH=%d",
- clazz->mName, i, MPH);
- anyRequiredButUnsupported = true;
- }
- // Application said it didn't really need the interface, so ignore with warning
- SL_LOGW("class %s interface %u requested but unavailable MPH=%d",
- clazz->mName, i, MPH);
- continue;
- }
- if (isRequired) {
- requiredMask |= (1 << index);
- }
- // The requested interface was both found and available, so expose it
- exposedMask |= (1 << index);
- // Note that we ignore duplicate requests, including equal and aliased IDs
- }
- if (anyRequiredButUnsupported) {
- return SL_RESULT_FEATURE_UNSUPPORTED;
- }
- }
- *pExposedMask = exposedMask;
- if (NULL != pRequiredMask) {
- *pRequiredMask = requiredMask;
- }
- return SL_RESULT_SUCCESS;
-}
-
-
-/* Interface initialization hooks */
-
-extern void
- I3DCommit_init(void *),
- I3DDoppler_init(void *),
- I3DGrouping_init(void *),
- I3DLocation_init(void *),
- I3DMacroscopic_init(void *),
- I3DSource_init(void *),
- IAndroidConfiguration_init(void *),
- IAndroidEffect_init(void *),
- IAndroidEffectCapabilities_init(void *),
- IAndroidEffectSend_init(void *),
- IAndroidBufferQueue_init(void *),
- IAudioDecoderCapabilities_init(void *),
- IAudioEncoder_init(void *),
- IAudioEncoderCapabilities_init(void *),
- IAudioIODeviceCapabilities_init(void *),
- IBassBoost_init(void *),
- IBufferQueue_init(void *),
- IDeviceVolume_init(void *),
- IDynamicInterfaceManagement_init(void *),
- IDynamicSource_init(void *),
- IEffectSend_init(void *),
- IEngine_init(void *),
- IEngineCapabilities_init(void *),
- IEnvironmentalReverb_init(void *),
- IEqualizer_init(void *),
- ILEDArray_init(void *),
- IMIDIMessage_init(void *),
- IMIDIMuteSolo_init(void *),
- IMIDITempo_init(void *),
- IMIDITime_init(void *),
- IMetadataExtraction_init(void *),
- IMetadataTraversal_init(void *),
- IMuteSolo_init(void *),
- IObject_init(void *),
- IOutputMix_init(void *),
- IOutputMixExt_init(void *),
- IPitch_init(void *),
- IPlay_init(void *),
- IPlaybackRate_init(void *),
- IPrefetchStatus_init(void *),
- IPresetReverb_init(void *),
- IRatePitch_init(void *),
- IRecord_init(void *),
- ISeek_init(void *),
- IThreadSync_init(void *),
- IVibra_init(void *),
- IVirtualizer_init(void *),
- IVisualization_init(void *),
- IVolume_init(void *);
-
-extern void
- I3DGrouping_deinit(void *),
- IAndroidEffect_deinit(void *),
- IAndroidEffectCapabilities_deinit(void *),
- IAndroidBufferQueue_deinit(void *),
- IBassBoost_deinit(void *),
- IBufferQueue_deinit(void *),
- IEngine_deinit(void *),
- IEnvironmentalReverb_deinit(void *),
- IEqualizer_deinit(void *),
- IObject_deinit(void *),
- IPresetReverb_deinit(void *),
- IThreadSync_deinit(void *),
- IVirtualizer_deinit(void *);
-
-extern bool
- IAndroidEffectCapabilities_Expose(void *),
- IBassBoost_Expose(void *),
- IEnvironmentalReverb_Expose(void *),
- IEqualizer_Expose(void *),
- IPresetReverb_Expose(void *),
- IVirtualizer_Expose(void *);
-
-extern void
- IXAEngine_init(void *),
- IStreamInformation_init(void*),
- IVideoDecoderCapabilities_init(void *);
-
-extern void
- IXAEngine_deinit(void *),
- IStreamInformation_deinit(void *),
- IVideoDecoderCapabilities_deinit(void *);
-
-extern bool
- IVideoDecoderCapabilities_expose(void *);
-
-#if !(USE_PROFILES & USE_PROFILES_MUSIC)
-#define IDynamicSource_init NULL
-#define IMetadataTraversal_init NULL
-#define IVisualization_init NULL
-#endif
-
-#if !(USE_PROFILES & USE_PROFILES_GAME)
-#define I3DCommit_init NULL
-#define I3DDoppler_init NULL
-#define I3DGrouping_init NULL
-#define I3DLocation_init NULL
-#define I3DMacroscopic_init NULL
-#define I3DSource_init NULL
-#define IMIDIMessage_init NULL
-#define IMIDIMuteSolo_init NULL
-#define IMIDITempo_init NULL
-#define IMIDITime_init NULL
-#define IPitch_init NULL
-#define IRatePitch_init NULL
-#define I3DGrouping_deinit NULL
-#endif
-
-#if !(USE_PROFILES & USE_PROFILES_BASE)
-#define IAudioDecoderCapabilities_init NULL
-#define IAudioEncoderCapabilities_init NULL
-#define IAudioEncoder_init NULL
-#define IAudioIODeviceCapabilities_init NULL
-#define IDeviceVolume_init NULL
-#define IEngineCapabilities_init NULL
-#define IThreadSync_init NULL
-#define IThreadSync_deinit NULL
-#endif
-
-#if !(USE_PROFILES & USE_PROFILES_OPTIONAL)
-#define ILEDArray_init NULL
-#define IVibra_init NULL
-#endif
-
-#ifndef ANDROID
-#define IAndroidConfiguration_init NULL
-#define IAndroidEffect_init NULL
-#define IAndroidEffectCapabilities_init NULL
-#define IAndroidEffectSend_init NULL
-#define IAndroidEffect_deinit NULL
-#define IAndroidEffectCapabilities_deinit NULL
-#define IAndroidEffectCapabilities_Expose NULL
-#define IAndroidBufferQueue_init NULL
-#define IStreamInformation_init NULL
-#define IAndroidBufferQueue_deinit NULL
-#define IStreamInformation_deinit NULL
-#endif
-
-#ifndef USE_OUTPUTMIXEXT
-#define IOutputMixExt_init NULL
-#endif
-
-
-/*static*/ const struct MPH_init MPH_init_table[MPH_MAX] = {
- { /* MPH_3DCOMMIT, */ I3DCommit_init, NULL, NULL, NULL, NULL },
- { /* MPH_3DDOPPLER, */ I3DDoppler_init, NULL, NULL, NULL, NULL },
- { /* MPH_3DGROUPING, */ I3DGrouping_init, NULL, I3DGrouping_deinit, NULL, NULL },
- { /* MPH_3DLOCATION, */ I3DLocation_init, NULL, NULL, NULL, NULL },
- { /* MPH_3DMACROSCOPIC, */ I3DMacroscopic_init, NULL, NULL, NULL, NULL },
- { /* MPH_3DSOURCE, */ I3DSource_init, NULL, NULL, NULL, NULL },
- { /* MPH_AUDIODECODERCAPABILITIES, */ IAudioDecoderCapabilities_init, NULL, NULL, NULL, NULL },
- { /* MPH_AUDIOENCODER, */ IAudioEncoder_init, NULL, NULL, NULL, NULL },
- { /* MPH_AUDIOENCODERCAPABILITIES, */ IAudioEncoderCapabilities_init, NULL, NULL, NULL, NULL },
- { /* MPH_AUDIOIODEVICECAPABILITIES, */ IAudioIODeviceCapabilities_init, NULL, NULL, NULL,
- NULL },
- { /* MPH_BASSBOOST, */ IBassBoost_init, NULL, IBassBoost_deinit, IBassBoost_Expose, NULL },
- { /* MPH_BUFFERQUEUE, */ IBufferQueue_init, NULL, IBufferQueue_deinit, NULL, NULL },
- { /* MPH_DEVICEVOLUME, */ IDeviceVolume_init, NULL, NULL, NULL, NULL },
- { /* MPH_DYNAMICINTERFACEMANAGEMENT, */ IDynamicInterfaceManagement_init, NULL, NULL, NULL,
- NULL },
- { /* MPH_DYNAMICSOURCE, */ IDynamicSource_init, NULL, NULL, NULL, NULL },
- { /* MPH_EFFECTSEND, */ IEffectSend_init, NULL, NULL, NULL, NULL },
- { /* MPH_ENGINE, */ IEngine_init, NULL, IEngine_deinit, NULL, NULL },
- { /* MPH_ENGINECAPABILITIES, */ IEngineCapabilities_init, NULL, NULL, NULL, NULL },
- { /* MPH_ENVIRONMENTALREVERB, */ IEnvironmentalReverb_init, NULL, IEnvironmentalReverb_deinit,
- IEnvironmentalReverb_Expose, NULL },
- { /* MPH_EQUALIZER, */ IEqualizer_init, NULL, IEqualizer_deinit, IEqualizer_Expose, NULL },
- { /* MPH_LED, */ ILEDArray_init, NULL, NULL, NULL, NULL },
- { /* MPH_METADATAEXTRACTION, */ IMetadataExtraction_init, NULL, NULL, NULL, NULL },
- { /* MPH_METADATATRAVERSAL, */ IMetadataTraversal_init, NULL, NULL, NULL, NULL },
- { /* MPH_MIDIMESSAGE, */ IMIDIMessage_init, NULL, NULL, NULL, NULL },
- { /* MPH_MIDITIME, */ IMIDITime_init, NULL, NULL, NULL, NULL },
- { /* MPH_MIDITEMPO, */ IMIDITempo_init, NULL, NULL, NULL, NULL },
- { /* MPH_MIDIMUTESOLO, */ IMIDIMuteSolo_init, NULL, NULL, NULL, NULL },
- { /* MPH_MUTESOLO, */ IMuteSolo_init, NULL, NULL, NULL, NULL },
- { /* MPH_NULL, */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_OBJECT, */ IObject_init, NULL, IObject_deinit, NULL, NULL },
- { /* MPH_OUTPUTMIX, */ IOutputMix_init, NULL, NULL, NULL, NULL },
- { /* MPH_PITCH, */ IPitch_init, NULL, NULL, NULL, NULL },
- { /* MPH_PLAY, */ IPlay_init, NULL, NULL, NULL, NULL },
- { /* MPH_PLAYBACKRATE, */ IPlaybackRate_init, NULL, NULL, NULL, NULL },
- { /* MPH_PREFETCHSTATUS, */ IPrefetchStatus_init, NULL, NULL, NULL, NULL },
- { /* MPH_PRESETREVERB, */ IPresetReverb_init, NULL, IPresetReverb_deinit,
- IPresetReverb_Expose, NULL },
- { /* MPH_RATEPITCH, */ IRatePitch_init, NULL, NULL, NULL, NULL },
- { /* MPH_RECORD, */ IRecord_init, NULL, NULL, NULL, NULL },
- { /* MPH_SEEK, */ ISeek_init, NULL, NULL, NULL, NULL },
- { /* MPH_THREADSYNC, */ IThreadSync_init, NULL, IThreadSync_deinit, NULL, NULL },
- { /* MPH_VIBRA, */ IVibra_init, NULL, NULL, NULL, NULL },
- { /* MPH_VIRTUALIZER, */ IVirtualizer_init, NULL, IVirtualizer_deinit, IVirtualizer_Expose,
- NULL },
- { /* MPH_VISUALIZATION, */ IVisualization_init, NULL, NULL, NULL, NULL },
- { /* MPH_VOLUME, */ IVolume_init, NULL, NULL, NULL, NULL },
-// Wilhelm desktop extended interfaces
- { /* MPH_OUTPUTMIXEXT, */ IOutputMixExt_init, NULL, NULL, NULL, NULL },
-// Android API level 9 extended interfaces
- { /* MPH_ANDROIDEFFECT */ IAndroidEffect_init, NULL, IAndroidEffect_deinit, NULL, NULL },
- { /* MPH_ANDROIDEFFECTCAPABILITIES */ IAndroidEffectCapabilities_init, NULL,
- IAndroidEffectCapabilities_deinit, IAndroidEffectCapabilities_Expose, NULL },
- { /* MPH_ANDROIDEFFECTSEND */ IAndroidEffectSend_init, NULL, NULL, NULL, NULL },
- { /* MPH_ANDROIDCONFIGURATION */ IAndroidConfiguration_init, NULL, NULL, NULL, NULL },
- { /* MPH_ANDROIDSIMPLEBUFFERQUEUE */ IBufferQueue_init /* alias */, NULL, NULL, NULL, NULL },
-// Android API level 10 extended interfaces
- { /* MPH_ANDROIDBUFFERQUEUESOURCE */ IAndroidBufferQueue_init, NULL, IAndroidBufferQueue_deinit,
- NULL, NULL },
-// OpenMAX AL 1.0.1 interfaces
- { /* MPH_XAAUDIODECODERCAPABILITIES */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAAUDIOENCODER */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAAUDIOENCODERCAPABILITIES */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAAUDIOIODEVICECAPABILITIES */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XACAMERA */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XACAMERACAPABILITIES */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XACONFIGEXTENSION */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XADEVICEVOLUME */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XADYNAMICINTERFACEMANAGEMENT 59 */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XADYNAMICSOURCE */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAENGINE */ IXAEngine_init, NULL, IXAEngine_deinit, NULL, NULL },
- { /* MPH_XAEQUALIZER */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAIMAGECONTROLS */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAIMAGEDECODERCAPABILITIES */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAIMAGEEFFECTS */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAIMAGEENCODER */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAIMAGEENCODERCAPABILITIES */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XALED */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAMETADATAEXTRACTION */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAMETADATAINSERTION */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAMETADATATRAVERSAL */ NULL, NULL, NULL, NULL, NULL },
-// { /* MPH_XANULL */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAOBJECT */ IObject_init, NULL, IObject_deinit, NULL, NULL },
- { /* MPH_XAOUTPUTMIX */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAPLAY */ IPlay_init, NULL, NULL, NULL, NULL },
- { /* MPH_XAPLAYBACKRATE */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAPREFETCHSTATUS, */ IPrefetchStatus_init, NULL, NULL, NULL, NULL },
- { /* MPH_XARADIO */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XARDS */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XARECORD */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XASEEK */ ISeek_init, NULL, NULL, NULL, NULL },
- { /* MPH_XASNAPSHOT */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XASTREAMINFORMATION */ IStreamInformation_init, NULL, IStreamInformation_deinit,
- NULL, NULL },
- { /* MPH_XATHREADSYNC */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAVIBRA */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAVIDEODECODERCAPABILITIES */ IVideoDecoderCapabilities_init, NULL,
- IVideoDecoderCapabilities_deinit, IVideoDecoderCapabilities_expose, NULL },
- { /* MPH_XAVIDEOENCODER */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAVIDEOENCODERCAPABILITIES */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAVIDEOPOSTPROCESSING */ NULL, NULL, NULL, NULL, NULL },
- { /* MPH_XAVOLUME, */ IVolume_init, NULL, NULL, NULL, NULL },
-};
-
-
-/** \brief Construct a new instance of the specified class, exposing selected interfaces */
-
-IObject *construct(const ClassTable *clazz, unsigned exposedMask, SLEngineItf engine)
-{
- IObject *thiz;
- // Do not change this to malloc; we depend on the object being memset to zero
- thiz = (IObject *) calloc(1, clazz->mSize);
- if (NULL != thiz) {
- SL_LOGV("construct %s at %p", clazz->mName, thiz);
- unsigned lossOfControlMask = 0;
- // a NULL engine means we are constructing the engine
- IEngine *thisEngine = (IEngine *) engine;
- if (NULL == thisEngine) {
- // thisEngine = &((CEngine *) thiz)->mEngine;
- thiz->mEngine = (CEngine *) thiz;
- } else {
- thiz->mEngine = (CEngine *) thisEngine->mThis;
- interface_lock_exclusive(thisEngine);
- if (MAX_INSTANCE <= thisEngine->mInstanceCount) {
- SL_LOGE("Too many objects");
- interface_unlock_exclusive(thisEngine);
- free(thiz);
- return NULL;
- }
- // pre-allocate a pending slot, but don't assign bit from mInstanceMask yet
- ++thisEngine->mInstanceCount;
- assert(((unsigned) ~0) != thisEngine->mInstanceMask);
- interface_unlock_exclusive(thisEngine);
- // const, no lock needed
- if (thisEngine->mLossOfControlGlobal) {
- lossOfControlMask = ~0;
- }
- }
- thiz->mLossOfControlMask = lossOfControlMask;
- thiz->mClass = clazz;
- const struct iid_vtable *x = clazz->mInterfaces;
- SLuint8 *interfaceStateP = thiz->mInterfaceStates;
- SLuint32 index;
- for (index = 0; index < clazz->mInterfaceCount; ++index, ++x, exposedMask >>= 1) {
- SLuint8 state;
- // initialize all interfaces with init hooks, even if not exposed
- const struct MPH_init *mi = &MPH_init_table[x->mMPH];
- VoidHook init = mi->mInit;
- if (NULL != init) {
- void *self = (char *) thiz + x->mOffset;
- // IObject does not have an mThis, so [1] is not always defined
- if (index) {
- ((IObject **) self)[1] = thiz;
- }
- // call the initialization hook
- (*init)(self);
- // IObject does not require a call to GetInterface
- if (index) {
- // This trickery invalidates the v-table until GetInterface
- ((size_t *) self)[0] ^= ~0;
- }
- // if interface is exposed, also call the optional expose hook
- BoolHook expose;
- state = (exposedMask & 1) && ((NULL == (expose = mi->mExpose)) || (*expose)(self)) ?
- INTERFACE_EXPOSED : INTERFACE_INITIALIZED;
- // FIXME log or report to application if an expose hook on a
- // required explicit interface fails at creation time
- } else {
- state = INTERFACE_UNINITIALIZED;
- }
- *interfaceStateP++ = state;
- }
- // note that the new object is not yet published; creator must call IObject_Publish
- }
- return thiz;
-}
diff --git a/wilhelm/src/sles_allinclusive.h b/wilhelm/src/sles_allinclusive.h
deleted file mode 100644
index 513f774..0000000
--- a/wilhelm/src/sles_allinclusive.h
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file sles_allinclusive.h Everything including the kitchen sink */
-
-#include <SLES/OpenSLES.h>
-#include <OMXAL/OpenMAXAL.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#include <OMXAL/OpenMAXAL_Android.h>
-#endif
-#include <stddef.h> // offsetof
-#include <stdlib.h> // malloc
-#include <string.h> // memcmp
-#include <strings.h>
-#include <stdio.h> // debugging
-#include <assert.h> // debugging
-#include <pthread.h>
-#include <unistd.h> // usleep
-#include <errno.h>
-
-#ifndef __cplusplus
-typedef int bool;
-#ifndef false
-#define false 0
-#endif
-#ifndef true
-#define true 1
-#endif
-#endif
-
-// The OpenSLES.h definitions of SL_PROFILES_... have casts, so are unusable by preprocessor
-#define USE_PROFILES_PHONE 0x1 // == SL_PROFILES_PHONE
-#define USE_PROFILES_MUSIC 0x2 // == SL_PROFILES_MUSIC
-#define USE_PROFILES_GAME 0x4 // == SL_PROFILES_GAME
-// Pseudo profiles, used to decide whether to include code for incomplete or untested features
-// Features that are not in union of all profiles: audio recorder, LED, Vibra
-#define USE_PROFILES_OPTIONAL 0x8
-// Features that are in the intersection of all profiles:
-// object priorities, preemption, loss of control, device configuration
-#define USE_PROFILES_BASE 0x10
-
-#include "MPH.h"
-#include "MPH_to.h"
-#include "devices.h"
-#include "ut/OpenSLESUT.h"
-#include "ThreadPool.h"
-
-typedef struct CEngine_struct CEngine;
-typedef struct CAudioPlayer_struct CAudioPlayer;
-typedef struct CAudioRecorder_struct CAudioRecorder;
-typedef struct C3DGroup_struct C3DGroup;
-typedef struct COutputMix_struct COutputMix;
-
-#ifdef USE_SNDFILE
-#include <sndfile.h>
-#include "desktop/SLSndFile.h"
-#endif // USE_SNDFILE
-
-#ifdef USE_SDL
-#include <SDL/SDL_audio.h>
-#endif // USE_SDL
-
-#define STEREO_CHANNELS 2
-
-/**
- * Constants to define unknown property values
- */
-#define UNKNOWN_NUMCHANNELS 0
-#define UNKNOWN_SAMPLERATE 0
-#define UNKNOWN_CHANNELMASK 0
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#include <utils/KeyedVector.h>
-#include "media/AudioSystem.h"
-#include "media/mediarecorder.h"
-#include "media/AudioRecord.h"
-#include "media/AudioTrack.h"
-#include "media/mediaplayer.h"
-#include <utils/String8.h>
-#define ANDROID_SL_MILLIBEL_MAX 0
-#include "android/android_sles_conversions.h"
-#include "android/android_defs.h"
-#endif
-
-#ifdef USE_OUTPUTMIXEXT
-#include "desktop/OutputMixExt.h"
-#endif
-
-#include "sllog.h"
-
-typedef enum {
- predestroy_error, // Application should not be calling destroy now
- predestroy_ok, // OK to destroy object now
- predestroy_again // Application did nothing wrong, but should destroy again to be effective
-} predestroy_t;
-
-// Hook functions
-
-typedef void (*VoidHook)(void *self);
-//typedef SLresult (*ResultHook)(void *self);
-typedef SLresult (*AsyncHook)(void *self, SLboolean async);
-typedef bool (*BoolHook)(void *self);
-typedef predestroy_t (*PreDestroyHook)(void *self);
-
-// Describes how an interface is related to a given class, used in iid_vtable::mInterface
-
-#define INTERFACE_IMPLICIT 0 // no need for application to request prior to GetInterface
-#define INTERFACE_EXPLICIT 1 // must be requested explicitly during object creation
-#define INTERFACE_DYNAMIC 2 // can be requested after object creation
-#define INTERFACE_UNAVAILABLE 3 // this interface is not available on objects of this class
-#define INTERFACE_IMPLICIT_PREREALIZE 4 // implicit, and can call GetInterface before Realize
-#define INTERFACE_EXPLICIT_PREREALIZE 5 // explicit, and can call GetInterface before Realize
-// 6 and 7 are reserved for the meaningless DYNAMIC_PREREALIZE and UNAVAILABLE_PREREALIZE
-// note that INTERFACE_OPTIONAL is always re-mapped to one of the above
-#define INTERFACE_PREREALIZE 4 // bit-mask to test for calling GetInterface before Realize
-
-// Profile-specific interfaces
-
-#if USE_PROFILES & USE_PROFILES_BASE
-#define INTERFACE_IMPLICIT_BASE INTERFACE_IMPLICIT
-#define INTERFACE_EXPLICIT_BASE INTERFACE_EXPLICIT
-#else
-#define INTERFACE_IMPLICIT_BASE INTERFACE_UNAVAILABLE
-#define INTERFACE_EXPLICIT_BASE INTERFACE_UNAVAILABLE
-#endif
-
-#if USE_PROFILES & USE_PROFILES_GAME
-#define INTERFACE_DYNAMIC_GAME INTERFACE_DYNAMIC
-#define INTERFACE_EXPLICIT_GAME INTERFACE_EXPLICIT
-#else
-#define INTERFACE_DYNAMIC_GAME INTERFACE_OPTIONAL
-#define INTERFACE_EXPLICIT_GAME INTERFACE_OPTIONAL
-#endif
-
-#if USE_PROFILES & USE_PROFILES_MUSIC
-#define INTERFACE_DYNAMIC_MUSIC INTERFACE_DYNAMIC
-#else
-#define INTERFACE_DYNAMIC_MUSIC INTERFACE_OPTIONAL
-#endif
-
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
-#define INTERFACE_DYNAMIC_GAME_MUSIC INTERFACE_DYNAMIC
-#define INTERFACE_EXPLICIT_GAME_MUSIC INTERFACE_EXPLICIT
-#else
-#define INTERFACE_DYNAMIC_GAME_MUSIC INTERFACE_OPTIONAL
-#define INTERFACE_EXPLICIT_GAME_MUSIC INTERFACE_OPTIONAL
-#endif
-
-#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_PHONE)
-#define INTERFACE_EXPLICIT_GAME_PHONE INTERFACE_EXPLICIT
-#else
-#define INTERFACE_EXPLICIT_GAME_PHONE INTERFACE_OPTIONAL
-#endif
-
-#if USE_PROFILES & USE_PROFILES_OPTIONAL
-#define INTERFACE_OPTIONAL INTERFACE_EXPLICIT
-#define INTERFACE_DYNAMIC_OPTIONAL INTERFACE_DYNAMIC
-#else
-#define INTERFACE_OPTIONAL INTERFACE_UNAVAILABLE
-#define INTERFACE_DYNAMIC_OPTIONAL INTERFACE_UNAVAILABLE
-#endif
-
-// Describes how an interface is related to a given object
-
-#define INTERFACE_UNINITIALIZED 0 ///< not available
-#define INTERFACE_INITIALIZED 1 ///< not requested at object creation time
-#define INTERFACE_EXPOSED 2 ///< requested at object creation time
-#define INTERFACE_ADDING_1 3 ///< part 1 of asynchronous AddInterface, pending
-#define INTERFACE_ADDING_2 4 ///< synchronous AddInterface, or part 2 of asynchronous
-#define INTERFACE_ADDED 5 ///< AddInterface has completed
-#define INTERFACE_REMOVING 6 ///< unlocked phase of (synchronous) RemoveInterface
-#define INTERFACE_SUSPENDING 7 ///< suspend in progress
-#define INTERFACE_SUSPENDED 8 ///< suspend has completed
-#define INTERFACE_RESUMING_1 9 ///< part 1 of asynchronous ResumeInterface, pending
-#define INTERFACE_RESUMING_2 10 ///< synchronous ResumeInterface, or part 2 of asynchronous
-#define INTERFACE_ADDING_1A 11 ///< part 1 of asynchronous AddInterface, aborted
-#define INTERFACE_RESUMING_1A 12 ///< part 1 of asynchronous ResumeInterface, aborted
-
-
-// Maps an interface ID to its offset within the class that exposes it
-
-struct iid_vtable {
- unsigned char mMPH; // primary MPH for this interface, does not include any aliases
- unsigned char mInterface; // relationship of interface to this class
- /*size_t*/ unsigned short mOffset;
-};
-
-// Per-class const data shared by all instances of the same class
-
-typedef struct {
- const struct iid_vtable *mInterfaces; // maps interface index to info about that interface
- SLuint32 mInterfaceCount; // number of possible interfaces
- const signed char *mMPH_to_index;
- const char * const mName;
- size_t mSize;
- // OpenSL ES and OpenMAX AL object IDs come from different ranges, and some objects such as
- // Engine, Output Mix, LED, and Vibra belong to both APIs, so we keep both object IDs
- SLuint16 mSLObjectID; // OpenSL ES object ID
- XAuint16 mXAObjectID; // OpenMAX AL object ID
- // hooks
- AsyncHook mRealize; // called with mutex locked; can temporarily unlock mutex (for async)
- AsyncHook mResume; // called with mutex locked; can temporarily unlock mutex (for async)
- VoidHook mDestroy; // called with mutex locked and must keep mutex locked throughout
- PreDestroyHook mPreDestroy; // called with mutex locked; can temporarily unlock mutex (for wait)
-} ClassTable;
-
-// BufferHeader describes each element of a BufferQueue, other than the data
-typedef struct {
- const void *mBuffer;
- SLuint32 mSize;
-} BufferHeader;
-
-#ifdef ANDROID
-// Holds information about all commands that can be passed alongside an MPEG-2 TS buffer
-// Is used with buffers of type kAndroidBufferTypeMpeg2Ts
-typedef struct {
- SLuint32 mTsCmdCode;
- SLAuint64 mPts;
-} Mpeg2TsCommands;
-
-// Holds information about all commands that can be passed alongside an AAC ADTS buffer
-// Is used with buffers of type kAndroidBufferTypeAacadts
-typedef struct {
- SLuint32 mAdtsCmdCode;
-} AdtsCommands;
-
-// Union of the different structures to hold items stored in an AdvancedBufferHeader
-// when an item comes from an AndroidBufferQueue as the data source, it's a command
-// when an item is output to an AndroidBufferQueue as the data sink, it's a message (or metadata)
-typedef union {
- Mpeg2TsCommands mTsCmdData;
- AdtsCommands mAdtsCmdData;
-} AdvancedBufferItems;
-
-// AdvancedBufferHeader describes each element of an AndroidBufferQueue, other than the data
-// and associated messages
-typedef struct {
- const void *mDataBuffer;
- SLuint32 mDataSize;
- SLuint32 mDataSizeConsumed;
- AdvancedBufferItems mItems;
- const void *mBufferContext;
- SLuint32 mBufferState;
-} AdvancedBufferHeader;
-#endif
-
-#ifdef USE_SNDFILE
-
-#define SndFile_BUFSIZE 512 // in 16-bit samples
-#define SndFile_NUMBUFS 2
-
-struct SndFile {
- // save URI also?
- SLchar *mPathname;
- SNDFILE *mSNDFILE;
- SF_INFO mSfInfo;
- pthread_mutex_t mMutex; // protects mSNDFILE only
- SLboolean mEOF; // sf_read returned zero sample frames
- SLuint32 mWhich; // which buffer to use next
- short mBuffer[SndFile_BUFSIZE * SndFile_NUMBUFS];
-};
-
-#endif // USE_SNDFILE
-
-#include "data.h"
-#include "itfstruct.h"
-#include "classes.h"
-
-struct MPH_init {
- VoidHook mInit; // called first to initialize the interface, right after object is allocated
- // Each interface is initialized regardless whether it is exposed to application.
- VoidHook mResume; // called to resume interface after suspension, not currently used
- VoidHook mDeinit; // called last when object is about to be destroyed
- BoolHook mExpose; // called after initialization, only if interface is exposed to application
- VoidHook mRemove; // called by DynamicInterfaceManager::RemoveInterface, and prior to mDeinit
- // will need a suspend hook when suspend is implemented
-};
-
-extern /*static*/ int IID_to_MPH(const SLInterfaceID iid);
-extern /*static*/ const struct MPH_init MPH_init_table[MPH_MAX];
-extern SLresult checkInterfaces(const ClassTable *clazz,
- SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds,
- const SLboolean *pInterfaceRequired, unsigned *pExposedMask, unsigned *pRequiredMask);
-extern IObject *construct(const ClassTable *clazz,
- unsigned exposedMask, SLEngineItf engine);
-extern const ClassTable *objectIDtoClass(SLuint32 objectID);
-extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];
-extern SLuint32 IObjectToObjectID(IObject *object);
-extern void IObject_Publish(IObject *thiz);
-extern void IObject_Destroy(SLObjectItf self);
-
-// Map an interface to it's "object ID" (which is really a class ID).
-// Note: this operation is undefined on IObject, as it lacks an mThis.
-// If you have an IObject, then use IObjectToObjectID directly.
-
-#define InterfaceToObjectID(thiz) IObjectToObjectID((thiz)->mThis)
-
-// Map an interface to it's corresponding IObject.
-// Note: this operation is undefined on IObject, as it lacks an mThis.
-// If you have an IObject, then you're done -- you already have what you need.
-
-#define InterfaceToIObject(thiz) ((thiz)->mThis)
-
-#define InterfaceToCAudioPlayer(thiz) (((CAudioPlayer*)InterfaceToIObject(thiz)))
-
-#define InterfaceToCAudioRecorder(thiz) (((CAudioRecorder*)InterfaceToIObject(thiz)))
-
-#define InterfaceToCAudioRecorder(thiz) (((CAudioRecorder*)InterfaceToIObject(thiz)))
-
-#define InterfaceToCMediaPlayer(thiz) (((CMediaPlayer*)InterfaceToIObject(thiz)))
-
-#ifdef ANDROID
-#include "android/MediaPlayer_to_android.h"
-#include "android/OutputMix_to_android.h"
-#include "android/AudioPlayer_to_android.h"
-#include "android/AudioRecorder_to_android.h"
-#endif
-
-extern predestroy_t C3DGroup_PreDestroy(void *self);
-
-extern SLresult CAudioPlayer_Realize(void *self, SLboolean async);
-extern SLresult CAudioPlayer_Resume(void *self, SLboolean async);
-extern void CAudioPlayer_Destroy(void *self);
-extern predestroy_t CAudioPlayer_PreDestroy(void *self);
-
-extern SLresult CAudioRecorder_Realize(void *self, SLboolean async);
-extern SLresult CAudioRecorder_Resume(void *self, SLboolean async);
-extern void CAudioRecorder_Destroy(void *self);
-extern predestroy_t CAudioRecorder_PreDestroy(void *self);
-
-extern SLresult CEngine_Realize(void *self, SLboolean async);
-extern SLresult CEngine_Resume(void *self, SLboolean async);
-extern void CEngine_Destroy(void *self);
-extern predestroy_t CEngine_PreDestroy(void *self);
-extern void CEngine_Destroyed(CEngine *self);
-
-extern SLresult COutputMix_Realize(void *self, SLboolean async);
-extern SLresult COutputMix_Resume(void *self, SLboolean async);
-extern void COutputMix_Destroy(void *self);
-extern predestroy_t COutputMix_PreDestroy(void *self);
-
-extern SLresult CMediaPlayer_Realize(void *self, SLboolean async);
-extern SLresult CMediaPlayer_Resume(void *self, SLboolean async);
-extern void CMediaPlayer_Destroy(void *self);
-extern predestroy_t CMediaPlayer_PreDestroy(void *self);
-
-#ifdef USE_SDL
-extern void SDL_open(IEngine *thisEngine);
-extern void SDL_close(void);
-#endif
-
-#define SL_OBJECT_STATE_REALIZING_1 ((SLuint32) 0x4) // async realize on work queue
-#define SL_OBJECT_STATE_REALIZING_2 ((SLuint32) 0x5) // sync realize, or async realize hook
-#define SL_OBJECT_STATE_RESUMING_1 ((SLuint32) 0x6) // async resume on work queue
-#define SL_OBJECT_STATE_RESUMING_2 ((SLuint32) 0x7) // sync resume, or async resume hook
-#define SL_OBJECT_STATE_SUSPENDING ((SLuint32) 0x8) // suspend in progress
-#define SL_OBJECT_STATE_REALIZING_1A ((SLuint32) 0x9) // abort while async realize on work queue
-#define SL_OBJECT_STATE_RESUMING_1A ((SLuint32) 0xA) // abort while async resume on work queue
-#define SL_OBJECT_STATE_DESTROYING ((SLuint32) 0xB) // destroy object when no strong references
-
-#ifdef USE_OUTPUTMIXEXT
-#define SL_PLAYSTATE_STOPPING ((SLuint32) 0x4) // Play::Stop while PLAYING
-// If we needed it, could have PLAYING mean mixer is currently reading from front buffer,
-// while PLAYABLE would mean application requested PLAYING, but buffer queue is empty
-#endif
-
-#ifndef ANDROID
-extern void *sync_start(void *arg);
-#endif
-extern SLresult err_to_result(int err);
-
-#ifdef __GNUC__
-#define ctz __builtin_ctz
-#else
-extern unsigned ctz(unsigned);
-#endif
-extern const char * const interface_names[MPH_MAX];
-#include "platform.h"
-#include "attr.h"
-#include "handlers.h"
-#include "trace.h"
-
-#ifdef USE_SNDFILE
-extern void audioPlayerTransportUpdate(CAudioPlayer *audioPlayer);
-#endif
-
-extern SLresult IBufferQueue_Enqueue(SLBufferQueueItf self, const void *pBuffer, SLuint32 size);
-extern SLresult IBufferQueue_Clear(SLBufferQueueItf self);
-extern SLresult IBufferQueue_RegisterCallback(SLBufferQueueItf self,
- slBufferQueueCallback callback, void *pContext);
-
-extern bool IsInterfaceInitialized(IObject *thiz, unsigned MPH);
-extern SLresult AcquireStrongRef(IObject *object, SLuint32 expectedObjectID);
-extern void ReleaseStrongRef(IObject *object);
-extern void ReleaseStrongRefAndUnlockExclusive(IObject *object);
-
-extern COutputMix *CAudioPlayer_GetOutputMix(CAudioPlayer *audioPlayer);
-extern SLresult IEngineCapabilities_QueryLEDCapabilities(SLEngineCapabilitiesItf self,
- SLuint32 *pIndex, SLuint32 *pLEDDeviceID, SLLEDDescriptor *pDescriptor);
-extern SLresult IEngineCapabilities_QueryVibraCapabilities(SLEngineCapabilitiesItf self,
- SLuint32 *pIndex, SLuint32 *pVibraDeviceID, SLVibraDescriptor *pDescriptor);
-
-extern CEngine *theOneTrueEngine;
-extern pthread_mutex_t theOneTrueMutex;
-extern unsigned theOneTrueRefCount;
-
-extern LI_API SLresult liCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions,
- const SLEngineOption *pEngineOptions, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired,
- const ClassTable *pCEngine_class);
-extern LI_API SLresult liQueryNumSupportedInterfaces(SLuint32 *pNumSupportedInterfaces,
- const ClassTable *clazz);
-extern LI_API SLresult liQuerySupportedInterfaces(SLuint32 index, SLInterfaceID *pInterfaceId,
- const ClassTable *clazz);
-
-// The EnqueueAsyncCallback macros provide a safe way to asynchronously call an application-level
-// callback handler that is permitted to do almost anything, including block. This is intended
-// primarily for "notification" callbacks such as play head progress. Do not use for callbacks
-// which must be synchronous, such as buffer queue completions. The enqueue may fail if
-// the callback queue is full. This almost always indicates an application error such as blocking
-// for an excessive time within a callback handler or requesting too frequent callbacks. The
-// recommended recovery is to either retry later, or log a warning or error as appropriate.
-// If the callback absolutely must be called, then you should be calling it directly instead.
-// Example usage:
-// CAudioPlayer *ap;
-// SLresult result = EnqueueAsyncCallback_ppi(ap, playCallback, &ap->mPlay.mItf, playContext,
-// SL_PLAYEVENT_HEADATEND);
-// if (SL_RESULT_SUCCESS != result) {
-// LOGW("Callback %p(%p, %p, SL_PLAYEVENT_HEADATEND) dropped", playCallback, &ap->mPlay.mItf,
-// playContext);
-// }
-// which replaces:
-// (*playCallback)(&ap->mPlay.mItf, playContext, SL_PLAYEVENT_HEADATEND);
-#define EnqueueAsyncCallback_ppi(object, handler, p1, p2, i1) \
- ThreadPool_add_ppi(&(object)->mObject.mEngine->mThreadPool, \
- (ClosureHandler_ppi) (handler), (p1), (p2), (i1))
-#define EnqueueAsyncCallback_ppii(object, handler, p1, p2, i1, i2) \
- ThreadPool_add_ppii(&(object)->mObject.mEngine->mThreadPool, \
- (ClosureHandler_ppii) (handler), (p1), (p2), (i1), (i2))
-#define EnqueueAsyncCallback_piipp(object, handler, p1, i1, i2, p2, p3) \
- ThreadPool_add_piipp(&(object)->mObject.mEngine->mThreadPool, \
- (ClosureHandler_piipp) (handler), (p1), (i1), (i2), (p2), (p3))
-
-#define SL_PREFETCHEVENT_NONE ((SLuint32) 0) // placeholder for non-existent SL_PREFETCHEVENT_*
diff --git a/wilhelm/src/sllog.c b/wilhelm/src/sllog.c
deleted file mode 100644
index 4364499..0000000
--- a/wilhelm/src/sllog.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-#ifdef ANDROID
-/** \brief Log messages are prefixed by this tag */
-const char slLogTag[] = "libOpenSLES";
-#endif
-
-#if 0
-// There is no support for configuring the logging level at runtime.
-// If that was needed, it could be done like this:
-// #define SL_LOGx(...) do { if (slLogLevel <= ...) ... } while (0)
-
-/** \brief Default runtime log level */
-
-SLAndroidLogLevel slLogLevel = USE_LOG_RUNTIME;
-
-/** \brief Set the runtime log level */
-
-SL_API void SLAPIENTRY slAndroidSetLogLevel(SLAndroidLogLevel logLevel)
-{
- // Errors can't be disabled
- if (logLevel > SLAndroidLogLevel_Error)
- logLevel = SLAndroidLogLevel_Error;
- slLogLevel = logLevel;
-}
-#endif
diff --git a/wilhelm/src/sllog.h b/wilhelm/src/sllog.h
deleted file mode 100644
index dd8f201..0000000
--- a/wilhelm/src/sllog.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Logging
-
-// In order of decreasing priority, the log priority levels are:
-// Assert
-// E(rror)
-// W(arn)
-// I(nfo)
-// D(ebug)
-// V(erbose)
-// Debug and verbose are usually compiled out except during development.
-
-/** These values match the definitions in system/core/include/cutils/log.h */
-#define SLAndroidLogLevel_Unknown 0
-#define SLAndroidLogLevel_Default 1
-#define SLAndroidLogLevel_Verbose 2
-#define SLAndroidLogLevel_Debug 3
-#define SLAndroidLogLevel_Info 4
-#define SLAndroidLogLevel_Warn 5
-#define SLAndroidLogLevel_Error 6
-#define SLAndroidLogLevel_Fatal 7
-#define SLAndroidLogLevel_Silent 8
-
-// USE_LOG is the minimum log priority level that is enabled at build time.
-// It is configured in Android.mk but can be overridden per source file.
-#ifndef USE_LOG
-#define USE_LOG SLAndroidLogLevel_Info
-#endif
-
-
-#ifdef ANDROID
-
-// The usual Android LOGx macros are not available, so we use the lower-level APIs.
-extern const char slLogTag[];
-
-// can't disable SL_LOGF
-#define SL_LOGF(...) __android_log_print(SLAndroidLogLevel_Fatal, slLogTag, __VA_ARGS__)
-
-#if (USE_LOG <= SLAndroidLogLevel_Error)
-#define SL_LOGE(...) __android_log_print(SLAndroidLogLevel_Error, slLogTag, __VA_ARGS__)
-#else
-#define SL_LOGE(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Warn)
-#define SL_LOGW(...) __android_log_print(SLAndroidLogLevel_Warn, slLogTag, __VA_ARGS__)
-#else
-#define SL_LOGW(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Info)
-#define SL_LOGI(...) __android_log_print(SLAndroidLogLevel_Info, slLogTag, __VA_ARGS__)
-#else
-#define SL_LOGI(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Debug)
-#define SL_LOGD(...) __android_log_print(SLAndroidLogLevel_Debug, slLogTag, __VA_ARGS__)
-#else
-#define SL_LOGD(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Verbose)
-#define SL_LOGV(...) __android_log_print(SLAndroidLogLevel_Verbose, slLogTag, __VA_ARGS__)
-#else
-#define SL_LOGV(...) do { } while (0)
-#endif
-
-#else // !defined(ANDROID)
-
-#if (USE_LOG <= SLAndroidLogLevel_Error)
-#define SL_LOGE(...) do { fprintf(stderr, "SL_LOGE: %s:%s:%d ", __FILE__, __FUNCTION__, __LINE__); \
- fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while(0)
-#else
-#define SL_LOGE(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Warn)
-#define SL_LOGW(...) do { fprintf(stderr, "SL_LOGW: %s:%s:%d ", __FILE__, __FUNCTION__, __LINE__); \
- fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while(0)
-#else
-#define SL_LOGW(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Info)
-#define SL_LOGI(...) do { fprintf(stderr, "SL_LOGI: %s:%s:%d ", __FILE__, __FUNCTION__, __LINE__); \
- fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while(0)
-#else
-#define SL_LOGI(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Debug)
-#define SL_LOGD(...) do { fprintf(stderr, "SL_LOGD: %s:%s:%d ", __FILE__, __FUNCTION__, __LINE__); \
- fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while(0)
-#else
-#define SL_LOGD(...) do { } while (0)
-#endif
-
-#if (USE_LOG <= SLAndroidLogLevel_Verbose)
-#define SL_LOGV(...) do { fprintf(stderr, "SL_LOGV: %s:%s:%d ", __FILE__, __FUNCTION__, __LINE__); \
- fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while(0)
-#else
-#define SL_LOGV(...) do { } while (0)
-#endif
-
-#endif // ANDROID
diff --git a/wilhelm/src/sync.c b/wilhelm/src/sync.c
deleted file mode 100644
index 14acc69..0000000
--- a/wilhelm/src/sync.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* sync */
-
-#include "sles_allinclusive.h"
-
-
-/** \brief Sync thread.
- * The sync thread runs periodically to synchronize audio state between
- * the application and platform-specific device driver; for best results
- * it should run about every graphics frame (e.g. 20 Hz to 50 Hz).
- */
-
-void *sync_start(void *arg)
-{
- CEngine *thiz = (CEngine *) arg;
- for (;;) {
-
- // FIXME should be driven by cond_signal rather than polling,
- // or at least make the poll interval longer or configurable
- usleep(20000*5);
-
- object_lock_exclusive(&thiz->mObject);
- if (thiz->mEngine.mShutdown) {
- thiz->mEngine.mShutdownAck = SL_BOOLEAN_TRUE;
- // broadcast not signal, because this condition is also used for other purposes
- object_cond_broadcast(&thiz->mObject);
- object_unlock_exclusive(&thiz->mObject);
- break;
- }
- if (thiz->m3DCommit.mWaiting) {
- thiz->m3DCommit.mWaiting = 0;
- ++thiz->m3DCommit.mGeneration;
- // There might be more than one thread blocked in Commit, so wake them all
- object_cond_broadcast(&thiz->mObject);
- // here is where we would process the enqueued 3D commands
- }
- // unsigned instanceMask = thiz->mEngine.mInstanceMask; // for debugger
- unsigned changedMask = thiz->mEngine.mChangedMask;
- thiz->mEngine.mChangedMask = 0;
- object_unlock_exclusive(&thiz->mObject);
-
- // now we know which objects exist, and which of those have changes
-
- unsigned combinedMask = changedMask /* | instanceMask for debugger */;
- while (combinedMask) {
- unsigned i = ctz(combinedMask);
- assert(MAX_INSTANCE > i);
- combinedMask &= ~(1 << i);
- IObject *instance = (IObject *) thiz->mEngine.mInstances[i];
- // Could be NULL during construct or destroy
- if (NULL == instance) {
- continue;
- }
-
- object_lock_exclusive(instance);
- unsigned attributesMask = instance->mAttributesMask;
- instance->mAttributesMask = 0;
-
- switch (IObjectToObjectID(instance)) {
- case SL_OBJECTID_AUDIOPLAYER:
- // do something here
- object_unlock_exclusive(instance);
-#ifdef USE_SNDFILE
- if (attributesMask & (ATTR_POSITION | ATTR_TRANSPORT)) {
- CAudioPlayer *audioPlayer = (CAudioPlayer *) instance;
- audioPlayerTransportUpdate(audioPlayer);
- }
-#endif
- break;
-
- default:
- object_unlock_exclusive(instance);
- break;
- }
- }
- }
- return NULL;
-}
diff --git a/wilhelm/src/trace.c b/wilhelm/src/trace.c
deleted file mode 100644
index 32ab080..0000000
--- a/wilhelm/src/trace.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* trace debugging */
-
-#include "sles_allinclusive.h"
-
-#ifdef USE_TRACE
-
-// This should be the only global variable
-static unsigned slTraceEnabled = SL_TRACE_DEFAULT;
-
-
-void slTraceSetEnabled(unsigned enabled)
-{
- slTraceEnabled = enabled;
-}
-
-
-void slTraceEnterGlobal(const char *function)
-{
- if (SL_TRACE_ENTER & slTraceEnabled) {
- SL_LOGD("Entering %s", function);
- }
-}
-
-
-void slTraceLeaveGlobal(const char *function, SLresult result)
-{
- if (SL_RESULT_SUCCESS == result) {
- if (SL_TRACE_LEAVE_SUCCESS & slTraceEnabled) {
- SL_LOGD("Leaving %s", function);
- }
- } else {
- if (SL_TRACE_LEAVE_FAILURE & slTraceEnabled) {
- const char *str = slesutResultToString(result);
- if (NULL != str) {
- SL_LOGW("Leaving %s (%s)", function, str);
- } else {
- SL_LOGW("Leaving %s (0x%X)", function, result);
- }
- }
- }
-}
-
-
-void slTraceEnterInterface(const char *function)
-{
- if (!(SL_TRACE_ENTER & slTraceEnabled)) {
- return;
- }
- if (*function == 'I') {
- ++function;
- }
- const char *underscore = function;
- while (*underscore != '\0') {
- if (*underscore == '_') {
- if (/*(strcmp(function, "BufferQueue_Enqueue") &&
- strcmp(function, "BufferQueue_GetState") &&
- strcmp(function, "OutputMixExt_FillBuffer")) &&*/
- true) {
- SL_LOGD("Entering %.*s::%s", (int) (underscore - function), function,
- &underscore[1]);
- }
- return;
- }
- ++underscore;
- }
- SL_LOGV("Entering %s", function);
-}
-
-
-void slTraceLeaveInterface(const char *function, SLresult result)
-{
- if (!((SL_TRACE_LEAVE_SUCCESS | SL_TRACE_LEAVE_FAILURE) & slTraceEnabled)) {
- return;
- }
- if (*function == 'I') {
- ++function;
- }
- const char *underscore = function;
- while (*underscore != '\0') {
- if (*underscore == '_') {
- break;
- }
- ++underscore;
- }
- if (SL_RESULT_SUCCESS == result) {
- if (SL_TRACE_LEAVE_SUCCESS & slTraceEnabled) {
- if (*underscore == '_') {
- SL_LOGD("Leaving %.*s::%s", (int) (underscore - function), function,
- &underscore[1]);
- } else {
- SL_LOGD("Leaving %s", function);
- }
- }
- } else {
- if (SL_TRACE_LEAVE_FAILURE & slTraceEnabled) {
- const char *str = slesutResultToString(result);
- if (*underscore == '_') {
- if (NULL != str) {
- SL_LOGW("Leaving %.*s::%s (%s)", (int) (underscore - function), function,
- &underscore[1], str);
- } else {
- SL_LOGW("Leaving %.*s::%s (0x%X)", (int) (underscore - function), function,
- &underscore[1], result);
- }
- } else {
- if (NULL != str) {
- SL_LOGW("Leaving %s (%s)", function, str);
- } else {
- SL_LOGW("Leaving %s (0x%X)", function, result);
- }
- }
- }
- }
-}
-
-
-void slTraceEnterInterfaceVoid(const char *function)
-{
- if (SL_TRACE_ENTER & slTraceEnabled) {
- slTraceEnterInterface(function);
- }
-}
-
-
-void slTraceLeaveInterfaceVoid(const char *function)
-{
- if (SL_TRACE_LEAVE_VOID & slTraceEnabled) {
- slTraceLeaveInterface(function, SL_RESULT_SUCCESS);
- }
-}
-
-#else
-
-void slTraceSetEnabled(unsigned enabled)
-{
-}
-
-#endif // USE_TRACE
diff --git a/wilhelm/src/trace.h b/wilhelm/src/trace.h
deleted file mode 100644
index 242a409..0000000
--- a/wilhelm/src/trace.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Trace debugging
-
-// Always defined, but may be a no-op if trace support is disabled at compile-time
-extern void slTraceSetEnabled(unsigned enabled);
-
-#define SL_TRACE_ENTER 0x1
-#define SL_TRACE_LEAVE_FAILURE 0x2
-#define SL_TRACE_LEAVE_VOID 0x4
-#define SL_TRACE_LEAVE_SUCCESS 0x8
-#define SL_TRACE_LEAVE (SL_TRACE_LEAVE_FAILURE | SL_TRACE_LEAVE_VOID | \
- SL_TRACE_LEAVE_SUCCESS)
-#define SL_TRACE_ALL (SL_TRACE_ENTER | SL_TRACE_LEAVE)
-#ifndef SL_TRACE_DEFAULT
-#define SL_TRACE_DEFAULT (SL_TRACE_LEAVE_FAILURE)
-#endif
-
-#ifndef USE_TRACE
-
-#define SL_ENTER_GLOBAL SLresult result;
-#define SL_LEAVE_GLOBAL return result;
-#define SL_ENTER_INTERFACE SLresult result;
-#define SL_LEAVE_INTERFACE return result;
-#define SL_ENTER_INTERFACE_VOID
-#define SL_LEAVE_INTERFACE_VOID return;
-
-#define XA_ENTER_GLOBAL XAresult result;
-#define XA_LEAVE_GLOBAL return result;
-#define XA_ENTER_INTERFACE XAresult result;
-#define XA_LEAVE_INTERFACE return result;
-
-#else
-
-extern void slTraceEnterGlobal(const char *function);
-extern void slTraceLeaveGlobal(const char *function, SLresult result);
-extern void slTraceEnterInterface(const char *function);
-extern void slTraceLeaveInterface(const char *function, SLresult result);
-extern void slTraceEnterInterfaceVoid(const char *function);
-extern void slTraceLeaveInterfaceVoid(const char *function);
-#define SL_ENTER_GLOBAL SLresult result; slTraceEnterGlobal(__FUNCTION__);
-#define SL_LEAVE_GLOBAL slTraceLeaveGlobal(__FUNCTION__, result); return result;
-#define SL_ENTER_INTERFACE SLresult result; slTraceEnterInterface(__FUNCTION__);
-#define SL_LEAVE_INTERFACE slTraceLeaveInterface(__FUNCTION__, result); return result;
-#define SL_ENTER_INTERFACE_VOID slTraceEnterInterfaceVoid(__FUNCTION__);
-#define SL_LEAVE_INTERFACE_VOID slTraceLeaveInterfaceVoid(__FUNCTION__); return;
-
-#define XA_ENTER_GLOBAL XAresult result; slTraceEnterGlobal(__FUNCTION__);
-#define XA_LEAVE_GLOBAL slTraceLeaveGlobal(__FUNCTION__, result); return result;
-#define XA_ENTER_INTERFACE XAresult result; slTraceEnterInterface(__FUNCTION__);
-#define XA_LEAVE_INTERFACE slTraceLeaveInterface(__FUNCTION__, result); return result;
-
-#endif
diff --git a/wilhelm/src/ut/OpenSLESUT.c b/wilhelm/src/ut/OpenSLESUT.c
deleted file mode 100644
index d6c2114..0000000
--- a/wilhelm/src/ut/OpenSLESUT.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file OpenSLESUT.c OpenSL ES Utility Toolkit */
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-#include "OpenSLESUT.h"
-#include <stdio.h>
-#include <string.h>
-
-
-/** \brief Maps an interface ID to its display name */
-
-typedef struct
-{
- const SLInterfaceID *iid; ///< The interface ID
- const char *name; ///< The display name
-} Pair;
-
-// ## is token concatenation e.g. a##b becomes ab
-// # is stringize operator to convert a symbol to a string constant e.g. #a becomes "a"
-
-#define _(x) { &SL_IID_##x, #x }
-
-/** \brief Array of mappings from interface IDs to display names */
-
-static Pair pairs[] = {
- _(3DCOMMIT),
- _(3DDOPPLER),
- _(3DGROUPING),
- _(3DLOCATION),
- _(3DMACROSCOPIC),
- _(3DSOURCE),
- _(AUDIODECODERCAPABILITIES),
- _(AUDIOENCODER),
- _(AUDIOENCODERCAPABILITIES),
- _(AUDIOIODEVICECAPABILITIES),
- _(BASSBOOST),
- _(BUFFERQUEUE),
- _(DEVICEVOLUME),
- _(DYNAMICINTERFACEMANAGEMENT),
- _(DYNAMICSOURCE),
- _(EFFECTSEND),
- _(ENGINE),
- _(ENGINECAPABILITIES),
- _(ENVIRONMENTALREVERB),
- _(EQUALIZER),
- _(LED),
- _(METADATAEXTRACTION),
- _(METADATATRAVERSAL),
- _(MIDIMESSAGE),
- _(MIDIMUTESOLO),
- _(MIDITEMPO),
- _(MIDITIME),
- _(MUTESOLO),
- _(NULL),
- _(OBJECT),
- _(OUTPUTMIX),
- _(PITCH),
- _(PLAY),
- _(PLAYBACKRATE),
- _(PREFETCHSTATUS),
- _(PRESETREVERB),
- _(RATEPITCH),
- _(RECORD),
- _(SEEK),
- _(THREADSYNC),
- _(VIBRA),
- _(VIRTUALIZER),
- _(VISUALIZATION),
- _(VOLUME),
-#if 0 // ifdef USE_OUTPUTMIXEXT
- _(OUTPUTMIXEXT),
-#endif
-#ifdef ANDROID
- _(ANDROIDEFFECT),
- _(ANDROIDEFFECTCAPABILITIES),
- _(ANDROIDEFFECTSEND),
- _(ANDROIDCONFIGURATION),
- _(ANDROIDSIMPLEBUFFERQUEUE)
-#endif
-};
-
-
-/** \brief Print an interface ID in human-readable format */
-
-void slesutPrintIID(SLInterfaceID iid)
-{
- Pair *p;
- const Pair *end = &pairs[sizeof(pairs)/sizeof(pairs[0])];
- for (p = pairs; p != end; ++p) {
- if (!memcmp(*p->iid, iid, sizeof(struct SLInterfaceID_))) {
- printf("SL_IID_%s = ", p->name);
- break;
- }
- }
- printf(
- "{ 0x%08X, 0x%04X, 0x%04X, 0x%04X, { 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X } }\n",
- (unsigned) iid->time_low, iid->time_mid, iid->time_hi_and_version, iid->clock_seq,
- iid->node[0], iid->node[1], iid->node[2], iid->node[3], iid->node[4], iid->node[5]);
-}
-
-
-/** \brief Print an array of interface IDs in human-readable format,
- * including whether they are required or optional
- */
-
-void slesutPrintIIDs(SLInterfaceID *pInterfaceIds, SLboolean *pInterfaceRequired,
- unsigned numInterfaces)
-{
- unsigned i;
- for (i = 0; i < numInterfaces; ++i) {
- printf("interfaces[%u]=", i);
- slesutPrintIID(pInterfaceIds[i]);
- printf(" %s\n", (unsigned) pInterfaceRequired[i] ? "required" : "optional");
- }
-}
-
-
-/** \brief Convert an object ID to a string or NULL. */
-
-const char *slesutObjectIDToString(SLuint32 objectID)
-{
- static const char * const objectIDstrings[10] = {
- "SL_OBJECTID_ENGINE",
- "SL_OBJECTID_LEDDEVICE",
- "SL_OBJECTID_VIBRADEVICE",
- "SL_OBJECTID_AUDIOPLAYER",
- "SL_OBJECTID_AUDIORECORDER",
- "SL_OBJECTID_MIDIPLAYER",
- "SL_OBJECTID_LISTENER",
- "SL_OBJECTID_3DGROUP",
- "SL_OBJECTID_OUTPUTMIX",
- "SL_OBJECTID_METADATAEXTRACTOR"
- };
- return (0x1001 <= objectID) && (objectID <= 0x100A) ? objectIDstrings[objectID - 0x1001] : NULL;
-}
diff --git a/wilhelm/src/ut/OpenSLESUT.h b/wilhelm/src/ut/OpenSLESUT.h
deleted file mode 100644
index 59f38ce..0000000
--- a/wilhelm/src/ut/OpenSLESUT.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file OpenSLESUT.h OpenSL ES Utility Toolkit */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void slesutPrintIID(SLInterfaceID iid);
-extern const char *slesutResultToString(SLresult result);
-extern const char *slesutObjectIDToString(SLuint32 objectID);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/wilhelm/src/ut/slesutResult.c b/wilhelm/src/ut/slesutResult.c
deleted file mode 100644
index 03c0f70..0000000
--- a/wilhelm/src/ut/slesutResult.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <SLES/OpenSLES.h>
-#include "OpenSLESUT.h"
-
-
-/** \brief Maximum result return code */
-
-#define SLESUT_RESULT_MAX (SL_RESULT_CONTROL_LOST + 1)
-
-/** \brief Array of strings correponding to each result code */
-
-static const char * const slesutResultStrings[SLESUT_RESULT_MAX] = {
- "SL_RESULT_SUCCESS",
- "SL_RESULT_PRECONDITIONS_VIOLATED",
- "SL_RESULT_PARAMETER_INVALID",
- "SL_RESULT_MEMORY_FAILURE",
- "SL_RESULT_RESOURCE_ERROR",
- "SL_RESULT_RESOURCE_LOST",
- "SL_RESULT_IO_ERROR",
- "SL_RESULT_BUFFER_INSUFFICIENT",
- "SL_RESULT_CONTENT_CORRUPTED",
- "SL_RESULT_CONTENT_UNSUPPORTED",
- "SL_RESULT_CONTENT_NOT_FOUND",
- "SL_RESULT_PERMISSION_DENIED",
- "SL_RESULT_FEATURE_UNSUPPORTED",
- "SL_RESULT_INTERNAL_ERROR",
- "SL_RESULT_UNKNOWN_ERROR",
- "SL_RESULT_OPERATION_ABORTED",
- "SL_RESULT_CONTROL_LOST"
-};
-
-
-/** \brief Convert a result code to a string or NULL. */
-
-const char *slesutResultToString(SLresult result)
-{
- // note that SLresult is unsigned
- return result < SLESUT_RESULT_MAX ? slesutResultStrings[result] : NULL;
-}
diff --git a/wilhelm/src/xa_entry.c b/wilhelm/src/xa_entry.c
deleted file mode 100644
index b1cddd5..0000000
--- a/wilhelm/src/xa_entry.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-/** \brief xaCreateEngine Function */
-
-XA_API XAresult XAAPIENTRY xaCreateEngine(XAObjectItf *pEngine, XAuint32 numOptions,
- const XAEngineOption *pEngineOptions, XAuint32 numInterfaces,
- const XAInterfaceID *pInterfaceIds, const XAboolean *pInterfaceRequired)
-{
- XA_ENTER_GLOBAL
-
- result = liCreateEngine((SLObjectItf *) pEngine, numOptions,
- (const SLEngineOption *) pEngineOptions, numInterfaces,
- (const SLInterfaceID *) pInterfaceIds, (const SLboolean *) pInterfaceRequired,
- objectIDtoClass(XA_OBJECTID_ENGINE));
-
- XA_LEAVE_GLOBAL
-}
-
-
-/** \brief xaQueryNumSupportedEngineInterfaces Function */
-
-XA_API XAresult XAAPIENTRY xaQueryNumSupportedEngineInterfaces(XAuint32 *pNumSupportedInterfaces)
-{
- XA_ENTER_GLOBAL
-
- result = liQueryNumSupportedInterfaces(pNumSupportedInterfaces,
- objectIDtoClass(XA_OBJECTID_ENGINE));
-
- XA_LEAVE_GLOBAL
-}
-
-
-/** \brief xaQuerySupportedEngineInterfaces Function */
-
-XA_API XAresult XAAPIENTRY xaQuerySupportedEngineInterfaces(XAuint32 index,
- XAInterfaceID *pInterfaceId)
-{
- XA_ENTER_GLOBAL
-
- result = liQuerySupportedInterfaces(index, (SLInterfaceID *) pInterfaceId,
- objectIDtoClass(XA_OBJECTID_ENGINE));
-
- XA_LEAVE_GLOBAL
-}
diff --git a/wilhelm/src/xa_iid.c b/wilhelm/src/xa_iid.c
deleted file mode 100644
index 0f51ae5..0000000
--- a/wilhelm/src/xa_iid.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sles_allinclusive.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// OpenMAX AL 1.0.1 interfaces
-
-const XAInterfaceID XA_IID_AUDIODECODERCAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XAAUDIODECODERCAPABILITIES];
-const XAInterfaceID XA_IID_AUDIOENCODER = (XAInterfaceID) &SL_IID_array[MPH_XAAUDIOENCODER];
-const XAInterfaceID XA_IID_AUDIOENCODERCAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XAAUDIOENCODERCAPABILITIES];
-const XAInterfaceID XA_IID_AUDIOIODEVICECAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XAAUDIOIODEVICECAPABILITIES];
-const XAInterfaceID XA_IID_CAMERA = (XAInterfaceID) &SL_IID_array[MPH_XACAMERA];
-const XAInterfaceID XA_IID_CAMERACAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XACAMERACAPABILITIES];
-const XAInterfaceID XA_IID_CONFIGEXTENSION = (XAInterfaceID) &SL_IID_array[MPH_XACONFIGEXTENSION];
-const XAInterfaceID XA_IID_DEVICEVOLUME = (XAInterfaceID) &SL_IID_array[MPH_XADEVICEVOLUME];
-const XAInterfaceID XA_IID_DYNAMICINTERFACEMANAGEMENT =
- (XAInterfaceID) &SL_IID_array[MPH_XADYNAMICINTERFACEMANAGEMENT];
-const XAInterfaceID XA_IID_DYNAMICSOURCE = (XAInterfaceID) &SL_IID_array[MPH_XADYNAMICSOURCE];
-const XAInterfaceID XA_IID_ENGINE = (XAInterfaceID) &SL_IID_array[MPH_XAENGINE];
-const XAInterfaceID XA_IID_EQUALIZER = (XAInterfaceID) &SL_IID_array[MPH_XAEQUALIZER];
-const XAInterfaceID XA_IID_IMAGECONTROLS = (XAInterfaceID) &SL_IID_array[MPH_XAIMAGECONTROLS];
-const XAInterfaceID XA_IID_IMAGEDECODERCAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XAIMAGEDECODERCAPABILITIES];
-const XAInterfaceID XA_IID_IMAGEEFFECTS = (XAInterfaceID) &SL_IID_array[MPH_XAIMAGEEFFECTS];
-const XAInterfaceID XA_IID_IMAGEENCODER = (XAInterfaceID) &SL_IID_array[MPH_XAIMAGEENCODER];
-const XAInterfaceID XA_IID_IMAGEENCODERCAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XAIMAGEENCODERCAPABILITIES];
-const XAInterfaceID XA_IID_LED = (XAInterfaceID) &SL_IID_array[MPH_XALED];
-const XAInterfaceID XA_IID_METADATAEXTRACTION =
- (XAInterfaceID) &SL_IID_array[MPH_XAMETADATAEXTRACTION];
-const XAInterfaceID XA_IID_METADATAINSERTION =
- (XAInterfaceID) &SL_IID_array[MPH_XAMETADATAINSERTION];
-const XAInterfaceID XA_IID_METADATATRAVERSAL =
- (XAInterfaceID) &SL_IID_array[MPH_XAMETADATATRAVERSAL];
-const XAInterfaceID XA_IID_NULL = (XAInterfaceID) &SL_IID_array[MPH_XANULL];
-const XAInterfaceID XA_IID_OBJECT = (XAInterfaceID) &SL_IID_array[MPH_XAOBJECT];
-const XAInterfaceID XA_IID_OUTPUTMIX = (XAInterfaceID) &SL_IID_array[MPH_XAOUTPUTMIX];
-const XAInterfaceID XA_IID_PLAY = (XAInterfaceID) &SL_IID_array[MPH_XAPLAY];
-const XAInterfaceID XA_IID_PLAYBACKRATE = (XAInterfaceID) &SL_IID_array[MPH_XAPLAYBACKRATE];
-const XAInterfaceID XA_IID_PREFETCHSTATUS = (XAInterfaceID) &SL_IID_array[MPH_XAPREFETCHSTATUS];
-const XAInterfaceID XA_IID_RADIO = (XAInterfaceID) &SL_IID_array[MPH_XARADIO];
-const XAInterfaceID XA_IID_RDS = (XAInterfaceID) &SL_IID_array[MPH_XARDS];
-const XAInterfaceID XA_IID_RECORD = (XAInterfaceID) &SL_IID_array[MPH_XARECORD];
-const XAInterfaceID XA_IID_SEEK = (XAInterfaceID) &SL_IID_array[MPH_XASEEK];
-const XAInterfaceID XA_IID_SNAPSHOT = (XAInterfaceID) &SL_IID_array[MPH_XASNAPSHOT];
-const XAInterfaceID XA_IID_STREAMINFORMATION =
- (XAInterfaceID) &SL_IID_array[MPH_XASTREAMINFORMATION];
-const XAInterfaceID XA_IID_THREADSYNC = (XAInterfaceID) &SL_IID_array[MPH_XATHREADSYNC];
-const XAInterfaceID XA_IID_VIBRA = (XAInterfaceID) &SL_IID_array[MPH_XAVIBRA];
-const XAInterfaceID XA_IID_VIDEODECODERCAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XAVIDEODECODERCAPABILITIES];
-const XAInterfaceID XA_IID_VIDEOENCODER = (XAInterfaceID) &SL_IID_array[MPH_XAVIDEOENCODER];
-const XAInterfaceID XA_IID_VIDEOENCODERCAPABILITIES =
- (XAInterfaceID) &SL_IID_array[MPH_XAVIDEOENCODERCAPABILITIES];
-const XAInterfaceID XA_IID_VIDEOPOSTPROCESSING =
- (XAInterfaceID) &SL_IID_array[MPH_XAVIDEOPOSTPROCESSING];
-const XAInterfaceID XA_IID_VOLUME = (XAInterfaceID) &SL_IID_array[MPH_XAVOLUME];
-
-// OpenMAX AL 1.0.1 Android API level 12 extended interfaces
-// GUID and MPH are shared by SL and XA
-const XAInterfaceID XA_IID_ANDROIDBUFFERQUEUESOURCE =
- (XAInterfaceID) &SL_IID_array[MPH_ANDROIDBUFFERQUEUESOURCE];
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/wilhelm/tests/Android.mk b/wilhelm/tests/Android.mk
deleted file mode 100644
index 9580245..0000000
--- a/wilhelm/tests/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Build the unit tests.
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-test_src_files := \
- mimeUri_test.cpp \
-
-shared_libraries := \
- libutils \
- libOpenSLES \
- libstlport
-
-static_libraries := \
- libgtest \
- libgtest_main
-
-c_includes := \
- bionic \
- bionic/libstdc++/include \
- external/gtest/include \
- system/media/wilhelm/include \
- external/stlport/stlport
-
-module_tags := tests
-
-$(foreach file,$(test_src_files), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
- $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
- $(eval LOCAL_C_INCLUDES := $(c_includes)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_MODULE := libopenslestests) \
- $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest) \
- $(eval LOCAL_MODULE_TAGS := $(module_tags)) \
- $(eval include $(BUILD_EXECUTABLE)) \
-)
-
-# Build the manual test programs.
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/wilhelm/tests/automated/Android.mk b/wilhelm/tests/automated/Android.mk
deleted file mode 100644
index fcb9eeb..0000000
--- a/wilhelm/tests/automated/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Build the unit tests.
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- bionic \
- bionic/libstdc++/include \
- external/gtest/include \
- system/media/wilhelm/include \
- external/stlport/stlport \
- system/media/wilhelm/src/ut
-
-LOCAL_SRC_FILES:= \
- BufferQueue_test.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES \
- libstlport
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT \
- libgtest
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
- #LOCAL_SHARED_LIBRARIES += librt
-endif
-
-LOCAL_MODULE:= BufferQueue_test
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-
-include $(BUILD_EXECUTABLE)
-
-# Build the manual test programs.
-include $(call all-subdir-makefiles)
diff --git a/wilhelm/tests/automated/BufferQueue_test.cpp b/wilhelm/tests/automated/BufferQueue_test.cpp
deleted file mode 100644
index 24b6d72..0000000
--- a/wilhelm/tests/automated/BufferQueue_test.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** \file BufferQueue_test.cpp */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "BufferQueue_test"
-
-#ifdef ANDROID
-#include <utils/Log.h>
-#else
-#define LOGV printf
-#endif
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <SLES/OpenSLES.h>
-#include "OpenSLESUT.h"
-#include <gtest/gtest.h>
-
-typedef struct {
- short left;
- short right;
-} stereo;
-
-// volume of sine wave in range 0.0 to 1.0
-static float gVolume = 1.0f;
-
-// 1 second of stereo audio at 44.1 kHz
-static stereo stereoBuffer1[44100 * 1];
-static const SLuint32 invalidNumBuffers[] = { 0, 0xFFFFFFFF, 0x80000000, 0x10002, 0x102,
- 0x101, 0x100 };
-static const SLuint32 validNumBuffers[] = { 1, 2, 3, 4, 5, 6, 7, 8, 255 };
-
-//-----------------------------------------------------------------
-/* Checks for error. If any errors exit the application! */
-void CheckErr(SLresult res) {
- if (SL_RESULT_SUCCESS != res) {
- const char *str = slesutResultToString(res);
- if (NULL == str)
- str = "unknown";
- fprintf(stderr, "CheckErr failure: %s (0x%x), exiting\n", str, res);
- //Fail the test case
- FAIL();
- }
-}
-
-static const SLInterfaceID ids[1] = { SL_IID_BUFFERQUEUE };
-static const SLboolean flags[1] = { SL_BOOLEAN_TRUE };
-static const SLInterfaceID ids_mutesolo[2] = { SL_IID_BUFFERQUEUE, SL_IID_MUTESOLO };
-static const SLboolean flags_mutesolo[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
-static const SLInterfaceID ids_seek[2] = { SL_IID_BUFFERQUEUE, SL_IID_SEEK };
-static const SLboolean flags_seek[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
-
-// The fixture for testing class BufferQueue
-class TestBufferQueue: public ::testing::Test {
-public:
- SLresult res;
- SLObjectItf outputmixObject;
- SLObjectItf engineObject;
-
- SLDataSource audiosrc;
- SLDataSink audiosnk;
- SLDataFormat_PCM pcm;
- SLDataLocator_OutputMix locator_outputmix;
- SLDataLocator_BufferQueue locator_bufferqueue;
- SLBufferQueueItf playerBufferQueue;
- SLBufferQueueState bufferqueueState;
- SLPlayItf playerPlay;
- SLObjectItf playerObject;
- SLEngineItf engineEngine;
- SLuint32 playerState;
-
-protected:
- TestBufferQueue() {
- }
-
- virtual ~TestBufferQueue() {
-
- }
-
- /*Test setup*/
- virtual void SetUp() {
-
- // create engine
- res = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- CheckErr(res);
- res = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- CheckErr(res);
- res = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- CheckErr(res);
-
- // create output mix
- res = (*engineEngine)->CreateOutputMix(engineEngine, &outputmixObject, 0, NULL, NULL);
- CheckErr(res);
- res = (*outputmixObject)->Realize(outputmixObject, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- locator_bufferqueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
- locator_bufferqueue.numBuffers = 0;
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputmixObject;
-
- pcm.formatType = SL_DATAFORMAT_PCM;
- pcm.numChannels = 2;
- pcm.samplesPerSec = SL_SAMPLINGRATE_44_1;
- pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
- pcm.containerSize = 16;
- pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
-
- audiosrc.pLocator = &locator_bufferqueue;
- audiosrc.pFormat = &pcm;
- audiosnk.pLocator = &locator_outputmix;
- audiosnk.pFormat = NULL;
-
- // initialize the test tone to be a sine sweep from 441 Hz to 882 Hz
- unsigned nframes = sizeof(stereoBuffer1) / sizeof(stereoBuffer1[0]);
- float nframes_ = (float) nframes;
- SLuint32 i;
- for (i = 0; i < nframes; ++i) {
- float i_ = (float) i;
- float pcm_ = sin((i_ * (1.0f + 0.5f * (i_ / nframes_)) * 0.01 * M_PI * 2.0));
- int pcm = (int) (pcm_ * 32766.0 * gVolume);
- ASSERT_TRUE(-32768 <= pcm && pcm <= 32767) << "pcm out of bound " << pcm;
- stereoBuffer1[i].left = pcm;
- stereoBuffer1[nframes - 1 - i].right = pcm;
- }
- }
-
- virtual void TearDown() {
- // Clean up the mixer and the engine
- // (must be done in that order, and after player destroyed)
- if (outputmixObject){
- (*outputmixObject)->Destroy(outputmixObject);
- outputmixObject = NULL;
- }
- if (engineObject){
- (*engineObject)->Destroy(engineObject);
- engineObject = NULL;
- }
- }
-
- void DestroyPlayer() {
- if (playerObject){
- //printf("destroy player\n");
- (*playerObject)->Destroy(playerObject);
- playerObject = NULL;
- }
- }
-
- /* Test case for creating audio player with various invalid values for numBuffers*/
- void InvalidBuffer() {
-
- for (unsigned i = 0; i < sizeof(invalidNumBuffers) / sizeof(invalidNumBuffers[0]); ++i) {
- SLuint32 numBuffers = invalidNumBuffers[i];
-
- locator_bufferqueue.numBuffers = numBuffers;
- //printf("create audio player - invalid\n");
- SLresult result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject,
- &audiosrc, &audiosnk, 1, ids, flags);
- ASSERT_EQ(SL_RESULT_PARAMETER_INVALID, result);
- ASSERT_EQ(NULL, playerObject);
-
- }
- }
-
- /*Prepare the buffer*/
- void PrepareValidBuffer(SLuint32 numBuffers) {
-
- locator_bufferqueue.numBuffers = numBuffers;
- //printf("create audio player - valid\n");
- res = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc, &audiosnk,
- 1, ids, flags);
- CheckErr(res);
- res = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- CheckErr(res);
- // get the play interface
- res = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- CheckErr(res);
- // verify that player is initially stopped
- res = (*playerPlay)->GetPlayState(playerPlay, &playerState);
- CheckErr(res);
- ASSERT_EQ(SL_PLAYSTATE_STOPPED, playerState);
-
- // get the buffer queue interface
- res = (*playerObject)->GetInterface(playerObject, SL_IID_BUFFERQUEUE, &playerBufferQueue);
- CheckErr(res);
-
- // verify that buffer queue is initially empty
- res = (*playerBufferQueue)->GetState(playerBufferQueue, &bufferqueueState);
- CheckErr(res);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.count);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.playIndex);
- }
-
- void EnqueueMaxBuffer(SLuint32 numBuffers) {
- SLuint32 j;
-
- for (j = 0; j < numBuffers; ++j) {
- res = (*playerBufferQueue)->Enqueue(playerBufferQueue, "test", 4);
- CheckErr(res);
- // verify that each buffer is enqueued properly and increments the buffer count
- res = (*playerBufferQueue)->GetState(playerBufferQueue, &bufferqueueState);
- CheckErr(res);
- ASSERT_EQ(j + 1, bufferqueueState.count);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.playIndex);
- }
- }
-
- void EnqueueExtraBuffer(SLuint32 numBuffers) {
- // enqueue one more buffer and make sure it fails
- res = (*playerBufferQueue)->Enqueue(playerBufferQueue, "test", 4);
- ASSERT_EQ(SL_RESULT_BUFFER_INSUFFICIENT, res);
- // verify that the failed enqueue did not affect the buffer count
- res = (*playerBufferQueue)->GetState(playerBufferQueue, &bufferqueueState);
- CheckErr(res);
- ASSERT_EQ(numBuffers, bufferqueueState.count);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.playIndex);
- }
-
- void SetPlayerState(SLuint32 state) {
- res = (*playerPlay)->SetPlayState(playerPlay, state);
- CheckErr(res);
- //verify the state can set correctly
- GetPlayerState(state);
- }
-
- void GetPlayerState(SLuint32 state) {
- res = (*playerPlay)->GetPlayState(playerPlay, &playerState);
- CheckErr(res);
- ASSERT_EQ(state, playerState);
- }
-
- void ClearQueue() {
- // now clear the buffer queue
- res = (*playerBufferQueue)->Clear(playerBufferQueue);
- CheckErr(res);
- // make sure the clear works
- res = (*playerBufferQueue)->GetState(playerBufferQueue, &bufferqueueState);
- CheckErr(res);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.count);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.playIndex);
- }
-
- void CheckBufferCount(SLuint32 ExpectedCount, SLuint32 ExpectedPlayIndex) {
- // changing the play state should not affect the buffer count
- res = (*playerBufferQueue)->GetState(playerBufferQueue, &bufferqueueState);
- CheckErr(res);
- ASSERT_EQ(ExpectedCount, bufferqueueState.count);
- ASSERT_EQ(ExpectedPlayIndex, bufferqueueState.playIndex);
- }
-
- void PlayBufferQueue() {
- // enqueue a buffer
- res = (*playerBufferQueue)->Enqueue(playerBufferQueue, stereoBuffer1,
- sizeof(stereoBuffer1));
- CheckErr(res);
- // set play state to playing
- res = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
- CheckErr(res);
- // state should be playing immediately after enqueue
- res = (*playerPlay)->GetPlayState(playerPlay, &playerState);
- CheckErr(res);
- ASSERT_EQ(SL_PLAYSTATE_PLAYING, playerState);
- // buffer should still be on the queue
- res = (*playerBufferQueue)->GetState(playerBufferQueue, &bufferqueueState);
- CheckErr(res);
- ASSERT_EQ((SLuint32) 1, bufferqueueState.count);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.playIndex);
- //LOGV("Before 1.5 sec");
- // wait 1.5 seconds
- usleep(1500000);
- //LOGV("After 1.5 sec");
- // state should still be playing
- res = (*playerPlay)->GetPlayState(playerPlay, &playerState);
- //LOGV("GetPlayState");
- CheckErr(res);
- ASSERT_EQ(SL_PLAYSTATE_PLAYING, playerState);
- // buffer should be removed from the queue
- res = (*playerBufferQueue)->GetState(playerBufferQueue, &bufferqueueState);
- CheckErr(res);
- ASSERT_EQ((SLuint32) 0, bufferqueueState.count);
- ASSERT_EQ((SLuint32) 1, bufferqueueState.playIndex);
- //LOGV("TestEnd");
- }
-};
-
-TEST_F(TestBufferQueue, testInvalidBuffer){
- //LOGV("Test Fixture: InvalidBuffer");
- InvalidBuffer();
-}
-
-TEST_F(TestBufferQueue, testMuteSolo) {
- // create audio player with buffer queue data source in stereo PCM format and ask for mute solo
- locator_bufferqueue.numBuffers = 1;
- SLresult result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc,
- &audiosnk, 2, ids_mutesolo, flags_mutesolo);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- ASSERT_TRUE(NULL != playerObject);
- DestroyPlayer();
- // create audio player with buffer queue data source in mono PCM format and ask for mute solo
- pcm.numChannels = 1;
- pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc, &audiosnk,
- 2, ids_mutesolo, flags_mutesolo);
- ASSERT_EQ(SL_RESULT_FEATURE_UNSUPPORTED, result);
- ASSERT_EQ(NULL, playerObject);
- DestroyPlayer();
-}
-
-TEST_F(TestBufferQueue, testSeek) {
- // can create audio player with buffer queue data source and ask for seek
- locator_bufferqueue.numBuffers = 1;
- SLresult result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject,
- &audiosrc, &audiosnk, 2, ids_seek, flags_seek);
- ASSERT_EQ(SL_RESULT_FEATURE_UNSUPPORTED, result);
- ASSERT_EQ(NULL, playerObject);
- DestroyPlayer();
-}
-
-TEST_F(TestBufferQueue, testValidBuffer) {
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- PrepareValidBuffer(numBuffers);
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testEnqueueMaxBuffer) {
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- PrepareValidBuffer(numBuffers);
- EnqueueMaxBuffer(numBuffers);
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testEnqueueExtraBuffer) {
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- PrepareValidBuffer(numBuffers);
- EnqueueMaxBuffer(numBuffers);
- EnqueueExtraBuffer(numBuffers);
- GetPlayerState(SL_PLAYSTATE_STOPPED);
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testEnqueueAtStopped) {
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- PrepareValidBuffer(numBuffers);
- SetPlayerState(SL_PLAYSTATE_STOPPED);
- EnqueueMaxBuffer(numBuffers);
- CheckBufferCount(numBuffers, (SLuint32) 0);
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testEnqueueAtPaused) {
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- PrepareValidBuffer(numBuffers);
- SetPlayerState(SL_PLAYSTATE_PAUSED);
- EnqueueMaxBuffer(numBuffers);
- CheckBufferCount(numBuffers, (SLuint32) 0);
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testClearQueue) {
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- PrepareValidBuffer(numBuffers);
- EnqueueMaxBuffer(numBuffers);
- ClearQueue();
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testStateTransitionEmptyQueue) {
- static const SLuint32 newStates[] = {
- SL_PLAYSTATE_PAUSED, // paused -> paused
- SL_PLAYSTATE_STOPPED, // paused -> stopped
- SL_PLAYSTATE_PAUSED, // stopped -> paused
- SL_PLAYSTATE_PLAYING, // paused -> playing
- SL_PLAYSTATE_PLAYING, // playing -> playing
- SL_PLAYSTATE_STOPPED, // playing -> stopped
- SL_PLAYSTATE_STOPPED, // stopped -> stopped
- SL_PLAYSTATE_PLAYING, // stopped -> playing
- SL_PLAYSTATE_PAUSED // playing -> paused
- };
-
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- SLuint32 j;
-
- PrepareValidBuffer(numBuffers);
- /* Set initial state to paused*/
- SetPlayerState(SL_PLAYSTATE_PAUSED);
-
- for (j = 0; j < sizeof(newStates) / sizeof(newStates[0]); ++j) {
- SetPlayerState(newStates[j]);
- CheckBufferCount((SLuint32) 0, (SLuint32) 0);
- }
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testStateTransitionNonEmptyQueue) {
- static const SLuint32 newStates[] = {
- SL_PLAYSTATE_PAUSED, // paused -> paused
- SL_PLAYSTATE_STOPPED, // paused -> stopped
- SL_PLAYSTATE_STOPPED, // stopped -> stopped
- SL_PLAYSTATE_PAUSED // stopped -> paused
- };
-
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- SLuint32 j;
-
- /* Prepare the player */
- PrepareValidBuffer(numBuffers);
- EnqueueMaxBuffer(numBuffers);
- SetPlayerState(SL_PLAYSTATE_PAUSED);
-
- for (j = 0; j < sizeof(newStates) / sizeof(newStates[0]); ++j) {
- SetPlayerState(newStates[j]);
- CheckBufferCount(numBuffers, (SLuint32) 0);
- }
- DestroyPlayer();
- }
-}
-
-TEST_F(TestBufferQueue, testStatePlayBuffer){
- for (unsigned i = 0; i < sizeof(validNumBuffers) / sizeof(validNumBuffers[0]); ++i) {
- SLuint32 numBuffers = validNumBuffers[i];
- PrepareValidBuffer(numBuffers);
- PlayBufferQueue();
- DestroyPlayer();
- }
-}
-
-int main(int argc, char **argv) {
- testing::InitGoogleTest(&argc, argv);
-#if 1 // temporary workaround if hardware volume control is not working
- const char *VOLUME = getenv("BufferQueue_test_VOLUME");
- if (NULL != VOLUME) {
- float volume = atof(VOLUME);
- if (volume >= 0.0f && volume <= 1.0f) {
- gVolume = volume;
- }
- }
-#endif
- return RUN_ALL_TESTS();
-}
diff --git a/wilhelm/tests/examples/Android.mk b/wilhelm/tests/examples/Android.mk
deleted file mode 100644
index ac06ee7..0000000
--- a/wilhelm/tests/examples/Android.mk
+++ /dev/null
@@ -1,325 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# slesTest_recBuffQueue
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestRecBuffQueue.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_recBuffQueue
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_playFdPath
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestPlayFdPath.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_playFdPath
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_feedback
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestFeedback.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
- #LOCAL_SHARED_LIBRARIES += librt
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_feedback
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_sawtoothBufferQueue
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestSawtoothBufferQueue.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
- #LOCAL_SHARED_LIBRARIES += librt
-endif
-
-LOCAL_MODULE:= slesTest_sawtoothBufferQueue
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_eqFdPath
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestEqFdPath.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_eqFdPath
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_eqOutputPath
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestEqOutputPath.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_eqOutputPath
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_bassboostPath
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestBassBoostPath.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_bassboostPath
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_virtualizer
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestVirtualizerPath.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_virtualizer
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_effectCapabilities
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestEffectCapabilities.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_effectCapabilities
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_sendToPresetReverb
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestSendToPresetReverb.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_sendToPresetReverb
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_decodeToBuffQueue
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestDecodeToBuffQueue.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_decodeToBuffQueue
-
-include $(BUILD_EXECUTABLE)
-
-###################
-# slesTestDecodeAac
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestDecodeAac.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := libcpustats
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTestDecodeAac
-
-include $(BUILD_EXECUTABLE)
-
-#######################################
-# OpenMAX AL example code
-
-# xaVideoDecoderCapabilities
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- xaVideoDecoderCapabilities.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenMAXAL
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= xaVideoDecoderCapabilities
-
-include $(BUILD_EXECUTABLE)
diff --git a/wilhelm/tests/examples/slesTestBassBoostPath.cpp b/wilhelm/tests/examples/slesTestBassBoostPath.cpp
deleted file mode 100644
index 96c3352..0000000
--- a/wilhelm/tests/examples/slesTestBassBoostPath.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-#define TIME_S_BETWEEN_BB_ON_OFF 3
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play an audio path by opening a file descriptor on that path */
-void TestBassBoostPathFromFD(SLObjectItf sl, const char* path, int16_t boostStrength, bool alwaysOn)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
-#ifdef ANDROID
- SLDataLocator_AndroidFD locatorFd;
-#else
- SLDataLocator_URI locatorUri;
-#endif
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Interfaces for the audio player */
- SLPlayItf playItf;
- SLPrefetchStatusItf prefetchItf;
- SLBassBoostItf bbItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for required interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PREFETCHSTATUS;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_BASSBOOST;
-
-#ifdef ANDROID
- /* Setup the data source structure for the URI */
- locatorFd.locatorType = SL_DATALOCATOR_ANDROIDFD;
- int fd = open(path, O_RDONLY);
- if (fd == -1) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
- locatorFd.fd = (SLint32) fd;
- locatorFd.length = SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE;
- locatorFd.offset = 0;
-#else
- locatorUri.locatorType = SL_DATALOCATOR_URI;
- locatorUri.URI = (SLchar *) path;
-#endif
-
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
-#ifdef ANDROID
- audioSource.pLocator = (void*)&locatorFd;
-#else
- audioSource.pLocator = (void*)&locatorUri;
-#endif
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 2,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLBassBoostItf interfaces for the player */
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_BASSBOOST, (void*)&bbItf);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- ExitOnError(result);
- }
-
- /* Get duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- durationInMsec = 5000;
- }
-
- /* Start playback */
- fprintf(stdout, "Starting to play\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- /* Configure BassBoost */
- SLboolean strengthSupported = SL_BOOLEAN_FALSE;
- result = (*bbItf)->IsStrengthSupported(bbItf, &strengthSupported);
- ExitOnError(result);
- if (SL_BOOLEAN_FALSE == strengthSupported) {
- fprintf(stdout, "BassBoost strength is not supported on this platform. Too bad!\n");
- } else {
- fprintf(stdout, "BassBoost strength is supported, setting strength to %d\n", boostStrength);
- result = (*bbItf)->SetStrength(bbItf, boostStrength);
- ExitOnError(result);
- }
-
- SLpermille strength = 0;
- result = (*bbItf)->GetRoundedStrength(bbItf, &strength);
- ExitOnError(result);
- fprintf(stdout, "Rounded strength of boost = %d\n", strength);
-
-
- /* Switch BassBoost on/off every TIME_S_BETWEEN_BB_ON_OFF seconds unless always on */
- SLboolean previousEnabled = SL_BOOLEAN_FALSE;
- for(unsigned int j=0 ; j<(durationInMsec/(1000*TIME_S_BETWEEN_BB_ON_OFF)) ; j++) {
- SLboolean enabled;
- result = (*bbItf)->IsEnabled(bbItf, &enabled);
- ExitOnError(result);
- enabled = alwaysOn || !enabled;
- if (enabled != previousEnabled) {
- result = (*bbItf)->SetEnabled(bbItf, enabled);
- ExitOnError(result);
- previousEnabled = enabled;
- if (SL_BOOLEAN_TRUE == enabled) {
- fprintf(stdout, "BassBoost on\n");
- } else {
- fprintf(stdout, "BassBoost off\n");
- }
- }
- usleep(TIME_S_BETWEEN_BB_ON_OFF * 1000 * 1000);
- }
-
- /* Make sure player is stopped */
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-
-#ifdef ANDROID
- close(fd);
-#endif
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- const char *programName = argv[0];
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLBassBoostItf ", programName);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_AndroidFD source / OutputMix sink\n");
- fprintf(stdout, "Plays the sound file designated by the given path, ");
- fprintf(stdout, "and applies a bass boost effect of the specified strength,\n");
- fprintf(stdout, "where strength is a integer value between 0 and 1000.\n");
- fprintf(stdout, "Every %d seconds, the BassBoost will be turned on and off,\n",
- TIME_S_BETWEEN_BB_ON_OFF);
- fprintf(stdout, "unless the --always-on option is specified before the path.\n");
-
- bool alwaysOn = false;
- if (argc >= 2 && !strcmp(argv[1], "--always-on")) {
- alwaysOn = true;
- --argc;
- ++argv;
- }
-
- if (argc < 3) {
- fprintf(stdout, "Usage: \t%s [--always-on] path bass_boost_strength\n", programName);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 1000\" \n", programName);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- // intentionally not checking that argv[2], the bassboost strength, is between 0 and 1000
- TestBassBoostPathFromFD(sl, argv[1], (int16_t)atoi(argv[2]), alwaysOn);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestDecodeAac.cpp b/wilhelm/tests/examples/slesTestDecodeAac.cpp
deleted file mode 100644
index 707ab37..0000000
--- a/wilhelm/tests/examples/slesTestDecodeAac.cpp
+++ /dev/null
@@ -1,791 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* AAC ADTS Decode Test
-
-First run the program from shell:
- # slesTestDecodeAac /sdcard/myFile.adts
-
-Expected output:
- OpenSL ES test slesTestDecodeAac: decodes a file containing AAC ADTS data
- Player created
- Player realized
- Enqueueing initial empty buffers to receive decoded PCM data 0 1
- Enqueueing initial full buffers of encoded ADTS data 0 1
- Starting to decode
- Frame counters: encoded=4579 decoded=4579
-
-These use adb on host to retrieve the decoded file:
- % adb pull /sdcard/myFile.adts.raw myFile.raw
-
-How to examine the output with Audacity:
- Project / Import raw data
- Select myFile.raw file, then click Open button
- Choose these options:
- Signed 16-bit PCM
- Little-endian
- 1 Channel (Mono) / 2 Channels (Stereo) based on the PCM information obtained when decoding
- Sample rate based on the PCM information obtained when decoding
- Click Import button
-
-*/
-
-#define QUERY_METADATA
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <cpustats/CentralTendencyStatistics.h>
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-
-/* Explicitly requesting SL_IID_ANDROIDBUFFERQUEUE and SL_IID_ANDROIDSIMPLEBUFFERQUEUE
- * on the AudioPlayer object for decoding, and
- * SL_IID_METADATAEXTRACTION for retrieving the format of the decoded audio.
- */
-#define NUM_EXPLICIT_INTERFACES_FOR_PLAYER 3
-
-/* Number of decoded samples produced by one AAC frame; defined by the standard */
-#define SAMPLES_PER_AAC_FRAME 1024
-/* Size of the encoded AAC ADTS buffer queue */
-#define NB_BUFFERS_IN_ADTS_QUEUE 2 // 2 to 4 is typical
-
-/* Size of the decoded PCM buffer queue */
-#define NB_BUFFERS_IN_PCM_QUEUE 2 // 2 to 4 is typical
-/* Size of each PCM buffer in the queue */
-#define BUFFER_SIZE_IN_BYTES (2*sizeof(short)*SAMPLES_PER_AAC_FRAME)
-
-/* Local storage for decoded PCM audio data */
-int8_t pcmData[NB_BUFFERS_IN_PCM_QUEUE * BUFFER_SIZE_IN_BYTES];
-
-/* destination for decoded data */
-static FILE* outputFp;
-
-#ifdef QUERY_METADATA
-/* metadata key index for the PCM format information we want to retrieve */
-static int channelCountKeyIndex = -1;
-static int sampleRateKeyIndex = -1;
-static int bitsPerSampleKeyIndex = -1;
-static int containerSizeKeyIndex = -1;
-static int channelMaskKeyIndex = -1;
-static int endiannessKeyIndex = -1;
-/* size of the struct to retrieve the PCM format metadata values: the values we're interested in
- * are SLuint32, but it is saved in the data field of a SLMetadataInfo, hence the larger size.
- * Note that this size is queried and displayed at l.XXX for demonstration/test purposes.
- * */
-#define PCM_METADATA_VALUE_SIZE 32
-/* used to query metadata values */
-static SLMetadataInfo *pcmMetaData = NULL;
-/* we only want to query / display the PCM format once */
-static bool formatQueried = false;
-#endif
-
-/* to signal to the test app that the end of the encoded ADTS stream has been reached */
-bool eos = false;
-bool endOfEncodedStream = false;
-
-void *ptr;
-unsigned char *frame;
-size_t filelen;
-size_t encodedFrames = 0;
-size_t encodedSamples = 0;
-size_t decodedFrames = 0;
-size_t decodedSamples = 0;
-size_t totalEncodeCompletions = 0; // number of Enqueue completions received
-CentralTendencyStatistics frameStats;
-size_t pauseFrame = 0; // pause after this many decoded frames, zero means don't pause
-SLboolean createRaw = SL_BOOLEAN_FALSE; // whether to create a .raw file containing PCM data
-
-/* constant to identify a buffer context which is the end of the stream to decode */
-static const int kEosBufferCntxt = 1980; // a magic value we can compare against
-
-/* protects shared variables */
-pthread_mutex_t eosLock = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t eosCondition = PTHREAD_COND_INITIALIZER;
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "Error code %u encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-//-----------------------------------------------------------------
-/* Structure for passing information to callback function */
-typedef struct CallbackCntxt_ {
-#ifdef QUERY_METADATA
- SLMetadataExtractionItf metaItf;
-#endif
- SLPlayItf playItf;
- SLint8* pDataBase; // Base address of local audio data storage
- SLint8* pData; // Current address of local audio data storage
-} CallbackCntxt;
-
-//-----------------------------------------------------------------
-/* Callback for SLPlayItf through which we receive the SL_PLAYEVENT_HEADATEND event */
-void PlayCallback(SLPlayItf caller, void *pContext, SLuint32 event) {
- SLmillisecond position;
- SLresult res = (*caller)->GetPosition(caller, &position);
- ExitOnError(res);
- if (event & SL_PLAYEVENT_HEADATMARKER) {
- printf("SL_PLAYEVENT_HEADATMARKER position=%u ms\n", position);
- }
- if (event & SL_PLAYEVENT_HEADATNEWPOS) {
- printf("SL_PLAYEVENT_HEADATNEWPOS position=%u ms\n", position);
- }
- if (event & SL_PLAYEVENT_HEADATEND) {
- printf("SL_PLAYEVENT_HEADATEND position=%u ms, all decoded data has been received\n",
- position);
- }
-}
-
-//-----------------------------------------------------------------
-/* Callback for AndroidBufferQueueItf through which we supply ADTS buffers */
-SLresult AndroidBufferQueueCallback(
- SLAndroidBufferQueueItf caller,
- void *pCallbackContext, /* input */
- void *pBufferContext, /* input */
- void *pBufferData, /* input */
- SLuint32 dataSize, /* input */
- SLuint32 dataUsed, /* input */
- const SLAndroidBufferItem *pItems,/* input */
- SLuint32 itemsLength /* input */)
-{
- // mutex on all global variables
- pthread_mutex_lock(&eosLock);
- SLresult res;
-
- // for demonstration purposes:
- // verify what type of information was enclosed in the processed buffer
- if (NULL != pBufferContext) {
- const int processedCommand = *(int *)pBufferContext;
- if (kEosBufferCntxt == processedCommand) {
- fprintf(stdout, "EOS was processed\n");
- }
- }
-
- ++totalEncodeCompletions;
- if (endOfEncodedStream) {
- // we continue to receive acknowledgement after each buffer was processed
- if (pBufferContext == (void *) kEosBufferCntxt) {
- printf("Received EOS completion after EOS\n");
- } else if (pBufferContext == NULL) {
- printf("Received ADTS completion after EOS\n");
- } else {
- fprintf(stderr, "Received acknowledgement after EOS with unexpected context %p\n",
- pBufferContext);
- }
- } else if (filelen == 0) {
- // signal EOS to the decoder rather than just starving it
- printf("Enqueue EOS: encoded frames=%u, decoded frames=%u\n", encodedFrames, decodedFrames);
- printf("You should now see %u ADTS completion%s followed by 1 EOS completion\n",
- NB_BUFFERS_IN_ADTS_QUEUE - 1, NB_BUFFERS_IN_ADTS_QUEUE != 2 ? "s" : "");
- SLAndroidBufferItem msgEos;
- msgEos.itemKey = SL_ANDROID_ITEMKEY_EOS;
- msgEos.itemSize = 0;
- // EOS message has no parameters, so the total size of the message is the size of the key
- // plus the size of itemSize, both SLuint32
- res = (*caller)->Enqueue(caller, (void *)&kEosBufferCntxt /*pBufferContext*/,
- NULL /*pData*/, 0 /*dataLength*/,
- &msgEos /*pMsg*/,
- sizeof(SLuint32)*2 /*msgLength*/);
- ExitOnError(res);
- endOfEncodedStream = true;
- // verify that we are at start of an ADTS frame
- } else if (!(filelen < 7 || frame[0] != 0xFF || (frame[1] & 0xF0) != 0xF0)) {
- if (pBufferContext != NULL) {
- fprintf(stderr, "Received acknowledgement before EOS with unexpected context %p\n",
- pBufferContext);
- }
- unsigned framelen = ((frame[3] & 3) << 11) | (frame[4] << 3) | (frame[5] >> 5);
- if (framelen <= filelen) {
- // push more data to the queue
- res = (*caller)->Enqueue(caller, NULL /*pBufferContext*/,
- frame, framelen, NULL, 0);
- ExitOnError(res);
- frame += framelen;
- filelen -= framelen;
- ++encodedFrames;
- encodedSamples += SAMPLES_PER_AAC_FRAME;
- frameStats.sample(framelen);
- } else {
- fprintf(stderr,
- "partial ADTS frame at EOF discarded; offset=%u, framelen=%u, filelen=%u\n",
- frame - (unsigned char *) ptr, framelen, filelen);
- frame += filelen;
- filelen = 0;
- }
- } else {
- fprintf(stderr, "corrupt ADTS frame encountered; offset=%u, filelen=%u\n",
- frame - (unsigned char *) ptr, filelen);
- frame += filelen;
- filelen = 0;
- }
- pthread_mutex_unlock(&eosLock);
-
- return SL_RESULT_SUCCESS;
-}
-
-//-----------------------------------------------------------------
-/* Callback for decoding buffer queue events */
-void DecPlayCallback(
- SLAndroidSimpleBufferQueueItf queueItf,
- void *pContext)
-{
- // mutex on all global variables
- pthread_mutex_lock(&eosLock);
-
- CallbackCntxt *pCntxt = (CallbackCntxt*)pContext;
-
- /* Save the decoded data to output file */
- if (outputFp != NULL && fwrite(pCntxt->pData, 1, BUFFER_SIZE_IN_BYTES, outputFp)
- < BUFFER_SIZE_IN_BYTES) {
- fprintf(stderr, "Error writing to output file");
- }
-
- /* Re-enqueue the now empty buffer */
- SLresult res;
- res = (*queueItf)->Enqueue(queueItf, pCntxt->pData, BUFFER_SIZE_IN_BYTES);
- ExitOnError(res);
-
- /* Increase data pointer by buffer size, with circular wraparound */
- pCntxt->pData += BUFFER_SIZE_IN_BYTES;
- if (pCntxt->pData >= pCntxt->pDataBase + (NB_BUFFERS_IN_PCM_QUEUE * BUFFER_SIZE_IN_BYTES)) {
- pCntxt->pData = pCntxt->pDataBase;
- }
-
- // Note: adding a sleep here or any sync point is a way to slow down the decoding, or
- // synchronize it with some other event, as the OpenSL ES framework will block until the
- // buffer queue callback return to proceed with the decoding.
-
-#ifdef QUERY_METADATA
- /* Example: query of the decoded PCM format */
- if (!formatQueried) {
- /* memory to receive the PCM format metadata */
- union {
- SLMetadataInfo pcmMetaData;
- char withData[PCM_METADATA_VALUE_SIZE];
- } u;
- res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, sampleRateKeyIndex,
- PCM_METADATA_VALUE_SIZE, &u.pcmMetaData); ExitOnError(res);
- // Note: here we could verify the following:
- // u.pcmMetaData->encoding == SL_CHARACTERENCODING_BINARY
- // u.pcmMetaData->size == sizeof(SLuint32)
- // but the call was successful for the PCM format keys, so those conditions are implied
- printf("sample rate = %d\n", *((SLuint32*)u.pcmMetaData.data));
- res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, channelCountKeyIndex,
- PCM_METADATA_VALUE_SIZE, &u.pcmMetaData); ExitOnError(res);
- printf("channel count = %d\n", *((SLuint32*)u.pcmMetaData.data));
- res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, bitsPerSampleKeyIndex,
- PCM_METADATA_VALUE_SIZE, &u.pcmMetaData); ExitOnError(res);
- printf("bits per sample = %d bits\n", *((SLuint32*)u.pcmMetaData.data));
- res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, containerSizeKeyIndex,
- PCM_METADATA_VALUE_SIZE, &u.pcmMetaData); ExitOnError(res);
- printf("container size = %d bits\n", *((SLuint32*)u.pcmMetaData.data));
- res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, channelMaskKeyIndex,
- PCM_METADATA_VALUE_SIZE, &u.pcmMetaData); ExitOnError(res);
- printf("channel mask = 0x%X (0x3=front left | front right, 0x4=front center)\n",
- *((SLuint32*)u.pcmMetaData.data));
- res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, endiannessKeyIndex,
- PCM_METADATA_VALUE_SIZE, &u.pcmMetaData); ExitOnError(res);
- printf("endianness = %d (1=big, 2=little)\n", *((SLuint32*)u.pcmMetaData.data));
- formatQueried = true;
- }
-#endif
-
- ++decodedFrames;
- decodedSamples += SAMPLES_PER_AAC_FRAME;
-
- /* Periodically ask for position and duration */
- if ((decodedFrames % 1000 == 0) || endOfEncodedStream) {
- SLmillisecond position;
- res = (*pCntxt->playItf)->GetPosition(pCntxt->playItf, &position);
- ExitOnError(res);
- SLmillisecond duration;
- res = (*pCntxt->playItf)->GetDuration(pCntxt->playItf, &duration);
- ExitOnError(res);
- if (duration == SL_TIME_UNKNOWN) {
- printf("After %u encoded %u decoded frames: position is %u ms, duration is "
- "unknown as expected\n",
- encodedFrames, decodedFrames, position);
- } else {
- printf("After %u encoded %u decoded frames: position is %u ms, duration is "
- "surprisingly %u ms\n",
- encodedFrames, decodedFrames, position, duration);
- }
- }
-
- if (endOfEncodedStream && decodedSamples >= encodedSamples) {
- eos = true;
- pthread_cond_signal(&eosCondition);
- }
- pthread_mutex_unlock(&eosLock);
-}
-
-//-----------------------------------------------------------------
-
-/* Decode an audio path by opening a file descriptor on that path */
-void TestDecToBuffQueue( SLObjectItf sl, const char *path, int fd)
-{
- // check what kind of object it is
- int ok;
- struct stat statbuf;
- ok = fstat(fd, &statbuf);
- if (ok < 0) {
- perror(path);
- return;
- }
-
- // verify that's it is a file
- if (!S_ISREG(statbuf.st_mode)) {
- fprintf(stderr, "%s: not an ordinary file\n", path);
- return;
- }
-
- // map file contents into memory to make it easier to access the ADTS frames directly
- ptr = mmap(NULL, statbuf.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, (off_t) 0);
- if (ptr == MAP_FAILED) {
- perror(path);
- return;
- }
- frame = (unsigned char *) ptr;
- filelen = statbuf.st_size;
-
- // create PCM .raw file
- if (createRaw) {
- size_t len = strlen((const char *) path);
- char* outputPath = (char*) malloc(len + 4 + 1); // save room to concatenate ".raw"
- if (NULL == outputPath) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
- memcpy(outputPath, path, len + 1);
- strcat(outputPath, ".raw");
- outputFp = fopen(outputPath, "w");
- if (NULL == outputFp) {
- // issue an error message, but continue the decoding anyway
- perror(outputPath);
- }
- } else {
- outputFp = NULL;
- }
-
- SLresult res;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one audio player */
- SLObjectItf player;
-
- /* Interfaces for the audio player */
- SLPlayItf playItf;
-#ifdef QUERY_METADATA
- /* to retrieve the decoded PCM format */
- SLMetadataExtractionItf mdExtrItf;
-#endif
- /* to retrieve the PCM samples */
- SLAndroidSimpleBufferQueueItf decBuffQueueItf;
- /* to queue the AAC data to decode */
- SLAndroidBufferQueueItf aacBuffQueueItf;
-
- SLboolean required[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
- SLInterfaceID iidArray[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(res);
-
- /* Initialize arrays required[] and iidArray[] */
- unsigned int i;
- for (i=0 ; i < NUM_EXPLICIT_INTERFACES_FOR_PLAYER ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Request the AndroidSimpleBufferQueue interface */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
- /* Request the AndroidBufferQueue interface */
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_ANDROIDBUFFERQUEUESOURCE;
-#ifdef QUERY_METADATA
- /* Request the MetadataExtraction interface */
- required[2] = SL_BOOLEAN_TRUE;
- iidArray[2] = SL_IID_METADATAEXTRACTION;
-#endif
-
- /* Setup the data source for queueing AAC buffers of ADTS data */
- SLDataLocator_AndroidBufferQueue loc_srcAbq = {
- SL_DATALOCATOR_ANDROIDBUFFERQUEUE /*locatorType*/,
- NB_BUFFERS_IN_ADTS_QUEUE /*numBuffers*/};
- SLDataFormat_MIME format_srcMime = {
- SL_DATAFORMAT_MIME /*formatType*/,
- SL_ANDROID_MIME_AACADTS /*mimeType*/,
- SL_CONTAINERTYPE_RAW /*containerType*/};
- SLDataSource decSource = {&loc_srcAbq /*pLocator*/, &format_srcMime /*pFormat*/};
-
- /* Setup the data sink, a buffer queue for buffers of PCM data */
- SLDataLocator_AndroidSimpleBufferQueue loc_destBq = {
- SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE/*locatorType*/,
- NB_BUFFERS_IN_PCM_QUEUE /*numBuffers*/ };
-
- /* declare we're decoding to PCM, the parameters after that need to be valid,
- but are ignored, the decoded format will match the source */
- SLDataFormat_PCM format_destPcm = { /*formatType*/ SL_DATAFORMAT_PCM, /*numChannels*/ 1,
- /*samplesPerSec*/ SL_SAMPLINGRATE_8, /*pcm.bitsPerSample*/ SL_PCMSAMPLEFORMAT_FIXED_16,
- /*/containerSize*/ 16, /*channelMask*/ SL_SPEAKER_FRONT_LEFT,
- /*endianness*/ SL_BYTEORDER_LITTLEENDIAN };
- SLDataSink decDest = {&loc_destBq /*pLocator*/, &format_destPcm /*pFormat*/};
-
- /* Create the audio player */
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &decSource, &decDest,
-#ifdef QUERY_METADATA
- NUM_EXPLICIT_INTERFACES_FOR_PLAYER,
-#else
- NUM_EXPLICIT_INTERFACES_FOR_PLAYER - 1,
-#endif
- iidArray, required);
- ExitOnError(res);
- printf("Player created\n");
-
- /* Realize the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE);
- ExitOnError(res);
- printf("Player realized\n");
-
- /* Get the play interface which is implicit */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(res);
-
- /* Enable callback when position passes through a marker (SL_PLAYEVENT_HEADATMARKER) */
- res = (*playItf)->SetMarkerPosition(playItf, 5000);
- ExitOnError(res);
-
- /* Enable callback for periodic position updates (SL_PLAYEVENT_HEADATNEWPOS) */
- res = (*playItf)->SetPositionUpdatePeriod(playItf, 3000);
- ExitOnError(res);
-
- /* Use the play interface to set up a callback for the SL_PLAYEVENT_HEAD* events */
- res = (*playItf)->SetCallbackEventsMask(playItf,
- SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS | SL_PLAYEVENT_HEADATEND);
- ExitOnError(res);
- res = (*playItf)->RegisterCallback(playItf, PlayCallback /*callback*/, NULL /*pContext*/);
- ExitOnError(res);
-
- /* Get the position before prefetch; should be zero */
- SLmillisecond position;
- res = (*playItf)->GetPosition(playItf, &position);
- ExitOnError(res);
- if (position == 0) {
- printf("The position before prefetch is zero as expected\n");
- } else if (position == SL_TIME_UNKNOWN) {
- printf("That's surprising the position before prefetch is unknown");
- } else {
- printf("That's surprising the position before prefetch is %u ms\n", position);
- }
-
- /* Get the duration before prefetch; should be unknown */
- SLmillisecond duration;
- res = (*playItf)->GetDuration(playItf, &duration);
- ExitOnError(res);
- if (duration == SL_TIME_UNKNOWN) {
- printf("The duration before prefetch is unknown as expected\n");
- } else {
- printf("That's surprising the duration before prefetch is %u ms\n", duration);
- }
-
- /* Get the buffer queue interface which was explicitly requested */
- res = (*player)->GetInterface(player, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, (void*)&decBuffQueueItf);
- ExitOnError(res);
-
- /* Get the Android buffer queue interface which was explicitly requested */
- res = (*player)->GetInterface(player, SL_IID_ANDROIDBUFFERQUEUESOURCE, (void*)&aacBuffQueueItf);
- ExitOnError(res);
-
-#ifdef QUERY_METADATA
- /* Get the metadata extraction interface which was explicitly requested */
- res = (*player)->GetInterface(player, SL_IID_METADATAEXTRACTION, (void*)&mdExtrItf);
- ExitOnError(res);
-#endif
-
- /* ------------------------------------------------------ */
- /* Initialize the callback and its context for the buffer queue of the decoded PCM */
- CallbackCntxt sinkCntxt;
- sinkCntxt.playItf = playItf;
-#ifdef QUERY_METADATA
- sinkCntxt.metaItf = mdExtrItf;
-#endif
- sinkCntxt.pDataBase = (int8_t*)&pcmData;
- sinkCntxt.pData = sinkCntxt.pDataBase;
- res = (*decBuffQueueItf)->RegisterCallback(decBuffQueueItf, DecPlayCallback, &sinkCntxt);
- ExitOnError(res);
-
- /* Enqueue buffers to map the region of memory allocated to store the decoded data */
- printf("Enqueueing initial empty buffers to receive decoded PCM data");
- for(i = 0 ; i < NB_BUFFERS_IN_PCM_QUEUE ; i++) {
- printf(" %d", i);
- res = (*decBuffQueueItf)->Enqueue(decBuffQueueItf, sinkCntxt.pData, BUFFER_SIZE_IN_BYTES);
- ExitOnError(res);
- sinkCntxt.pData += BUFFER_SIZE_IN_BYTES;
- if (sinkCntxt.pData >= sinkCntxt.pDataBase +
- (NB_BUFFERS_IN_PCM_QUEUE * BUFFER_SIZE_IN_BYTES)) {
- sinkCntxt.pData = sinkCntxt.pDataBase;
- }
- }
- printf("\n");
-
- /* Initialize the callback for the Android buffer queue of the encoded data */
- res = (*aacBuffQueueItf)->RegisterCallback(aacBuffQueueItf, AndroidBufferQueueCallback, NULL);
- ExitOnError(res);
-
- /* Enqueue the content of our encoded data before starting to play,
- we don't want to starve the player initially */
- printf("Enqueueing initial full buffers of encoded ADTS data");
- for (i=0 ; i < NB_BUFFERS_IN_ADTS_QUEUE ; i++) {
- if (filelen < 7 || frame[0] != 0xFF || (frame[1] & 0xF0) != 0xF0)
- break;
- unsigned framelen = ((frame[3] & 3) << 11) | (frame[4] << 3) | (frame[5] >> 5);
- printf(" %d", i);
- res = (*aacBuffQueueItf)->Enqueue(aacBuffQueueItf, NULL /*pBufferContext*/,
- frame, framelen, NULL, 0);
- ExitOnError(res);
- frame += framelen;
- filelen -= framelen;
- ++encodedFrames;
- encodedSamples += SAMPLES_PER_AAC_FRAME;
- frameStats.sample(framelen);
- }
- printf("\n");
-
-#ifdef QUERY_METADATA
- /* ------------------------------------------------------ */
- /* Display the metadata obtained from the decoder */
- // This is for test / demonstration purposes only where we discover the key and value sizes
- // of a PCM decoder. An application that would want to directly get access to those values
- // can make assumptions about the size of the keys and their matching values (all SLuint32)
- SLuint32 itemCount;
- res = (*mdExtrItf)->GetItemCount(mdExtrItf, &itemCount);
- ExitOnError(res);
- printf("itemCount=%u\n", itemCount);
- SLuint32 keySize, valueSize;
- SLMetadataInfo *keyInfo, *value;
- for(i=0 ; i<itemCount ; i++) {
- keyInfo = NULL; keySize = 0;
- value = NULL; valueSize = 0;
- res = (*mdExtrItf)->GetKeySize(mdExtrItf, i, &keySize);
- ExitOnError(res);
- res = (*mdExtrItf)->GetValueSize(mdExtrItf, i, &valueSize);
- ExitOnError(res);
- keyInfo = (SLMetadataInfo*) malloc(keySize);
- if (NULL != keyInfo) {
- res = (*mdExtrItf)->GetKey(mdExtrItf, i, keySize, keyInfo);
- ExitOnError(res);
- printf("key[%d] size=%d, name=%s \tvalue size=%d encoding=0x%X langCountry=%s\n",
- i, keyInfo->size, keyInfo->data, valueSize, keyInfo->encoding,
- keyInfo->langCountry);
- /* find out the key index of the metadata we're interested in */
- if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_NUMCHANNELS)) {
- channelCountKeyIndex = i;
- } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_SAMPLERATE)) {
- sampleRateKeyIndex = i;
- } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE)) {
- bitsPerSampleKeyIndex = i;
- } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_CONTAINERSIZE)) {
- containerSizeKeyIndex = i;
- } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_CHANNELMASK)) {
- channelMaskKeyIndex = i;
- } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_ENDIANNESS)) {
- endiannessKeyIndex = i;
- } else {
- printf("Unknown key %s ignored\n", (char *)keyInfo->data);
- }
- free(keyInfo);
- }
- }
- if (channelCountKeyIndex != -1) {
- printf("Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_NUMCHANNELS, channelCountKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_NUMCHANNELS);
- }
- if (sampleRateKeyIndex != -1) {
- printf("Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_SAMPLERATE, sampleRateKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_SAMPLERATE);
- }
- if (bitsPerSampleKeyIndex != -1) {
- printf("Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE, bitsPerSampleKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_BITSPERSAMPLE);
- }
- if (containerSizeKeyIndex != -1) {
- printf("Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_CONTAINERSIZE, containerSizeKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_CONTAINERSIZE);
- }
- if (channelMaskKeyIndex != -1) {
- printf("Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_CHANNELMASK, channelMaskKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_CHANNELMASK);
- }
- if (endiannessKeyIndex != -1) {
- printf("Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_ENDIANNESS, endiannessKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_ENDIANNESS);
- }
-#endif
-
- /* ------------------------------------------------------ */
- /* Start decoding */
- printf("Starting to decode\n");
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING);
- ExitOnError(res);
-
- /* Decode until the end of the stream is reached */
- pthread_mutex_lock(&eosLock);
- while (!eos) {
- if (pauseFrame > 0) {
- if (decodedFrames >= pauseFrame) {
- pauseFrame = 0;
- printf("Pausing after decoded frame %u for 10 seconds\n", decodedFrames);
- pthread_mutex_unlock(&eosLock);
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PAUSED);
- ExitOnError(res);
- sleep(10);
- printf("Resuming\n");
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING);
- ExitOnError(res);
- pthread_mutex_lock(&eosLock);
- } else {
- pthread_mutex_unlock(&eosLock);
- usleep(10*1000);
- pthread_mutex_lock(&eosLock);
- }
- } else {
- pthread_cond_wait(&eosCondition, &eosLock);
- }
- }
- pthread_mutex_unlock(&eosLock);
-
- /* This just means done enqueueing; there may still more data in decode queue! */
- // FIXME here is where we should wait for HEADATEND
- usleep(100 * 1000);
-
- pthread_mutex_lock(&eosLock);
- printf("Frame counters: encoded=%u decoded=%u\n", encodedFrames, decodedFrames);
- printf("Sample counters: encoded=%u decoded=%u\n", encodedSamples, decodedSamples);
- printf("Total encode completions received: actual=%u, expected=%u\n",
- totalEncodeCompletions, encodedFrames+1/*EOS*/);
- pthread_mutex_unlock(&eosLock);
-
- /* Get the final position and duration */
- res = (*playItf)->GetPosition(playItf, &position);
- ExitOnError(res);
- res = (*playItf)->GetDuration(playItf, &duration);
- ExitOnError(res);
- if (duration == SL_TIME_UNKNOWN) {
- printf("The final position is %u ms, duration is unknown\n", position);
- } else {
- printf("The final position is %u ms, duration is %u ms\n", position, duration);
- }
-
- printf("Frame length statistics:\n");
- printf(" n = %u frames\n", frameStats.n());
- printf(" mean = %.1f bytes\n", frameStats.mean());
- printf(" minimum = %.1f bytes\n", frameStats.minimum());
- printf(" maximum = %.1f bytes\n", frameStats.maximum());
- printf(" stddev = %.1f bytes\n", frameStats.stddev());
-
- /* ------------------------------------------------------ */
- /* End of decoding */
-
-destroyRes:
- /* Destroy the AudioPlayer object */
- (*player)->Destroy(player);
-
- if (outputFp != NULL) {
- fclose(outputFp);
- }
-
- // unmap the ADTS AAC file from memory
- ok = munmap(ptr, statbuf.st_size);
- if (0 != ok) {
- perror(path);
- }
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult res;
- SLObjectItf sl;
-
- printf("OpenSL ES test %s: decodes a file containing AAC ADTS data\n", argv[0]);
-
- if (argc != 2) {
- printf("Usage: \t%s source_file\n", argv[0]);
- printf("Example: \"%s /sdcard/myFile.adts\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- // open pathname of encoded ADTS AAC file to get a file descriptor
- int fd;
- fd = open(argv[1], O_RDONLY);
- if (fd < 0) {
- perror(argv[1]);
- return EXIT_FAILURE;
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- res = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(res);
-
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(res);
-
- TestDecToBuffQueue(sl, argv[1], fd);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- // close the file
- (void) close(fd);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestDecodeToBuffQueue.cpp b/wilhelm/tests/examples/slesTestDecodeToBuffQueue.cpp
deleted file mode 100644
index 7798028..0000000
--- a/wilhelm/tests/examples/slesTestDecodeToBuffQueue.cpp
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Audio Decode Test
-
-First run the program from shell:
- # slesTest_decodeToBuffQueue /sdcard/myFile.mp3 4
-
-These use adb on host to retrieve the decoded file:
- % adb pull /sdcard/myFile.mp3.raw myFile.raw
-
-How to examine the output with Audacity:
- Project / Import raw data
- Select myFile.raw file, then click Open button
- Choose these options:
- Signed 16-bit PCM
- Little-endian
- 1 Channel (Mono) / 2 Channels (Stereo) based on the selected file
- Sample rate same as the selected file
- Click Import button
-
-*/
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-#include <utils/threads.h>
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-
-/* Explicitly requesting SL_IID_ANDROIDSIMPLEBUFFERQUEUE and SL_IID_PREFETCHSTATUS
- * on the AudioPlayer object for decoding, SL_IID_METADATAEXTRACTION for retrieving the
- * format of the decoded audio */
-#define NUM_EXPLICIT_INTERFACES_FOR_PLAYER 3
-
-/* Size of the decode buffer queue */
-#define NB_BUFFERS_IN_QUEUE 4
-/* Size of each buffer in the queue */
-#define BUFFER_SIZE_IN_SAMPLES 1152 // number of samples per MP3 frame
-#define BUFFER_SIZE_IN_BYTES (2*BUFFER_SIZE_IN_SAMPLES)
-
-/* Local storage for decoded audio data */
-int8_t pcmData[NB_BUFFERS_IN_QUEUE * BUFFER_SIZE_IN_BYTES];
-
-/* destination for decoded data */
-static FILE* gFp;
-
-/* to display the number of decode iterations */
-static int counter=0;
-
-/* metadata key index for the PCM format information we want to retrieve */
-static int channelCountKeyIndex = -1;
-static int sampleRateKeyIndex = -1;
-/* size of the struct to retrieve the PCM format metadata values: the values we're interested in
- * are SLuint32, but it is saved in the data field of a SLMetadataInfo, hence the larger size.
- * Nate that this size is queried and displayed at l.452 for demonstration/test purposes.
- * */
-#define PCM_METADATA_VALUE_SIZE 32
-/* used to query metadata values */
-static SLMetadataInfo *pcmMetaData = NULL;
-/* we only want to query / display the PCM format once */
-static bool formatQueried = false;
-
-/* to signal to the test app the end of the stream to decode has been reached */
-bool eos = false;
-android::Mutex eosLock;
-android::Condition eosCondition;
-
-/* used to detect errors likely to have occured when the OpenSL ES framework fails to open
- * a resource, for instance because a file URI is invalid, or an HTTP server doesn't respond.
- */
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "Error code %u encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-/* Used to signal prefetching failures */
-bool prefetchError = false;
-
-//-----------------------------------------------------------------
-/* Structure for passing information to callback function */
-typedef struct CallbackCntxt_ {
- SLPlayItf playItf;
- SLMetadataExtractionItf metaItf;
- SLuint32 size;
- SLint8* pDataBase; // Base address of local audio data storage
- SLint8* pData; // Current address of local audio data storage
-} CallbackCntxt;
-
-//-----------------------------------------------------------------
-void SignalEos() {
- android::Mutex::Autolock autoLock(eosLock);
- eos = true;
- eosCondition.signal();
-}
-
-//-----------------------------------------------------------------
-/* Callback for "prefetch" events, here used to detect audio resource opening errors */
-void PrefetchEventCallback( SLPrefetchStatusItf caller, void *pContext, SLuint32 event)
-{
- SLpermille level = 0;
- SLresult result;
- result = (*caller)->GetFillLevel(caller, &level);
- ExitOnError(result);
- SLuint32 status;
- //fprintf(stdout, "PrefetchEventCallback: received event %u\n", event);
- result = (*caller)->GetPrefetchStatus(caller, &status);
- ExitOnError(result);
- if ((PREFETCHEVENT_ERROR_CANDIDATE == (event & PREFETCHEVENT_ERROR_CANDIDATE))
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- fprintf(stdout, "PrefetchEventCallback: Error while prefetching data, exiting\n");
- prefetchError = true;
- SignalEos();
- }
-}
-
-/* Callback for "playback" events, i.e. event happening during decoding */
-void DecProgressCallback(
- SLPlayItf caller,
- void *pContext,
- SLuint32 event)
-{
- SLresult result;
- SLmillisecond msec;
- result = (*caller)->GetPosition(caller, &msec);
- ExitOnError(result);
-
- if (SL_PLAYEVENT_HEADATEND & event) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATEND current position=%u ms\n", msec);
- SignalEos();
- }
-
- if (SL_PLAYEVENT_HEADATNEWPOS & event) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATNEWPOS current position=%u ms\n", msec);
- }
-
- if (SL_PLAYEVENT_HEADATMARKER & event) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATMARKER current position=%u ms\n", msec);
- }
-}
-
-//-----------------------------------------------------------------
-/* Callback for decoding buffer queue events */
-void DecPlayCallback(
- SLAndroidSimpleBufferQueueItf queueItf,
- void *pContext)
-{
- counter++;
-
- CallbackCntxt *pCntxt = (CallbackCntxt*)pContext;
-
- if (counter % 1000 == 0) {
- SLmillisecond msec;
- SLresult result = (*pCntxt->playItf)->GetPosition(pCntxt->playItf, &msec);
- ExitOnError(result);
- printf("DecPlayCallback called (iteration %d): current position=%u ms\n", counter, msec);
- }
-
- /* Save the decoded data */
- if (fwrite(pCntxt->pDataBase, 1, BUFFER_SIZE_IN_BYTES, gFp) < BUFFER_SIZE_IN_BYTES) {
- fprintf(stdout, "Error writing to output file, signaling EOS\n");
- SignalEos();
- return;
- }
-
- /* Increase data pointer by buffer size */
- pCntxt->pData += BUFFER_SIZE_IN_BYTES;
-
- if (pCntxt->pData >= pCntxt->pDataBase + (NB_BUFFERS_IN_QUEUE * BUFFER_SIZE_IN_BYTES)) {
- pCntxt->pData = pCntxt->pDataBase;
- }
-
- ExitOnError( (*queueItf)->Enqueue(queueItf, pCntxt->pDataBase, BUFFER_SIZE_IN_BYTES) );
- // Note: adding a sleep here or any sync point is a way to slow down the decoding, or
- // synchronize it with some other event, as the OpenSL ES framework will block until the
- // buffer queue callback return to proceed with the decoding.
-
-#if 0
- /* Example: buffer queue state display */
- SLAndroidSimpleBufferQueueState decQueueState;
- ExitOnError( (*queueItf)->GetState(queueItf, &decQueueState) );
-
- fprintf(stderr, "\DecBufferQueueCallback now has pCntxt->pData=%p queue: "
- "count=%u playIndex=%u\n",
- pCntxt->pData, decQueueState.count, decQueueState.index);
-#endif
-
-#if 0
- /* Example: display duration in callback where we use the callback context for the SLPlayItf*/
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- SLresult result = (*pCntxt->playItf)->GetDuration(pCntxt->playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (in dec callback)\n");
- } else {
- fprintf(stdout, "Content duration is %ums (in dec callback)\n",
- durationInMsec);
- }
-#endif
-
-#if 0
- /* Example: display position in callback where we use the callback context for the SLPlayItf*/
- SLmillisecond posMsec = SL_TIME_UNKNOWN;
- SLresult result = (*pCntxt->playItf)->GetPosition(pCntxt->playItf, &posMsec);
- ExitOnError(result);
- if (posMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content position is unknown (in dec callback)\n");
- } else {
- fprintf(stdout, "Content position is %ums (in dec callback)\n",
- posMsec);
- }
-#endif
-
- /* Example: query of the decoded PCM format */
- if (formatQueried) {
- return;
- }
- SLresult res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, sampleRateKeyIndex,
- PCM_METADATA_VALUE_SIZE, pcmMetaData); ExitOnError(res);
- // Note: here we could verify the following:
- // pcmMetaData->encoding == SL_CHARACTERENCODING_BINARY
- // pcmMetaData->size == sizeof(SLuint32)
- // but the call was successful for the PCM format keys, so those conditions are implied
- fprintf(stdout, "sample rate = %dHz, ", *((SLuint32*)pcmMetaData->data));
- res = (*pCntxt->metaItf)->GetValue(pCntxt->metaItf, channelCountKeyIndex,
- PCM_METADATA_VALUE_SIZE, pcmMetaData); ExitOnError(res);
- fprintf(stdout, " channel count = %d\n", *((SLuint32*)pcmMetaData->data));
- formatQueried = true;
-}
-
-//-----------------------------------------------------------------
-
-/* Decode an audio path by opening a file descriptor on that path */
-void TestDecToBuffQueue( SLObjectItf sl, const char* path)
-{
- size_t len = strlen((const char *) path);
- char* outputPath = (char*) malloc(len + 4 + 1); // save room to concatenate ".raw"
- if (NULL == outputPath) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
- memcpy(outputPath, path, len + 1);
- strcat(outputPath, ".raw");
- gFp = fopen(outputPath, "w");
- if (NULL == gFp) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
-
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one audio player */
- SLObjectItf player;
-
- /* Interfaces for the audio player */
- SLAndroidSimpleBufferQueueItf decBuffQueueItf;
- SLPrefetchStatusItf prefetchItf;
- SLPlayItf playItf;
- SLMetadataExtractionItf mdExtrItf;
-
- /* Source of audio data for the decoding */
- SLDataSource decSource;
- SLDataLocator_URI decUri;
- SLDataFormat_MIME decMime;
-
- /* Data sink for decoded audio */
- SLDataSink decDest;
- SLDataLocator_AndroidSimpleBufferQueue decBuffQueue;
- SLDataFormat_PCM pcm;
-
- SLboolean required[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
- SLInterfaceID iidArray[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < NUM_EXPLICIT_INTERFACES_FOR_PLAYER ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* allocate memory to receive the PCM format metadata */
- if (!pcmMetaData) {
- pcmMetaData = (SLMetadataInfo*) malloc(PCM_METADATA_VALUE_SIZE);
- }
-
- formatQueried = false;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Request the AndroidSimpleBufferQueue interface */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
- /* Request the PrefetchStatus interface */
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
- /* Request the PrefetchStatus interface */
- required[2] = SL_BOOLEAN_TRUE;
- iidArray[2] = SL_IID_METADATAEXTRACTION;
-
- /* Setup the data source */
- decUri.locatorType = SL_DATALOCATOR_URI;
- decUri.URI = (SLchar*)path;
- decMime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- decMime.mimeType = (SLchar*)NULL;
- decMime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
- decSource.pLocator = (void *) &decUri;
- decSource.pFormat = (void *) &decMime;
-
- /* Setup the data sink */
- decBuffQueue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
- decBuffQueue.numBuffers = NB_BUFFERS_IN_QUEUE;
- /* set up the format of the data in the buffer queue */
- pcm.formatType = SL_DATAFORMAT_PCM;
- // FIXME valid value required but currently ignored
- pcm.numChannels = 1;
- pcm.samplesPerSec = SL_SAMPLINGRATE_8;
- pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
- pcm.containerSize = 16;
- pcm.channelMask = SL_SPEAKER_FRONT_LEFT;
- pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
-
- decDest.pLocator = (void *) &decBuffQueue;
- decDest.pFormat = (void * ) &pcm;
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &decSource, &decDest,
- NUM_EXPLICIT_INTERFACES_FOR_PLAYER, iidArray, required);
- ExitOnError(result);
- fprintf(stdout, "Player created\n");
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE);
- ExitOnError(result);
- fprintf(stdout, "Player realized\n");
-
- /* Get the play interface which is implicit */
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- /* Set up the player callback to get events during the decoding */
- // FIXME currently ignored
- result = (*playItf)->SetMarkerPosition(playItf, 2000);
- ExitOnError(result);
- result = (*playItf)->SetPositionUpdatePeriod(playItf, 500);
- ExitOnError(result);
- result = (*playItf)->SetCallbackEventsMask(playItf,
- SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS | SL_PLAYEVENT_HEADATEND);
- ExitOnError(result);
- result = (*playItf)->RegisterCallback(playItf, DecProgressCallback, NULL);
- ExitOnError(result);
- fprintf(stdout, "Play callback registered\n");
-
- /* Get the buffer queue interface which was explicitly requested */
- result = (*player)->GetInterface(player, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- (void*)&decBuffQueueItf);
- ExitOnError(result);
-
- /* Get the prefetch status interface which was explicitly requested */
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- /* Get the metadata extraction interface which was explicitly requested */
- result = (*player)->GetInterface(player, SL_IID_METADATAEXTRACTION, (void*)&mdExtrItf);
- ExitOnError(result);
-
- /* ------------------------------------------------------ */
- /* Initialize the callback and its context for the decoding buffer queue */
- CallbackCntxt cntxt;
- cntxt.playItf = playItf;
- cntxt.metaItf = mdExtrItf;
- cntxt.pDataBase = (int8_t*)&pcmData;
- cntxt.pData = cntxt.pDataBase;
- cntxt.size = sizeof(pcmData);
- result = (*decBuffQueueItf)->RegisterCallback(decBuffQueueItf, DecPlayCallback, &cntxt);
- ExitOnError(result);
-
- /* Enqueue buffers to map the region of memory allocated to store the decoded data */
- fprintf(stdout,"Enqueueing buffer ");
- for(int i = 0 ; i < NB_BUFFERS_IN_QUEUE ; i++) {
- fprintf(stdout,"%d ", i);
- result = (*decBuffQueueItf)->Enqueue(decBuffQueueItf, cntxt.pData, BUFFER_SIZE_IN_BYTES);
- ExitOnError(result);
- cntxt.pData += BUFFER_SIZE_IN_BYTES;
- }
- fprintf(stdout,"\n");
- cntxt.pData = cntxt.pDataBase;
-
- /* ------------------------------------------------------ */
- /* Initialize the callback for prefetch errors, if we can't open the resource to decode */
- result = (*prefetchItf)->RegisterCallback(prefetchItf, PrefetchEventCallback, &prefetchItf);
- ExitOnError(result);
- result = (*prefetchItf)->SetCallbackEventsMask(prefetchItf, PREFETCHEVENT_ERROR_CANDIDATE);
- ExitOnError(result);
-
- /* ------------------------------------------------------ */
- /* Prefetch the data so we can get information about the format before starting to decode */
- /* 1/ cause the player to prefetch the data */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
- /* 2/ block until data has been prefetched */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- SLuint32 timeOutIndex = 50; // time out prefetching after 5s
- while ((prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) && (timeOutIndex > 0) &&
- !prefetchError) {
- usleep(10 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- timeOutIndex--;
- }
- if (timeOutIndex == 0 || prefetchError) {
- fprintf(stderr, "Failure to prefetch data in time, exiting\n");
- ExitOnError(SL_RESULT_CONTENT_NOT_FOUND);
- }
-
- /* ------------------------------------------------------ */
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown\n");
- } else {
- fprintf(stdout, "Content duration is %ums\n", durationInMsec);
- }
-
- /* ------------------------------------------------------ */
- /* Display the metadata obtained from the decoder */
- // This is for test / demonstration purposes only where we discover the key and value sizes
- // of a PCM decoder. An application that would want to directly get access to those values
- // can make assumptions about the size of the keys and their matching values (all SLuint32)
- SLuint32 itemCount;
- result = (*mdExtrItf)->GetItemCount(mdExtrItf, &itemCount);
- SLuint32 i, keySize, valueSize;
- SLMetadataInfo *keyInfo, *value;
- for(i=0 ; i<itemCount ; i++) {
- keyInfo = NULL; keySize = 0;
- value = NULL; valueSize = 0;
- result = (*mdExtrItf)->GetKeySize(mdExtrItf, i, &keySize);
- ExitOnError(result);
- result = (*mdExtrItf)->GetValueSize(mdExtrItf, i, &valueSize);
- ExitOnError(result);
- keyInfo = (SLMetadataInfo*) malloc(keySize);
- if (NULL != keyInfo) {
- result = (*mdExtrItf)->GetKey(mdExtrItf, i, keySize, keyInfo);
- ExitOnError(result);
- fprintf(stdout, "key[%d] size=%d, name=%s \tvalue size=%d \n",
- i, keyInfo->size, keyInfo->data, valueSize);
- /* find out the key index of the metadata we're interested in */
- if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_NUMCHANNELS)) {
- channelCountKeyIndex = i;
- } else if (!strcmp((char*)keyInfo->data, ANDROID_KEY_PCMFORMAT_SAMPLERATE)) {
- sampleRateKeyIndex = i;
- }
- free(keyInfo);
- }
- }
- if (channelCountKeyIndex != -1) {
- fprintf(stdout, "Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_NUMCHANNELS, channelCountKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_NUMCHANNELS);
- }
- if (sampleRateKeyIndex != -1) {
- fprintf(stdout, "Key %s is at index %d\n",
- ANDROID_KEY_PCMFORMAT_SAMPLERATE, sampleRateKeyIndex);
- } else {
- fprintf(stderr, "Unable to find key %s\n", ANDROID_KEY_PCMFORMAT_SAMPLERATE);
- }
-
- /* ------------------------------------------------------ */
- /* Start decoding */
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING);
- ExitOnError(result);
- fprintf(stdout, "Starting to decode\n");
-
- /* Decode until the end of the stream is reached */
- {
- android::Mutex::Autolock autoLock(eosLock);
- while (!eos) {
- eosCondition.wait(eosLock);
- }
- }
- fprintf(stdout, "EOS signaled\n");
-
- /* ------------------------------------------------------ */
- /* End of decoding */
-
- /* Stop decoding */
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
- fprintf(stdout, "Stopped decoding\n");
-
- /* Destroy the AudioPlayer object */
- (*player)->Destroy(player);
-
- fclose(gFp);
-
- free(pcmMetaData);
- pcmMetaData = NULL;
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf and SLAndroidSimpleBufferQueueItf ",
- argv[0]);
- fprintf(stdout, "on an AudioPlayer object to decode a URI to PCM\n");
-
- if (argc != 2) {
- fprintf(stdout, "Usage: \t%s source_file\n", argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/myFile.mp3\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- TestDecToBuffQueue(sl, argv[1]);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestEffectCapabilities.cpp b/wilhelm/tests/examples/slesTestEffectCapabilities.cpp
deleted file mode 100644
index 494a027..0000000
--- a/wilhelm/tests/examples/slesTestEffectCapabilities.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-
-
-#define MAX_NUMBER_INTERFACES 1
-
-#define GUID_DISPLAY_LENGTH 35
-#define FX_NAME_LENGTH 64
-
-static int testMode;
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-//-----------------------------------------------------------------
-void guidToString(const SLInterfaceID guid, char *str) {
- if ((NULL == guid) || (NULL == str)) {
- return;
- }
- snprintf(str, GUID_DISPLAY_LENGTH, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
- guid->time_low,
- guid->time_mid,
- guid->time_hi_and_version,
- guid->clock_seq,
- guid->node[0],
- guid->node[1],
- guid->node[2],
- guid->node[3],
- guid->node[4],
- guid->node[5]);
-}
-
-//-----------------------------------------------------------------
-
-/* Query available effects on Android */
-void TestGenericFxCapabilities( )
-{
-
- SLresult result;
- SLObjectItf sl;
-
- /* ------------------------------------------------------ */
- /* Engine configuration and creation */
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- iidArray[0] = SL_IID_ANDROIDEFFECTCAPABILITIES;
- required[0] = SL_BOOLEAN_TRUE;
-
-
- result = slCreateEngine( &sl, 1, EngineOption, 1, iidArray, required);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
-
- SLEngineItf EngineItf;
- SLAndroidEffectCapabilitiesItf EffectLibItf;
-
- /* Get the SL Engine interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Get the Android Effect Capabilities interface */
- result = (*sl)->GetInterface(sl, SL_IID_ANDROIDEFFECTCAPABILITIES, (void*)&EffectLibItf);
- ExitOnError(result);
-
- /* ------------------------------------------------------ */
- /* Query the effect library */
-
- SLuint32 nbEffects = 0;
- result = (*EffectLibItf)->QueryNumEffects(EffectLibItf, &nbEffects);
- ExitOnError(result);
- fprintf(stdout, "Effect library contains %d effects:\n", nbEffects);
-
- SLchar effectName[FX_NAME_LENGTH+1];
- SLuint16 effectNameLength = FX_NAME_LENGTH;
- char typeString[GUID_DISPLAY_LENGTH];
- char implString[GUID_DISPLAY_LENGTH];
-
- SLInterfaceID effectType, effectImplementation;
- for (SLuint32 i = 0 ; i < nbEffects ; i++ ) {
- fprintf(stdout,"- effect %d: ", i);
- memset(effectName, 'Z', FX_NAME_LENGTH+1);
- effectNameLength = FX_NAME_LENGTH;
- result = (*EffectLibItf)->QueryEffect(EffectLibItf, i,
- &effectType, &effectImplementation, effectName, &effectNameLength);
- if ('Z' != effectName[FX_NAME_LENGTH]) {
- fprintf(stderr, "QueryEffect wrote beyond end of buffer\n");
- continue;
- }
- ExitOnError(result);
- printf("length=%u ", effectNameLength);
- if (FX_NAME_LENGTH < effectNameLength) {
- printf(" (>max) ");
- effectNameLength = FX_NAME_LENGTH;
- }
- guidToString(effectType, typeString);
- guidToString(effectImplementation, implString);
- effectName[FX_NAME_LENGTH - 1] = '\0';
- fprintf(stdout, " type=%s, impl=%s name=%.*s \n", typeString, implString, effectNameLength,
- effectName);
- }
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLAndroidEffectCapabilitiesItf.\n", argv[0]);
-
- TestGenericFxCapabilities();
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestEqFdPath.cpp b/wilhelm/tests/examples/slesTestEqFdPath.cpp
deleted file mode 100644
index ed1fb32..0000000
--- a/wilhelm/tests/examples/slesTestEqFdPath.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-#define TIME_S_BETWEEN_EQ_ON_OFF 3
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play an audio path by opening a file descriptor on that path */
-void TestEQPathFromFD( SLObjectItf sl, const char* path
-#ifdef ANDROID
- , SLAint64 offset, SLAint64 size
-#endif
- , bool alwaysOn
- )
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
-#ifdef ANDROID
- SLDataLocator_AndroidFD locatorFd;
-#else
- SLDataLocator_URI locatorUri;
-#endif
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play and PrefetchStatus interfaces for the audio player */
- SLPlayItf playItf;
- SLPrefetchStatusItf prefetchItf;
- SLEqualizerItf eqItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for SLPrefetchStatusItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PREFETCHSTATUS;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_EQUALIZER;
-
- /* Setup the data source structure for the URI */
-#ifdef ANDROID
- locatorFd.locatorType = SL_DATALOCATOR_ANDROIDFD;
- int fd = open(path, O_RDONLY);
- if (fd == -1) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
- locatorFd.fd = (SLint32) fd;
- locatorFd.length = size;
- locatorFd.offset = offset;
-#else
- locatorUri.locatorType = SL_DATALOCATOR_URI;
- locatorUri.URI = (SLchar *) path;
-#endif
-
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
-#ifdef ANDROID
- audioSource.pLocator = (void*)&locatorFd;
-#else
- audioSource.pLocator = (void*)&locatorUri;
-#endif
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 2,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLAndroidStreamTypeItf interfaces for the player*/
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_EQUALIZER, (void*)&eqItf);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- ExitOnError(result);
- }
-
- /* Get duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- durationInMsec = 5000;
- }
-
- /* Start playback */
- fprintf(stdout, "Starting to play\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- /* Configure EQ */
- SLuint16 nbPresets, preset, nbBands = 0;
- result = (*eqItf)->GetNumberOfBands(eqItf, &nbBands);
- ExitOnError(result);
- result = (*eqItf)->GetNumberOfPresets(eqItf, &nbPresets);
- ExitOnError(result);
- /* Start from a preset */
- preset = nbPresets > 2 ? 2 : 0;
- result = (*eqItf)->UsePreset(eqItf, preset);
-
- preset = 1977;
- result = (*eqItf)->GetCurrentPreset(eqItf, &preset);
- ExitOnError(result);
- if (SL_EQUALIZER_UNDEFINED == preset) {
- fprintf(stderr, "Using SL_EQUALIZER_UNDEFINED preset, unexpected here!\n");
- } else {
- fprintf(stdout, "Using preset %d\n", preset);
- }
-
- /* Tweak it so it's obvious it gets turned on/off later */
- SLmillibel minLevel, maxLevel = 0;
- result = (*eqItf)->GetBandLevelRange(eqItf, &minLevel, &maxLevel);
- ExitOnError(result);
- fprintf(stdout, "Band level range = %dmB to %dmB\n", minLevel, maxLevel);
-
- SLuint16 b = 0;
- for(b = 0 ; b < nbBands/2 ; b++) {
- result = (*eqItf)->SetBandLevel(eqItf, b, minLevel);
- ExitOnError(result);
- }
- for(b = nbBands/2 ; b < nbBands ; b++) {
- result = (*eqItf)->SetBandLevel(eqItf, b, maxLevel);
- ExitOnError(result);
- }
-
- SLmillibel level = 0;
- for(b = 0 ; b < nbBands ; b++) {
- result = (*eqItf)->GetBandLevel(eqItf, b, &level);
- ExitOnError(result);
- fprintf(stdout, "Band %d level = %dmB\n", b, level);
- }
-
- /* Switch EQ on/off every TIME_S_BETWEEN_EQ_ON_OFF seconds unless always on */
- SLboolean previousEnabled = SL_BOOLEAN_FALSE;
- for(unsigned int j=0 ; j<(durationInMsec/(1000*TIME_S_BETWEEN_EQ_ON_OFF)) ; j++) {
- SLboolean enabled;
- result = (*eqItf)->IsEnabled(eqItf, &enabled);
- ExitOnError(result);
- enabled = alwaysOn || !enabled;
- if (enabled != previousEnabled) {
- result = (*eqItf)->SetEnabled(eqItf, enabled);
- ExitOnError(result);
- previousEnabled = enabled;
- if (SL_BOOLEAN_TRUE == enabled) {
- fprintf(stdout, "EQ on\n");
- } else {
- fprintf(stdout, "EQ off\n");
- }
- }
- usleep(TIME_S_BETWEEN_EQ_ON_OFF * 1000 * 1000);
- }
-
- /* Make sure player is stopped */
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-
-#ifdef ANDROID
- close(fd);
-#endif
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- const char *programName = argv[0];
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLEqualizerItf ", programName);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_AndroidFD source / OutputMix sink\n");
- fprintf(stdout, "Plays the sound file designated by the given path, ");
- fprintf(stdout, "starting at the specified offset, and using the specified length.\n");
- fprintf(stdout, "Omit the length of the file for it to be computed by the system.\n");
- fprintf(stdout, "Every %d seconds, the EQ will be turned on and off,\n",
- TIME_S_BETWEEN_EQ_ON_OFF);
- fprintf(stdout, "unless the --always-on option is specified before the path.\n");
-
- bool alwaysOn = false;
- if (argc >= 2 && !strcmp(argv[1], "--always-on")) {
- alwaysOn = true;
- --argc;
- ++argv;
- }
-
-#ifdef ANDROID
- if (argc < 3)
-#else
- if (argc < 1)
-#endif
- {
- fprintf(stdout, "Usage: \t%s [--always-on] path offsetInBytes [sizeInBytes]\n", programName);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 0 344460\" \n", programName);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
-#ifdef ANDROID
- if (argc == 3) {
- fprintf(stdout, "\nno file size given, using SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE\n\n");
- TestEQPathFromFD(sl, argv[1], (SLAint64)atoi(argv[2]),
- SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE, alwaysOn);
- } else {
- TestEQPathFromFD(sl, argv[1], (SLAint64)atoi(argv[2]), (SLAint64)atoi(argv[3]), alwaysOn);
- }
-#else
- TestEQPathFromFD(sl, argv[1]);
-#endif
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestEqOutputPath.cpp b/wilhelm/tests/examples/slesTestEqOutputPath.cpp
deleted file mode 100644
index 072cd96..0000000
--- a/wilhelm/tests/examples/slesTestEqOutputPath.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-#define TIME_S_BETWEEN_EQ_ON_OFF 3
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play an audio path by opening a file descriptor on that path */
-void TestEQPathFromFD( SLObjectItf sl, const char* path
-#ifdef ANDROID
- , SLAint64 offset, SLAint64 size
-#endif
- , bool alwaysOn
- )
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
-#ifdef ANDROID
- SLDataLocator_AndroidFD locatorFd;
-#else
- SLDataLocator_URI locatorUri;
-#endif
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play and PrefetchStatus interfaces for the audio player */
- SLPlayItf playItf;
- SLPrefetchStatusItf prefetchItf;
-
- /* Effect interface for the output mix */
- SLEqualizerItf eqOutputItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Set arrays required[] and iidArray[] for SLEqualizerItf interface */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_EQUALIZER;
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Get the SLEqualizerItf interface */
- result = (*outputMix)->GetInterface(outputMix, SL_IID_EQUALIZER, (void*)&eqOutputItf);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for SLPrefetchStatusItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PREFETCHSTATUS;
-
- /* Setup the data source structure for the URI */
-#ifdef ANDROID
- locatorFd.locatorType = SL_DATALOCATOR_ANDROIDFD;
- int fd = open(path, O_RDONLY);
- if (fd == -1) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
- locatorFd.fd = (SLint32) fd;
- locatorFd.length = size;
- locatorFd.offset = offset;
-#else
- locatorUri.locatorType = SL_DATALOCATOR_URI;
- locatorUri.URI = (SLchar *) path;
-#endif
-
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
-#ifdef ANDROID
- audioSource.pLocator = (void*)&locatorFd;
-#else
- audioSource.pLocator = (void*)&locatorUri;
-#endif
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 1,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLAndroidStreamTypeItf interfaces for the player*/
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- ExitOnError(result);
- }
-
- /* Get duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- durationInMsec = 5000;
- }
-
- /* Start playback */
- fprintf(stdout, "Starting to play\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- /* Configure EQ */
- SLuint16 nbPresets, preset, nbBands = 0;
- result = (*eqOutputItf)->GetNumberOfBands(eqOutputItf, &nbBands);
- ExitOnError(result);
- result = (*eqOutputItf)->GetNumberOfPresets(eqOutputItf, &nbPresets);
- ExitOnError(result);
- /* Start from a preset */
- preset = nbPresets > 2 ? 2 : 0;
- result = (*eqOutputItf)->UsePreset(eqOutputItf, preset);
-
- preset = 1977;
- result = (*eqOutputItf)->GetCurrentPreset(eqOutputItf, &preset);
- ExitOnError(result);
- if (SL_EQUALIZER_UNDEFINED == preset) {
- fprintf(stderr, "Using SL_EQUALIZER_UNDEFINED preset, unexpected here!\n");
- } else {
- fprintf(stdout, "Using preset %d\n", preset);
- }
-
- /* Tweak it so it's obvious it gets turned on/off later */
- SLmillibel minLevel, maxLevel = 0;
- result = (*eqOutputItf)->GetBandLevelRange(eqOutputItf, &minLevel, &maxLevel);
- ExitOnError(result);
- fprintf(stdout, "Band level range = %dmB to %dmB\n", minLevel, maxLevel);
-
- SLuint16 b = 0;
- for(b = 0 ; b < nbBands/2 ; b++) {
- result = (*eqOutputItf)->SetBandLevel(eqOutputItf, b, minLevel);
- ExitOnError(result);
- }
- for(b = nbBands/2 ; b < nbBands ; b++) {
- result = (*eqOutputItf)->SetBandLevel(eqOutputItf, b, maxLevel);
- ExitOnError(result);
- }
-
- SLmillibel level = 0;
- for(b = 0 ; b < nbBands ; b++) {
- result = (*eqOutputItf)->GetBandLevel(eqOutputItf, b, &level);
- ExitOnError(result);
- fprintf(stdout, "Band %d level = %dmB\n", b, level);
- }
-
- /* Switch EQ on/off every TIME_S_BETWEEN_EQ_ON_OFF seconds unless always on */
- SLboolean previousEnabled = SL_BOOLEAN_FALSE;
- for(unsigned int j=0 ; j<(durationInMsec/(1000*TIME_S_BETWEEN_EQ_ON_OFF)) ; j++) {
- SLboolean enabled;
- result = (*eqOutputItf)->IsEnabled(eqOutputItf, &enabled);
- ExitOnError(result);
- enabled = alwaysOn || !enabled;
- if (enabled != previousEnabled) {
- result = (*eqOutputItf)->SetEnabled(eqOutputItf, enabled);
- ExitOnError(result);
- previousEnabled = enabled;
- if (SL_BOOLEAN_TRUE == enabled) {
- fprintf(stdout, "EQ on\n");
- } else {
- fprintf(stdout, "EQ off\n");
- }
- }
- usleep(TIME_S_BETWEEN_EQ_ON_OFF * 1000 * 1000);
- }
-
- /* Make sure player is stopped */
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-
-#ifdef ANDROID
- close(fd);
-#endif
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- const char *programName = argv[0];
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLEqualizerItf ", programName);
- fprintf(stdout, "on an OutputMix object\n");
- fprintf(stdout, "Plays the sound file designated by the given path, ");
- fprintf(stdout, "starting at the specified offset, and using the specified length.\n");
- fprintf(stdout, "Omit the length of the file for it to be computed by the system.\n");
- fprintf(stdout, "Every %d seconds, the EQ will be turned on and off,\n",
- TIME_S_BETWEEN_EQ_ON_OFF);
- fprintf(stdout, "unless the --always-on option is specified before the path.\n");
-
- bool alwaysOn = false;
- if (argc >= 2 && !strcmp(argv[1], "--always-on")) {
- alwaysOn = true;
- --argc;
- ++argv;
- }
-
-#ifdef ANDROID
- if (argc < 3) {
- fprintf(stdout, "Usage: \t%s [--always-on] path offsetInBytes [sizeInBytes]\n",
- programName);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 0 344460\" \n", programName);
- exit(EXIT_FAILURE);
- }
-#endif
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
-#ifdef ANDROID
- if (argc == 3) {
- fprintf(stdout, "\nno file size given, using SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE\n\n");
- TestEQPathFromFD(sl, argv[1], (SLAint64)atoi(argv[2]),
- SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE, alwaysOn);
- } else {
- TestEQPathFromFD(sl, argv[1], (SLAint64)atoi(argv[2]), (SLAint64)atoi(argv[3]), alwaysOn);
- }
-#else
- TestEQPathFromFD(sl, argv[1], alwaysOn);
-#endif
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestFeedback.cpp b/wilhelm/tests/examples/slesTestFeedback.cpp
deleted file mode 100644
index 80d9d32..0000000
--- a/wilhelm/tests/examples/slesTestFeedback.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Test program to record from default audio input and playback to default audio output.
-// It will generate feedback (Larsen effect) if played through on-device speakers,
-// or acts as a delay if played through headset.
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define ASSERT_EQ(x, y) do { if ((x) == (y)) ; else { fprintf(stderr, "0x%x != 0x%x\n", \
- (unsigned) (x), (unsigned) (y)); assert((x) == (y)); } } while (0)
-
-// default values
-static SLuint32 rxBufCount = 2; // -r#
-static SLuint32 txBufCount = 2; // -t#
-static SLuint32 bufSizeInFrames = 512; // -f#
-static SLuint32 channels = 1; // -c#
-static SLuint32 sampleRate = 44100; // -s#
-static SLuint32 exitAfterSeconds = 60; // -e#
-static SLuint32 freeBufCount = 0; // calculated
-static SLuint32 bufSizeInBytes = 0; // calculated
-
-// Storage area for the buffer queues
-static char **rxBuffers;
-static char **txBuffers;
-static char **freeBuffers;
-
-// Buffer indices
-static SLuint32 rxFront; // oldest recording
-static SLuint32 rxRear; // next to be recorded
-static SLuint32 txFront; // oldest playing
-static SLuint32 txRear; // next to be played
-static SLuint32 freeFront; // oldest free
-static SLuint32 freeRear; // next to be freed
-
-static SLAndroidSimpleBufferQueueItf recorderBufferQueue;
-static SLBufferQueueItf playerBufferQueue;
-
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-
-// Called after audio recorder fills a buffer with data
-static void recorderCallback(SLAndroidSimpleBufferQueueItf caller, void *context)
-{
- SLresult result;
-
- pthread_mutex_lock(&mutex);
-
- // We should only be called when a recording buffer is done
- assert(rxFront <= rxBufCount);
- assert(rxRear <= rxBufCount);
- assert(rxFront != rxRear);
- char *buffer = rxBuffers[rxFront];
-
- // Remove buffer from record queue
- if (++rxFront > rxBufCount) {
- rxFront = 0;
- }
-
- // Enqueue the just-filled buffer for the player
- result = (*playerBufferQueue)->Enqueue(playerBufferQueue, buffer, bufSizeInBytes);
- if (SL_RESULT_SUCCESS == result) {
-
- // There was room in the play queue, update our model of it
- assert(txFront <= txBufCount);
- assert(txRear <= txBufCount);
- SLuint32 txRearNext = txRear+1;
- if (txRearNext > txBufCount) {
- txRearNext = 0;
- }
- assert(txRearNext != txFront);
- txBuffers[txRear] = buffer;
- txRear = txRearNext;
-
- } else {
-
- // Here if record has a filled buffer to play, but play queue is full.
- assert(SL_RESULT_BUFFER_INSUFFICIENT == result);
- write(1, "?", 1);
-
- // We could either try again later, or discard. For now we discard and re-use buffer.
- // Enqueue this same buffer for the recorder to fill again.
- result = (*recorderBufferQueue)->Enqueue(recorderBufferQueue, buffer, bufSizeInBytes);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // Update our model of the record queue
- SLuint32 rxRearNext = rxRear+1;
- if (rxRearNext > rxBufCount) {
- rxRearNext = 0;
- }
- assert(rxRearNext != rxFront);
- rxBuffers[rxRear] = buffer;
- rxRear = rxRearNext;
-
- }
-
- pthread_mutex_unlock(&mutex);
-}
-
-
-// Called after audio player empties a buffer of data
-static void playerCallback(SLBufferQueueItf caller, void *context)
-{
- SLresult result;
-
- pthread_mutex_lock(&mutex);
-
- // Get the buffer that just finished playing
- assert(txFront <= txBufCount);
- assert(txRear <= txBufCount);
- assert(txFront != txRear);
- char *buffer = txBuffers[txFront];
- if (++txFront > txBufCount) {
- txFront = 0;
- }
-
- // First try to enqueue the free buffer for recording
- result = (*recorderBufferQueue)->Enqueue(recorderBufferQueue, buffer, bufSizeInBytes);
- if (SL_RESULT_SUCCESS == result) {
-
- // There was room in the record queue, update our model of it
- assert(rxFront <= rxBufCount);
- assert(rxRear <= rxBufCount);
- SLuint32 rxRearNext = rxRear+1;
- if (rxRearNext > rxBufCount) {
- rxRearNext = 0;
- }
- assert(rxRearNext != rxFront);
- rxBuffers[rxRear] = buffer;
- rxRear = rxRearNext;
-
- } else {
-
- // Here if record queue is full
- assert(SL_RESULT_BUFFER_INSUFFICIENT == result);
-
- // Instead enqueue the free buffer on the free queue
- assert(freeFront <= freeBufCount);
- assert(freeRear <= freeBufCount);
- SLuint32 freeRearNext = freeRear+1;
- if (freeRearNext > freeBufCount) {
- freeRearNext = 0;
- }
- // There must always be room in the free queue
- assert(freeRearNext != freeFront);
- freeBuffers[freeRear] = buffer;
- freeRear = freeRearNext;
-
- }
-
- pthread_mutex_unlock(&mutex);
-}
-
-// Main program
-int main(int argc, char **argv)
-{
- // process command-line options
- int i;
- for (i = 1; i < argc; ++i) {
- char *arg = argv[i];
- if (arg[0] != '-') {
- break;
- }
- // -r# number of slots in receive buffer queue
- if (!strncmp(arg, "-r", 2)) {
- rxBufCount = atoi(&arg[2]);
- if (rxBufCount < 1 || rxBufCount > 16) {
- fprintf(stderr, "%s: unusual receive buffer queue size (%u buffers)\n", argv[0],
- (unsigned) rxBufCount);
- }
- // -t# number of slots in transmit buffer queue
- } else if (!strncmp(arg, "-t", 2)) {
- txBufCount = atoi(&arg[2]);
- if (txBufCount < 1 || txBufCount > 16) {
- fprintf(stderr, "%s: unusual transmit buffer queue size (%u buffers)\n", argv[0],
- (unsigned) txBufCount);
- }
- // -f# size of each buffer in frames
- } else if (!strncmp(arg, "-f", 2)) {
- bufSizeInFrames = atoi(&arg[2]);
- if (bufSizeInFrames == 0) {
- fprintf(stderr, "%s: unusual buffer size (%u frames)\n", argv[0],
- (unsigned) bufSizeInFrames);
- }
- // -c1 mono or -c2 stereo
- } else if (!strncmp(arg, "-c", 2)) {
- channels = atoi(&arg[2]);
- if (channels < 1 || channels > 2) {
- fprintf(stderr, "%s: unusual channel count ignored (%u)\n", argv[0],
- (unsigned) channels);
- channels = 2;
- }
- // -s# sample rate in Hz
- } else if (!strncmp(arg, "-s", 2)) {
- sampleRate = atoi(&arg[2]);
- switch (sampleRate) {
- case 8000:
- case 11025:
- case 12000:
- case 16000:
- case 22050:
- case 24000:
- case 32000:
- case 44100:
- case 48000:
- break;
- default:
- fprintf(stderr, "%s: unusual sample rate (%u Hz)\n", argv[0],
- (unsigned) sampleRate);
- break;
- }
- // -e# exit after this many seconds
- } else if (!strncmp(arg, "-e", 2)) {
- exitAfterSeconds = atoi(&arg[2]);
- } else
- fprintf(stderr, "%s: unknown option %s\n", argv[0], arg);
- }
- // no other arguments allowed
- if (i < argc) {
- fprintf(stderr, "usage: %s -r# -t# -f# -s# -c#\n", argv[0]);
- fprintf(stderr, " -r# receive buffer queue count for microphone input, default 1\n");
- fprintf(stderr, " -t# transmit buffer queue count for speaker output, default 2\n");
- fprintf(stderr, " -f# number of frames per buffer, default 512\n");
- fprintf(stderr, " -s# sample rate in Hz, default 44100\n");
- fprintf(stderr, " -c1 mono\n");
- fprintf(stderr, " -c2 stereo, default\n");
- }
- // compute total free buffers as -r plus -t
- freeBufCount = rxBufCount + txBufCount;
- // compute buffer size
- bufSizeInBytes = channels * bufSizeInFrames * sizeof(short);
-
- // Initialize free buffers
- freeBuffers = (char **) calloc(freeBufCount+1, sizeof(char *));
- unsigned j;
- for (j = 0; j < freeBufCount; ++j) {
- freeBuffers[j] = (char *) malloc(bufSizeInBytes);
- }
- freeFront = 0;
- freeRear = freeBufCount;
- freeBuffers[j] = NULL;
-
- // Initialize record queue
- rxBuffers = (char **) calloc(rxBufCount+1, sizeof(char *));
- rxFront = 0;
- rxRear = 0;
-
- // Initialize play queue
- txBuffers = (char **) calloc(txBufCount+1, sizeof(char *));
- txFront = 0;
- txRear = 0;
-
- SLresult result;
-
- // create engine
- SLObjectItf engineObject;
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // create output mix
- SLObjectItf outputmixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputmixObject, 0, NULL, NULL);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*outputmixObject)->Realize(outputmixObject, SL_BOOLEAN_FALSE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // create an audio player with buffer queue source and output mix sink
- SLDataSource audiosrc;
- SLDataSink audiosnk;
- SLDataFormat_PCM pcm;
- SLDataLocator_OutputMix locator_outputmix;
- SLDataLocator_BufferQueue locator_bufferqueue_tx;
- locator_bufferqueue_tx.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
- locator_bufferqueue_tx.numBuffers = txBufCount;
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputmixObject;
- pcm.formatType = SL_DATAFORMAT_PCM;
- pcm.numChannels = channels;
- pcm.samplesPerSec = sampleRate * 1000;
- pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
- pcm.containerSize = 16;
- pcm.channelMask = channels == 1 ? SL_SPEAKER_FRONT_CENTER :
- (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT);
- pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
- audiosrc.pLocator = &locator_bufferqueue_tx;
- audiosrc.pFormat = &pcm;
- audiosnk.pLocator = &locator_outputmix;
- audiosnk.pFormat = NULL;
- SLObjectItf playerObject = NULL;
- SLObjectItf recorderObject = NULL;
- SLInterfaceID ids_tx[1] = {SL_IID_BUFFERQUEUE};
- SLboolean flags_tx[1] = {SL_BOOLEAN_TRUE};
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc, &audiosnk,
- 1, ids_tx, flags_tx);
- if (SL_RESULT_CONTENT_UNSUPPORTED == result) {
- fprintf(stderr, "Could not create audio player (result %x), check sample rate\n", result);
- goto cleanup;
- }
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerObject)->GetInterface(playerObject, SL_IID_BUFFERQUEUE, &playerBufferQueue);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerBufferQueue)->RegisterCallback(playerBufferQueue, playerCallback, NULL);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // Create an audio recorder with microphone device source and buffer queue sink.
- // The buffer queue as sink is an Android-specific extension.
-
- SLDataLocator_IODevice locator_iodevice;
- SLDataLocator_AndroidSimpleBufferQueue locator_bufferqueue_rx;
- locator_iodevice.locatorType = SL_DATALOCATOR_IODEVICE;
- locator_iodevice.deviceType = SL_IODEVICE_AUDIOINPUT;
- locator_iodevice.deviceID = SL_DEFAULTDEVICEID_AUDIOINPUT;
- locator_iodevice.device = NULL;
- audiosrc.pLocator = &locator_iodevice;
- audiosrc.pFormat = NULL;
- locator_bufferqueue_rx.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
- locator_bufferqueue_rx.numBuffers = rxBufCount;
- audiosnk.pLocator = &locator_bufferqueue_rx;
- audiosnk.pFormat = &pcm;
- {
- SLInterfaceID ids_rx[1] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
- SLboolean flags_rx[1] = {SL_BOOLEAN_TRUE};
- result = (*engineEngine)->CreateAudioRecorder(engineEngine, &recorderObject, &audiosrc,
- &audiosnk, 1, ids_rx, flags_rx);
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "Could not create audio recorder (result %x), "
- "check sample rate and channel count\n", result);
- goto cleanup;
- }
- }
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*recorderObject)->Realize(recorderObject, SL_BOOLEAN_FALSE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLRecordItf recorderRecord;
- result = (*recorderObject)->GetInterface(recorderObject, SL_IID_RECORD, &recorderRecord);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*recorderObject)->GetInterface(recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- &recorderBufferQueue);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*recorderBufferQueue)->RegisterCallback(recorderBufferQueue, recorderCallback, NULL);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // Enqueue some empty buffers for the recorder
- for (j = 0; j < rxBufCount; ++j) {
-
- // allocate a free buffer
- assert(freeFront != freeRear);
- char *buffer = freeBuffers[freeFront];
- if (++freeFront > freeBufCount) {
- freeFront = 0;
- }
-
- // put on record queue
- SLuint32 rxRearNext = rxRear + 1;
- if (rxRearNext > rxBufCount) {
- rxRearNext = 0;
- }
- assert(rxRearNext != rxFront);
- rxBuffers[rxRear] = buffer;
- rxRear = rxRearNext;
- result = (*recorderBufferQueue)->Enqueue(recorderBufferQueue,
- buffer, bufSizeInBytes);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- }
-
- // Kick off the recorder
- result = (*recorderRecord)->SetRecordState(recorderRecord, SL_RECORDSTATE_RECORDING);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // Wait patiently
- do {
- usleep(1000000);
- write(1, ".", 1);
- SLBufferQueueState playerBQState;
- result = (*playerBufferQueue)->GetState(playerBufferQueue, &playerBQState);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLAndroidSimpleBufferQueueState recorderBQState;
- result = (*recorderBufferQueue)->GetState(recorderBufferQueue, &recorderBQState);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- } while (--exitAfterSeconds);
-
- // Tear down the objects and exit
-cleanup:
- if (NULL != playerObject) {
- (*playerObject)->Destroy(playerObject);
- }
- if (NULL != recorderObject) {
- (*recorderObject)->Destroy(recorderObject);
- }
- (*outputmixObject)->Destroy(outputmixObject);
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestPlayFdPath.cpp b/wilhelm/tests/examples/slesTestPlayFdPath.cpp
deleted file mode 100644
index 92532a7..0000000
--- a/wilhelm/tests/examples/slesTestPlayFdPath.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-#define TEST_MUTE 0
-#define TEST_SOLO 1
-
-static int testMode;
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stdout, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play an audio path by opening a file descriptor on that path */
-void TestPlayPathFromFD( SLObjectItf sl, const char* path, SLAint64 offset, SLAint64 size)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
- SLDataLocator_AndroidFD locatorFd;
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play and PrefetchStatus interfaces for the audio player */
- SLPlayItf playItf;
- SLPrefetchStatusItf prefetchItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for SLPrefetchStatusItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PREFETCHSTATUS;
-
- /* Setup the data source structure for the URI */
- locatorFd.locatorType = SL_DATALOCATOR_ANDROIDFD;
- int fd = open(path, O_RDONLY);
- if (fd == -1) {
- perror(path);
- exit(EXIT_FAILURE);
- }
- locatorFd.fd = (SLint32) fd;
- locatorFd.length = size;
- locatorFd.offset = offset;
-
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
- audioSource.pLocator = (void*)&locatorFd;
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 1,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLAndroidStreamTypeItf interfaces for the player*/
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- ExitOnError(result);
- }
-
- /* Get duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- durationInMsec = 5000;
- }
-
- /* Start playback */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- usleep(durationInMsec * 1000);
-
- /* Make sure player is stopped */
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-
- close(fd);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf ", argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_AndroidFD source / OutputMix sink\n");
- fprintf(stdout, "Plays the sound file designated by the given path, ");
- fprintf(stdout, "starting at the specified offset, and using the specified length.\n");
- fprintf(stdout, "Omit the length of the file for it to be computed by the system.\n");
-
- if (argc < 3) {
- fprintf(stdout, "Usage: \t%s path offsetInBytes [sizeInBytes]\n", argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 0 344460\" \n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- if (argc == 3) {
- fprintf(stdout, "no file size given, using SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE\n");
- TestPlayPathFromFD(sl, argv[1], (SLAint64)atoi(argv[2]),
- SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE);
- } else {
- TestPlayPathFromFD(sl, argv[1], (SLAint64)atoi(argv[2]), (SLAint64)atoi(argv[3]));
- }
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestRecBuffQueue.cpp b/wilhelm/tests/examples/slesTestRecBuffQueue.cpp
deleted file mode 100644
index 1f5d794..0000000
--- a/wilhelm/tests/examples/slesTestRecBuffQueue.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Audio Record Test
-
-First run the program from shell:
- # slesTest_recBuffQueue /sdcard/myrec.raw 4
-
-These use adb on host to retrive the file:
- % adb pull /sdcard/myrec.raw myrec.raw
-
-How to examine the output with Audacity:
- Project / Import raw data
- Select myrec.raw file, then click Open button
- Choose these options:
- Signed 16-bit PCM
- Little-endian
- 1 Channel (Mono)
- Sample rate 22050 Hz
- Click Import button
-
-*/
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-
-/* Preset number to use for recording */
-SLuint32 presetValue = SL_ANDROID_RECORDING_PRESET_NONE;
-
-/* Explicitly requesting SL_IID_ANDROIDSIMPLEBUFFERQUEUE and SL_IID_ANDROIDCONFIGURATION
- * on the AudioRecorder object */
-#define NUM_EXPLICIT_INTERFACES_FOR_RECORDER 2
-
-/* Size of the recording buffer queue */
-#define NB_BUFFERS_IN_QUEUE 1
-/* Size of each buffer in the queue */
-#define BUFFER_SIZE_IN_SAMPLES 1024
-#define BUFFER_SIZE_IN_BYTES (2*BUFFER_SIZE_IN_SAMPLES)
-
-/* Local storage for Audio data */
-int8_t pcmData[NB_BUFFERS_IN_QUEUE * BUFFER_SIZE_IN_BYTES];
-
-/* destination for recorded data */
-static FILE* gFp;
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stdout, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-//-----------------------------------------------------------------
-/* Structure for passing information to callback function */
-typedef struct CallbackCntxt_ {
- SLPlayItf playItf;
- SLuint32 size;
- SLint8* pDataBase; // Base address of local audio data storage
- SLint8* pData; // Current address of local audio data storage
-} CallbackCntxt;
-
-
-//-----------------------------------------------------------------
-/* Callback for recording buffer queue events */
-void RecCallback(
- SLRecordItf caller,
- void *pContext,
- SLuint32 event)
-{
- if (SL_RECORDEVENT_HEADATNEWPOS & event) {
- SLmillisecond pMsec = 0;
- (*caller)->GetPosition(caller, &pMsec);
- fprintf(stdout, "SL_RECORDEVENT_HEADATNEWPOS current position=%ums\n", pMsec);
- }
-
- if (SL_RECORDEVENT_HEADATMARKER & event) {
- SLmillisecond pMsec = 0;
- (*caller)->GetPosition(caller, &pMsec);
- fprintf(stdout, "SL_RECORDEVENT_HEADATMARKER current position=%ums\n", pMsec);
- }
-}
-
-//-----------------------------------------------------------------
-/* Callback for recording buffer queue events */
-void RecBufferQueueCallback(
- SLAndroidSimpleBufferQueueItf queueItf,
- void *pContext)
-{
- //fprintf(stdout, "RecBufferQueueCallback called\n");
-
- CallbackCntxt *pCntxt = (CallbackCntxt*)pContext;
-
- /* Save the recorded data */
- fwrite(pCntxt->pDataBase, BUFFER_SIZE_IN_BYTES, 1, gFp);
-
- /* Increase data pointer by buffer size */
- pCntxt->pData += BUFFER_SIZE_IN_BYTES;
-
- if (pCntxt->pData >= pCntxt->pDataBase + (NB_BUFFERS_IN_QUEUE * BUFFER_SIZE_IN_BYTES)) {
- pCntxt->pData = pCntxt->pDataBase;
- }
-
- ExitOnError( (*queueItf)->Enqueue(queueItf, pCntxt->pDataBase, BUFFER_SIZE_IN_BYTES) );
-
- SLAndroidSimpleBufferQueueState recQueueState;
- ExitOnError( (*queueItf)->GetState(queueItf, &recQueueState) );
-
- /*fprintf(stderr, "\tRecBufferQueueCallback now has pCntxt->pData=%p queue: "
- "count=%u playIndex=%u\n",
- pCntxt->pData, recQueueState.count, recQueueState.index);*/
-}
-
-//-----------------------------------------------------------------
-
-/* Play an audio path by opening a file descriptor on that path */
-void TestRecToBuffQueue( SLObjectItf sl, const char* path, SLAint64 durationInSeconds)
-{
- gFp = fopen(path, "w");
- if (NULL == gFp) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
-
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one audio recorder */
- SLObjectItf recorder;
-
- /* Interfaces for the audio recorder */
- SLAndroidSimpleBufferQueueItf recBuffQueueItf;
- SLRecordItf recordItf;
- SLAndroidConfigurationItf configItf;
-
- /* Source of audio data for the recording */
- SLDataSource recSource;
- SLDataLocator_IODevice ioDevice;
-
- /* Data sink for recorded audio */
- SLDataSink recDest;
- SLDataLocator_AndroidSimpleBufferQueue recBuffQueue;
- SLDataFormat_PCM pcm;
-
- SLboolean required[NUM_EXPLICIT_INTERFACES_FOR_RECORDER];
- SLInterfaceID iidArray[NUM_EXPLICIT_INTERFACES_FOR_RECORDER];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < NUM_EXPLICIT_INTERFACES_FOR_RECORDER ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
-
- /* ------------------------------------------------------ */
- /* Configuration of the recorder */
-
- /* Request the AndroidSimpleBufferQueue and AndroidConfiguration interfaces */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_ANDROIDCONFIGURATION;
-
- /* Setup the data source */
- ioDevice.locatorType = SL_DATALOCATOR_IODEVICE;
- ioDevice.deviceType = SL_IODEVICE_AUDIOINPUT;
- ioDevice.deviceID = SL_DEFAULTDEVICEID_AUDIOINPUT;
- ioDevice.device = NULL;
- recSource.pLocator = (void *) &ioDevice;
- recSource.pFormat = NULL;
-
- /* Setup the data sink */
- recBuffQueue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
- recBuffQueue.numBuffers = NB_BUFFERS_IN_QUEUE;
- /* set up the format of the data in the buffer queue */
- pcm.formatType = SL_DATAFORMAT_PCM;
- pcm.numChannels = 1;
- pcm.samplesPerSec = SL_SAMPLINGRATE_22_05;
- pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
- pcm.containerSize = 16;
- pcm.channelMask = SL_SPEAKER_FRONT_LEFT;
- pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
-
- recDest.pLocator = (void *) &recBuffQueue;
- recDest.pFormat = (void * ) &pcm;
-
- /* Create the audio recorder */
- result = (*EngineItf)->CreateAudioRecorder(EngineItf, &recorder, &recSource, &recDest,
- NUM_EXPLICIT_INTERFACES_FOR_RECORDER, iidArray, required);
- ExitOnError(result);
- fprintf(stdout, "Recorder created\n");
-
- /* Get the Android configuration interface which is explicit */
- result = (*recorder)->GetInterface(recorder, SL_IID_ANDROIDCONFIGURATION, (void*)&configItf);
- ExitOnError(result);
-
- /* Use the configuration interface to configure the recorder before it's realized */
- if (presetValue != SL_ANDROID_RECORDING_PRESET_NONE) {
- result = (*configItf)->SetConfiguration(configItf, SL_ANDROID_KEY_RECORDING_PRESET,
- &presetValue, sizeof(SLuint32));
- ExitOnError(result);
- fprintf(stdout, "Recorder parameterized with preset %u\n", presetValue);
- } else {
- printf("Using default record preset\n");
- }
-
- SLuint32 presetRetrieved = SL_ANDROID_RECORDING_PRESET_NONE;
- SLuint32 presetSize = 2*sizeof(SLuint32); // intentionally too big
- result = (*configItf)->GetConfiguration(configItf, SL_ANDROID_KEY_RECORDING_PRESET,
- &presetSize, (void*)&presetRetrieved);
- ExitOnError(result);
- if (presetValue == SL_ANDROID_RECORDING_PRESET_NONE) {
- printf("The default record preset appears to be %u\n", presetRetrieved);
- } else if (presetValue != presetRetrieved) {
- fprintf(stderr, "Error retrieving recording preset as %u instead of %u\n", presetRetrieved, presetValue);
- ExitOnError(SL_RESULT_INTERNAL_ERROR);
- }
-
- /* Realize the recorder in synchronous mode. */
- result = (*recorder)->Realize(recorder, SL_BOOLEAN_FALSE);
- ExitOnError(result);
- fprintf(stdout, "Recorder realized\n");
-
- /* Get the record interface which is implicit */
- result = (*recorder)->GetInterface(recorder, SL_IID_RECORD, (void*)&recordItf);
- ExitOnError(result);
-
- /* Set up the recorder callback to get events during the recording */
- result = (*recordItf)->SetMarkerPosition(recordItf, 2000);
- ExitOnError(result);
- result = (*recordItf)->SetPositionUpdatePeriod(recordItf, 500);
- ExitOnError(result);
- result = (*recordItf)->SetCallbackEventsMask(recordItf,
- SL_RECORDEVENT_HEADATMARKER | SL_RECORDEVENT_HEADATNEWPOS);
- ExitOnError(result);
- result = (*recordItf)->RegisterCallback(recordItf, RecCallback, NULL);
- ExitOnError(result);
- fprintf(stdout, "Recorder callback registered\n");
-
- /* Get the buffer queue interface which was explicitly requested */
- result = (*recorder)->GetInterface(recorder, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- (void*)&recBuffQueueItf);
- ExitOnError(result);
-
- /* ------------------------------------------------------ */
- /* Initialize the callback and its context for the recording buffer queue */
- CallbackCntxt cntxt;
- cntxt.pDataBase = (int8_t*)&pcmData;
- cntxt.pData = cntxt.pDataBase;
- cntxt.size = sizeof(pcmData);
- result = (*recBuffQueueItf)->RegisterCallback(recBuffQueueItf, RecBufferQueueCallback, &cntxt);
- ExitOnError(result);
-
- /* Enqueue buffers to map the region of memory allocated to store the recorded data */
- fprintf(stdout,"Enqueueing buffer ");
- for(int i = 0 ; i < NB_BUFFERS_IN_QUEUE ; i++) {
- fprintf(stdout,"%d ", i);
- result = (*recBuffQueueItf)->Enqueue(recBuffQueueItf, cntxt.pData, BUFFER_SIZE_IN_BYTES);
- ExitOnError(result);
- cntxt.pData += BUFFER_SIZE_IN_BYTES;
- }
- fprintf(stdout,"\n");
- cntxt.pData = cntxt.pDataBase;
-
- /* ------------------------------------------------------ */
- /* Start recording */
- result = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_RECORDING);
- ExitOnError(result);
- fprintf(stdout, "Starting to record\n");
-
- /* Record for at least a second */
- if (durationInSeconds < 1) {
- durationInSeconds = 1;
- }
- usleep(durationInSeconds * 1000 * 1000);
-
- /* ------------------------------------------------------ */
- /* End of recording */
-
- /* Stop recording */
- result = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED);
- ExitOnError(result);
- fprintf(stdout, "Stopped recording\n");
-
- /* Destroy the AudioRecorder object */
- (*recorder)->Destroy(recorder);
-
- fclose(gFp);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- const char *prog = argv[0];
- fprintf(stdout, "OpenSL ES test %s: exercises SLRecordItf and SLAndroidSimpleBufferQueueItf ",
- prog);
- fprintf(stdout, "on an AudioRecorder object\n");
-
- int i;
- for (i = 1; i < argc; ++i) {
- const char *arg = argv[i];
- if (arg[0] != '-') {
- break;
- }
- switch (arg[1]) {
- case 'p': // preset number
- presetValue = atoi(&arg[2]);
- break;
- default:
- fprintf(stderr, "%s: unknown option %s\n", prog, arg);
- break;
- }
- }
-
- if (argc-i < 2) {
- fprintf(stdout, "Usage: \t%s [-p#] destination_file duration_in_seconds\n", prog);
- fprintf(stdout, "Example: \"%s /sdcard/myrec.raw 4\" \n", prog);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- TestRecToBuffQueue(sl, argv[i], (SLAint64)atoi(argv[i+1]));
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestSawtoothBufferQueue.cpp b/wilhelm/tests/examples/slesTestSawtoothBufferQueue.cpp
deleted file mode 100644
index ccca77f..0000000
--- a/wilhelm/tests/examples/slesTestSawtoothBufferQueue.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Copyright (c) 2009 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and /or associated documentation files (the "Materials "), to deal in the
- * Materials without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials,
- * and to permit persons to whom the Materials are furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE
- * MATERIALS.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-/* Local storage for Audio data in 16 bit words */
-#define AUDIO_DATA_STORAGE_SIZE 4096 * 100
-/* Audio data buffer size in 16 bit words. 8 data segments are used in
-this simple example */
-#define AUDIO_DATA_BUFFER_SIZE 4096/8
-
-/* Checks for error. If any errors exit the application! */
-void CheckErr( SLresult res )
-{
- if ( res != SL_RESULT_SUCCESS )
- {
- fprintf(stdout, "%u SL failure, exiting\n", res);
- exit(EXIT_FAILURE);
- }
- else {
- //fprintf(stdout, "%d SL success, proceeding...\n", res);
- }
-}
-
-/* Structure for passing information to callback function */
-typedef struct CallbackCntxt_ {
- SLPlayItf playItf;
- SLint16* pDataBase; // Base adress of local audio data storage
- SLint16* pData; // Current adress of local audio data storage
- SLuint32 size;
-} CallbackCntxt;
-
-/* Local storage for Audio data */
-SLint16 pcmData[AUDIO_DATA_STORAGE_SIZE];
-
-/* Callback for Buffer Queue events */
-void BufferQueueCallback(
- SLBufferQueueItf queueItf,
- void *pContext)
-{
- //fprintf(stdout, "BufferQueueCallback called\n");
- SLresult res;
- //fprintf(stdout, " pContext=%p\n", pContext);
- CallbackCntxt *pCntxt = (CallbackCntxt*)pContext;
-
- if(pCntxt->pData < (pCntxt->pDataBase + pCntxt->size))
- {
- //fprintf(stdout, "callback: before enqueue\n");
- res = (*queueItf)->Enqueue(queueItf, (void*) pCntxt->pData,
- 2 * AUDIO_DATA_BUFFER_SIZE); /* Size given in bytes. */
- CheckErr(res);
- /* Increase data pointer by buffer size */
- pCntxt->pData += AUDIO_DATA_BUFFER_SIZE;
- }
- //fprintf(stdout, "end of BufferQueueCallback()\n");
-}
-
-/* Play some audio from a buffer queue */
-void TestPlaySawtoothBufferQueue( SLObjectItf sl )
-{
- SLEngineItf EngineItf;
-
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
-
- SLresult res;
-
- SLDataSource audioSource;
- SLDataLocator_BufferQueue bufferQueue;
- SLDataFormat_PCM pcm;
-
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- SLObjectItf player;
- SLPlayItf playItf;
- SLBufferQueueItf bufferQueueItf;
- SLBufferQueueState state;
-
- SLObjectItf OutputMix;
- SLVolumeItf volumeItf;
-
- int i;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Callback context for the buffer queue callback function */
- CallbackCntxt cntxt;
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- CheckErr(res);
-
- /* Initialize arrays required[] and iidArray[] */
- for (i=0;i<MAX_NUMBER_INTERFACES;i++)
- {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- // Set arrays required[] and iidArray[] for VOLUME interface
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- // Create Output Mix object to be used by player
- res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
- iidArray, required); CheckErr(res);
-
- // Realizing the Output Mix object in synchronous mode.
- res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
-#if 0
- res = (*OutputMix)->GetInterface(OutputMix, SL_IID_VOLUME,
- (void*)&volumeItf); CheckErr(res);
-#endif
-
- /* Setup the data source structure for the buffer queue */
- bufferQueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
- bufferQueue.numBuffers = 4; /* Four buffers in our buffer queue */
-
- /* Setup the format of the content in the buffer queue */
- pcm.formatType = SL_DATAFORMAT_PCM;
- pcm.numChannels = 1;//2;
- pcm.samplesPerSec = SL_SAMPLINGRATE_44_1;
- pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
- pcm.containerSize = 16;
- pcm.channelMask = SL_SPEAKER_FRONT_LEFT;// | SL_SPEAKER_FRONT_RIGHT;
- pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
-
- audioSource.pFormat = (void *)&pcm;
- audioSource.pLocator = (void *)&bufferQueue;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = OutputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Initialize the audio data to play */
- unsigned int j;
- for (j = 0; j < sizeof(pcmData)/sizeof(pcmData[0]); ++j) {
- pcmData[j] = j*(100 + j / 200);// % 1000;
- }
-
- /* Initialize the context for Buffer queue callbacks */
- cntxt.pDataBase = /*(void*)&*/pcmData;
- cntxt.pData = cntxt.pDataBase;
- cntxt.size = sizeof(pcmData) / 2;
-
- /* Set arrays required[] and iidArray[] for SEEK interface
- (PlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_BUFFERQUEUE;
-
- /* Create the music player */
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player,
- &audioSource, &audioSink, 1, iidArray, required); CheckErr(res);
- fprintf(stdout, "bufferQueue example: after CreateAudioPlayer\n");
-
- /* Realizing the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE); CheckErr(res);
- fprintf(stdout, "bufferQueue example: after Realize\n");
-
- /* Get seek and play interfaces */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- CheckErr(res);
- fprintf(stdout, "bufferQueue example: after GetInterface(PLAY)\n");
-
- res = (*player)->GetInterface(player, SL_IID_BUFFERQUEUE,
- (void*)&bufferQueueItf); CheckErr(res);
-
- /* Setup to receive buffer queue event callbacks */
- res = (*bufferQueueItf)->RegisterCallback(bufferQueueItf,
- BufferQueueCallback, &cntxt); CheckErr(res);
-
-#if 0
- /* Before we start set volume to -3dB (-300mB) */
- res = (*volumeItf)->SetVolumeLevel(volumeItf, -300); CheckErr(res);
-#endif
-
- /* Enqueue a few buffers to get the ball rolling */
- res = (*bufferQueueItf)->Enqueue(bufferQueueItf, cntxt.pData,
- 2 * AUDIO_DATA_BUFFER_SIZE); /* Size given in bytes. */
- CheckErr(res);
- cntxt.pData += AUDIO_DATA_BUFFER_SIZE;
-
- res = (*bufferQueueItf)->Enqueue(bufferQueueItf, cntxt.pData,
- 2 * AUDIO_DATA_BUFFER_SIZE); /* Size given in bytes. */
- CheckErr(res);
- cntxt.pData += AUDIO_DATA_BUFFER_SIZE;
-
- res = (*bufferQueueItf)->Enqueue(bufferQueueItf, cntxt.pData,
- 2 * AUDIO_DATA_BUFFER_SIZE); /* Size given in bytes. */
- CheckErr(res);
- cntxt.pData += AUDIO_DATA_BUFFER_SIZE;
-
- /* Play the PCM samples using a buffer queue */
- fprintf(stdout, "bufferQueue example: starting to play\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- CheckErr(res);
-
- /* Wait until the PCM data is done playing, the buffer queue callback
- will continue to queue buffers until the entire PCM data has been
- played. This is indicated by waiting for the count member of the
- SLBufferQueueState to go to zero.
- */
- res = (*bufferQueueItf)->GetState(bufferQueueItf, &state);
- CheckErr(res);
-
- // while (state.playIndex < 100) {
- while (state.count) {
- usleep(10000);
- (*bufferQueueItf)->GetState(bufferQueueItf, &state);
- }
-
- /* Make sure player is stopped */
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- CheckErr(res);
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*OutputMix)->Destroy(OutputMix);
-}
-
-
-
-int main(int argc, char* const argv[])
-{
- SLresult res;
- SLObjectItf sl;
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE}};
-
- res = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE); CheckErr(res);
-
- /* Run the test */
- TestPlaySawtoothBufferQueue(sl);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestSendToPresetReverb.cpp b/wilhelm/tests/examples/slesTestSendToPresetReverb.cpp
deleted file mode 100644
index 5b68ef6..0000000
--- a/wilhelm/tests/examples/slesTestSendToPresetReverb.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-
-#define MAX_NUMBER_INTERFACES 4
-
-#define TIME_S_BETWEEN_SETTING_CHANGE 3
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-// Prefetch status callback
-
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-SLboolean errorInPrefetchCallback = SL_BOOLEAN_FALSE;
-
-void prefetch_callback(SLPrefetchStatusItf caller, void *context, SLuint32 event)
-{
- SLresult result;
- assert(context == NULL);
- SLpermille level;
- result = (*caller)->GetFillLevel(caller, &level);
- ExitOnError(result);
- SLuint32 status;
- result = (*caller)->GetPrefetchStatus(caller, &status);
- ExitOnError(result);
- if ((PREFETCHEVENT_ERROR_CANDIDATE == (event & PREFETCHEVENT_ERROR_CANDIDATE))
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- errorInPrefetchCallback = SL_BOOLEAN_TRUE;
- }
-}
-
-//-----------------------------------------------------------------
-
-/* Play an audio path and feed a global reverb */
-void TestSendToPresetReverb( SLObjectItf sl, const char* path, int preset, SLmillibel directLevel,
- SLmillibel sendLevel, bool alwaysOn, bool useFd, bool loop)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
-#ifdef ANDROID
- SLDataLocator_AndroidFD locatorFd;
-#endif
- SLDataLocator_URI locatorUri;
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Interfaces for the audio player */
- SLPlayItf playItf;
- SLPrefetchStatusItf prefetchItf;
- SLEffectSendItf effectSendItf;
- SLSeekItf seekItf;
-
- /* Interface for the output mix */
- SLPresetReverbItf reverbItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Set arrays required[] and iidArray[] for required interfaces */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PRESETREVERB;
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 1, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Get the SLPresetReverbItf for the output mix */
- result = (*outputMix)->GetInterface(outputMix, SL_IID_PRESETREVERB, (void*)&reverbItf);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Select the reverb preset */
- fprintf(stdout, "\nUsing preset ");
- switch(preset) {
- case SL_REVERBPRESET_NONE:
- fprintf(stdout, "SL_REVERBPRESET_NONE, don't expect to hear reverb\n");
- break;
- case SL_REVERBPRESET_SMALLROOM: fprintf(stdout, "SL_REVERBPRESET_SMALLROOM\n"); break;
- case SL_REVERBPRESET_MEDIUMROOM: fprintf(stdout, "SL_REVERBPRESET_MEDIUMROOM\n"); break;
- case SL_REVERBPRESET_LARGEROOM: fprintf(stdout, "SL_REVERBPRESET_LARGEROOM\n"); break;
- case SL_REVERBPRESET_MEDIUMHALL: fprintf(stdout, "SL_REVERBPRESET_MEDIUMHALL\n"); break;
- case SL_REVERBPRESET_LARGEHALL: fprintf(stdout, "SL_REVERBPRESET_LARGEHALL\n"); break;
- case SL_REVERBPRESET_PLATE: fprintf(stdout, "SL_REVERBPRESET_PLATE\n"); break;
- default:
- fprintf(stdout, "unknown, use at your own risk\n"); break;
- }
- result = (*reverbItf)->SetPreset(reverbItf, preset);
- ExitOnError(result);
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for required interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PREFETCHSTATUS;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_EFFECTSEND;
- required[2] = SL_BOOLEAN_TRUE;
- iidArray[2] = SL_IID_SEEK;
-
- locatorUri.locatorType = SL_DATALOCATOR_URI;
- locatorUri.URI = (SLchar *) path;
- audioSource.pLocator = (void*)&locatorUri;
- if (useFd) {
-#ifdef ANDROID
- /* Setup the data source structure for the URI */
- locatorFd.locatorType = SL_DATALOCATOR_ANDROIDFD;
- int fd = open(path, O_RDONLY);
- if (fd == -1) {
- perror(path);
- exit(EXIT_FAILURE);
- }
- locatorFd.fd = (SLint32) fd;
- locatorFd.length = SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE;
- locatorFd.offset = 0;
- audioSource.pLocator = (void*)&locatorFd;
-#else
- fprintf(stderr, "option --fd is not supported\n");
-#endif
- }
-
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 3,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLEffectSendItf interfaces for the player*/
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
- result = (*prefetchItf)->RegisterCallback(prefetchItf, prefetch_callback, NULL);
- ExitOnError(result);
- result = (*prefetchItf)->SetCallbackEventsMask(prefetchItf,
- SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_EFFECTSEND, (void*)&effectSendItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_SEEK, (void*)&seekItf);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- if (errorInPrefetchCallback) {
- fprintf(stderr, "Error during prefetch, exiting\n");
- exit(EXIT_FAILURE);
- }
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- ExitOnError(result);
- }
-
- /* Get duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- printf("Duration unknown, assuming 10 seconds\n");
- durationInMsec = 10000;
- } else {
- printf("Duration is %.1f seconds\n", durationInMsec / 1000.0);
- }
-
- /* Feed the output mix' reverb from the audio player using the given send level */
- result = (*effectSendItf)->EnableEffectSend(effectSendItf, reverbItf, SL_BOOLEAN_TRUE,
- sendLevel);
- ExitOnError(result);
-
- result = (*effectSendItf)->SetDirectLevel(effectSendItf, directLevel);
- ExitOnError(result);
- fprintf(stdout, "Set direct level to %dmB\n", directLevel);
-
- result = (*effectSendItf)->SetSendLevel(effectSendItf, reverbItf, sendLevel);
- ExitOnError(result);
- fprintf(stdout, "Set send level to %dmB\n", sendLevel);
-
- /* Enable looping */
- if (loop) {
- result = (*seekItf)->SetLoop(seekItf, SL_BOOLEAN_TRUE, (SLmillisecond) 0, SL_TIME_UNKNOWN);
- ExitOnError(result);
- }
-
- /* Start playback */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- /* Disable preset reverb every TIME_S_BETWEEN_SETTING_CHANGE seconds unless always on */
- SLboolean previousEnabled = SL_BOOLEAN_FALSE;
- SLuint32 playState;
- for (;;) {
- result = (*playItf)->GetPlayState(playItf, &playState);
- ExitOnError(result);
- if (playState != SL_PLAYSTATE_PLAYING)
- break;
- SLboolean enabled;
- enabled = alwaysOn || !previousEnabled;
- if (enabled != previousEnabled) {
- result = (*reverbItf)->SetPreset(reverbItf, enabled ? preset : SL_REVERBPRESET_NONE);
- fprintf(stdout, "SetPreset(%d)=%d\n", enabled ? preset : SL_REVERBPRESET_NONE, result);
- ExitOnError(result);
- previousEnabled = enabled;
- if (enabled) {
- fprintf(stdout, "Reverb on\n");
- } else {
- fprintf(stdout, "Reverb off\n");
- }
- }
- usleep(TIME_S_BETWEEN_SETTING_CHANGE * 1000 * 1000);
- }
-
- /* Make sure player is stopped */
- assert(playState == SL_PLAYSTATE_STOPPED);
-#if 0
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-#endif
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-
-#ifdef ANDROID
- if (useFd)
- close(locatorFd.fd);
-#endif
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- const char *programName = argv[0];
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLEffectSendItf ", programName);
- fprintf(stdout, "on AudioPlayer and SLPresetReverbItf on OutputMix.\n");
- fprintf(stdout, "Plays the sound file designated by the given path, ");
- fprintf(stdout, "and sends a specified amount of energy to a global reverb\n");
- fprintf(stdout, "(sendLevel in mB), with a given direct level (in mB).\n");
- fprintf(stdout, "Every %d seconds, the reverb is turned on and off,\n",
- TIME_S_BETWEEN_SETTING_CHANGE);
- fprintf(stdout, "unless the --always-on option is specified before the path.\n");
-
- bool alwaysOn = false;
- bool useFd = false;
- bool loop = false;
- int i;
- for (i = 1; i < argc; ++i) {
- const char *arg = argv[i];
- if (arg[0] != '-')
- break;
- if (!strcmp(arg, "--always-on")) {
- alwaysOn = true;
- } else if (!strcmp(arg, "--fd")) {
- useFd = true;
- } else if (!strcmp(arg, "--loop")) {
- loop = true;
- } else {
- fprintf(stderr, "unknown option %s ignored\n", arg);
- }
- }
-
- if (argc - i != 4) {
- fprintf(stdout, "Usage: \t%s [--always-on] [--fd] [--loop] path preset directLevel "
- "sendLevel\n", programName);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 6 -2000 0\" \n", programName);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- // intentionally not checking that levels are of correct value
- TestSendToPresetReverb(sl, argv[i], atoi(argv[i+1]), (SLmillibel)atoi(argv[i+2]),
- (SLmillibel)atoi(argv[i+3]), alwaysOn, useFd, loop);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/slesTestVirtualizerPath.cpp b/wilhelm/tests/examples/slesTestVirtualizerPath.cpp
deleted file mode 100644
index e6b01b8..0000000
--- a/wilhelm/tests/examples/slesTestVirtualizerPath.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-#define TIME_S_BETWEEN_VIRT_ON_OFF 3
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play an audio path by opening a file descriptor on that path */
-void TestVirtualizerPathFromFD( SLObjectItf sl, const char* path, int16_t virtStrength,
- bool alwaysOn)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
-#ifdef ANDROID
- SLDataLocator_AndroidFD locatorFd;
-#else
- SLDataLocator_URI locatorUri;
-#endif
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play and PrefetchStatus interfaces for the audio player */
- SLPlayItf playItf;
- SLPrefetchStatusItf prefetchItf;
- SLVirtualizerItf virtItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for SLPrefetchStatusItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PREFETCHSTATUS;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_VIRTUALIZER;
-
-#ifdef ANDROID
- /* Setup the data source structure for the URI */
- locatorFd.locatorType = SL_DATALOCATOR_ANDROIDFD;
- int fd = open(path, O_RDONLY);
- if (fd == -1) {
- ExitOnError(SL_RESULT_RESOURCE_ERROR);
- }
- locatorFd.fd = (SLint32) fd;
- locatorFd.length = SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE;
- locatorFd.offset = 0;
-#else
- locatorUri.locatorType = SL_DATALOCATOR_URI;
- locatorUri.URI = (SLchar *) path;
-#endif
-
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
-#ifdef ANDROID
- audioSource.pLocator = (void*)&locatorFd;
-#else
- audioSource.pLocator = (void*)&locatorUri;
-#endif
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 2,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLAndroidStreamTypeItf interfaces for the player*/
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_VIRTUALIZER, (void*)&virtItf);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- ExitOnError(result);
- }
-
- /* Get duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- durationInMsec = 5000;
- }
-
- /* Start playback */
- fprintf(stdout, "Starting to play\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- /* Configure Virtualizer */
- SLboolean strengthSupported = SL_BOOLEAN_FALSE;
- result = (*virtItf)->IsStrengthSupported(virtItf, &strengthSupported);
- ExitOnError(result);
- if (SL_BOOLEAN_FALSE == strengthSupported) {
- fprintf(stdout, "Virtualizer strength is not supported on this platform. Too bad!\n");
- } else {
- fprintf(stdout, "Virtualizer strength is supported, setting strength to %d\n",
- virtStrength);
- result = (*virtItf)->SetStrength(virtItf, virtStrength);
- ExitOnError(result);
- }
-
- SLpermille strength = 0;
- result = (*virtItf)->GetRoundedStrength(virtItf, &strength);
- ExitOnError(result);
- fprintf(stdout, "Rounded strength of virt = %d\n", strength);
-
-
- /* Switch Virtualizer on/off every TIME_S_BETWEEN_VIRT_ON_OFF seconds unless always on */
- SLboolean previousEnabled = SL_BOOLEAN_FALSE;
- for(unsigned int j=0 ; j<(durationInMsec/(1000*TIME_S_BETWEEN_VIRT_ON_OFF)) ; j++) {
- SLboolean enabled;
- result = (*virtItf)->IsEnabled(virtItf, &enabled);
- ExitOnError(result);
- enabled = alwaysOn || !enabled;
- if (enabled != previousEnabled) {
- result = (*virtItf)->SetEnabled(virtItf, enabled);
- ExitOnError(result);
- previousEnabled = enabled;
- if (SL_BOOLEAN_TRUE == enabled) {
- fprintf(stdout, "Virtualizer on\n");
- } else {
- fprintf(stdout, "Virtualizer off\n");
- }
- }
- usleep(TIME_S_BETWEEN_VIRT_ON_OFF * 1000 * 1000);
- }
-
- /* Make sure player is stopped */
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-
-#ifdef ANDROID
- close(fd);
-#endif
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- const char *programName = argv[0];
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLVirtualizerItf ", programName);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_AndroidFD source / OutputMix sink\n");
- fprintf(stdout, "Plays the sound file designated by the given path, ");
- fprintf(stdout, "and applies a virtualization effect of the specified strength,\n");
- fprintf(stdout, "where strength is an integer value between 0 and 1000.\n");
- fprintf(stdout, "Every %d seconds, the Virtualizer will be turned on and off,\n",
- TIME_S_BETWEEN_VIRT_ON_OFF);
- fprintf(stdout, "unless the --always-on option is specified before the path.\n");
-
- bool alwaysOn = false;
- if (argc >= 2 && !strcmp(argv[1], "--always-on")) {
- alwaysOn = true;
- --argc;
- ++argv;
- }
-
- if (argc < 3) {
- fprintf(stdout, "Usage: \t%s [--always-on] path virtualization_strength\n", programName);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 1000\" \n", programName);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- // intentionally not checking that argv[2], the virtualizer strength, is between 0 and 1000
- TestVirtualizerPathFromFD(sl, argv[1], (int16_t)atoi(argv[2]), alwaysOn);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/examples/xaVideoDecoderCapabilities.cpp b/wilhelm/tests/examples/xaVideoDecoderCapabilities.cpp
deleted file mode 100644
index 46d1a9b..0000000
--- a/wilhelm/tests/examples/xaVideoDecoderCapabilities.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-#include <OMXAL/OpenMAXAL.h>
-#include <OMXAL/OpenMAXAL_Android.h> // for VP8 definitions
-
-#define NUM_ENGINE_INTERFACES 1
-
-char unknown[50];
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( XAresult result , int line)
-{
- if (XA_RESULT_SUCCESS != result) {
- fprintf(stderr, "Error %u encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-const char* videoCodecIdToString(XAuint32 decoderId) {
- switch(decoderId) {
- case XA_VIDEOCODEC_MPEG2: return "XA_VIDEOCODEC_MPEG2"; break;
- case XA_VIDEOCODEC_H263: return "XA_VIDEOCODEC_H263"; break;
- case XA_VIDEOCODEC_MPEG4: return "XA_VIDEOCODEC_MPEG4"; break;
- case XA_VIDEOCODEC_AVC: return "XA_VIDEOCODEC_AVC"; break;
- case XA_VIDEOCODEC_VC1: return "XA_VIDEOCODEC_VC1"; break;
- case XA_ANDROID_VIDEOCODEC_VP8: return "XA_ANDROID_VIDEOCODEC_VP8"; break;
- default:
- sprintf(unknown, "Video codec %d unknown to OpenMAX AL", decoderId);
- return unknown;
- }
-}
-
-//-----------------------------------------------------------------
-void TestVideoDecoderCapabilities() {
-
- XAObjectItf xa;
- XAresult res;
-
- /* parameters for the OpenMAX AL engine creation */
- XAEngineOption EngineOption[] = {
- {(XAuint32) XA_ENGINEOPTION_THREADSAFE, (XAuint32) XA_BOOLEAN_TRUE}
- };
- XAInterfaceID itfIidArray[NUM_ENGINE_INTERFACES] = { XA_IID_VIDEODECODERCAPABILITIES };
- XAboolean itfRequired[NUM_ENGINE_INTERFACES] = { XA_BOOLEAN_TRUE };
-
- /* create OpenMAX AL engine */
- res = xaCreateEngine( &xa, 1, EngineOption, NUM_ENGINE_INTERFACES, itfIidArray, itfRequired);
- ExitOnError(res);
-
- /* realize the engine in synchronous mode. */
- res = (*xa)->Realize(xa, XA_BOOLEAN_FALSE); ExitOnError(res);
-
- /* Get the video decoder capabilities interface which was explicitly requested */
- XAVideoDecoderCapabilitiesItf decItf;
- res = (*xa)->GetInterface(xa, XA_IID_VIDEODECODERCAPABILITIES, (void*)&decItf);
- ExitOnError(res);
-
- /* Query the platform capabilities */
- XAuint32 numDecoders = 0;
- XAuint32 *decoderIds = NULL;
-
- /* -> Number of decoders */
- res = (*decItf)->GetVideoDecoders(decItf, &numDecoders, NULL); ExitOnError(res);
- fprintf(stdout, "Found %d video decoders\n", numDecoders);
- if (0 == numDecoders) {
- fprintf(stderr, "0 video decoders is not an acceptable number, exiting\n");
- goto destroyRes;
- }
-
- /* -> Decoder list */
- decoderIds = (XAuint32 *) malloc(numDecoders * sizeof(XAuint32));
- res = (*decItf)->GetVideoDecoders(decItf, &numDecoders, decoderIds); ExitOnError(res);
- fprintf(stdout, "Decoders:\n");
- for(XAuint32 i = 0 ; i < numDecoders ; i++) {
- fprintf(stdout, "decoder %d is %s\n", i, videoCodecIdToString(decoderIds[i]));
- }
-
- /* -> Decoder capabilities */
- /* for each decoder */
- for(XAuint32 i = 0 ; i < numDecoders ; i++) {
- XAuint32 nbCombinations = 0;
- /* get the number of profile / level combinations */
- res = (*decItf)->GetVideoDecoderCapabilities(decItf, decoderIds[i], &nbCombinations, NULL);
- ExitOnError(res);
- fprintf(stdout, "decoder %s has %d profile/level combinations:\n\t",
- videoCodecIdToString(decoderIds[i]), nbCombinations);
- /* display the profile / level combinations */
- for(XAuint32 pl = 0 ; pl < nbCombinations ; pl++) {
- XAVideoCodecDescriptor decDescriptor;
- res = (*decItf)->GetVideoDecoderCapabilities(decItf, decoderIds[i], &pl, &decDescriptor);
- ExitOnError(res);
- fprintf(stdout, "%u/%u ", decDescriptor.profileSetting, decDescriptor.levelSetting);
- ExitOnError(res);
- }
- fprintf(stdout, "\n");
- }
-
-destroyRes:
- free(decoderIds);
-
- /* shutdown OpenMAX AL */
- (*xa)->Destroy(xa);
-}
-
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- XAresult result;
- XAObjectItf sl;
-
- fprintf(stdout, "OpenMAX AL test %s: exercises SLAudioDecoderCapabiltiesItf ", argv[0]);
- fprintf(stdout, "and displays the list of supported video decoders, and for each, lists the ");
- fprintf(stdout, "profile / levels combinations, that map to the constants defined in ");
- fprintf(stdout, "\"XA_VIDEOPROFILE and XA_VIDEOLEVEL\" section of the specification\n\n");
-
- TestVideoDecoderCapabilities();
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/listening/Android.mk b/wilhelm/tests/listening/Android.mk
deleted file mode 100644
index 89d838a..0000000
--- a/wilhelm/tests/listening/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- seekTorture.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_seekTorture
-
-include $(BUILD_EXECUTABLE)
-
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTest_playMuteSolo.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_playMuteSolo
-
-include $(BUILD_EXECUTABLE)
diff --git a/wilhelm/tests/listening/seekTorture.c b/wilhelm/tests/listening/seekTorture.c
deleted file mode 100644
index 25dbd9b..0000000
--- a/wilhelm/tests/listening/seekTorture.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This test program tortures the seek APIs by positioning "randomly" in a file.
-// It needs as input a permuted .wav and .map produced by the permute tool.
-
-#include <SLES/OpenSLES.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#define ASSERT_EQ(x, y) assert((x) == (y))
-
-int main(int argc, char **argv)
-{
- if (argc != 3) {
- fprintf(stderr, "usage: %s file.wav file.map\n", argv[0]);
- fprintf(stderr, " where file.wav and file.map are created by the permute tool\n");
- return EXIT_FAILURE;
- }
-
- SLresult result;
-
- // create engine
- SLObjectItf engineObject;
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // create output mix
- SLObjectItf outputmixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputmixObject, 0, NULL, NULL);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*outputmixObject)->Realize(outputmixObject, SL_BOOLEAN_FALSE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
- // create an audio player with URI source and output mix sink
- SLDataSource audiosrc;
- SLDataSink audiosnk;
- SLDataLocator_OutputMix locator_outputmix;
- SLDataLocator_URI locator_uri;
- SLDataFormat_MIME mime;
- locator_uri.locatorType = SL_DATALOCATOR_URI;
- locator_uri.URI = (SLchar *) argv[1];
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputmixObject;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar *) NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
- audiosrc.pLocator = &locator_uri;
- audiosrc.pFormat = &mime;
- audiosnk.pLocator = &locator_outputmix;
- audiosnk.pFormat = NULL;
- SLObjectItf playerObject;
- SLInterfaceID ids[1] = {SL_IID_SEEK};
- SLboolean flags[1] = {SL_BOOLEAN_TRUE};
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc, &audiosnk,
- 1, ids, flags);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLSeekItf playerSeek;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_SEEK, &playerSeek);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLmillisecond duration;
- result = (*playerPlay)->GetDuration(playerPlay, &duration);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PAUSED);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerPlay)->GetDuration(playerPlay, &duration);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
-
-#if 1
- // play back a file in permuted order using the seek map
- FILE *fp_map = fopen(argv[2], "r");
- if (fp_map != NULL) {
- unsigned position, duration;
- while (fscanf(fp_map, "%u %u", &position, &duration) == 2) {
- printf("%u %u\n", position, duration);
- result = (*playerSeek)->SetPosition(playerSeek, (SLmillisecond) position,
- SL_SEEKMODE_ACCURATE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- if (duration > 0)
- usleep(duration * 1000);
- }
- }
-#else
- set_conio_terminal_mode();
-
- // loop repeatedly, inflicting seek pain each cycle
- for (;;) {
- if (kbhit()) {
- switch (getch()) {
- case 'q':
- goto out;
- }
- }
- SLmillisecond delay = 100 + (rand() & 8191);
- printf("sleep %u\n", (unsigned) delay);
- usleep(delay * 1000);
- SLmillisecond newPos = duration * ((rand() & 65535) / 65536.0);
- printf("seek %u\n", (unsigned) newPos);
- result = (*playerSeek)->SetPosition(playerSeek, newPos, SL_SEEKMODE_ACCURATE);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- SLmillisecond nowPos;
- result = (*playerPlay)->GetPosition(playerPlay, &nowPos);
- ASSERT_EQ(SL_RESULT_SUCCESS, result);
- printf("now %u\n", (unsigned) newPos);
- }
-out:
-#endif
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/listening/slesTest_playMuteSolo.cpp b/wilhelm/tests/listening/slesTest_playMuteSolo.cpp
deleted file mode 100644
index 0159cda..0000000
--- a/wilhelm/tests/listening/slesTest_playMuteSolo.cpp
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-#define TEST_MUTE 0
-#define TEST_SOLO 1
-
-typedef struct {
- int testMode;
- SLPlayItf playItf;
- SLMuteSoloItf muteSoloItf;
-} Context;
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stdout, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-// These are extensions to OpenSL ES 1.0.1 values
-
-#define SL_PREFETCHSTATUS_UNKNOWN 0
-#define SL_PREFETCHSTATUS_ERROR (-1)
-
-// Mutex and condition shared with main program to protect prefetch_status
-
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-SLuint32 prefetch_status = SL_PREFETCHSTATUS_UNKNOWN;
-
-/* used to detect errors likely to have occured when the OpenSL ES framework fails to open
- * a resource, for instance because a file URI is invalid, or an HTTP server doesn't respond.
- */
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-// Prefetch status callback
-
-void prefetch_callback(SLPrefetchStatusItf caller, void *context, SLuint32 event)
-{
- SLresult result;
- assert(context == NULL);
- SLpermille level;
- result = (*caller)->GetFillLevel(caller, &level);
- assert(SL_RESULT_SUCCESS == result);
- SLuint32 status;
- result = (*caller)->GetPrefetchStatus(caller, &status);
- assert(SL_RESULT_SUCCESS == result);
- SLuint32 new_prefetch_status;
- if ((event & PREFETCHEVENT_ERROR_CANDIDATE) == PREFETCHEVENT_ERROR_CANDIDATE
- && level == 0 && status == SL_PREFETCHSTATUS_UNDERFLOW) {
- new_prefetch_status = SL_PREFETCHSTATUS_ERROR;
- } else if (event == SL_PREFETCHEVENT_STATUSCHANGE &&
- status == SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- new_prefetch_status = status;
- } else {
- return;
- }
- int ok;
- ok = pthread_mutex_lock(&mutex);
- assert(ok == 0);
- prefetch_status = new_prefetch_status;
- ok = pthread_cond_signal(&cond);
- assert(ok == 0);
- ok = pthread_mutex_unlock(&mutex);
- assert(ok == 0);
-}
-
-//-----------------------------------------------------------------
-/* PlayItf callback for an audio player, will be called for every SL_PLAYEVENT_HEADATNEWPOS event */
-void PlayEventCallback( SLPlayItf caller, void *pContext, SLuint32 event)
-{
- Context *context = (Context *) pContext;
- SLPlayItf playItf = context->playItf;
- SLMuteSoloItf muteSolo = context->muteSoloItf;
- SLuint8 numChannels = 0;
- SLresult res = (*muteSolo)->GetNumChannels(muteSolo, &numChannels); ExitOnError(res);
- //fprintf(stdout, "Content has %d channel(s)\n", numChannels);
- SLmillisecond position;
- res = (*playItf)->GetPosition(playItf, &position); ExitOnError(res);
- printf("position=%u\n", (unsigned) position);
-
- switch (context->testMode) {
- case TEST_MUTE: {
- //---------------------------------------------------
- if (numChannels > 1) { // SLMuteSoloItf only works if more than one channel
- SLboolean leftMuted = SL_BOOLEAN_TRUE;
- res = (*muteSolo)->GetChannelMute(muteSolo, 0, &leftMuted); ExitOnError(res);
- // swap channel mute
- res = (*muteSolo)->SetChannelMute(muteSolo, 0,
- leftMuted == SL_BOOLEAN_TRUE ? SL_BOOLEAN_FALSE : SL_BOOLEAN_TRUE);
- ExitOnError(res);
- res = (*muteSolo)->SetChannelMute(muteSolo, 1,
- leftMuted == SL_BOOLEAN_TRUE ? SL_BOOLEAN_TRUE : SL_BOOLEAN_FALSE);
- ExitOnError(res);
- if (leftMuted == SL_BOOLEAN_TRUE) { // we've swapped the channel mute above
- fprintf(stdout, "channel 0: playing, channel 1: muted\n");
- } else {
- fprintf(stdout, "channel 0: muted, channel 1: playing\n");
- }
- }
- } break;
-
- case TEST_SOLO: {
- //---------------------------------------------------
- if (numChannels > 1) { // SLMuteSoloItf only works if more than one channel
- SLboolean leftSoloed = SL_BOOLEAN_TRUE;
- res = (*muteSolo)->GetChannelSolo(muteSolo, 0, &leftSoloed); ExitOnError(res);
- // swap channel solo
- res = (*muteSolo)->SetChannelSolo(muteSolo, 0,
- leftSoloed == SL_BOOLEAN_TRUE ? SL_BOOLEAN_FALSE : SL_BOOLEAN_TRUE);
- ExitOnError(res);
- res = (*muteSolo)->SetChannelSolo(muteSolo, 1,
- leftSoloed == SL_BOOLEAN_TRUE ? SL_BOOLEAN_TRUE : SL_BOOLEAN_FALSE);
- ExitOnError(res);
- if (leftSoloed == SL_BOOLEAN_TRUE) { // we've swapped the channel solo above
- fprintf(stdout, "channel 0: normal, channel 1: soloed\n");
- } else {
- fprintf(stdout, "channel 0: soloed, channel 1: normal\n");
- }
- }
- } break;
-
- default:
- break;
- }
-}
-
-//-----------------------------------------------------------------
-
-/* Play an audio URIs, mute and solo channels */
-void TestPlayUri( SLObjectItf sl, const char* path)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an output mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play, Volume and PrefetchStatus interfaces for the audio player */
- SLPlayItf playItf;
- SLMuteSoloItf muteSoloItf;
- SLPrefetchStatusItf prefetchItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for SLMuteSoloItf and SLPrefetchStatusItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_MUTESOLO;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
- audioSource.pLocator = (void*)&uri;
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 2,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLMuteSoloItf interfaces for the player */
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- // get the prefetch status interface
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- // enable prefetch status callbacks
- result = (*prefetchItf)->RegisterCallback(prefetchItf, prefetch_callback, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*prefetchItf)->SetCallbackEventsMask(prefetchItf,
- SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the mute solo interface
- result = (*player)->GetInterface(player, SL_IID_MUTESOLO, (void*)&muteSoloItf);
- ExitOnError(result);
-
- // Attempt to get the duration before it is necessarily known.
- // This should always return successfully.
- // The reported duration may be either
- // a particular duration or SL_TIME_UNKNOWN, depending on the platform.
- SLmillisecond duration;
- result = (*playItf)->GetDuration(playItf, &duration);
- ExitOnError(result);
- printf("GetDuration after Realize but before pre-fetch: result=%u, duration=%u\n",
- result, duration);
-
- // Attempt to get the channel count before it is necessarily known.
- // This should either return successfully with a specific value (e.g. 1 or 2),
- // or fail with SL_RESULT_PRECONDITIONS_VIOLATED, depending on the platform.
- SLuint8 numChannels = 123;
- result = (*muteSoloItf)->GetNumChannels(muteSoloItf, &numChannels);
- printf("GetNumChannels after Realize but before pre-fetch: result=%u, numChannels=%u\n",
- result, numChannels);
- if (result != SL_RESULT_PRECONDITIONS_VIOLATED) {
- ExitOnError(result);
- }
-
- /* Initialize a context for use by the play event callback */
- Context context;
- context.playItf = playItf;
- context.muteSoloItf = muteSoloItf;
- context.testMode = TEST_MUTE;
-
- /* Setup to receive playback events on position updates */
- result = (*playItf)->RegisterCallback(playItf, PlayEventCallback, (void *) &context);
- ExitOnError(result);
- result = (*playItf)->SetCallbackEventsMask(playItf, SL_PLAYEVENT_HEADATNEWPOS);
- ExitOnError(result);
- result = (*playItf)->SetPositionUpdatePeriod(playItf, 1000);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- // wait for prefetch status callback to indicate either sufficient data or error
- pthread_mutex_lock(&mutex);
- while (prefetch_status == SL_PREFETCHSTATUS_UNKNOWN) {
- pthread_cond_wait(&cond, &mutex);
- }
- pthread_mutex_unlock(&mutex);
- if (prefetch_status == SL_PREFETCHSTATUS_ERROR) {
- fprintf(stderr, "Error during prefetch, exiting\n");
- goto destroyKillKill;
- }
-
- /* Query the duration */
- result = (*playItf)->GetDuration(playItf, &duration);
- printf("GetDuration after Realize and after pre-fetch: result=%u, duration=%u\n",
- result, duration);
- ExitOnError(result);
-
- /* Query the number of channels */
- numChannels = 123;
- result = (*muteSoloItf)->GetNumChannels(muteSoloItf, &numChannels);
- printf("GetNumChannels after Realize and after pre-fetch: result=%u, numChannels=%u\n",
- result, numChannels);
- ExitOnError(result);
- fprintf(stdout, "Content has %d channel(s)\n", numChannels);
-
- if (numChannels == 1) {
- fprintf(stdout, "SLMuteSolotItf only works one content with more than one channel. Bye\n");
- goto destroyKillKill;
- } else {
- /* Mute left channel */
- result = (*muteSoloItf)->SetChannelMute(muteSoloItf, 0, SL_BOOLEAN_TRUE);
- ExitOnError(result);
- result = (*muteSoloItf)->SetChannelMute(muteSoloItf, 1, SL_BOOLEAN_FALSE);
- ExitOnError(result);
- }
-
- /* Run the test for 10s */
- /* see PlayEventCallback() for more of the test of the SLMuteSoloItf interface */
- fprintf(stdout, "\nTesting mute functionality:\n");
- context.testMode = TEST_MUTE;
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING ); ExitOnError(result);
- usleep( 5 * 1000 * 1000);
- result = (*muteSoloItf)->SetChannelMute(muteSoloItf, 0, SL_BOOLEAN_FALSE); ExitOnError(result);
- result = (*muteSoloItf)->SetChannelMute(muteSoloItf, 1, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "\nTesting solo functionality:\n");
- context.testMode = TEST_SOLO;
- usleep( 5 * 1000 * 1000);
-
- /* Make sure player is stopped */
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
-destroyKillKill:
-
- /* Destroy the players */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLVolumeItf, SLMuteSoloItf\n",
- argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound and alternates the muting of the channels (for 5s).\n");
- fprintf(stdout, " and then alternates the solo\'ing of the channels (for 5s).\n");
- fprintf(stdout, "Stops after 10s\n");
-
- if (argc == 1) {
- fprintf(stdout, "Usage: \t%s url\n", argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3\"\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- if (argc > 1) {
- TestPlayUri(sl, argv[1]);
- }
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/Android.mk b/wilhelm/tests/mimeUri/Android.mk
deleted file mode 100644
index 04742ba..0000000
--- a/wilhelm/tests/mimeUri/Android.mk
+++ /dev/null
@@ -1,209 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# slesTest_playStates
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTest_playStates.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_playStates
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_playStreamType
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestPlayStreamType.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_playStreamType
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_playUri
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestPlayUri.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_playUri
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_loopUri
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestLoopUri.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_loopUri
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_playUri2
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestPlayUri2.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_playUri2
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_slowDownUri
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestSlowDownUri.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_slowDownUri
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_manyPlayers
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestManyPlayers.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_manyPlayers
-
-include $(BUILD_EXECUTABLE)
-
-# slesTest_getPositionUri
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestGetPositionUri.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_CFLAGS += -UNDEBUG
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_getPositionUri
-
-include $(BUILD_EXECUTABLE)
diff --git a/wilhelm/tests/mimeUri/slesTestGetPositionUri.cpp b/wilhelm/tests/mimeUri/slesTestGetPositionUri.cpp
deleted file mode 100644
index bb29bc5..0000000
--- a/wilhelm/tests/mimeUri/slesTestGetPositionUri.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <utils/threads.h>
-
-#include <SLES/OpenSLES.h>
-
-/* tolerance in ms for this test in time difference between reported position and time since
- * playback was requested to start. This is reasonable for a local file.
- */
-#define TIME_TOLERANCE_MS 600
-
-/* explicitly requesting SL_IID_VOLUME and SL_IID_PREFETCHSTATUS
- * on the AudioPlayer object */
-#define NUM_EXPLICIT_INTERFACES_FOR_PLAYER 2
-
-/* used to detect errors likely to have occured when the OpenSL ES framework fails to open
- * a resource, for instance because a file URI is invalid, or an HTTP server doesn't respond. */
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-/* to signal to the test app the end of the stream to decode has been reached */
-bool eos = false;
-android::Mutex eosLock;
-android::Condition eosCondition;
-
-//-----------------------------------------------------------------
-//* Exits the application if an error is encountered */
-#define CheckErr(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-bool prefetchError = false;
-
-//-----------------------------------------------------------------
-void SignalEos() {
- android::Mutex::Autolock autoLock(eosLock);
- eos = true;
- eosCondition.signal();
-}
-
-//-----------------------------------------------------------------
-/* PrefetchStatusItf callback for an audio player */
-void PrefetchEventCallback( SLPrefetchStatusItf caller, void *pContext, SLuint32 event)
-{
- SLpermille level = 0;
- SLresult res = (*caller)->GetFillLevel(caller, &level); CheckErr(res);
- SLuint32 status;
- //fprintf(stdout, "PrefetchEventCallback: received event %u\n", event);
- res = (*caller)->GetPrefetchStatus(caller, &status); CheckErr(res);
- if ((PREFETCHEVENT_ERROR_CANDIDATE == (event & PREFETCHEVENT_ERROR_CANDIDATE))
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- fprintf(stdout, "PrefetchEventCallback: Error while prefetching data, exiting\n");
- prefetchError = true;
- return;
- }
- if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- fprintf(stdout, "PrefetchEventCallback: Buffer fill level is = %d\n", level);
- }
- if (event & SL_PREFETCHEVENT_STATUSCHANGE) {
- fprintf(stdout, "PrefetchEventCallback: Prefetch Status is = %u\n", status);
- }
-}
-
-
-//-----------------------------------------------------------------
-/* PlayItf callback for playback events */
-void PlayEventCallback(
- SLPlayItf caller,
- void *pContext,
- SLuint32 event)
-{
- SLmillisecond posMsec = SL_TIME_UNKNOWN;
- SLresult res;
- if (SL_PLAYEVENT_HEADATEND & event) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATEND reached\n");
-#if 0
- res = (*caller)->GetPosition(caller, &posMsec); CheckErr(res);
- fprintf(stdout, "after getPosition in SL_PLAYEVENT_HEADATEND handler\n");
- if (posMsec == SL_TIME_UNKNOWN) {
- fprintf(stderr, "Error: position is SL_TIME_UNKNOWN at SL_PLAYEVENT_HEADATEND\n");
- } else {
- fprintf(stdout, "position is %d at SL_PLAYEVENT_HEADATEND\n", posMsec);
- }
- // FIXME compare position against duration
-#endif
- SignalEos();
- }
-
- if (SL_PLAYEVENT_HEADATNEWPOS & event) {
- res = (*caller)->GetPosition(caller, &posMsec); CheckErr(res);
- fprintf(stdout, "SL_PLAYEVENT_HEADATNEWPOS current position=%ums\n", posMsec);
- }
-
- if (SL_PLAYEVENT_HEADATMARKER & event) {
- res = (*caller)->GetPosition(caller, &posMsec); CheckErr(res);
- fprintf(stdout, "SL_PLAYEVENT_HEADATMARKER current position=%ums\n", posMsec);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play some audio from a URI and regularly query the position */
-void TestGetPositionUri( SLObjectItf sl, const char* path)
-{
- SLEngineItf EngineItf;
-
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
-
- SLresult res;
-
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- SLObjectItf player;
- SLPlayItf playItf;
- SLVolumeItf volItf;
- SLPrefetchStatusItf prefetchItf;
-
- SLObjectItf OutputMix;
-
- /* variables for the duration and position tests */
- SLuint16 counter = 0;
- SLmillisecond posInMsec = SL_TIME_UNKNOWN;
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
-
- SLboolean required[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
- SLInterfaceID iidArray[NUM_EXPLICIT_INTERFACES_FOR_PLAYER];
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- CheckErr(res);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < NUM_EXPLICIT_INTERFACES_FOR_PLAYER ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- // Set arrays required[] and iidArray[] for VOLUME and PREFETCHSTATUS interface
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
- // Create Output Mix object to be used by player
- res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
- iidArray, required); CheckErr(res);
-
- // Realizing the Output Mix object in synchronous mode.
- res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&uri;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = OutputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Create the audio player */
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink,
- NUM_EXPLICIT_INTERFACES_FOR_PLAYER, iidArray, required); CheckErr(res);
-
- /* Realizing the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE); CheckErr(res);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get interfaces */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_VOLUME, (void*)&volItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->RegisterCallback(prefetchItf, PrefetchEventCallback, &prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->SetCallbackEventsMask(prefetchItf,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
- CheckErr(res);
-
- /* Configure fill level updates every 5 percent */
- res = (*prefetchItf)->SetFillUpdatePeriod(prefetchItf, 50); CheckErr(res);
-
- /* Set up the player callback to get events during the decoding */
- res = (*playItf)->SetMarkerPosition(playItf, 2000);
- CheckErr(res);
- res = (*playItf)->SetPositionUpdatePeriod(playItf, 500);
- CheckErr(res);
- res = (*playItf)->SetCallbackEventsMask(playItf,
- SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS | SL_PLAYEVENT_HEADATEND);
- CheckErr(res);
- res = (*playItf)->RegisterCallback(playItf, PlayEventCallback, NULL);
- CheckErr(res);
-
- /* Set the player volume */
- res = (*volItf)->SetVolumeLevel( volItf, -300);
- CheckErr(res);
-
- /* Play the URI */
- /* first cause the player to prefetch the data */
- fprintf(stdout, "Setting the player to PAUSED to cause it to prefetch the data\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED ); CheckErr(res);
-
- usleep(100 * 1000);
- /* wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- SLuint32 timeOutIndex = 100; // 10s
- while ((prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) && (timeOutIndex > 0) &&
- !prefetchError) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- timeOutIndex--;
- }
-
- if (timeOutIndex == 0 || prefetchError) {
- fprintf(stderr, "We're done waiting, failed to prefetch data in time, exiting\n");
- goto destroyRes;
- }
-
- /* Display duration */
- res = (*playItf)->GetDuration(playItf, &durationInMsec); CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stderr, "Error: Content duration is unknown after prefetch completed, exiting\n");
- goto destroyRes;
- } else {
- fprintf(stdout, "Content duration is %u ms (after prefetch completed)\n", durationInMsec);
- }
-
- fprintf(stdout, "Setting the player to PLAYING\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING ); CheckErr(res);
-
- /* Test GetPosition every second */
- while ((counter*1000) < durationInMsec) {
- counter++;
- usleep(1 * 1000 * 1000); //1s
- res = (*playItf)->GetPosition(playItf, &posInMsec); CheckErr(res);
- if (posInMsec == SL_TIME_UNKNOWN) {
- fprintf(stderr, "Error: position is SL_TIME_UNKNOWN %ds after start, exiting\n",
- counter);
- goto destroyRes;
- } else {
- fprintf(stderr, "position is %dms %ds after start\n", posInMsec, counter);
- }
- // this test would probably deserve to be improved by relying on drift relative to
- // a clock, as the operations between two consecutive sleep() are taking time as well
- // and can add up
- if (((SLint32)posInMsec > (counter*1000 + TIME_TOLERANCE_MS)) ||
- ((SLint32)posInMsec < (counter*1000 - TIME_TOLERANCE_MS))) {
- fprintf(stderr, "Error: position drifted too much, exiting\n");
- goto destroyRes;
- }
- }
-
- /* Play until the end of file is reached */
- {
- android::Mutex::Autolock autoLock(eosLock);
- while (!eos) {
- eosCondition.wait(eosLock);
- }
- }
- fprintf(stdout, "EOS signaled, stopping playback\n");
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED); CheckErr(res);
-
-destroyRes:
-
- /* Destroy the player */
- fprintf(stdout, "Destroying the player\n");
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*OutputMix)->Destroy(OutputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult res;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf", argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound and requests position at various times\n\n");
-
- if (argc == 1) {
- fprintf(stdout, "Usage: %s path \n\t%s url\n", argv[0], argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3\" or \"%s file:///sdcard/my.mp3\"\n",
- argv[0], argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE}};
-
- res = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- TestGetPositionUri(sl, argv[1]);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/slesTestLoopUri.cpp b/wilhelm/tests/mimeUri/slesTestLoopUri.cpp
deleted file mode 100644
index dab0a8e..0000000
--- a/wilhelm/tests/mimeUri/slesTestLoopUri.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 2
-
-#define REPETITIONS 4
-
-// These are extensions to OpenSL ES 1.0.1 values
-
-#define SL_PREFETCHSTATUS_UNKNOWN 0
-#define SL_PREFETCHSTATUS_ERROR (-1)
-
-// Mutex and condition shared with main program to protect prefetch_status
-
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-SLuint32 prefetch_status = SL_PREFETCHSTATUS_UNKNOWN;
-
-/* used to detect errors likely to have occured when the OpenSL ES framework fails to open
- * a resource, for instance because a file URI is invalid, or an HTTP server doesn't respond.
- */
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-//-----------------------------------------------------------------
-//* Exits the application if an error is encountered */
-#define CheckErr(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-//-----------------------------------------------------------------
-/* PrefetchStatusItf callback for an audio player */
-void PrefetchEventCallback( SLPrefetchStatusItf caller, void *pContext, SLuint32 event)
-{
- SLresult result;
- // pContext is unused here, so we pass NULL
- assert(pContext == NULL);
- SLpermille level = 0;
- result = (*caller)->GetFillLevel(caller, &level);
- CheckErr(result);
- SLuint32 status;
- result = (*caller)->GetPrefetchStatus(caller, &status);
- CheckErr(result);
- if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Buffer fill level is = %d\n", level);
- }
- if (event & SL_PREFETCHEVENT_STATUSCHANGE) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Prefetch Status is = %u\n", status);
- }
- SLuint32 new_prefetch_status;
- if ((event & PREFETCHEVENT_ERROR_CANDIDATE) == PREFETCHEVENT_ERROR_CANDIDATE
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Error while prefetching data, exiting\n");
- new_prefetch_status = SL_PREFETCHSTATUS_ERROR;
- } else if (event == SL_PREFETCHEVENT_STATUSCHANGE &&
- status == SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- new_prefetch_status = status;
- } else {
- return;
- }
- int ok;
- ok = pthread_mutex_lock(&mutex);
- assert(ok == 0);
- prefetch_status = new_prefetch_status;
- ok = pthread_cond_signal(&cond);
- assert(ok == 0);
- ok = pthread_mutex_unlock(&mutex);
- assert(ok == 0);
-}
-
-
-//-----------------------------------------------------------------
-/* PlayItf callback for playback events */
-void PlayEventCallback(
- SLPlayItf caller,
- void *pContext,
- SLuint32 event)
-{
- // pContext is unused here, so we pass NULL
- assert(NULL == pContext);
- if (SL_PLAYEVENT_HEADATEND == event) {
- printf("SL_PLAYEVENT_HEADATEND reached\n");
- } else {
- fprintf(stderr, "Unexpected play event 0x%x", event);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play some music from a URI */
-void TestLoopUri( SLObjectItf sl, const char* path)
-{
- SLEngineItf EngineItf;
-
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
-
- SLresult res;
-
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- SLObjectItf player;
- SLPlayItf playItf;
- SLSeekItf seekItf;
- SLPrefetchStatusItf prefetchItf;
-
- SLObjectItf OutputMix;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- CheckErr(res);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- // Create Output Mix object to be used by player
- res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
- iidArray, required); CheckErr(res);
-
- // Realizing the Output Mix object in synchronous mode.
- res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&uri;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = OutputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Create the audio player */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_SEEK;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink,
- MAX_NUMBER_INTERFACES, iidArray, required); CheckErr(res);
-
- /* Realizing the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE); CheckErr(res);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get interfaces */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_SEEK, (void*)&seekItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->RegisterCallback(prefetchItf, PrefetchEventCallback, NULL);
- CheckErr(res);
- res = (*prefetchItf)->SetCallbackEventsMask(prefetchItf,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
- CheckErr(res);
-
- /* Configure fill level updates every 5 percent */
- (*prefetchItf)->SetFillUpdatePeriod(prefetchItf, 50);
-
- /* Set up the player callback to get head-at-end events */
- res = (*playItf)->SetCallbackEventsMask(playItf, SL_PLAYEVENT_HEADATEND);
- CheckErr(res);
- res = (*playItf)->RegisterCallback(playItf, PlayEventCallback, NULL);
- CheckErr(res);
-
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (before starting to prefetch)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (before starting to prefetch)\n",
- durationInMsec);
- }
-
- /* Loop on the whole of the content */
- res = (*seekItf)->SetLoop(seekItf, SL_BOOLEAN_TRUE, 0, SL_TIME_UNKNOWN);
- CheckErr(res);
-
- /* Play the URI */
- /* first cause the player to prefetch the data */
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- CheckErr(res);
-
- // wait for prefetch status callback to indicate either sufficient data or error
- pthread_mutex_lock(&mutex);
- while (prefetch_status == SL_PREFETCHSTATUS_UNKNOWN) {
- pthread_cond_wait(&cond, &mutex);
- }
- pthread_mutex_unlock(&mutex);
- if (prefetch_status == SL_PREFETCHSTATUS_ERROR) {
- fprintf(stderr, "Error during prefetch, exiting\n");
- goto destroyRes;
- }
-
- /* Display duration again, */
- res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (after prefetch completed)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (after prefetch completed)\n", durationInMsec);
- }
-
- /* Start playing */
- fprintf(stdout, "starting to play\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- CheckErr(res);
-
- /* Wait as long as the duration of the content, times the repetitions,
- * before stopping the loop */
- usleep( (REPETITIONS-1) * durationInMsec * 1100);
- res = (*seekItf)->SetLoop(seekItf, SL_BOOLEAN_FALSE, 0, SL_TIME_UNKNOWN);
- CheckErr(res);
- fprintf(stdout, "As of now, stopped looping (sound shouldn't repeat from now on)\n");
- /* wait some more to make sure it doesn't repeat */
- usleep(durationInMsec * 1000);
-
- /* Stop playback */
- fprintf(stdout, "stopping playback\n");
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- CheckErr(res);
-
-destroyRes:
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*OutputMix)->Destroy(OutputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult res;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLSeekItf ", argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound and loops it %d times.\n\n", REPETITIONS);
-
- if (argc == 1) {
- fprintf(stdout, "Usage: \n\t%s path \n\t%s url\n", argv[0], argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3\" or \"%s file:///sdcard/my.mp3\"\n",
- argv[0], argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE}};
-
- res = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- TestLoopUri(sl, argv[1]);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/slesTestManyPlayers.cpp b/wilhelm/tests/mimeUri/slesTestManyPlayers.cpp
deleted file mode 100644
index cb45a3c..0000000
--- a/wilhelm/tests/mimeUri/slesTestManyPlayers.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-//#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 2
-#define MAX_NUMBER_PLAYERS 40
-
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-/* the OpenSL ES engine from which we create all other resources */
-SLObjectItf slEngine;
-SLEngineItf engineItf;
-SLObjectItf outputMix;
-
-SLboolean required[MAX_NUMBER_INTERFACES];
-SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
-SLObjectItf audioPlayer[MAX_NUMBER_PLAYERS];
-bool validplayer[MAX_NUMBER_PLAYERS];
-int playerNum[MAX_NUMBER_PLAYERS];
-SLPlayItf playItfs[MAX_NUMBER_PLAYERS];
-SLVolumeItf volItfs[MAX_NUMBER_PLAYERS];
-SLPrefetchStatusItf prefetchItfs[MAX_NUMBER_PLAYERS];
-
-SLDataSource audioSource;
-SLDataLocator_URI uri;
-SLDataFormat_MIME mime;
-
-SLDataSink audioSink;
-SLDataLocator_OutputMix locator_outputmix;
-
-
-//-----------------------------------------------------------------
-//* Exits the application if an error is encountered */
-#define CheckErr(x) ExitOnErrorFunc(x, -1, __LINE__)
-#define CheckErrPlyr(x, id) ExitOnErrorFunc(x, id, __LINE__)
-
-void ExitOnErrorFunc( SLresult result, int playerId, int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- if (playerId == -1) {
- fprintf(stderr, "Error %u code encountered at line %d, exiting\n", result, line);
- } else {
- fprintf(stderr, "Error %u code encountered at line %d for player %d, exiting\n",
- result, line, playerId);
- }
- exit(EXIT_FAILURE);
- }
-}
-
-//-----------------------------------------------------------------
-/* PrefetchStatusItf callback for an audio player */
-void PrefetchEventCallback( SLPrefetchStatusItf caller, void *pContext, SLuint32 event)
-{
- SLresult res;
- SLpermille level = 0;
- int* pPlayerId = (int*)pContext;
- res = (*caller)->GetFillLevel(caller, &level); CheckErrPlyr(res, *pPlayerId);
- SLuint32 status;
- //fprintf(stdout, "PrefetchEventCallback: received event %u\n", event);
- res = (*caller)->GetPrefetchStatus(caller, &status); CheckErrPlyr(res, *pPlayerId);
- if ((PREFETCHEVENT_ERROR_CANDIDATE == (event & PREFETCHEVENT_ERROR_CANDIDATE))
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- fprintf(stdout, "PrefetchEventCallback: Error while prefetching data for player %d, "
- "exiting\n", *pPlayerId);
- exit(EXIT_FAILURE);
- }
- if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- fprintf(stdout, "PrefetchEventCallback: Buffer fill level is = %d for player %d\n",
- level, *pPlayerId);
- }
- if (event & SL_PREFETCHEVENT_STATUSCHANGE) {
- fprintf(stdout, "PrefetchEventCallback: Prefetch Status is = %u for player %d\n",
- status, *pPlayerId);
- }
-}
-
-
-//-----------------------------------------------------------------
-/* PlayItf callback for playback events */
-void PlayEventCallback(
- SLPlayItf caller,
- void *pContext,
- SLuint32 event)
-{
- SLresult res;
- int* pPlayerId = (int*)pContext;
- if (SL_PLAYEVENT_HEADATEND & event) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATEND reached for player %d\n", *pPlayerId);
- //SignalEos();
- }
-
- if (SL_PLAYEVENT_HEADATNEWPOS & event) {
- SLmillisecond pMsec = 0;
- res = (*caller)->GetPosition(caller, &pMsec); CheckErrPlyr(res, *pPlayerId);
- fprintf(stdout, "SL_PLAYEVENT_HEADATNEWPOS current position=%ums for player %d\n",
- pMsec, *pPlayerId);
- }
-
- if (SL_PLAYEVENT_HEADATMARKER & event) {
- SLmillisecond pMsec = 0;
- res = (*caller)->GetPosition(caller, &pMsec); CheckErrPlyr(res, *pPlayerId);
- fprintf(stdout, "SL_PLAYEVENT_HEADATMARKER current position=%ums for player %d\n",
- pMsec, *pPlayerId);
- }
-}
-
-
-//-----------------------------------------------------------------
-void TestSetup(const char* path) {
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
- SLresult res;
-
- /* Create the engine */
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE}};
-
- res = slCreateEngine( &slEngine, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
- /* Realizing the SL Engine in synchronous mode. */
- res = (*slEngine)->Realize(slEngine, SL_BOOLEAN_FALSE);
- CheckErr(res);
- /* Get the SL Engine Interface which is implicit */
- res = (*slEngine)->GetInterface(slEngine, SL_IID_ENGINE, (void*)&engineItf);
- CheckErr(res);
-
- /* Create Output Mix object to be used by player */
- res = (*engineItf)->CreateOutputMix(engineItf, &outputMix, 0,
- iidArray, required); CheckErr(res);
- /* Realizing the Output Mix object in synchronous mode. */
- res = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- /* Setup the data source structure for the URI */
- // the syntax below is more future-proof than the individual field initialization
- // with regards to OpenSL ES 1.1 but adds scary compilation warnings
- //uri = { SL_DATALOCATOR_URI /*locatorType*/, (SLchar*) path /*URI*/ };
- //mime = { /*formatType*/ SL_DATAFORMAT_MIME, /*mimeType*/ (SLchar*)NULL,
- // /*containerType*/ SL_CONTAINERTYPE_UNSPECIFIED };
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&uri;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
- /* Set arrays required[] and iidArray[] for VOLUME and PREFETCHSTATUS interface */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
-
- fprintf(stdout, "TestSetup(%s) completed\n", path);
-}
-
-
-//-----------------------------------------------------------------
-void TestTeardown() {
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-
- /* Shutdown OpenSL ES */
- (*slEngine)->Destroy(slEngine);
-}
-
-
-//-----------------------------------------------------------------
-/**
- * Create a player and, if the creation is successful,
- * configure it, and start playing.
- */
-void CreatePlayer(int playerId) {
- SLresult res;
- playerNum[playerId] = playerId;
-
- /* Create the audio player */
- res = (*engineItf)->CreateAudioPlayer(engineItf, &audioPlayer[playerId],
- &audioSource, &audioSink, MAX_NUMBER_INTERFACES, iidArray, required);
- if (SL_RESULT_SUCCESS != res) {
- // do not abort the test, just flag the player as not a candidate for destruction
- fprintf(stdout, "CreateAudioPlayer for player %d failed\n", playerId);
- validplayer[playerId] = false;
- return;
- }
- validplayer[playerId] = true;
-
- /* Realizing the player in synchronous mode. */
- res = (*audioPlayer[playerId])->Realize(audioPlayer[playerId], SL_BOOLEAN_FALSE);
- if (SL_RESULT_SUCCESS != res) {
- // do not abort the test, just stop the player initialization here
- fprintf(stdout, "Realize for player %d failed\n", playerId);
- // this player is still a candidate for destruction
- return;
- }
- // after this point, any failure is a test failure
-
- /* Get interfaces */
- res = (*audioPlayer[playerId])->GetInterface(audioPlayer[playerId], SL_IID_PLAY,
- (void*)&playItfs[playerId]);
- CheckErrPlyr(res, playerId);
-
- res = (*audioPlayer[playerId])->GetInterface(audioPlayer[playerId], SL_IID_VOLUME,
- (void*)&volItfs[playerId]);
- CheckErrPlyr(res, playerId);
-
- res = (*audioPlayer[playerId])->GetInterface(audioPlayer[playerId], SL_IID_PREFETCHSTATUS,
- (void*)&prefetchItfs[playerId]);
- CheckErrPlyr(res, playerId);
- res = (*prefetchItfs[playerId])->RegisterCallback(prefetchItfs[playerId], PrefetchEventCallback,
- &playerNum[playerId]);
- CheckErrPlyr(res, playerId);
- res = (*prefetchItfs[playerId])->SetCallbackEventsMask(prefetchItfs[playerId],
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
- CheckErrPlyr(res, playerId);
-
- /* Set the player volume */
- res = (*volItfs[playerId])->SetVolumeLevel( volItfs[playerId], -300);
- CheckErrPlyr(res, playerId);
-
- /* Set up the player callback to get events during the decoding */
- res = (*playItfs[playerId])->SetMarkerPosition(playItfs[playerId], 2000);
- CheckErrPlyr(res, playerId);
- res = (*playItfs[playerId])->SetPositionUpdatePeriod(playItfs[playerId], 500);
- CheckErrPlyr(res, playerId);
- res = (*playItfs[playerId])->SetCallbackEventsMask(playItfs[playerId],
- SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS | SL_PLAYEVENT_HEADATEND);
- CheckErrPlyr(res, playerId);
- res = (*playItfs[playerId])->RegisterCallback(playItfs[playerId], PlayEventCallback,
- &playerNum[playerId]);
- CheckErrPlyr(res, playerId);
-
- /* Configure fill level updates every 5 percent */
- (*prefetchItfs[playerId])->SetFillUpdatePeriod(prefetchItfs[playerId], 50);
-
- /* Play the URI */
- /* first cause the player to prefetch the data */
- fprintf(stdout, "Setting player %d to PAUSED\n", playerId);
- res = (*playItfs[playerId])->SetPlayState( playItfs[playerId], SL_PLAYSTATE_PAUSED );
- CheckErrPlyr(res, playerId);
- /* wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- SLuint32 timeOutIndex = 10; // 1s, should be enough for a local file
- while ((prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) && (timeOutIndex > 0)) {
- usleep(100 * 1000);
- res = (*prefetchItfs[playerId])->GetPrefetchStatus(prefetchItfs[playerId], &prefetchStatus);
- CheckErrPlyr(res, playerId);
- timeOutIndex--;
- }
-
- if (timeOutIndex == 0) {
- fprintf(stderr, "Prefetch timed out for player %d\n", playerId);
- return;
- }
- res = (*playItfs[playerId])->SetPlayState( playItfs[playerId], SL_PLAYSTATE_PLAYING );
- CheckErrPlyr(res, playerId);
-
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- res = (*playItfs[playerId])->GetDuration(playItfs[playerId], &durationInMsec);
- CheckErrPlyr(res, playerId);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown for player %d\n", playerId);
- } else {
- fprintf(stdout, "Content duration is %u ms for player %d\n", durationInMsec, playerId);
- }
-}
-
-//-----------------------------------------------------------------
-void DestroyPlayer(int playerId) {
- fprintf(stdout, "About to destroy player %d\n", playerId);
- /* Destroy the player */
- (*audioPlayer[playerId])->Destroy(audioPlayer[playerId]);
-}
-
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- fprintf(stdout, "OpenSL ES test %s: creates and destroys as many ", argv[0]);
- fprintf(stdout, "AudioPlayer objects as possible (max=%d)\n\n", MAX_NUMBER_PLAYERS);
-
- if (argc == 1) {
- fprintf(stdout, "Usage: %s path \n\t%s url\n", argv[0], argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3\" or \"%s file:///sdcard/my.mp3\"\n",
- argv[0], argv[0]);
- exit(EXIT_FAILURE);
- }
-
- TestSetup(argv[1]);
-
- for (int i=0 ; i<MAX_NUMBER_PLAYERS ; i++) {
- CreatePlayer(i);
- }
- fprintf(stdout, "After creating %d AudioPlayers\n", MAX_NUMBER_PLAYERS);
-
- /* Wait for an arbitrary amount of time. if playing a long file, the players will still
- be playing while the destructions start. */
- usleep(10*1000*1000); // 10s
-
- for (int i=0 ; i<MAX_NUMBER_PLAYERS ; i++) {
- if (validplayer[i]) {
- DestroyPlayer(i);
- }
- }
- fprintf(stdout, "After destroying valid players among %d AudioPlayers\n", MAX_NUMBER_PLAYERS);
-
- TestTeardown();
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/slesTestPlayStreamType.cpp b/wilhelm/tests/mimeUri/slesTestPlayStreamType.cpp
deleted file mode 100644
index 8987c45..0000000
--- a/wilhelm/tests/mimeUri/slesTestPlayStreamType.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-
-#define MAX_NUMBER_INTERFACES 2
-
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stdout, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play an audio URIs on the given stream type */
-void TestStreamTypeConfiguration( SLObjectItf sl, const char* path, const SLint32 type)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play, Volume and AndroidStreamType interfaces for the audio player */
- SLPlayItf playItf;
- SLPrefetchStatusItf prefetchItf;
-#ifdef ANDROID
- SLAndroidConfigurationItf configItf;
-#endif
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for SLAndroidConfigurationItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_PREFETCHSTATUS;
-#ifdef ANDROID
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_ANDROIDCONFIGURATION;
-#endif
-
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
- audioSource.pLocator = (void*)&uri;
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink,
- MAX_NUMBER_INTERFACES, iidArray, required);
- ExitOnError(result);
-
- /* Retrieve the configuration interface before the player is realized so its resources
- * can be configured.
- */
-#ifdef ANDROID
- result = (*player)->GetInterface(player, SL_IID_ANDROIDCONFIGURATION, (void*)&configItf);
- ExitOnError(result);
-
- /* Set the Android audio stream type on the player */
- result = (*configItf)->SetConfiguration(configItf,
- SL_ANDROID_KEY_STREAM_TYPE, &type, sizeof(SLint32));
- if (SL_RESULT_PARAMETER_INVALID == result) {
- fprintf(stderr, "invalid stream type %d\n", type);
- } else {
- ExitOnError(result);
- }
-#endif
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLAndroidConfigurationItf interfaces for player */
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- ExitOnError(result);
- }
-
- /* Get duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- durationInMsec = 5000;
- }
-
- /* Start playback */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- usleep((durationInMsec/2) * 1000);
-
-#ifdef ANDROID
- /* Get the stream type during playback */
- SLint32 currentType = -1;
- SLuint32 valueSize = sizeof(SLint32) * 2; // trying too big on purpose
- result = (*configItf)->GetConfiguration(configItf,
- SL_ANDROID_KEY_STREAM_TYPE, &valueSize, NULL);
- ExitOnError(result);
- if (valueSize != sizeof(SLint32)) {
- fprintf(stderr, "ERROR: size for stream type is %u, should be %u\n",
- valueSize, sizeof(SLint32));
- }
- result = (*configItf)->GetConfiguration(configItf,
- SL_ANDROID_KEY_STREAM_TYPE, &valueSize, ¤tType);
- ExitOnError(result);
- if (currentType != type) {
- fprintf(stderr, "ERROR: stream type is %u, should be %u\n", currentType, type);
- }
-#endif
-
- usleep((durationInMsec/2) * 1000);
-
- /* Make sure player is stopped */
- fprintf(stdout, "Stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
-#ifdef ANDROID
- /* Try again to get the stream type, just in case it changed behind our back */
- result = (*configItf)->GetConfiguration(configItf,
- SL_ANDROID_KEY_STREAM_TYPE, &valueSize, ¤tType);
- ExitOnError(result);
- if (currentType != type) {
- fprintf(stderr, "ERROR: stream type is %u, should be %u\n", currentType, type);
- }
-#endif
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLAndroidConfigurationItf\n",
- argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound on the specified android stream type\n");
-
- if (argc < 3) {
- fprintf(stdout, "Usage: \t%s url stream_type\n", argv[0]);
- fprintf(stdout, " where stream_type is one of the SL_ANDROID_STREAM_ constants.\n");
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 5\" \n", argv[0]);
- fprintf(stdout, "Stream type %d is the default (media or music), %d is notifications\n",
- SL_ANDROID_STREAM_MEDIA, SL_ANDROID_STREAM_NOTIFICATION);
- return EXIT_FAILURE;
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- TestStreamTypeConfiguration(sl, argv[1], (SLint32)atoi(argv[2]));
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/slesTestPlayUri.cpp b/wilhelm/tests/mimeUri/slesTestPlayUri.cpp
deleted file mode 100644
index 19fcb53..0000000
--- a/wilhelm/tests/mimeUri/slesTestPlayUri.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Copyright (c) 2009 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and /or associated documentation files (the "Materials "), to deal in the
- * Materials without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials,
- * and to permit persons to whom the Materials are furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE
- * MATERIALS.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-//#include <string.h>
-#include <unistd.h>
-//#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-
-//#define TEST_VOLUME_ITF
-//#define TEST_COLD_START
-
-#define MAX_NUMBER_INTERFACES 2
-
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-//-----------------------------------------------------------------
-//* Exits the application if an error is encountered */
-#define CheckErr(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-bool prefetchError = false;
-
-//-----------------------------------------------------------------
-/* PrefetchStatusItf callback for an audio player */
-void PrefetchEventCallback( SLPrefetchStatusItf caller, void *pContext, SLuint32 event)
-{
- SLpermille level = 0;
- SLresult result;
- result = (*caller)->GetFillLevel(caller, &level);
- CheckErr(result);
- SLuint32 status;
- //fprintf(stdout, "PrefetchEventCallback: received event %u\n", event);
- result = (*caller)->GetPrefetchStatus(caller, &status);
- CheckErr(result);
- if ((PREFETCHEVENT_ERROR_CANDIDATE == (event & PREFETCHEVENT_ERROR_CANDIDATE))
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- fprintf(stdout, "PrefetchEventCallback: Error while prefetching data, exiting\n");
- prefetchError = true;
- }
- if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- fprintf(stdout, "PrefetchEventCallback: Buffer fill level is = %d\n", level);
- }
- if (event & SL_PREFETCHEVENT_STATUSCHANGE) {
- fprintf(stdout, "PrefetchEventCallback: Prefetch Status is = %u\n", status);
- }
-}
-
-
-//-----------------------------------------------------------------
-/* PlayItf callback for playback events */
-void PlayEventCallback(
- SLPlayItf caller,
- void *pContext,
- SLuint32 event)
-{
- if (SL_PLAYEVENT_HEADATEND & event) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATEND reached\n");
- //SignalEos();
- }
-
- if (SL_PLAYEVENT_HEADATNEWPOS & event) {
- SLmillisecond pMsec = 0;
- (*caller)->GetPosition(caller, &pMsec);
- fprintf(stdout, "SL_PLAYEVENT_HEADATNEWPOS current position=%ums\n", pMsec);
- }
-
- if (SL_PLAYEVENT_HEADATMARKER & event) {
- SLmillisecond pMsec = 0;
- (*caller)->GetPosition(caller, &pMsec);
- fprintf(stdout, "SL_PLAYEVENT_HEADATMARKER current position=%ums\n", pMsec);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play some music from a URI */
-void TestPlayUri( SLObjectItf sl, const char* path)
-{
- SLEngineItf EngineItf;
-
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
-
- SLresult res;
-
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- SLObjectItf player;
- SLPlayItf playItf;
- SLVolumeItf volItf;
- SLPrefetchStatusItf prefetchItf;
-
- SLObjectItf OutputMix;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- CheckErr(res);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- // Set arrays required[] and iidArray[] for VOLUME and PREFETCHSTATUS interface
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
- // Create Output Mix object to be used by player
- res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
- iidArray, required); CheckErr(res);
-
- // Realizing the Output Mix object in synchronous mode.
- res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&uri;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = OutputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Create the audio player */
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink,
- MAX_NUMBER_INTERFACES, iidArray, required); CheckErr(res);
-
- /* Realizing the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE); CheckErr(res);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get interfaces */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_VOLUME, (void*)&volItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->RegisterCallback(prefetchItf, PrefetchEventCallback, &prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->SetCallbackEventsMask(prefetchItf,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
- CheckErr(res);
-
- /* Configure fill level updates every 5 percent */
- (*prefetchItf)->SetFillUpdatePeriod(prefetchItf, 50);
-
- /* Set up the player callback to get events during the decoding */
- res = (*playItf)->SetMarkerPosition(playItf, 2000);
- CheckErr(res);
- res = (*playItf)->SetPositionUpdatePeriod(playItf, 500);
- CheckErr(res);
- res = (*playItf)->SetCallbackEventsMask(playItf,
- SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS | SL_PLAYEVENT_HEADATEND);
- CheckErr(res);
- res = (*playItf)->RegisterCallback(playItf, PlayEventCallback, NULL);
- CheckErr(res);
-
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (before starting to prefetch)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (before starting to prefetch)\n",
- durationInMsec);
- }
-
- /* Set the player volume */
- res = (*volItf)->SetVolumeLevel( volItf, -300);
- CheckErr(res);
-
- /* Play the URI */
- /* first cause the player to prefetch the data */
- fprintf(stdout, "Before set to PAUSED\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- fprintf(stdout, "After set to PAUSED\n");
- CheckErr(res);
-
- usleep(100 * 1000);
- /* wait until there's data to play */
- //SLpermille fillLevel = 0;
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- SLuint32 timeOutIndex = 100; // 10s
- while ((prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) && (timeOutIndex > 0) &&
- !prefetchError) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- timeOutIndex--;
- }
-
- if (timeOutIndex == 0 || prefetchError) {
- fprintf(stderr, "We\'re done waiting, failed to prefetch data in time, exiting\n");
- goto destroyRes;
- }
-
- /* Display duration again, */
- res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (after prefetch completed)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (after prefetch completed)\n", durationInMsec);
- }
-
- fprintf(stdout, "URI example: starting to play\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- CheckErr(res);
-
-#ifdef TEST_VOLUME_ITF
- usleep(5*1000 * 1000);
- fprintf(stdout, "setting vol to 0\n");
- (*volItf)->SetVolumeLevel( volItf, 0);
- usleep(3*1000 * 1000);
- fprintf(stdout, "setting vol to -20dB\n");
- (*volItf)->SetVolumeLevel( volItf, -2000);
- usleep(3*1000 * 1000);
- fprintf(stdout, "mute\n");
- (*volItf)->SetMute( volItf, SL_BOOLEAN_TRUE);
- usleep(3*1000 * 1000);
- fprintf(stdout, "setting vol to 0dB while muted\n");
- (*volItf)->SetVolumeLevel( volItf, 0);
- usleep(3*1000 * 1000);
- fprintf(stdout, "unmuting\n");
- (*volItf)->SetMute( volItf, SL_BOOLEAN_FALSE);
- usleep(3*1000 * 1000);
-#endif
-
-#ifndef TEST_COLD_START
- usleep(durationInMsec * 1000);
-#else
- /* Wait as long as the duration of the content before stopping */
- /* Experiment: wait for the duration + 200ms: with a cold start of the audio hardware, we */
- /* won't see the SL_PLAYEVENT_HEADATEND event, due to hw wake up induced latency, but */
- /* with a warm start it will be received. */
- usleep((durationInMsec + 200) * 1000);
-#endif
-
- /* Make sure player is stopped */
- fprintf(stdout, "URI example: stopping playback\n");
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- CheckErr(res);
-
-destroyRes:
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*OutputMix)->Destroy(OutputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult res;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLVolumeItf ", argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound and stops after its reported duration\n\n");
-
- if (argc == 1) {
- fprintf(stdout, "Usage: %s path \n\t%s url\n", argv[0], argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3\" or \"%s file:///sdcard/my.mp3\"\n",
- argv[0], argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE}};
-
- res = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- TestPlayUri(sl, argv[1]);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/slesTestPlayUri2.cpp b/wilhelm/tests/mimeUri/slesTestPlayUri2.cpp
deleted file mode 100644
index 9b84b65..0000000
--- a/wilhelm/tests/mimeUri/slesTestPlayUri2.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-void ExitOnError( SLresult result )
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stdout, "%u error code encountered, exiting\n", result);
- exit(EXIT_FAILURE);
- }
-}
-
-//-----------------------------------------------------------------
-/* PlayItf callback for an audio player */
-void PlayEventCallback( SLPlayItf caller, void *pContext, SLuint32 event)
-{
- fprintf(stdout, "PlayEventCallback event = ");
- if (event & SL_PLAYEVENT_HEADATEND) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATEND ");
- }
- if (event & SL_PLAYEVENT_HEADATMARKER) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATMARKER ");
- }
- if (event & SL_PLAYEVENT_HEADATNEWPOS) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATNEWPOS ");
- }
- if (event & SL_PLAYEVENT_HEADMOVING) {
- fprintf(stdout, "SL_PLAYEVENT_HEADMOVING ");
- }
- if (event & SL_PLAYEVENT_HEADSTALLED) {
- fprintf(stdout, "SL_PLAYEVENT_HEADSTALLED");
- }
- fprintf(stdout, "\n");
-}
-
-//-----------------------------------------------------------------
-
-/* Play two audio URIs, pan them left and right */
-void TestPlayUri( SLObjectItf sl, const char* path, const char* path2)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: two players and an ouput mix */
- SLObjectItf player, player2, outputMix;
-
- /* Source of audio data to play, we'll reuse the same source for two different players */
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- /* Data sinks for the two audio players */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play, Volume and PrefetchStatus interfaces for the audio players */
- SLPlayItf playItf, playItf2;
- SLVolumeItf volItf, volItf2;
- SLPrefetchStatusItf prefetchItf, prefetchItf2;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
- /* Set arrays required[] and iidArray[] for SLVolumeItf and SLPrefetchStatusItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used each player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the players */
-
- /* Setup the data source structure for the first URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&uri;
-
- /* Create the first audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink, 2,
- iidArray, required);
- ExitOnError(result);
-
- /* Create the second audio player with a different path for its data source */
- uri.URI = (SLchar*) path2;
- audioSource.pLocator = (void *)&uri;
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player2, &audioSource, &audioSink, 2,
- iidArray, required);
- ExitOnError(result);
-
- /* Realize the players in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- result = (*player)->Realize(player2, SL_BOOLEAN_FALSE); ExitOnError(result);
- //fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLVolumeItf and SLPrefetchStatusItf interfaces for each player */
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
- result = (*player)->GetInterface(player2, SL_IID_PLAY, (void*)&playItf2);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_VOLUME, (void*)&volItf);
- ExitOnError(result);
- result = (*player2)->GetInterface(player2, SL_IID_VOLUME, (void*)&volItf2);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
- result = (*player2)->GetInterface(player2, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf2);
- ExitOnError(result);
-
- /* Setup to receive playback events */
- result = (*playItf)->RegisterCallback(playItf, PlayEventCallback, &playItf);
- ExitOnError(result);
- result = (*playItf)->SetCallbackEventsMask(playItf,
- SL_PLAYEVENT_HEADATEND| SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS
- | SL_PLAYEVENT_HEADMOVING | SL_PLAYEVENT_HEADSTALLED);
- ExitOnError(result);
-
- /* Set the player volume */
- result = (*volItf)->SetVolumeLevel( volItf, -300);
- ExitOnError(result);
- /* Pan the first player to the left */
- result = (*volItf)->EnableStereoPosition( volItf, SL_BOOLEAN_TRUE); ExitOnError(result);
- result = (*volItf)->SetStereoPosition( volItf, -1000); ExitOnError(result);
- /* Pan the second player to the right */
- result = (*volItf2)->EnableStereoPosition( volItf2, SL_BOOLEAN_TRUE); ExitOnError(result);
- result = (*volItf2)->SetStereoPosition( volItf2, 1000); ExitOnError(result);
-
- /* ------------------------------------------------------ */
- /* Playback */
-
- /* Start the data prefetching by setting the players to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
- result = (*playItf2)->SetPlayState( playItf2, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- }
- prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf2)->GetPrefetchStatus(prefetchItf2, &prefetchStatus);
- }
-
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- /* Wait 2s before starting the second player */
- usleep(2000 * 1000);
- fprintf(stdout, "URI example: starting to play %s\n", path2);
- result = (*playItf2)->SetPlayState( playItf2, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
-
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- result = (*playItf)->GetDuration(playItf, &durationInMsec);
- ExitOnError(result);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration of first URI is unknown\n");
- } else {
- fprintf(stdout, "Content duration of first URI is %u ms\n", durationInMsec);
- }
-
- /* Wait as long as the duration of the first URI + 2s before stopping */
- if (durationInMsec == SL_TIME_UNKNOWN) {
- durationInMsec = 5000; /* arbitrary time when duration is unknown */
- }
- usleep((durationInMsec + 2000) * 1000);
-
- /* Make sure player is stopped */
- fprintf(stdout, "URI example: stopping playback\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
- result = (*playItf2)->SetPlayState(playItf2, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
- /* Destroy the players */
- (*player)->Destroy(player);
- (*player2)->Destroy(player2);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLVolumeItf (incl. stereo position) ",
- argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays two sounds (or twice the same) and pans them left and right.");
- fprintf(stdout, "Stops after the end of the first + 2s\n");
-
- if (argc == 1) {
- fprintf(stdout, "Usage: \n\t%s url1 url2 \n\t%s url\n", argv[0], argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3 http://blabla/my.wav\" ", argv[0]);
- fprintf(stdout, "or \"%s file:///sdcard/my.mp3\"\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- if (argc == 2) {
- TestPlayUri(sl, argv[1], argv[1]);
- } else if (argc == 3) {
- TestPlayUri(sl, argv[1], argv[2]);
- }
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/slesTestSlowDownUri.cpp b/wilhelm/tests/mimeUri/slesTestSlowDownUri.cpp
deleted file mode 100644
index 0c2dc7e..0000000
--- a/wilhelm/tests/mimeUri/slesTestSlowDownUri.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 3
-
-#define REPETITIONS 4 // 4 repetitions, but will stop the looping before the end
-
-#define INITIAL_RATE 2000 // 2x normal playback speed
-
-// These are extensions to OpenSL ES 1.0.1 values
-
-#define SL_PREFETCHSTATUS_UNKNOWN 0
-#define SL_PREFETCHSTATUS_ERROR (-1)
-
-// Mutex and condition shared with main program to protect prefetch_status
-
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-SLuint32 prefetch_status = SL_PREFETCHSTATUS_UNKNOWN;
-
-/* used to detect errors likely to have occured when the OpenSL ES framework fails to open
- * a resource, for instance because a file URI is invalid, or an HTTP server doesn't respond.
- */
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-//-----------------------------------------------------------------
-//* Exits the application if an error is encountered */
-#define CheckErr(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-//-----------------------------------------------------------------
-/* PlayItf callback for an audio player */
-void PlayEventCallback( SLPlayItf caller, void *pContext, SLuint32 event)
-{
- fprintf(stdout, "PlayEventCallback event = ");
- if (event & SL_PLAYEVENT_HEADATEND) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATEND \n");
- /* slow playback down by 2x for next loop, if possible */
- SLpermille minRate, maxRate, stepSize, rate = 1000;
- SLuint32 capa;
- assert(NULL != pContext);
- SLPlaybackRateItf pRateItf = (SLPlaybackRateItf)pContext;
- SLresult res = (*pRateItf)->GetRate(pRateItf, &rate); CheckErr(res);
- res = (*pRateItf)->GetRateRange(pRateItf, 0, &minRate, &maxRate, &stepSize, &capa);
- CheckErr(res);
- fprintf(stdout, "old rate = %d, minRate=%d, maxRate=%d\n", rate, minRate, maxRate);
- rate /= 2;
- if (rate < minRate) {
- rate = minRate;
- }
- fprintf(stdout, "new rate = %d\n", rate);
- res = (*pRateItf)->SetRate(pRateItf, rate); CheckErr(res);
- if (res == SL_RESULT_FEATURE_UNSUPPORTED) {
- fprintf(stderr, "new playback rate %d per mille is unsupported\n", rate);
- } else {
- CheckErr(res);
- }
- }
- if (event & SL_PLAYEVENT_HEADATMARKER) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATMARKER ");
- }
- if (event & SL_PLAYEVENT_HEADATNEWPOS) {
- fprintf(stdout, "SL_PLAYEVENT_HEADATNEWPOS ");
- }
- if (event & SL_PLAYEVENT_HEADMOVING) {
- fprintf(stdout, "SL_PLAYEVENT_HEADMOVING ");
- }
- if (event & SL_PLAYEVENT_HEADSTALLED) {
- fprintf(stdout, "SL_PLAYEVENT_HEADSTALLED");
- }
- fprintf(stdout, "\n");
-}
-
-//-----------------------------------------------------------------
-/* PrefetchStatusItf callback for an audio player */
-void PrefetchEventCallback( SLPrefetchStatusItf caller, void *pContext, SLuint32 event)
-{
- //fprintf(stdout, "\t\tPrefetchEventCallback: received event %u\n", event);
- SLresult result;
- assert(pContext == NULL);
- SLpermille level = 0;
- result = (*caller)->GetFillLevel(caller, &level);
- CheckErr(result);
- SLuint32 status;
- result = (*caller)->GetPrefetchStatus(caller, &status);
- CheckErr(result);
- if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Buffer fill level is = %d\n", level);
- }
- if (event & SL_PREFETCHEVENT_STATUSCHANGE) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Prefetch Status is = %u\n", status);
- }
- SLuint32 new_prefetch_status;
- if ((event & PREFETCHEVENT_ERROR_CANDIDATE) == PREFETCHEVENT_ERROR_CANDIDATE
- && level == 0 && status == SL_PREFETCHSTATUS_UNDERFLOW) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Error while prefetching data, exiting\n");
- new_prefetch_status = SL_PREFETCHSTATUS_ERROR;
- } else if (event == SL_PREFETCHEVENT_STATUSCHANGE &&
- status == SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- new_prefetch_status = status;
- } else {
- return;
- }
- int ok;
- ok = pthread_mutex_lock(&mutex);
- assert(ok == 0);
- prefetch_status = new_prefetch_status;
- ok = pthread_cond_signal(&cond);
- assert(ok == 0);
- ok = pthread_mutex_unlock(&mutex);
- assert(ok == 0);
-}
-
-// Display rate capabilities in a nicely formatted way
-
-void printCapabilities(SLuint32 capabilities)
-{
- bool needBar = false;
- printf("0x%x (", capabilities);
-#define _(x) \
- if (capabilities & SL_RATEPROP_##x) { \
- if (needBar) \
- printf("|"); \
- printf("SL_RATEPROP_" #x); \
- needBar = true; \
- capabilities &= ~SL_RATEPROP_##x; \
- }
- _(SILENTAUDIO)
- _(STAGGEREDAUDIO)
- _(NOPITCHCORAUDIO)
- _(PITCHCORAUDIO)
- if (capabilities != 0) {
- if (needBar)
- printf("|");
- printf("0x%x", capabilities);
- needBar = true;
- }
- if (!needBar)
- printf("N/A");
- printf(")");
-}
-
-//-----------------------------------------------------------------
-
-/* Play some music from a URI */
-void TestSlowDownUri( SLObjectItf sl, const char* path)
-{
- SLEngineItf EngineItf;
-
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
-
- SLresult res;
-
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- SLObjectItf player;
- SLPlayItf playItf;
- SLSeekItf seekItf;
- SLPrefetchStatusItf prefetchItf;
- SLPlaybackRateItf rateItf;
-
- SLObjectItf OutputMix;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf); CheckErr(res);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- // Create Output Mix object to be used by player
- res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
- iidArray, required); CheckErr(res);
-
- // Realizing the Output Mix object in synchronous mode.
- res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE); CheckErr(res);
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&uri;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = OutputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /******************************************************/
- /* Create the audio player */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_SEEK;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
- required[2] = SL_BOOLEAN_TRUE;
- iidArray[2] = SL_IID_PLAYBACKRATE;
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink,
- MAX_NUMBER_INTERFACES, iidArray, required); CheckErr(res);
-
- /* Realizing the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE); CheckErr(res);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get interfaces */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf); CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_SEEK, (void*)&seekItf); CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_PLAYBACKRATE, (void*)&rateItf); CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->RegisterCallback(prefetchItf, PrefetchEventCallback, NULL);
- CheckErr(res);
- res = (*prefetchItf)->SetCallbackEventsMask(prefetchItf,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE); CheckErr(res);
-
- /* Configure fill level updates every 5 percent */
- (*prefetchItf)->SetFillUpdatePeriod(prefetchItf, 50); CheckErr(res);
-
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- res = (*playItf)->GetDuration(playItf, &durationInMsec); CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (before starting to prefetch)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (before starting to prefetch)\n",
- durationInMsec);
- }
-
- /* Loop on the whole of the content */
- res = (*seekItf)->SetLoop(seekItf, SL_BOOLEAN_TRUE, 0, SL_TIME_UNKNOWN); CheckErr(res);
-
- /* Set up marker and position callbacks */
- res = (*playItf)->RegisterCallback(playItf, PlayEventCallback, (void *) rateItf); CheckErr(res);
- res = (*playItf)->SetCallbackEventsMask(playItf,
- SL_PLAYEVENT_HEADATEND | SL_PLAYEVENT_HEADATMARKER | SL_PLAYEVENT_HEADATNEWPOS);
- res = (*playItf)->SetMarkerPosition(playItf, 1500); CheckErr(res);
- res = (*playItf)->SetPositionUpdatePeriod(playItf, 500); CheckErr(res);
-
- /* Get the default rate */
- SLpermille rate = 1234;
- res = (*rateItf)->GetRate(rateItf, &rate); CheckErr(res);
- printf("default rate = %d per mille\n", rate);
- assert(1000 == rate);
-
- /* Get the default rate properties */
- SLuint32 properties = 0;
- res = (*rateItf)->GetProperties(rateItf, &properties); CheckErr(res);
- printf("default rate properties: ");
- printCapabilities(properties);
- printf("\n");
- assert(SL_RATEPROP_NOPITCHCORAUDIO == properties);
-
- /* Get all supported playback rate ranges */
- SLuint8 index;
- for (index = 0; ; ++index) {
- SLpermille minRate, maxRate, stepSize;
- SLuint32 capabilities;
- res = (*rateItf)->GetRateRange(rateItf, index, &minRate, &maxRate, &stepSize, &capabilities);
- if (res == SL_RESULT_PARAMETER_INVALID) {
- if (index == 0) {
- fprintf(stderr, "implementation supports no rate ranges\n");
- }
- break;
- }
- CheckErr(res);
- if (index == 255) {
- fprintf(stderr, "implementation supports way too many rate ranges, I'm giving up\n");
- break;
- }
- printf("range[%u]: min=%d, max=%d, capabilities=", index, minRate, maxRate);
- printCapabilities(capabilities);
- printf("\n");
- }
-
- /* Change the playback rate before playback */
- res = (*rateItf)->SetRate(rateItf, INITIAL_RATE);
- if (res == SL_RESULT_FEATURE_UNSUPPORTED || res == SL_RESULT_PARAMETER_INVALID) {
- fprintf(stderr, "initial playback rate %d per mille is unsupported\n", INITIAL_RATE);
- } else {
- CheckErr(res);
- }
-
- /******************************************************/
- /* Play the URI */
- /* first cause the player to prefetch the data */
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED ); CheckErr(res);
-
- // wait for prefetch status callback to indicate either sufficient data or error
- pthread_mutex_lock(&mutex);
- while (prefetch_status == SL_PREFETCHSTATUS_UNKNOWN) {
- pthread_cond_wait(&cond, &mutex);
- }
- pthread_mutex_unlock(&mutex);
- if (prefetch_status == SL_PREFETCHSTATUS_ERROR) {
- fprintf(stderr, "Error during prefetch, exiting\n");
- goto destroyRes;
- }
-
- /* Display duration again, */
- res = (*playItf)->GetDuration(playItf, &durationInMsec); CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (after prefetch completed)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (after prefetch completed)\n", durationInMsec);
- }
-
- /* Start playing */
- fprintf(stdout, "starting to play\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING ); CheckErr(res);
-
- /* Wait as long as the duration of the content, times the repetitions,
- * before stopping the loop */
-#if 1
- usleep( (REPETITIONS-1) * durationInMsec * 1100);
-#else
- int ii;
- for (ii = 0; ii < REPETITIONS; ++ii) {
- usleep(durationInMsec * 1100);
- PlayEventCallback(playItf, (void *) rateItf, SL_PLAYEVENT_HEADATEND);
- }
-#endif
-
- res = (*seekItf)->SetLoop(seekItf, SL_BOOLEAN_FALSE, 0, SL_TIME_UNKNOWN); CheckErr(res);
- fprintf(stdout, "As of now, stopped looping (sound shouldn't repeat from now on)\n");
- /* wait some more to make sure it doesn't repeat */
- usleep(durationInMsec * 1000);
-
- /* Stop playback */
- fprintf(stdout, "stopping playback\n");
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED); CheckErr(res);
-
-destroyRes:
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*OutputMix)->Destroy(OutputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult res;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLSeekItf, SLPlaybackRateItf\n",
- argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound and loops it %d times while changing the \n", REPETITIONS);
- fprintf(stdout, "playback rate each time.\n\n");
-
- if (argc == 1) {
- fprintf(stdout, "Usage: \n\t%s path \n\t%s url\n", argv[0], argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3\" or \"%s file:///sdcard/my.mp3\"\n",
- argv[0], argv[0]);
- return EXIT_FAILURE;
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE}};
-
- res = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- TestSlowDownUri(sl, argv[1]);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri/slesTest_playStates.cpp b/wilhelm/tests/mimeUri/slesTest_playStates.cpp
deleted file mode 100644
index 040be9f..0000000
--- a/wilhelm/tests/mimeUri/slesTest_playStates.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 2
-
-#define TEST_MUTE 0
-#define TEST_SOLO 1
-
-static int testMode;
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define ExitOnError(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stdout, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play an audio URIs, play, pause, stop */
-void TestPlayUri( SLObjectItf sl, const char* path)
-{
- SLresult result;
- SLEngineItf EngineItf;
-
- /* Objects this application uses: one player and an ouput mix */
- SLObjectItf player, outputMix;
-
- /* Source of audio data to play */
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- /* Data sinks for the audio player */
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- /* Play, Volume and PrefetchStatus interfaces for the audio player */
- SLPlayItf playItf;
- SLMuteSoloItf muteSoloItf;
- SLPrefetchStatusItf prefetchItf;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- result = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- ExitOnError(result);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- /* ------------------------------------------------------ */
- /* Configuration of the output mix */
-
- /* Create Output Mix object to be used by the player */
- result = (*EngineItf)->CreateOutputMix(EngineItf, &outputMix, 0, iidArray, required);
- ExitOnError(result);
-
- /* Realize the Output Mix object in synchronous mode */
- result = (*outputMix)->Realize(outputMix, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputMix;
- audioSink.pLocator = (void*)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* ------------------------------------------------------ */
- /* Configuration of the player */
-
- /* Set arrays required[] and iidArray[] for SLMuteSoloItf and SLPrefetchStatusItf interfaces */
- /* (SLPlayItf is implicit) */
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_MUTESOLO;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- /* this is how ignored mime information is specified, according to OpenSL ES spec
- * in 9.1.6 SLDataFormat_MIME and 8.23 SLMetadataTraversalItf GetChildInfo */
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void*)&mime;
- audioSource.pLocator = (void*)&uri;
-
- /* Create the audio player */
- result = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink,
- MAX_NUMBER_INTERFACES, iidArray, required);
- ExitOnError(result);
-
- /* Realize the player in synchronous mode. */
- result = (*player)->Realize(player, SL_BOOLEAN_FALSE); ExitOnError(result);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get the SLPlayItf, SLPrefetchStatusItf and SLMuteSoloItf interfaces for the player */
- result = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- ExitOnError(result);
-
- result = (*player)->GetInterface(player, SL_IID_MUTESOLO, (void*)&muteSoloItf);
- ExitOnError(result);
-
-
- fprintf(stdout, "Player configured\n");
-
- /* ------------------------------------------------------ */
- /* Playback and test */
-
- /* Start the data prefetching by setting the player to the paused state */
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
-
- /* Wait until there's data to play */
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- }
-
-
- /* Testing play states */
- /* let it play for 2s */
- fprintf(stdout, "----- Playing\n");
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
- usleep(2 * 1000 * 1000);
-
- /* pause for 1s*/
- fprintf(stdout, "----- Pausing (1s)\n");
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- ExitOnError(result);
- usleep(2 * 1000 * 1000);
-
- /* resume */
- fprintf(stdout, "----- Playing (2s, should have resumed where it paused)\n");
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
- usleep(2 * 1000 * 1000);
-
- /* stop */
- fprintf(stdout, "----- Stopping\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
- /* play for 2s */
- fprintf(stdout, "----- Playing (2s, should have started from the beginning\n");
- result = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- ExitOnError(result);
- usleep(2 * 1000 * 1000);
-
- /* stop */
- fprintf(stdout, "----- Stopping\n");
- result = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- ExitOnError(result);
-
-destroyKillKill:
-
- /* Destroy the players */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*outputMix)->Destroy(outputMix);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult result;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLVolumeItf, SLMuteSoloItf\n",
- argv[0]);
- fprintf(stdout, "and AudioPlayer with SLDataLocator_URI source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound and alternates the muting of the channels (for 5s).\n");
- fprintf(stdout, " and then alternates the solo\'ing of the channels (for 5s).\n");
- fprintf(stdout, "Stops after 10s\n");
-
- if (argc == 1) {
- fprintf(stdout, "Usage: \t%s url\n", argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.mp3\"\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE, (SLuint32) SL_BOOLEAN_TRUE}
- };
-
- result = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- ExitOnError(result);
-
- /* Realizing the SL Engine in synchronous mode. */
- result = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- ExitOnError(result);
-
- if (argc > 1) {
- TestPlayUri(sl, argv[1]);
- }
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/mimeUri_test.cpp b/wilhelm/tests/mimeUri_test.cpp
deleted file mode 100644
index ded5d5c..0000000
--- a/wilhelm/tests/mimeUri_test.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Copyright (c) 2009 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and /or associated documentation files (the "Materials "), to deal in the
- * Materials without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials,
- * and to permit persons to whom the Materials are furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE
- * MATERIALS.
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "slesTestPlayUri"
-
-#include <utils/Log.h>
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <gtest/gtest.h>
-#include <SLES/OpenSLES.h>
-
-
-#define MAX_NUMBER_INTERFACES 3
-#define MAX_NUMBER_OUTPUT_DEVICES 6
-
-//The expected playback duration
-const int MP3_DURATION = 71030; //71 secs
-
-
-//-----------------------------------------------------------------
-/* Checks for error. If any errors exit the application! */
-void CheckErr( SLresult res )
-{
- if ( res != SL_RESULT_SUCCESS ) {
- fprintf(stderr, "%u SL failure, exiting\n", res);
- //Fail the test case
- ASSERT_TRUE(false);
- }
-}
-
-//-----------------------------------------------------------------
-/* PrefetchStatusItf callback for an audio player */
-void PrefetchEventCallback( SLPrefetchStatusItf caller, void *pContext, SLuint32 event)
-{
- SLpermille level = 0;
- (*caller)->GetFillLevel(caller, &level);
- SLuint32 status;
- fprintf(stdout, "\t\tPrefetchEventCallback: received event %u\n", event);
- (*caller)->GetPrefetchStatus(caller, &status);
- if ((event & (SL_PREFETCHEVENT_STATUSCHANGE|SL_PREFETCHEVENT_FILLLEVELCHANGE))
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- fprintf(stderr, "\t\tPrefetchEventCallback: Error while prefetching data, exiting\n");
- ASSERT_TRUE(false);
- }
- if (event & SL_PREFETCHEVENT_FILLLEVELCHANGE) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Buffer fill level is = %d\n", level);
- }
- if (event & SL_PREFETCHEVENT_STATUSCHANGE) {
- fprintf(stdout, "\t\tPrefetchEventCallback: Prefetch Status is = %u\n", status);
- }
-
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play some music from a URI */
-void TestPlayUri( SLObjectItf sl, const char* path)
-{
- SLEngineItf EngineItf;
-
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
-
- SLresult res;
-
- SLDataSource audioSource;
- SLDataLocator_URI uri;
- SLDataFormat_MIME mime;
-
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- SLObjectItf player;
- SLPlayItf playItf;
- SLVolumeItf volItf;
- SLPrefetchStatusItf prefetchItf;
-
- SLObjectItf OutputMix;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- CheckErr(res);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- // Set arrays required[] and iidArray[] for VOLUME and PREFETCHSTATUS interface
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_PREFETCHSTATUS;
- // Create Output Mix object to be used by player
- res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
- iidArray, required); CheckErr(res);
-
- // Realizing the Output Mix object in synchronous mode.
- res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- /* Setup the data source structure for the URI */
- uri.locatorType = SL_DATALOCATOR_URI;
- uri.URI = (SLchar*) path;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&uri;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = OutputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Create the audio player */
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player,
- &audioSource, &audioSink, 2, iidArray, required); CheckErr(res);
-
- /* Realizing the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE); CheckErr(res);
-
- /* Get interfaces */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_VOLUME, (void*)&volItf);
- CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_PREFETCHSTATUS, (void*)&prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->RegisterCallback(prefetchItf, PrefetchEventCallback, &prefetchItf);
- CheckErr(res);
- res = (*prefetchItf)->SetCallbackEventsMask(prefetchItf,
- SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
-
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
-
- /* Set the player volume */
- res = (*volItf)->SetVolumeLevel( volItf, -300);
- CheckErr(res);
-
- /* Play the URI */
- /* first cause the player to prefetch the data */
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- CheckErr(res);
-
- /* wait until there's data to play */
- //SLpermille fillLevel = 0;
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- SLuint32 timeOutIndex = 100; // 10s
- while ((prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) && (timeOutIndex > 0)) {
- usleep(100 * 1000);
- (*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- timeOutIndex--;
- }
-
- if (timeOutIndex == 0) {
- fprintf(stderr, "Error: Failed to prefetch data in time, exiting\n");
- ASSERT_TRUE(false);
- // goto destroyRes;
- }
-
- /* Display duration again, */
- res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stderr, "Error: GetDuration returned SL_TIME_UNKNOWN (after prefetch completed)\n");
- ASSERT_TRUE(false);
- }
- SLint32 durationDiffMsec = durationInMsec - MP3_DURATION;
- if (durationDiffMsec < 0) { durationDiffMsec *= -1; }
- if (durationDiffMsec > (MP3_DURATION/20)) {
- fprintf(stderr, "Error: GetDuration returned %d, more than 5percent off from expected %d\n",
- durationInMsec, MP3_DURATION);
- ASSERT_TRUE(false);
- }
-
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- CheckErr(res);
-
- /* Play for the song duration*/
- usleep(MP3_DURATION * 1000);
-
- /* Validate the play position*/
- SLmillisecond currentPositionInMsec = SL_TIME_UNKNOWN;
- res = (*playItf)->GetPosition(playItf, ¤tPositionInMsec);
- CheckErr(res);
- if (currentPositionInMsec == SL_TIME_UNKNOWN) {
- fprintf(stderr, "Error: GetPosition returns SL_TIME_UNKNOWN after expected duration\n");
- ASSERT_TRUE(false);
- } else if ( currentPositionInMsec <= 0 ||
- currentPositionInMsec > (MP3_DURATION * 1.1) ){
- fprintf(stderr, "Error: GetPosition returns %i, should be expected duration for test\n",
- (int) currentPositionInMsec);
- ASSERT_TRUE(false);
- }
-
- /* Make sure player is stopped */
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- CheckErr(res);
-
-destroyRes:
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*OutputMix)->Destroy(OutputMix);
-
- fprintf(stdout, "End of test reached\n");
-}
-
-
-// The fixture for testing class MimeUri
-class MimeUri: public ::testing::Test {
-public:
- SLresult res;
- SLObjectItf sl;
-
-protected:
- MimeUri() {
- // You can do set-up work for each test here.
- SLEngineOption EngineOption[] = { { (SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE } };
-
- res = slCreateEngine(&sl, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
-
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- CheckErr(res);
- }
-
- virtual ~MimeUri() {
- // You can do clean-up work that doesn't throw exceptions here.
- (*sl)->Destroy(sl);
- }
-
- virtual void SetUp() {
- // Code here will be called immediately after the constructor (right
- // before each test).
-
- }
-
- virtual void TearDown() {
- // Code here will be called immediately after each test (right
- // before the destructor).
-
- }
-};
-
-TEST_F(MimeUri, testPlayAbsPath){
- TestPlayUri(sl, "/sdcard/media_api/music/MP3_256kbps_2ch.mp3");
-}
-
-TEST_F(MimeUri, testPlayfilePath){
- TestPlayUri(sl, "file:///sdcard/media_api/music/MP3_256kbps_2ch.mp3");
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char **argv)
-{
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/wilhelm/tests/native-media/Android.mk b/wilhelm/tests/native-media/Android.mk
deleted file mode 100644
index 73d7ec8..0000000
--- a/wilhelm/tests/native-media/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- src/com/example/nativemedia/NativeMedia.java \
- src/com/example/nativemedia/MyGLSurfaceView.java
-
-LOCAL_PACKAGE_NAME := native-media
-LOCAL_CERTIFICATE := platform
-
-LOCAL_JNI_SHARED_LIBRARIES := libnative-media-jni
-
-include $(BUILD_PACKAGE)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/wilhelm/tests/native-media/AndroidManifest.xml b/wilhelm/tests/native-media/AndroidManifest.xml
deleted file mode 100644
index ab94d1d..0000000
--- a/wilhelm/tests/native-media/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.nativemedia">
-
- <uses-feature android:glEsVersion="0x00020000" />
-
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".NativeMedia"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- </application>
-
-
-<uses-permission android:name="android.permission.INTERNET"></uses-permission>
-</manifest>
diff --git a/wilhelm/tests/native-media/jni/Android.mk b/wilhelm/tests/native-media/jni/Android.mk
deleted file mode 100644
index 4d111ac..0000000
--- a/wilhelm/tests/native-media/jni/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := libnative-media-jni
-LOCAL_SRC_FILES := native-media-jni.c
-LOCAL_CFLAGS += -Isystem/media/wilhelm/include
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_SHARED_LIBRARIES += libutils libOpenMAXAL libandroid
-
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/wilhelm/tests/native-media/jni/native-media-jni.c b/wilhelm/tests/native-media/jni/native-media-jni.c
deleted file mode 100644
index 943f47a..0000000
--- a/wilhelm/tests/native-media/jni/native-media-jni.c
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <jni.h>
-#include <pthread.h>
-#include <string.h>
-//#define LOG_NDEBUG 0
-#define LOG_TAG "NativeMedia"
-#include <utils/Log.h>
-
-#include <OMXAL/OpenMAXAL.h>
-#include <OMXAL/OpenMAXAL_Android.h>
-
-#include <android/native_window_jni.h>
-
-// engine interfaces
-static XAObjectItf engineObject = NULL;
-static XAEngineItf engineEngine = NULL;
-
-// output mix interfaces
-static XAObjectItf outputMixObject = NULL;
-
-// streaming media player interfaces
-static XAObjectItf playerObj = NULL;
-static XAPlayItf playerPlayItf = NULL;
-static XAAndroidBufferQueueItf playerBQItf = NULL;
-static XAStreamInformationItf playerStreamInfoItf = NULL;
-static XAVolumeItf playerVolItf = NULL;
-
-// number of required interfaces for the MediaPlayer creation
-#define NB_MAXAL_INTERFACES 3 // XAAndroidBufferQueueItf, XAStreamInformationItf and XAPlayItf
-
-// video sink for the player
-static ANativeWindow* theNativeWindow;
-
-// number of buffers in our buffer queue, an arbitrary number
-#define NB_BUFFERS 16
-
-// we're streaming MPEG-2 transport stream data, operate on transport stream block size
-#define MPEG2_TS_BLOCK_SIZE 188
-
-// number of MPEG-2 transport stream blocks per buffer, an arbitrary number
-#define BLOCKS_PER_BUFFER 20
-
-// determines how much memory we're dedicating to memory caching
-#define BUFFER_SIZE (BLOCKS_PER_BUFFER*MPEG2_TS_BLOCK_SIZE)
-
-// where we cache in memory the data to play
-// note this memory is re-used by the buffer queue callback
-char dataCache[BUFFER_SIZE * NB_BUFFERS];
-
-// handle of the file to play
-FILE *file;
-
-// has the app reached the end of the file
-jboolean reachedEof = JNI_FALSE;
-
-// constant to identify a buffer context which is the end of the stream to decode
-static const int kEosBufferCntxt = 1980; // a magic value we can compare against
-
-// for mutual exclusion between callback thread and application thread(s)
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-
-// whether a discontinuity is in progress
-jboolean discontinuity = JNI_FALSE;
-
-static jboolean enqueueInitialBuffers(jboolean discontinuity);
-
-// Callback for XAPlayItf through which we receive the XA_PLAYEVENT_HEADATEND event */
-void PlayCallback(XAPlayItf caller, void *pContext, XAuint32 event) {
- if (event & XA_PLAYEVENT_HEADATEND) {
- LOGV("XA_PLAYEVENT_HEADATEND received, all MP2TS data has been decoded\n");
- }
-}
-
-// AndroidBufferQueueItf callback for an audio player
-XAresult AndroidBufferQueueCallback(
- XAAndroidBufferQueueItf caller,
- void *pCallbackContext, /* input */
- void *pBufferContext, /* input */
- void *pBufferData, /* input */
- XAuint32 dataSize, /* input */
- XAuint32 dataUsed, /* input */
- const XAAndroidBufferItem *pItems,/* input */
- XAuint32 itemsLength /* input */)
-{
- XAresult res;
- int ok;
-
- // pCallbackContext was specified as NULL at RegisterCallback and is unused here
- assert(NULL == pCallbackContext);
-
- // note there is never any contention on this mutex unless a discontinuity request is active
- ok = pthread_mutex_lock(&mutex);
- assert(0 == ok);
-
- // was a discontinuity requested?
- if (discontinuity) {
- // FIXME sorry, can't rewind after EOS
- if (!reachedEof) {
- // clear the buffer queue
- res = (*playerBQItf)->Clear(playerBQItf);
- assert(XA_RESULT_SUCCESS == res);
- // rewind the data source so we are guaranteed to be at an appropriate point
- rewind(file);
- // Enqueue the initial buffers, with a discontinuity indicator on first buffer
- (void) enqueueInitialBuffers(JNI_TRUE);
- }
- // acknowledge the discontinuity request
- discontinuity = JNI_FALSE;
- ok = pthread_cond_signal(&cond);
- assert(0 == ok);
- goto exit;
- }
-
- if ((pBufferData == NULL) && (pBufferContext != NULL)) {
- const int processedCommand = *(int *)pBufferContext;
- if (kEosBufferCntxt == processedCommand) {
- LOGV("EOS was processed\n");
- // our buffer with the EOS message has been consumed
- assert(0 == dataSize);
- goto exit;
- }
- }
-
- // pBufferData is a pointer to a buffer that we previously Enqueued
- assert(BUFFER_SIZE == dataSize);
- assert(dataCache <= (char *) pBufferData && (char *) pBufferData <
- &dataCache[BUFFER_SIZE * NB_BUFFERS]);
- assert(0 == (((char *) pBufferData - dataCache) % BUFFER_SIZE));
-
-#if 0
- // sample code to use the XAVolumeItf
- XAAndroidBufferQueueState state;
- (*caller)->GetState(caller, &state);
- switch (state.index) {
- case 300:
- (*playerVolItf)->SetVolumeLevel(playerVolItf, -600); // -6dB
- LOGV("setting volume to -6dB");
- break;
- case 400:
- (*playerVolItf)->SetVolumeLevel(playerVolItf, -1200); // -12dB
- LOGV("setting volume to -12dB");
- break;
- case 500:
- (*playerVolItf)->SetVolumeLevel(playerVolItf, 0); // full volume
- LOGV("setting volume to 0dB (full volume)");
- break;
- case 600:
- (*playerVolItf)->SetMute(playerVolItf, XA_BOOLEAN_TRUE); // mute
- LOGV("muting player");
- break;
- case 700:
- (*playerVolItf)->SetMute(playerVolItf, XA_BOOLEAN_FALSE); // unmute
- LOGV("unmuting player");
- break;
- case 800:
- (*playerVolItf)->SetStereoPosition(playerVolItf, -1000);
- (*playerVolItf)->EnableStereoPosition(playerVolItf, XA_BOOLEAN_TRUE);
- LOGV("pan sound to the left (hard-left)");
- break;
- case 900:
- (*playerVolItf)->EnableStereoPosition(playerVolItf, XA_BOOLEAN_FALSE);
- LOGV("disabling stereo position");
- break;
- default:
- break;
- }
-#endif
-
- // don't bother trying to read more data once we've hit EOF
- if (reachedEof) {
- goto exit;
- }
-
- size_t nbRead;
- // note we do call fread from multiple threads, but never concurrently
- nbRead = fread(pBufferData, BUFFER_SIZE, 1, file);
- if (nbRead > 0) {
- assert(1 == nbRead);
- res = (*caller)->Enqueue(caller, NULL /*pBufferContext*/,
- pBufferData /*pData*/,
- nbRead * BUFFER_SIZE /*dataLength*/,
- NULL /*pMsg*/,
- 0 /*msgLength*/);
- assert(XA_RESULT_SUCCESS == res);
- } else {
- // signal EOS
- XAAndroidBufferItem msgEos[1];
- msgEos[0].itemKey = XA_ANDROID_ITEMKEY_EOS;
- msgEos[0].itemSize = 0;
- // EOS message has no parameters, so the total size of the message is the size of the key
- // plus the size if itemSize, both XAuint32
- res = (*caller)->Enqueue(caller, (void *)&kEosBufferCntxt /*pBufferContext*/,
- NULL /*pData*/, 0 /*dataLength*/,
- msgEos /*pMsg*/,
- // FIXME == sizeof(BufferItem)? */
- sizeof(XAuint32)*2 /*msgLength*/);
- assert(XA_RESULT_SUCCESS == res);
- reachedEof = JNI_TRUE;
- }
-
-exit:
- ok = pthread_mutex_unlock(&mutex);
- assert(0 == ok);
- return XA_RESULT_SUCCESS;
-}
-
-
-void StreamChangeCallback (XAStreamInformationItf caller,
- XAuint32 eventId,
- XAuint32 streamIndex,
- void * pEventData,
- void * pContext )
-{
- LOGV("StreamChangeCallback called for stream %u", streamIndex);
- // pContext was specified as NULL at RegisterStreamChangeCallback and is unused here
- assert(NULL == pContext);
- switch (eventId) {
- case XA_STREAMCBEVENT_PROPERTYCHANGE: {
- /** From spec 1.0.1:
- "This event indicates that stream property change has occurred.
- The streamIndex parameter identifies the stream with the property change.
- The pEventData parameter for this event is not used and shall be ignored."
- */
-
- XAresult res;
- XAuint32 domain;
- res = (*caller)->QueryStreamType(caller, streamIndex, &domain);
- assert(XA_RESULT_SUCCESS == res);
- switch (domain) {
- case XA_DOMAINTYPE_VIDEO: {
- XAVideoStreamInformation videoInfo;
- res = (*caller)->QueryStreamInformation(caller, streamIndex, &videoInfo);
- assert(XA_RESULT_SUCCESS == res);
- LOGI("Found video size %u x %u, codec ID=%u, frameRate=%u, bitRate=%u, duration=%u ms",
- videoInfo.width, videoInfo.height, videoInfo.codecId, videoInfo.frameRate,
- videoInfo.bitRate, videoInfo.duration);
- } break;
- default:
- fprintf(stderr, "Unexpected domain %u\n", domain);
- break;
- }
- } break;
- default:
- fprintf(stderr, "Unexpected stream event ID %u\n", eventId);
- break;
- }
-}
-
-
-// create the engine and output mix objects
-void Java_com_example_nativemedia_NativeMedia_createEngine(JNIEnv* env, jclass clazz)
-{
- XAresult res;
-
- // create engine
- res = xaCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(XA_RESULT_SUCCESS == res);
-
- // realize the engine
- res = (*engineObject)->Realize(engineObject, XA_BOOLEAN_FALSE);
- assert(XA_RESULT_SUCCESS == res);
-
- // get the engine interface, which is needed in order to create other objects
- res = (*engineObject)->GetInterface(engineObject, XA_IID_ENGINE, &engineEngine);
- assert(XA_RESULT_SUCCESS == res);
-
- // create output mix
- res = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(XA_RESULT_SUCCESS == res);
-
- // realize the output mix
- res = (*outputMixObject)->Realize(outputMixObject, XA_BOOLEAN_FALSE);
- assert(XA_RESULT_SUCCESS == res);
-
-}
-
-
-// Enqueue the initial buffers, and optionally signal a discontinuity in the first buffer
-static jboolean enqueueInitialBuffers(jboolean discontinuity)
-{
-
- /* Fill our cache */
- size_t nbRead;
- nbRead = fread(dataCache, BUFFER_SIZE, NB_BUFFERS, file);
- if (nbRead <= 0) {
- // could be premature EOF or I/O error
- LOGE("Error filling cache, exiting\n");
- return JNI_FALSE;
- }
- assert(1 <= nbRead && nbRead <= NB_BUFFERS);
- LOGV("Initially queueing %u buffers of %u bytes each", nbRead, BUFFER_SIZE);
-
- /* Enqueue the content of our cache before starting to play,
- we don't want to starve the player */
- size_t i;
- for (i = 0; i < nbRead; i++) {
- XAresult res;
- if (discontinuity) {
- // signal discontinuity
- XAAndroidBufferItem items[1];
- items[0].itemKey = XA_ANDROID_ITEMKEY_DISCONTINUITY;
- items[0].itemSize = 0;
- // DISCONTINUITY message has no parameters,
- // so the total size of the message is the size of the key
- // plus the size if itemSize, both XAuint32
- res = (*playerBQItf)->Enqueue(playerBQItf, NULL /*pBufferContext*/,
- dataCache + i*BUFFER_SIZE, BUFFER_SIZE, items /*pMsg*/,
- // FIXME == sizeof(BufferItem)? */
- sizeof(XAuint32)*2 /*msgLength*/);
- discontinuity = JNI_FALSE;
- } else {
- res = (*playerBQItf)->Enqueue(playerBQItf, NULL /*pBufferContext*/,
- dataCache + i*BUFFER_SIZE, BUFFER_SIZE, NULL, 0);
- }
- assert(XA_RESULT_SUCCESS == res);
- }
-
- return JNI_TRUE;
-}
-
-
-// create streaming media player
-jboolean Java_com_example_nativemedia_NativeMedia_createStreamingMediaPlayer(JNIEnv* env,
- jclass clazz, jstring filename)
-{
- XAresult res;
-
- // convert Java string to UTF-8
- const char *utf8 = (*env)->GetStringUTFChars(env, filename, NULL);
- assert(NULL != utf8);
-
- // open the file to play
- file = fopen(utf8, "rb");
- if (file == NULL) {
- LOGE("Failed to open %s", utf8);
- return JNI_FALSE;
- }
-
- // configure data source
- XADataLocator_AndroidBufferQueue loc_abq = { XA_DATALOCATOR_ANDROIDBUFFERQUEUE, NB_BUFFERS };
- XADataFormat_MIME format_mime = {
- XA_DATAFORMAT_MIME, XA_ANDROID_MIME_MP2TS, XA_CONTAINERTYPE_MPEG_TS };
- XADataSource dataSrc = {&loc_abq, &format_mime};
-
- // configure audio sink
- XADataLocator_OutputMix loc_outmix = { XA_DATALOCATOR_OUTPUTMIX, outputMixObject };
- XADataSink audioSnk = { &loc_outmix, NULL };
-
- // configure image video sink
- XADataLocator_NativeDisplay loc_nd = {
- XA_DATALOCATOR_NATIVEDISPLAY, // locatorType
- // the video sink must be an ANativeWindow created from a Surface or SurfaceTexture
- (void*)theNativeWindow, // hWindow
- // must be NULL
- NULL // hDisplay
- };
- XADataSink imageVideoSink = {&loc_nd, NULL};
-
- // declare interfaces to use
- XAboolean required[NB_MAXAL_INTERFACES]
- = {XA_BOOLEAN_TRUE, XA_BOOLEAN_TRUE, XA_BOOLEAN_TRUE};
- XAInterfaceID iidArray[NB_MAXAL_INTERFACES]
- = {XA_IID_PLAY, XA_IID_ANDROIDBUFFERQUEUESOURCE,
- XA_IID_STREAMINFORMATION};
-
-
- // create media player
- res = (*engineEngine)->CreateMediaPlayer(engineEngine, &playerObj, &dataSrc,
- NULL, &audioSnk, &imageVideoSink, NULL, NULL,
- NB_MAXAL_INTERFACES /*XAuint32 numInterfaces*/,
- iidArray /*const XAInterfaceID *pInterfaceIds*/,
- required /*const XAboolean *pInterfaceRequired*/);
- assert(XA_RESULT_SUCCESS == res);
-
- // release the Java string and UTF-8
- (*env)->ReleaseStringUTFChars(env, filename, utf8);
-
- // realize the player
- res = (*playerObj)->Realize(playerObj, XA_BOOLEAN_FALSE);
- assert(XA_RESULT_SUCCESS == res);
-
- // get the play interface
- res = (*playerObj)->GetInterface(playerObj, XA_IID_PLAY, &playerPlayItf);
- assert(XA_RESULT_SUCCESS == res);
-
- // get the stream information interface (for video size)
- res = (*playerObj)->GetInterface(playerObj, XA_IID_STREAMINFORMATION, &playerStreamInfoItf);
- assert(XA_RESULT_SUCCESS == res);
-
- // get the volume interface
- res = (*playerObj)->GetInterface(playerObj, XA_IID_VOLUME, &playerVolItf);
- assert(XA_RESULT_SUCCESS == res);
-
- // get the Android buffer queue interface
- res = (*playerObj)->GetInterface(playerObj, XA_IID_ANDROIDBUFFERQUEUESOURCE, &playerBQItf);
- assert(XA_RESULT_SUCCESS == res);
-
- // specify which events we want to be notified of
- res = (*playerBQItf)->SetCallbackEventsMask(playerBQItf, XA_ANDROIDBUFFERQUEUEEVENT_PROCESSED);
-
- // use the play interface to set up a callback for the XA_PLAYEVENT_HEADATEND event */
- res = (*playerPlayItf)->SetCallbackEventsMask(playerPlayItf, XA_PLAYEVENT_HEADATEND);
- assert(XA_RESULT_SUCCESS == res);
- res = (*playerPlayItf)->RegisterCallback(playerPlayItf,
- PlayCallback /*callback*/, NULL /*pContext*/);
- assert(XA_RESULT_SUCCESS == res);
-
- // register the callback from which OpenMAX AL can retrieve the data to play
- res = (*playerBQItf)->RegisterCallback(playerBQItf, AndroidBufferQueueCallback, NULL);
- assert(XA_RESULT_SUCCESS == res);
-
- // we want to be notified of the video size once it's found, so we register a callback for that
- res = (*playerStreamInfoItf)->RegisterStreamChangeCallback(playerStreamInfoItf,
- StreamChangeCallback, NULL);
-
- // enqueue the initial buffers
- if (!enqueueInitialBuffers(JNI_FALSE)) {
- return JNI_FALSE;
- }
-
- // prepare the player
- res = (*playerPlayItf)->SetPlayState(playerPlayItf, XA_PLAYSTATE_PAUSED);
- assert(XA_RESULT_SUCCESS == res);
-
- // set the volume
- res = (*playerVolItf)->SetVolumeLevel(playerVolItf, 0);//-300);
- assert(XA_RESULT_SUCCESS == res);
-
- // start the playback
- res = (*playerPlayItf)->SetPlayState(playerPlayItf, XA_PLAYSTATE_PLAYING);
- assert(XA_RESULT_SUCCESS == res);
-
- return JNI_TRUE;
-}
-
-
-// set the playing state for the streaming media player
-void Java_com_example_nativemedia_NativeMedia_setPlayingStreamingMediaPlayer(JNIEnv* env,
- jclass clazz, jboolean isPlaying)
-{
- XAresult res;
-
- // make sure the streaming media player was created
- if (NULL != playerPlayItf) {
-
- // set the player's state
- res = (*playerPlayItf)->SetPlayState(playerPlayItf, isPlaying ?
- XA_PLAYSTATE_PLAYING : XA_PLAYSTATE_PAUSED);
- assert(XA_RESULT_SUCCESS == res);
-
- }
-
-}
-
-
-// shut down the native media system
-void Java_com_example_nativemedia_NativeMedia_shutdown(JNIEnv* env, jclass clazz)
-{
- // destroy streaming media player object, and invalidate all associated interfaces
- if (playerObj != NULL) {
- (*playerObj)->Destroy(playerObj);
- playerObj = NULL;
- playerPlayItf = NULL;
- playerBQItf = NULL;
- playerStreamInfoItf = NULL;
- playerVolItf = NULL;
- }
-
- // destroy output mix object, and invalidate all associated interfaces
- if (outputMixObject != NULL) {
- (*outputMixObject)->Destroy(outputMixObject);
- outputMixObject = NULL;
- }
-
- // destroy engine object, and invalidate all associated interfaces
- if (engineObject != NULL) {
- (*engineObject)->Destroy(engineObject);
- engineObject = NULL;
- engineEngine = NULL;
- }
-
- // close the file
- if (file != NULL) {
- fclose(file);
- file = NULL;
- }
-
- // make sure we don't leak native windows
- if (theNativeWindow != NULL) {
- ANativeWindow_release(theNativeWindow);
- theNativeWindow = NULL;
- }
-}
-
-
-// set the surface
-void Java_com_example_nativemedia_NativeMedia_setSurface(JNIEnv *env, jclass clazz, jobject surface)
-{
- // obtain a native window from a Java surface
- theNativeWindow = ANativeWindow_fromSurface(env, surface);
-}
-
-
-// set the surface texture
-void Java_com_example_nativemedia_NativeMedia_setSurfaceTexture(JNIEnv *env, jclass clazz,
- jobject surfaceTexture)
-{
- // obtain a native window from a Java surface texture
- theNativeWindow = ANativeWindow_fromSurfaceTexture(env, surfaceTexture);
-}
-
-
-// rewind the streaming media player
-void Java_com_example_nativemedia_NativeMedia_rewindStreamingMediaPlayer(JNIEnv *env, jclass clazz)
-{
- XAresult res;
-
- // make sure the streaming media player was created
- if (NULL != playerBQItf && NULL != file) {
- // first wait for buffers currently in queue to be drained
- int ok;
- ok = pthread_mutex_lock(&mutex);
- assert(0 == ok);
- discontinuity = JNI_TRUE;
- // wait for discontinuity request to be observed by buffer queue callback
- // FIXME sorry, can't rewind after EOS
- while (discontinuity && !reachedEof) {
- ok = pthread_cond_wait(&cond, &mutex);
- assert(0 == ok);
- }
- ok = pthread_mutex_unlock(&mutex);
- assert(0 == ok);
- }
-
-}
diff --git a/wilhelm/tests/native-media/res/drawable/icon.png b/wilhelm/tests/native-media/res/drawable/icon.png
deleted file mode 100644
index a07c69f..0000000
--- a/wilhelm/tests/native-media/res/drawable/icon.png
+++ /dev/null
Binary files differ
diff --git a/wilhelm/tests/native-media/res/layout/main.xml b/wilhelm/tests/native-media/res/layout/main.xml
deleted file mode 100644
index d303b19..0000000
--- a/wilhelm/tests/native-media/res/layout/main.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
-<TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello"
- />
-<TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/source_select"
- />
-<Spinner
- android:id="@+id/source_spinner"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/source_prompt"
- />
-<TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/sink_select"
- />
-<Spinner
- android:id="@+id/sink_spinner"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/sink_prompt"
- />
-
-<LinearLayout
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- >
- <Button
- android:id="@+id/start_java"
- android:text="@string/start_java"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
- <Button
- android:id="@+id/start_native"
- android:text="@string/start_native"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
-</LinearLayout>
-
-<LinearLayout
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- >
- <Button
- android:id="@+id/rewind_java"
- android:text="@string/rewind_java"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
- <Button
- android:id="@+id/rewind_native"
- android:text="@string/rewind_native"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
-</LinearLayout>
-
-<LinearLayout
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="S1"
- />
- <SurfaceView
- android:id="@+id/surfaceview1"
- android:layout_width="320px"
- android:layout_height="240px"
- />
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="S2"
- />
- <SurfaceView
- android:id="@+id/surfaceview2"
- android:layout_width="400px"
- android:layout_height="224px"
- />
-</LinearLayout>
-
-<LinearLayout
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="ST1"
- />
- <com.example.nativemedia.MyGLSurfaceView
- android:id="@+id/glsurfaceview1"
- android:layout_width="320px"
- android:layout_height="240px"
- />
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="ST2"
- />
- <com.example.nativemedia.MyGLSurfaceView
- android:id="@+id/glsurfaceview2"
- android:layout_width="320px"
- android:layout_height="240px"
- />
-</LinearLayout>
-
-</LinearLayout>
diff --git a/wilhelm/tests/native-media/res/values/strings.xml b/wilhelm/tests/native-media/res/values/strings.xml
deleted file mode 100644
index 2b5207e..0000000
--- a/wilhelm/tests/native-media/res/values/strings.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hello">Hello, Android, using native media!</string>
- <string name="app_name">NativeMedia</string>
-
- <string name="start_java">Start/Pause Java MediaPlayer</string>
- <string name="start_native">Start/Pause native MediaPlayer</string>
-
- <string name="rewind_java">Rewind Java MediaPlayer</string>
- <string name="rewind_native">Rewind native MediaPlayer</string>
-
- <string name="source_select">Please select the media source</string>
- <string name="source_prompt">Media source</string>
- <string-array name="source_array">
- <item>/sdcard/Videos/bar.ts</item>
- <item>http://iphoned5.akamai.com.edgesuite.net/mhbarron/nasatv/nasatv_1500.m3u8</item>
- <item>http://iphone.video.hsn.com/iPhone_high.m3u8</item>
- <item>http://mlbsegqa.mlb.com/mlbam/dev/build84/2010/10/29/test1/master_wired.m3u8</item>
- <item>/sdcard/Videos/mpeg4_qvga_24fps.3gp</item>
- <item>/sdcard/Videos/burnAfterReading.m4v</item>
- </string-array>
-
- <string name="sink_select">Please select the video sink</string>
- <string name="sink_prompt">Video sink</string>
- <string-array name="sink_array">
- <item>Surface 1</item>
- <item>Surface 2</item>
- <item>SurfaceTexture 1</item>
- <item>SurfaceTexture 2</item>
- </string-array>
-
-</resources>
diff --git a/wilhelm/tests/native-media/src/com/example/nativemedia/MyGLSurfaceView.java b/wilhelm/tests/native-media/src/com/example/nativemedia/MyGLSurfaceView.java
deleted file mode 100644
index 688bea7..0000000
--- a/wilhelm/tests/native-media/src/com/example/nativemedia/MyGLSurfaceView.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.nativemedia;
-
-import android.graphics.SurfaceTexture;
-import android.util.Log;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-
-import android.view.MotionEvent;
-import android.content.Context;
-
-import android.opengl.GLES20;
-import android.opengl.GLSurfaceView;
-import android.opengl.Matrix;
-
-import android.hardware.SensorManager;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.Sensor;
-
-// Remove once surfacetexture timestamps are in
-import java.lang.System;
-
-import android.util.AttributeSet;
-
-public class MyGLSurfaceView extends GLSurfaceView {
-
- MyRenderer mRenderer;
-
- public MyGLSurfaceView(Context context) {
- super(context, null);
- }
-
- public MyGLSurfaceView(Context context, AttributeSet attributeSet) {
- super(context, attributeSet);
- init(context);
- }
-
- private void init(Context context) {
- setEGLContextClientVersion(2);
- mRenderer = new MyRenderer(context);
- setRenderer(mRenderer);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- }
-
- public SurfaceTexture getSurfaceTexture() {
- return mRenderer.getSurfaceTexture();
- }
-}
-
-class MyRenderer implements GLSurfaceView.Renderer, SurfaceTexture.OnFrameAvailableListener {
- private Context mContext;
-
- public MyRenderer(Context context) {
- mContext = context;
-
- mVertices = ByteBuffer.allocateDirect(mVerticesData.length
- * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer();
- mVertices.put(mVerticesData).position(0);
-
- Matrix.setIdentityM(mSTMatrix, 0);
- Matrix.setIdentityM(mMMatrix, 0);
- Matrix.rotateM(mMMatrix, 0, 20, 0, 1, 0);
- }
-
- public void onDrawFrame(GL10 glUnused) {
- synchronized(this) {
- if (updateSurface) {
- mSurface.updateTexImage();
-
- mSurface.getTransformMatrix(mSTMatrix);
- updateSurface = false;
- }
- }
-
- // Ignore the passed-in GL10 interface, and use the GLES20
- // class's static methods instead.
- GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
- GLES20.glUseProgram(mProgram);
- checkGlError("glUseProgram");
-
- GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
- GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureID);
-
- mVertices.position(VERTICES_DATA_POS_OFFSET);
- GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
- VERTICES_DATA_STRIDE_BYTES, mVertices);
- checkGlError("glVertexAttribPointer maPosition");
- GLES20.glEnableVertexAttribArray(maPositionHandle);
- checkGlError("glEnableVertexAttribArray maPositionHandle");
-
- mVertices.position(VERTICES_DATA_UV_OFFSET);
- GLES20.glVertexAttribPointer(maTextureHandle, 3, GLES20.GL_FLOAT, false,
- VERTICES_DATA_STRIDE_BYTES, mVertices);
- checkGlError("glVertexAttribPointer maTextureHandle");
- GLES20.glEnableVertexAttribArray(maTextureHandle);
- checkGlError("glEnableVertexAttribArray maTextureHandle");
-
- Matrix.multiplyMM(mMVPMatrix, 0, mVMatrix, 0, mMMatrix, 0);
- Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0);
-
- GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
- GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
-
- GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
- checkGlError("glDrawArrays");
- }
-
- public void onSurfaceChanged(GL10 glUnused, int width, int height) {
- // Ignore the passed-in GL10 interface, and use the GLES20
- // class's static methods instead.
- GLES20.glViewport(0, 0, width, height);
- mRatio = (float) width / height;
- Matrix.frustumM(mProjMatrix, 0, -mRatio, mRatio, -1, 1, 3, 7);
- }
-
- public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
- // Ignore the passed-in GL10 interface, and use the GLES20
- // class's static methods instead.
-
- /* Set up alpha blending and an Android background color */
- GLES20.glEnable(GLES20.GL_BLEND);
- GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
- GLES20.glClearColor(0.643f, 0.776f, 0.223f, 1.0f);
-
- /* Set up shaders and handles to their variables */
- mProgram = createProgram(mVertexShader, mFragmentShader);
- if (mProgram == 0) {
- return;
- }
- maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
- checkGlError("glGetAttribLocation aPosition");
- if (maPositionHandle == -1) {
- throw new RuntimeException("Could not get attrib location for aPosition");
- }
- maTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord");
- checkGlError("glGetAttribLocation aTextureCoord");
- if (maTextureHandle == -1) {
- throw new RuntimeException("Could not get attrib location for aTextureCoord");
- }
-
- muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
- checkGlError("glGetUniformLocation uMVPMatrix");
- if (muMVPMatrixHandle == -1) {
- throw new RuntimeException("Could not get attrib location for uMVPMatrix");
- }
-
- muSTMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uSTMatrix");
- checkGlError("glGetUniformLocation uSTMatrix");
- if (muMVPMatrixHandle == -1) {
- throw new RuntimeException("Could not get attrib location for uSTMatrix");
- }
-
- checkGlError("glGetUniformLocation uCRatio");
- if (muMVPMatrixHandle == -1) {
- throw new RuntimeException("Could not get attrib location for uCRatio");
- }
-
- /*
- * Create our texture. This has to be done each time the
- * surface is created.
- */
-
- int[] textures = new int[1];
- GLES20.glGenTextures(1, textures, 0);
-
- mTextureID = textures[0];
- GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureID);
- checkGlError("glBindTexture mTextureID");
-
- // Can't do mipmapping with camera source
- GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_NEAREST);
- GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER,
- GLES20.GL_LINEAR);
- // Clamp to edge is the only option
- GLES20.glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S,
- GLES20.GL_CLAMP_TO_EDGE);
- GLES20.glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T,
- GLES20.GL_CLAMP_TO_EDGE);
- checkGlError("glTexParameteri mTextureID");
-
- /*
- * Create the SurfaceTexture that will feed this textureID, and pass it to the camera
- */
-
- mSurface = new SurfaceTexture(mTextureID);
- mSurface.setOnFrameAvailableListener(this);
-
- Matrix.setLookAtM(mVMatrix, 0, 0, 0, 4f, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
-
- synchronized(this) {
- updateSurface = false;
- }
- }
-
- synchronized public void onFrameAvailable(SurfaceTexture surface) {
- /* For simplicity, SurfaceTexture calls here when it has new
- * data available. Call may come in from some random thread,
- * so let's be safe and use synchronize. No OpenGL calls can be done here.
- */
- updateSurface = true;
- //Log.v(TAG, "onFrameAvailable " + surface.getTimestamp());
- }
-
- private int loadShader(int shaderType, String source) {
- int shader = GLES20.glCreateShader(shaderType);
- if (shader != 0) {
- GLES20.glShaderSource(shader, source);
- GLES20.glCompileShader(shader);
- int[] compiled = new int[1];
- GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
- if (compiled[0] == 0) {
- Log.e(TAG, "Could not compile shader " + shaderType + ":");
- Log.e(TAG, GLES20.glGetShaderInfoLog(shader));
- GLES20.glDeleteShader(shader);
- shader = 0;
- }
- }
- return shader;
- }
-
- private int createProgram(String vertexSource, String fragmentSource) {
- int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
- if (vertexShader == 0) {
- return 0;
- }
- int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
- if (pixelShader == 0) {
- return 0;
- }
-
- int program = GLES20.glCreateProgram();
- if (program != 0) {
- GLES20.glAttachShader(program, vertexShader);
- checkGlError("glAttachShader");
- GLES20.glAttachShader(program, pixelShader);
- checkGlError("glAttachShader");
- GLES20.glLinkProgram(program);
- int[] linkStatus = new int[1];
- GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
- if (linkStatus[0] != GLES20.GL_TRUE) {
- Log.e(TAG, "Could not link program: ");
- Log.e(TAG, GLES20.glGetProgramInfoLog(program));
- GLES20.glDeleteProgram(program);
- program = 0;
- }
- }
- return program;
- }
-
- private void checkGlError(String op) {
- int error;
- while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
- Log.e(TAG, op + ": glError " + error);
- throw new RuntimeException(op + ": glError " + error);
- }
- }
-
- private static final int FLOAT_SIZE_BYTES = 4;
- private static final int VERTICES_DATA_STRIDE_BYTES = 5 * FLOAT_SIZE_BYTES;
- private static final int VERTICES_DATA_POS_OFFSET = 0;
- private static final int VERTICES_DATA_UV_OFFSET = 3;
- private final float[] mVerticesData = {
- // X, Y, Z, U, V
- -1.0f, -1.0f, 0, 0.f, 0.f,
- 1.0f, -1.0f, 0, 1.f, 0.f,
- -1.0f, 1.0f, 0, 0.f, 1.f,
- 1.0f, 1.0f, 0, 1.f, 1.f,
- };
-
- private FloatBuffer mVertices;
-
- private final String mVertexShader =
- "uniform mat4 uMVPMatrix;\n" +
- "uniform mat4 uSTMatrix;\n" +
- "attribute vec4 aPosition;\n" +
- "attribute vec4 aTextureCoord;\n" +
- "varying vec2 vTextureCoord;\n" +
- "void main() {\n" +
- " gl_Position = uMVPMatrix * aPosition;\n" +
- " vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" +
- "}\n";
-
- private final String mFragmentShader =
- "#extension GL_OES_EGL_image_external : require\n" +
- "precision mediump float;\n" +
- "varying vec2 vTextureCoord;\n" +
- "uniform samplerExternalOES sTexture;\n" +
- "void main() {\n" +
- " gl_FragColor = texture2D(sTexture, vTextureCoord);\n" +
- "}\n";
-
- private float[] mMVPMatrix = new float[16];
- private float[] mProjMatrix = new float[16];
- private float[] mMMatrix = new float[16];
- private float[] mVMatrix = new float[16];
- private float[] mSTMatrix = new float[16];
-
- private int mProgram;
- private int mTextureID;
- private int muMVPMatrixHandle;
- private int muSTMatrixHandle;
- private int maPositionHandle;
- private int maTextureHandle;
-
- private float mRatio = 1.0f;
- private SurfaceTexture mSurface;
- private boolean updateSurface = false;
-
- private static final String TAG = "MyRenderer";
-
- // Magic key
- private static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
-
- public SurfaceTexture getSurfaceTexture() {
- return mSurface;
- }
-}
diff --git a/wilhelm/tests/native-media/src/com/example/nativemedia/NativeMedia.java b/wilhelm/tests/native-media/src/com/example/nativemedia/NativeMedia.java
deleted file mode 100644
index 01636d2..0000000
--- a/wilhelm/tests/native-media/src/com/example/nativemedia/NativeMedia.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.nativemedia;
-
-import android.app.Activity;
-import android.graphics.SurfaceTexture;
-import android.media.MediaPlayer;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.Spinner;
-import java.io.IOException;
-
-import android.content.Context;
-
-import android.graphics.SurfaceTexture;
-
-import android.media.MediaPlayer.OnPreparedListener;
-import android.media.MediaPlayer;
-
-public class NativeMedia extends Activity {
- static final String TAG = "NativeMedia";
-
- String mSourceString = null;
- String mSinkString = null;
-
- // member variables for Java media player
- MediaPlayer mMediaPlayer;
- boolean mMediaPlayerIsPrepared = false;
- SurfaceView mSurfaceView1;
- SurfaceHolder mSurfaceHolder1;
-
- // member variables for native media player
- boolean mIsPlayingStreaming = false;
- SurfaceView mSurfaceView2;
- SurfaceHolder mSurfaceHolder2;
-
- VideoSink mSelectedVideoSink;
- VideoSink mJavaMediaPlayerVideoSink;
- VideoSink mNativeMediaPlayerVideoSink;
-
- SurfaceHolderVideoSink mSurfaceHolder1VideoSink, mSurfaceHolder2VideoSink;
- GLViewVideoSink mGLView1VideoSink, mGLView2VideoSink;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
-
- mGLView1 = (MyGLSurfaceView) findViewById(R.id.glsurfaceview1);
- mGLView2 = (MyGLSurfaceView) findViewById(R.id.glsurfaceview2);
-
- //setContentView(mGLView);
- //setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
-
- // initialize native media system
- createEngine();
-
- // set up the Surface 1 video sink
- mSurfaceView1 = (SurfaceView) findViewById(R.id.surfaceview1);
- mSurfaceHolder1 = mSurfaceView1.getHolder();
-
- mSurfaceHolder1.addCallback(new SurfaceHolder.Callback() {
-
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- Log.v(TAG, "surfaceChanged format=" + format + ", width=" + width + ", height=" + height);
- }
-
- public void surfaceCreated(SurfaceHolder holder) {
- Log.v(TAG, "surfaceCreated");
- setSurface(holder.getSurface());
- }
-
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.v(TAG, "surfaceDestroyed");
- }
-
- });
-
- // set up the Surface 2 video sink
- mSurfaceView2 = (SurfaceView) findViewById(R.id.surfaceview2);
- mSurfaceHolder2 = mSurfaceView2.getHolder();
-
- mSurfaceHolder2.addCallback(new SurfaceHolder.Callback() {
-
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- Log.v(TAG, "surfaceChanged format=" + format + ", width=" + width + ", height=" + height);
- }
-
- public void surfaceCreated(SurfaceHolder holder) {
- Log.v(TAG, "surfaceCreated");
- setSurface(holder.getSurface());
- }
-
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.v(TAG, "surfaceDestroyed");
- }
-
- });
-
- // create Java media player
- mMediaPlayer = new MediaPlayer();
-
- // set up Java media player listeners
- mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
-
- public void onPrepared(MediaPlayer mediaPlayer) {
- int width = mediaPlayer.getVideoWidth();
- int height = mediaPlayer.getVideoHeight();
- Log.v(TAG, "onPrepared width=" + width + ", height=" + height);
- if (width != 0 && height != 0 && mJavaMediaPlayerVideoSink != null) {
- mJavaMediaPlayerVideoSink.setFixedSize(width, height);
- }
- mMediaPlayerIsPrepared = true;
- mediaPlayer.start();
- }
-
- });
-
- mMediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
-
- public void onVideoSizeChanged(MediaPlayer mediaPlayer, int width, int height) {
- Log.v(TAG, "onVideoSizeChanged width=" + width + ", height=" + height);
- if (width != 0 && height != 0 && mJavaMediaPlayerVideoSink != null) {
- mJavaMediaPlayerVideoSink.setFixedSize(width, height);
- }
- }
-
- });
-
- // initialize content source spinner
- Spinner sourceSpinner = (Spinner) findViewById(R.id.source_spinner);
- ArrayAdapter<CharSequence> sourceAdapter = ArrayAdapter.createFromResource(
- this, R.array.source_array, android.R.layout.simple_spinner_item);
- sourceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- sourceSpinner.setAdapter(sourceAdapter);
- sourceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
-
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- mSourceString = parent.getItemAtPosition(pos).toString();
- Log.v(TAG, "onItemSelected " + mSourceString);
- }
-
- public void onNothingSelected(AdapterView parent) {
- Log.v(TAG, "onNothingSelected");
- mSourceString = null;
- }
-
- });
-
- // initialize video sink spinner
- Spinner sinkSpinner = (Spinner) findViewById(R.id.sink_spinner);
- ArrayAdapter<CharSequence> sinkAdapter = ArrayAdapter.createFromResource(
- this, R.array.sink_array, android.R.layout.simple_spinner_item);
- sinkAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- sinkSpinner.setAdapter(sinkAdapter);
- sinkSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
-
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- mSinkString = parent.getItemAtPosition(pos).toString();
- Log.v(TAG, "onItemSelected " + mSinkString);
- if ("Surface 1".equals(mSinkString)) {
- if (mSurfaceHolder1VideoSink == null) {
- mSurfaceHolder1VideoSink = new SurfaceHolderVideoSink(mSurfaceHolder1);
- }
- mSelectedVideoSink = mSurfaceHolder1VideoSink;
- } else if ("Surface 2".equals(mSinkString)) {
- if (mSurfaceHolder2VideoSink == null) {
- mSurfaceHolder2VideoSink = new SurfaceHolderVideoSink(mSurfaceHolder2);
- }
- mSelectedVideoSink = mSurfaceHolder2VideoSink;
- } else if ("SurfaceTexture 1".equals(mSinkString)) {
- if (mGLView1VideoSink == null) {
- mGLView1VideoSink = new GLViewVideoSink(mGLView1);
- }
- mSelectedVideoSink = mGLView1VideoSink;
- } else if ("SurfaceTexture 2".equals(mSinkString)) {
- if (mGLView2VideoSink == null) {
- mGLView2VideoSink = new GLViewVideoSink(mGLView2);
- }
- mSelectedVideoSink = mGLView2VideoSink;
- }
- }
-
- public void onNothingSelected(AdapterView parent) {
- Log.v(TAG, "onNothingSelected");
- mSinkString = null;
- mSelectedVideoSink = null;
- }
-
- });
-
- // initialize button click handlers
-
- // Java MediaPlayer start/pause
-
- ((Button) findViewById(R.id.start_java)).setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View view) {
- if (mJavaMediaPlayerVideoSink == null) {
- if (mSelectedVideoSink == null) {
- return;
- }
- mSelectedVideoSink.useAsSinkForJava(mMediaPlayer);
- mJavaMediaPlayerVideoSink = mSelectedVideoSink;
- }
- if (!mMediaPlayerIsPrepared) {
- if (mSourceString != null) {
- try {
- mMediaPlayer.setDataSource(mSourceString);
- } catch (IOException e) {
- Log.e(TAG, "IOException " + e);
- }
- mMediaPlayer.prepareAsync();
- }
- } else if (mMediaPlayer.isPlaying()) {
- mMediaPlayer.pause();
- } else {
- mMediaPlayer.start();
- }
- }
-
- });
-
- // native MediaPlayer start/pause
-
- ((Button) findViewById(R.id.start_native)).setOnClickListener(new View.OnClickListener() {
-
- boolean created = false;
- public void onClick(View view) {
- if (!created) {
- if (mNativeMediaPlayerVideoSink == null) {
- if (mSelectedVideoSink == null) {
- return;
- }
- mSelectedVideoSink.useAsSinkForNative();
- mNativeMediaPlayerVideoSink = mSelectedVideoSink;
- }
- if (mSourceString != null) {
- created = createStreamingMediaPlayer(mSourceString);
- }
- }
- if (created) {
- mIsPlayingStreaming = !mIsPlayingStreaming;
- setPlayingStreamingMediaPlayer(mIsPlayingStreaming);
- }
- }
-
- });
-
- // Java MediaPlayer rewind
-
- ((Button) findViewById(R.id.rewind_java)).setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View view) {
- if (mMediaPlayerIsPrepared) {
- mMediaPlayer.seekTo(0);
- }
- }
-
- });
-
- // native MediaPlayer rewind
-
- ((Button) findViewById(R.id.rewind_native)).setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View view) {
- if (mNativeMediaPlayerVideoSink != null) {
- rewindStreamingMediaPlayer();
- }
- }
-
- });
-
- }
-
- /** Called when the activity is about to be paused. */
- @Override
- protected void onPause()
- {
- mIsPlayingStreaming = false;
- setPlayingStreamingMediaPlayer(false);
- mGLView1.onPause();
- mGLView2.onPause();
- super.onPause();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mGLView1.onResume();
- mGLView2.onResume();
- }
-
- /** Called when the activity is about to be destroyed. */
- @Override
- protected void onDestroy()
- {
- shutdown();
- super.onDestroy();
- }
-
- private MyGLSurfaceView mGLView1, mGLView2;
-
- /** Native methods, implemented in jni folder */
- public static native void createEngine();
- public static native boolean createStreamingMediaPlayer(String filename);
- public static native void setPlayingStreamingMediaPlayer(boolean isPlaying);
- public static native void shutdown();
- public static native void setSurface(Surface surface);
- public static native void setSurfaceTexture(SurfaceTexture surfaceTexture);
- public static native void rewindStreamingMediaPlayer();
-
- /** Load jni .so on initialization */
- static {
- System.loadLibrary("native-media-jni");
- }
-
- // VideoSink abstracts out the difference between Surface and SurfaceTexture
- // aka SurfaceHolder and GLSurfaceView
- static abstract class VideoSink {
-
- abstract void setFixedSize(int width, int height);
- abstract void useAsSinkForJava(MediaPlayer mediaPlayer);
- abstract void useAsSinkForNative();
-
- }
-
- static class SurfaceHolderVideoSink extends VideoSink {
-
- private final SurfaceHolder mSurfaceHolder;
-
- SurfaceHolderVideoSink(SurfaceHolder surfaceHolder) {
- mSurfaceHolder = surfaceHolder;
- }
-
- void setFixedSize(int width, int height) {
- mSurfaceHolder.setFixedSize(width, height);
- }
-
- void useAsSinkForJava(MediaPlayer mediaPlayer) {
- mediaPlayer.setDisplay(mSurfaceHolder);
- }
-
- void useAsSinkForNative() {
- setSurface(mSurfaceHolder.getSurface());
- }
-
- }
-
- static class GLViewVideoSink extends VideoSink {
-
- private final MyGLSurfaceView mMyGLSurfaceView;
-
- GLViewVideoSink(MyGLSurfaceView myGLSurfaceView) {
- mMyGLSurfaceView = myGLSurfaceView;
- }
-
- void setFixedSize(int width, int height) {
- }
-
- void useAsSinkForJava(MediaPlayer mediaPlayer) {
- SurfaceTexture st = mMyGLSurfaceView.getSurfaceTexture();
- Surface s = new Surface(st);
- mediaPlayer.setSurface(s);
- s.release();
- }
-
- void useAsSinkForNative() {
- setSurfaceTexture(mMyGLSurfaceView.getSurfaceTexture());
- }
-
- }
-
-}
diff --git a/wilhelm/tests/sandbox/Android.mk b/wilhelm/tests/sandbox/Android.mk
deleted file mode 100644
index 53c4fd0..0000000
--- a/wilhelm/tests/sandbox/Android.mk
+++ /dev/null
@@ -1,467 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# intbufq
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- intbufq.c \
- getch.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
- #LOCAL_SHARED_LIBRARIES += librt
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_intbufq
-
-include $(BUILD_EXECUTABLE)
-
-# multiplay
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- multiplay.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_multiplay
-
-include $(BUILD_EXECUTABLE)
-
-# engine
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include \
- system/media/wilhelm/src/ut
-
-LOCAL_SRC_FILES:= \
- engine.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_engine
-
-include $(BUILD_EXECUTABLE)
-
-# object
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include \
- system/media/wilhelm/src/ut
-
-LOCAL_SRC_FILES:= \
- object.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_object
-
-include $(BUILD_EXECUTABLE)
-
-# configbq
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- configbq.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_configbq
-
-include $(BUILD_EXECUTABLE)
-
-# reverb
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- reverb.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_reverb
-
-include $(BUILD_EXECUTABLE)
-
-# srcsink
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- srcsink.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_srcsink
-
-include $(BUILD_EXECUTABLE)
-
-# outputmix
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include \
- system/media/wilhelm/src/ut
-
-LOCAL_SRC_FILES:= \
- outputmix.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_outputmix
-
-include $(BUILD_EXECUTABLE)
-
-# urimime
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- urimime.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_urimime
-
-include $(BUILD_EXECUTABLE)
-
-# dim
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- dim.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_dim
-
-include $(BUILD_EXECUTABLE)
-
-# multithread
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- multithread.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_multithread
-
-include $(BUILD_EXECUTABLE)
-
-# playbq
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- playbq.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT \
- libsndfile
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_playbq
-
-# commented out because libsndfile is not yet standard
-#include $(BUILD_EXECUTABLE)
-
-# monkey
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- monkey.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_monkey
-
-include $(BUILD_EXECUTABLE)
-
-# xa
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- xa.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenMAXAL
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_xa
-
-include $(BUILD_EXECUTABLE)
-
-# dual
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- dual.c
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES \
- libOpenMAXAL
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= slesTest_dual
-
-include $(BUILD_EXECUTABLE)
-
-# xaplay
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- xaplay.c nativewindow.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenMAXAL \
- libgui \
- libbinder \
- libandroid
-
-LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_CFLAGS += -UNDEBUG
-
-LOCAL_MODULE:= xaplay
-
-include $(BUILD_EXECUTABLE)
diff --git a/wilhelm/tests/sandbox/configbq.c b/wilhelm/tests/sandbox/configbq.c
deleted file mode 100644
index 3ae1a0a..0000000
--- a/wilhelm/tests/sandbox/configbq.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Test various buffer queue configurations
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <SLES/OpenSLES.h>
-
-typedef struct {
- SLuint8 numChannels;
- SLuint32 milliHz;
- SLuint8 bitsPerSample;
-} PCM;
-
-PCM formats[] = {
- {1, SL_SAMPLINGRATE_8, 8},
- {2, SL_SAMPLINGRATE_8, 8},
- {1, SL_SAMPLINGRATE_8, 16},
- {2, SL_SAMPLINGRATE_8, 16},
- {1, SL_SAMPLINGRATE_11_025, 8},
- {2, SL_SAMPLINGRATE_11_025, 8},
- {1, SL_SAMPLINGRATE_11_025, 16},
- {2, SL_SAMPLINGRATE_11_025, 16},
- {1, SL_SAMPLINGRATE_12, 8},
- {2, SL_SAMPLINGRATE_12, 8},
- {1, SL_SAMPLINGRATE_12, 16},
- {2, SL_SAMPLINGRATE_12, 16},
- {1, SL_SAMPLINGRATE_16, 8},
- {2, SL_SAMPLINGRATE_16, 8},
- {1, SL_SAMPLINGRATE_16, 16},
- {2, SL_SAMPLINGRATE_16, 16},
- {1, SL_SAMPLINGRATE_22_05, 8},
- {2, SL_SAMPLINGRATE_22_05, 8},
- {1, SL_SAMPLINGRATE_22_05, 16},
- {2, SL_SAMPLINGRATE_22_05, 16},
- {1, SL_SAMPLINGRATE_24, 8},
- {2, SL_SAMPLINGRATE_24, 8},
- {1, SL_SAMPLINGRATE_24, 16},
- {2, SL_SAMPLINGRATE_24, 16},
- {1, SL_SAMPLINGRATE_32, 8},
- {2, SL_SAMPLINGRATE_32, 8},
- {1, SL_SAMPLINGRATE_32, 16},
- {2, SL_SAMPLINGRATE_32, 16},
- {1, SL_SAMPLINGRATE_44_1, 8},
- {2, SL_SAMPLINGRATE_44_1, 8},
- {1, SL_SAMPLINGRATE_44_1, 16},
- {2, SL_SAMPLINGRATE_44_1, 16},
- {1, SL_SAMPLINGRATE_48, 8},
- {2, SL_SAMPLINGRATE_48, 8},
- {1, SL_SAMPLINGRATE_48, 16},
- {2, SL_SAMPLINGRATE_48, 16},
- {0, 0, 0}
-};
-
-int main(int argc, char **argv)
-{
- SLresult result;
- SLObjectItf engineObject;
-
- // create engine
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // create output mix
- SLObjectItf outputMixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // loop over all formats
- PCM *format;
- float hzLeft = 440.0; // A440 (Concert A)
- float hzRight = 440.0;
- for (format = formats; format->numChannels; ++format) {
-
- printf("Channels: %d, sample rate: %u, bits: %u\n", format->numChannels,
- format->milliHz / 1000, format->bitsPerSample);
-
- // configure audio source
- SLDataLocator_BufferQueue loc_bufq;
- loc_bufq.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
- loc_bufq.numBuffers = 1;
- SLDataFormat_PCM format_pcm;
- format_pcm.formatType = SL_DATAFORMAT_PCM;
- format_pcm.numChannels = format->numChannels;
- format_pcm.samplesPerSec = format->milliHz;
- format_pcm.bitsPerSample = format->bitsPerSample;
- format_pcm.containerSize = format->bitsPerSample;
- format_pcm.channelMask = 0;
- format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
- SLDataSource audioSrc;
- audioSrc.pLocator = &loc_bufq;
- audioSrc.pFormat = &format_pcm;
-
- // configure audio sink
- SLDataLocator_OutputMix loc_outmix;
- loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- loc_outmix.outputMix = outputMixObject;
- SLDataSink audioSnk;
- audioSnk.pLocator = &loc_outmix;
- audioSnk.pFormat = NULL;
-
- // create audio player
- SLuint32 numInterfaces = 1;
- SLInterfaceID ids[1];
- SLboolean req[1];
- ids[0] = SL_IID_BUFFERQUEUE;
- req[0] = SL_BOOLEAN_TRUE;
- SLObjectItf playerObject;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, numInterfaces, ids, req);
- if (SL_RESULT_SUCCESS != result) {
- printf("failed %u\n", result);
- continue;
- }
-
- // realize the player
- result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // generate a sine wave buffer, ascending in half-steps for each format
-#define N (44100*4)
- static unsigned char buffer[N];
- unsigned i;
- for (i = 0; i < N; ) {
- float seconds = (((i * 8) / (format->bitsPerSample * format->numChannels)) * 1000.0) /
- format->milliHz;
- short sampleLeft = sin(seconds * M_PI_2 * hzLeft) * 32767.0;
- short sampleRight = sin(seconds * M_PI_2 * hzRight) * 32767.0;
- if (2 == format->numChannels) {
- if (8 == format->bitsPerSample) {
- buffer[i++] = (sampleLeft + 32768) >> 8;
- buffer[i++] = (sampleRight + 32768) >> 8;
- } else {
- assert(16 == format->bitsPerSample);
- buffer[i++] = sampleLeft & 0xFF;
- buffer[i++] = sampleLeft >> 8;
- buffer[i++] = sampleRight & 0xFF;
- buffer[i++] = sampleRight >> 8;
- }
- } else {
- assert(1 == format->numChannels);
- // cast to int and divide by 2 are needed to prevent overflow
- short sampleMono = ((int) sampleLeft + (int) sampleRight) / 2;
- if (8 == format->bitsPerSample) {
- buffer[i++] = (sampleMono + 32768) >> 8;
- } else {
- assert(16 == format->bitsPerSample);
- buffer[i++] = sampleMono & 0xFF;
- buffer[i++] = sampleMono >> 8;
- }
- }
- if (seconds >= 1.0f)
- break;
- }
-
- // get the buffer queue interface and enqueue a buffer
- SLBufferQueueItf playerBufferQueue;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_BUFFERQUEUE,
- &playerBufferQueue);
- assert(SL_RESULT_SUCCESS == result);
- result = (*playerBufferQueue)->Enqueue(playerBufferQueue, buffer, i);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the play interface
- SLPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- assert(SL_RESULT_SUCCESS == result);
-
- // set the player's state to playing
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
- assert(SL_RESULT_SUCCESS == result);
-
- // wait for the buffer to be played
- for (;;) {
- SLBufferQueueState state;
- result = (*playerBufferQueue)->GetState(playerBufferQueue, &state);
- assert(SL_RESULT_SUCCESS == result);
- if (state.count == 0)
- break;
- usleep(20000);
- }
-
- // destroy audio player
- (*playerObject)->Destroy(playerObject);
-
- //usleep(1000000);
- hzLeft *= 1.05946309; // twelfth root of 2
- hzRight /= 1.05946309;
- }
-
- // destroy output mix
- (*outputMixObject)->Destroy(outputMixObject);
-
- // destroy engine
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/dim.c b/wilhelm/tests/sandbox/dim.c
deleted file mode 100644
index 8e815df..0000000
--- a/wilhelm/tests/sandbox/dim.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Test dynamic interface management
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-int main(int argc, char **argv)
-{
- if (argc != 1) {
- fprintf(stderr, "usage: %s\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- SLresult result;
- SLObjectItf engineObject;
-
- // create engine
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // create output mix
- SLObjectItf outputMixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the dynamic interface management interface for output mix, before realize
- SLDynamicInterfaceManagementItf outputMixDIM;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_DYNAMICINTERFACEMANAGEMENT,
- &outputMixDIM);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
- assert(NULL == outputMixDIM);
-
- // realize output mix
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the dynamic interface management interface for output mix, after realize
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_DYNAMICINTERFACEMANAGEMENT,
- &outputMixDIM);
- assert(SL_RESULT_SUCCESS == result);
- assert(NULL != outputMixDIM);
-
- // register callback
- result = (*outputMixDIM)->RegisterCallback(outputMixDIM, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
-
- // get environmental reverb interface, before add or resume
- SLEnvironmentalReverbItf outputMixEnvironmentalReverb;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == outputMixEnvironmentalReverb);
-
- // resume environmental reverb interface
- result = (*outputMixDIM)->ResumeInterface(outputMixDIM, SL_IID_ENVIRONMENTALREVERB,
- SL_BOOLEAN_FALSE);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
-
- // get environmental reverb interface, after resume but before add
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == outputMixEnvironmentalReverb);
-
- // add environmental reverb interface
- result = (*outputMixDIM)->AddInterface(outputMixDIM, SL_IID_ENVIRONMENTALREVERB,
- SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // get environmental reverb interface, after add
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_SUCCESS == result);
- assert(NULL != outputMixEnvironmentalReverb);
-
- // add environmental reverb interface again
- result = (*outputMixDIM)->AddInterface(outputMixDIM, SL_IID_ENVIRONMENTALREVERB,
- SL_BOOLEAN_FALSE);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
-
- // resume environmental reverb interface
- result = (*outputMixDIM)->ResumeInterface(outputMixDIM, SL_IID_ENVIRONMENTALREVERB,
- SL_BOOLEAN_FALSE);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
-
- // remove environmental reverb interface (FIXME not yet implemented)
- result = (*outputMixDIM)->RemoveInterface(outputMixDIM, SL_IID_ENVIRONMENTALREVERB);
- assert((SL_RESULT_SUCCESS == result) || (SL_RESULT_FEATURE_UNSUPPORTED == result));
-
- // FIXME once remove is implemented we can try this
- if (SL_RESULT_SUCCESS == result) {
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
- assert(NULL == outputMixEnvironmentalReverb);
- result = (*outputMixDIM)->RemoveInterface(outputMixDIM, SL_IID_ENVIRONMENTALREVERB);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
- result = (*outputMixDIM)->AddInterface(outputMixDIM, SL_IID_ENVIRONMENTALREVERB,
- SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_SUCCESS == result);
- assert(NULL != outputMixEnvironmentalReverb);
- }
-
- // get non-sensical play interface, before add
- SLPlayItf outputMixPlay;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_PLAY, &outputMixPlay);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == outputMixPlay);
-
- // add play interface
- result = (*outputMixDIM)->AddInterface(outputMixDIM, SL_IID_PLAY, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
-
- // get play interface should still fail
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_PLAY, &outputMixPlay);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == outputMixPlay);
-
- // destroy output mix
- (*outputMixObject)->Destroy(outputMixObject);
-
- // destroy engine
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/dual.c b/wilhelm/tests/sandbox/dual.c
deleted file mode 100644
index c3da1ff..0000000
--- a/wilhelm/tests/sandbox/dual.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Dual engine test
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SLES/OpenSLES.h>
-#include <OMXAL/OpenMAXAL.h>
-
-int main(int argc, char **argv)
-{
- XAresult xaResult;
- XAObjectItf xaEngineObject;
-
- SLresult slResult;
- SLObjectItf slEngineObject;
-
- printf("xaCreateEngine\n");
- xaResult = xaCreateEngine(&xaEngineObject, 0, NULL, 0, NULL, NULL);
- printf("xaResult = %d\n", xaResult);
- assert(XA_RESULT_SUCCESS == xaResult);
- printf("xaEngineObject = %p\n", xaEngineObject);
-
- printf("realize xaEngineObject\n");
- xaResult = (*xaEngineObject)->Realize(xaEngineObject, XA_BOOLEAN_FALSE);
- printf("xaResult = %d\n", xaResult);
-
- printf("GetInterface for XA_IID_ENGINE\n");
- XAEngineItf xaEngineEngine;
- xaResult = (*xaEngineObject)->GetInterface(xaEngineObject, XA_IID_ENGINE, &xaEngineEngine);
- printf("xaResult = %d\n", xaResult);
- printf("xaEngineEngine = %p\n", xaEngineEngine);
- assert(XA_RESULT_SUCCESS == xaResult);
-
- printf("slCreateEngine\n");
- slResult = slCreateEngine(&slEngineObject, 0, NULL, 0, NULL, NULL);
- printf("slResult = %d\n", slResult);
- assert(SL_RESULT_SUCCESS == slResult);
- printf("slEngineObject = %p\n", slEngineObject);
-
- printf("realize slEngineObject\n");
- slResult = (*slEngineObject)->Realize(slEngineObject, SL_BOOLEAN_FALSE);
- printf("slResult = %d\n", slResult);
-
- printf("GetInterface for SL_IID_ENGINE\n");
- SLEngineItf slEngineEngine;
- slResult = (*slEngineObject)->GetInterface(slEngineObject, SL_IID_ENGINE, &slEngineEngine);
- printf("slResult = %d\n", slResult);
- printf("slEngineEngine = %p\n", slEngineEngine);
- assert(SL_RESULT_SUCCESS == slResult);
-
- printf("destroying xaEngineObject\n");
- (*xaEngineObject)->Destroy(xaEngineObject);
-
- printf("destroying slEngineObject\n");
- (*slEngineObject)->Destroy(slEngineObject);
-
- printf("exit\n");
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/engine.c b/wilhelm/tests/sandbox/engine.c
deleted file mode 100644
index f18ea91..0000000
--- a/wilhelm/tests/sandbox/engine.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <SLES/OpenSLES.h>
-#include "OpenSLESUT.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main(int argc, char **argv)
-{
- printf("Get number of available engine interfaces\n");
- SLresult result;
- SLuint32 numSupportedInterfaces = 12345;
- result = slQueryNumSupportedEngineInterfaces(&numSupportedInterfaces);
- assert(SL_RESULT_SUCCESS == result);
- result = slQueryNumSupportedEngineInterfaces(NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
-
- printf("Engine number of supported interfaces %u\n", numSupportedInterfaces);
- SLInterfaceID *engine_ids = calloc(numSupportedInterfaces+1, sizeof(SLInterfaceID));
- assert(engine_ids != NULL);
- SLboolean *engine_req = calloc(numSupportedInterfaces+1, sizeof(SLboolean));
- assert(engine_req != NULL);
-
- printf("Display the ID of each available interface\n");
- SLuint32 index;
- for (index = 0; index < numSupportedInterfaces + 1; ++index) {
- SLInterfaceID interfaceID;
- memset(&interfaceID, 0x55, sizeof(interfaceID));
- result = slQuerySupportedEngineInterfaces(index, &interfaceID);
- if (index < numSupportedInterfaces) {
- assert(SL_RESULT_SUCCESS == result);
- printf("interface[%u] ", index);
- slesutPrintIID(interfaceID);
- engine_ids[index] = interfaceID;
- engine_req[index] = SL_BOOLEAN_TRUE;
- } else {
- assert(SL_RESULT_PARAMETER_INVALID == result);
- }
- result = slQuerySupportedEngineInterfaces(index, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- }
-
- printf("Create an engine and request all available interfaces\n");
- SLObjectItf engineObject;
- if (0 < numSupportedInterfaces) {
- printf("Create engine with numSupportedInterfaces > 0 but NULL pointers\n");
- result = slCreateEngine(&engineObject, 0, NULL, numSupportedInterfaces, engine_ids, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == engineObject);
- result = slCreateEngine(&engineObject, 0, NULL, numSupportedInterfaces, NULL, engine_req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == engineObject);
- }
-
- printf("Create engine with no place to return the new engine object\n");
- result = slCreateEngine(NULL, 0, NULL, numSupportedInterfaces, engine_ids, engine_req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
-
- printf("Create engine with NULL interface pointer\n");
- SLInterfaceID null_id[1] = {NULL};
- SLboolean null_req[1] = {SL_BOOLEAN_FALSE};
- result = slCreateEngine(&engineObject, 0, NULL, 1, null_id, null_req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == engineObject);
-
- printf("Create an engine with numOptions > 0 but NULL pointer\n");
- result = slCreateEngine(&engineObject, 1, NULL, 0, NULL, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == engineObject);
- SLEngineOption options[2];
- options[0].feature = 0x12345;
- options[0].data = 0;
-
- printf("Create engine with non-sensical option\n");
- result = slCreateEngine(&engineObject, 1, options, 0, NULL, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == engineObject);
-
- printf("Create an engine and require non-sensical volume interface\n");
- engine_ids[numSupportedInterfaces] = SL_IID_VOLUME;
- engine_req[numSupportedInterfaces] = SL_BOOLEAN_TRUE;
- result = slCreateEngine(&engineObject, 0, NULL, numSupportedInterfaces+1, engine_ids,
- engine_req);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == engineObject);
-
- printf("Create an engine and politely request a non-sensical interface with options\n");
- engine_req[numSupportedInterfaces] = SL_BOOLEAN_FALSE;
- options[0].feature = SL_ENGINEOPTION_THREADSAFE;
- options[0].data = (SLuint32) SL_BOOLEAN_TRUE;
- options[1].feature = SL_ENGINEOPTION_LOSSOFCONTROL;
- options[1].data = (SLuint32) SL_BOOLEAN_FALSE;
- result = slCreateEngine(&engineObject, 2, options, numSupportedInterfaces+1, engine_ids,
- engine_req);
- assert(SL_RESULT_SUCCESS == result);
- printf("Engine object %p\n", engineObject);
-
- printf("Get each available interface before realization\n");
- for (index = 0; index < numSupportedInterfaces; ++index) {
- void *interface = NULL;
- // Use the interface ID as returned by slQuerySupportedEngineInterfaces
- result = (*engineObject)->GetInterface(engineObject, engine_ids[index], &interface);
- assert(SL_RESULT_SUCCESS == result || SL_RESULT_PRECONDITIONS_VIOLATED == result);
- if (SL_RESULT_SUCCESS == result) {
- printf("interface available pre-realize: ");
- slesutPrintIID(engine_ids[index]);
- }
- }
-
- printf("Destroy engine before realization\n");
- (*engineObject)->Destroy(engineObject);
-
- printf("Create engine again\n");
- result = slCreateEngine(&engineObject, 0, NULL, numSupportedInterfaces, engine_ids, engine_req);
- assert(SL_RESULT_SUCCESS == result);
- printf("Engine object %p\n", engineObject);
-
- printf("Realize the engine\n");
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- printf("Get each available interface after realization\n");
- for (index = 0; index < numSupportedInterfaces; ++index) {
- void *interface = NULL;
- result = (*engineObject)->GetInterface(engineObject, engine_ids[index], &interface);
- assert(SL_RESULT_SUCCESS == result);
- printf("interface[%u] %p\n", index, interface);
- // Use a copy of the interface ID to make sure lookup is not purely relying on address
- void *interface_again = NULL;
- struct SLInterfaceID_ copy = *engine_ids[index];
- result = (*engineObject)->GetInterface(engineObject, ©, &interface_again);
- assert(SL_RESULT_SUCCESS == result);
- // Calling GetInterface multiple times should return the same interface
- assert(interface_again == interface);
- }
-
- SLObjectItf engineObject2;
-#if 0
- printf("Create too many engines\n");
- result = slCreateEngine(&engineObject2, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_RESOURCE_ERROR == result);
- assert(NULL == engineObject2);
-#endif
-
- printf("Destroy engine\n");
- (*engineObject)->Destroy(engineObject);
-
- printf("Now should be able to create another engine\n");
- result = slCreateEngine(&engineObject2, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
-
- printf("Exit without destroying engine -- examine log for expected error message\n");
- free(engine_ids);
- free(engine_req);
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/getch.c b/wilhelm/tests/sandbox/getch.c
deleted file mode 100644
index 446770a..0000000
--- a/wilhelm/tests/sandbox/getch.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-C non-blocking keyboard input
-http://stackoverflow.com/questions/448944/c-non-blocking-keyboard-input
-*/
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/select.h>
-#include <termios.h>
-#include <unistd.h>
-#include "getch.h"
-
-struct termios orig_termios;
-
-void reset_terminal_mode()
-{
- tcsetattr(0, TCSANOW, &orig_termios);
-}
-
-void set_conio_terminal_mode()
-{
- struct termios new_termios;
-
- /* take two copies - one for now, one for later */
- tcgetattr(0, &orig_termios);
- memcpy(&new_termios, &orig_termios, sizeof(new_termios));
-
- /* register cleanup handler, and set the new terminal mode */
- atexit(reset_terminal_mode);
- cfmakeraw(&new_termios);
- new_termios.c_oflag |= OPOST;
- tcsetattr(0, TCSANOW, &new_termios);
-}
-
-int kbhit()
-{
- struct timeval tv = { 0L, 0L };
- fd_set fds;
- FD_ZERO(&fds); // not in original posting to stackoverflow
- FD_SET(0, &fds);
- return select(1, &fds, NULL, NULL, &tv);
-}
-
-int getch()
-{
- int r;
- unsigned char c;
- if ((r = read(0, &c, sizeof(c))) < 0) {
- return r;
- } else {
- return c;
- }
-}
-
-#if 0
-int main(int argc, char *argv[])
-{
- set_conio_terminal_mode();
-
- while (!kbhit()) {
- /* do some work */
- }
- (void)getch(); /* consume the character */
-}
-#endif
diff --git a/wilhelm/tests/sandbox/getch.h b/wilhelm/tests/sandbox/getch.h
deleted file mode 100644
index 802c3f4..0000000
--- a/wilhelm/tests/sandbox/getch.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-extern int kbhit();
-extern int getch(void);
-extern void set_conio_terminal_mode(void);
diff --git a/wilhelm/tests/sandbox/intbufq.c b/wilhelm/tests/sandbox/intbufq.c
deleted file mode 100644
index e06685f..0000000
--- a/wilhelm/tests/sandbox/intbufq.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* interactive buffer queue test program */
-
-#ifdef ANDROID
-#define USE_ANDROID_SIMPLE_BUFFER_QUEUE // change to #undef for compatibility testing
-#endif
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <SLES/OpenSLES.h>
-#ifdef USE_ANDROID_SIMPLE_BUFFER_QUEUE
-#include <SLES/OpenSLES_Android.h>
-#endif
-#include "getch.h"
-
-#ifdef USE_ANDROID_SIMPLE_BUFFER_QUEUE
-#define DATALOCATOR_BUFFERQUEUE SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE
-#define IID_BUFFERQUEUE SL_IID_ANDROIDSIMPLEBUFFERQUEUE
-#define BufferQueueItf SLAndroidSimpleBufferQueueItf
-#define BufferQueueState SLAndroidSimpleBufferQueueState
-#define INDEX index
-#else
-#define DATALOCATOR_BUFFERQUEUE SL_DATALOCATOR_BUFFERQUEUE
-#define IID_BUFFERQUEUE SL_IID_BUFFERQUEUE
-#define BufferQueueItf SLBufferQueueItf
-#define BufferQueueState SLBufferQueueState
-#define INDEX playIndex
-#endif
-
-#define checkResult(r) do { if ((r) != SL_RESULT_SUCCESS) fprintf(stderr, "error %d at %s:%d\n", \
- (int) r, __FILE__, __LINE__); } while (0)
-
-typedef struct {
- short left;
- short right;
-} frame_t;
-
-#define SINE_FRAMES (44100*5)
-frame_t sine[SINE_FRAMES];
-
-#define SQUARE_FRAMES (44100*5)
-frame_t square[SQUARE_FRAMES];
-
-#define SAWTOOTH_FRAMES (44100*5)
-frame_t sawtooth[SAWTOOTH_FRAMES];
-
-#define HALF_FRAMES (44100*5)
-frame_t half[HALF_FRAMES];
-
-BufferQueueItf expectedCaller = NULL;
-void *expectedContext = NULL;
-
-static void callback(BufferQueueItf caller, void *context)
-{
- putchar('.');
- if (caller != expectedCaller)
- printf("caller %p expected %p\r\n", caller, expectedCaller);
- if (context != expectedContext)
- printf("context %p expected %p\r\n", context, expectedContext);
- fflush(stdout);
-}
-
-int main(int argc, char **argv)
-{
- SLresult result;
-
- // create engine
- SLObjectItf engineObject;
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- checkResult(result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- checkResult(result);
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- checkResult(result);
-
- // create output mix
- SLObjectItf outputmixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputmixObject, 0, NULL, NULL);
- checkResult(result);
- result = (*outputmixObject)->Realize(outputmixObject, SL_BOOLEAN_FALSE);
- checkResult(result);
-
- // create audio player
- SLDataSource audiosrc;
- SLDataSink audiosnk;
- SLDataFormat_PCM pcm;
- SLDataLocator_OutputMix locator_outputmix;
- SLDataLocator_BufferQueue locator_bufferqueue;
- locator_bufferqueue.locatorType = DATALOCATOR_BUFFERQUEUE;
- locator_bufferqueue.numBuffers = 255;
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = outputmixObject;
- pcm.formatType = SL_DATAFORMAT_PCM;
- pcm.numChannels = 2;
- pcm.samplesPerSec = SL_SAMPLINGRATE_44_1;
- pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
- pcm.containerSize = 16;
- pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
- audiosrc.pLocator = &locator_bufferqueue;
- audiosrc.pFormat = &pcm;
- audiosnk.pLocator = &locator_outputmix;
- audiosnk.pFormat = NULL;
- SLObjectItf playerObject;
- SLInterfaceID ids[2] = {IID_BUFFERQUEUE, SL_IID_MUTESOLO};
- SLboolean flags[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audiosrc, &audiosnk,
- 2, ids, flags);
- checkResult(result);
- result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- checkResult(result);
- SLPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- checkResult(result);
- BufferQueueItf playerBufferqueue;
- result = (*playerObject)->GetInterface(playerObject, IID_BUFFERQUEUE, &playerBufferqueue);
- checkResult(result);
- SLMuteSoloItf playerMuteSolo;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_MUTESOLO, &playerMuteSolo);
- checkResult(result);
- SLuint8 numChannels = 123;
- result = (*playerMuteSolo)->GetNumChannels(playerMuteSolo, &numChannels);
- assert(2 == numChannels);
- SLuint32 state;
- state = SL_PLAYSTATE_PLAYING;
- result = (*playerPlay)->SetPlayState(playerPlay, state);
- checkResult(result);
-
- unsigned i;
- float pi2 = 3.14*2;
- float hz = 441;
- float sr = 44100;
- for (i = 0; i < SINE_FRAMES; ++i) {
- sine[i].left = sin((float) (i / (sr / hz)) * pi2 ) * 32000.0;
- sine[i].right = sine[i].left;
- }
- for (i = 0; i < SQUARE_FRAMES; ++i) {
- square[i].left = (i % (unsigned) (sr / hz)) < 50 ? 32767 : -32768;
- square[i].right = square[i].left;
- }
- for (i = 0; i < SAWTOOTH_FRAMES; ++i) {
- sawtooth[i].left = ((((int) (i % (unsigned) (sr / hz))) - 50) / 100.0) * 60000.0 - 30000.0;
- sawtooth[i].right = sawtooth[i].left;
- }
- for (i = 0; i < HALF_FRAMES; ++i) {
- half[i].left = sine[i].left;
- half[i].right = sawtooth[i].right / 2;
- }
-
- set_conio_terminal_mode();
- int in_count = 0;
- unsigned count = 0;
- for (;;) {
- usleep(10000);
- if (kbhit()) {
- frame_t *buffer;
- unsigned size;
- BufferQueueState bufqstate;
- int ch = getch();
- switch (ch) {
- case '0' ... '9':
- if (in_count) {
- count = count * 10 + (ch - '0');
- } else {
- count = ch - '0';
- in_count = 1;
- }
- continue;
- case 'i':
- buffer = sine;
- size = sizeof(sine);
- goto enqueue;
- case 'q':
- buffer = square;
- size = sizeof(square);
- goto enqueue;
- case 'h':
- buffer = half;
- size = sizeof(half);
- goto enqueue;
- case 'r':
- if (in_count) {
- expectedCaller = playerBufferqueue;
- expectedContext = (void *) count;
- } else {
- expectedCaller = NULL;
- expectedContext = (void *) NULL;
- }
- result = (*playerBufferqueue)->RegisterCallback(playerBufferqueue, in_count ?
- callback : NULL, expectedContext);
- checkResult(result);
- break;
- case 'a':
- buffer = sawtooth;
- size = sizeof(sawtooth);
-enqueue:
- for (i = 0; i < (in_count ? count : 1); ++i) {
- result = (*playerBufferqueue)->Enqueue(playerBufferqueue, buffer, size);
- checkResult(result);
- }
- break;
- case 'c':
- result = (*playerBufferqueue)->Clear(playerBufferqueue);
- checkResult(result);
- putchar('\r');
- result = (*playerBufferqueue)->GetState(playerBufferqueue, &bufqstate);
- checkResult(result);
- if (bufqstate.count != 0)
- printf("\rcount=%u\r\n", (unsigned) bufqstate.count);
-#if 0
- putchar('\r');
- putchar('\n');
-#endif
- fflush(stdout);
- break;
- case 'g':
- result = (*playerBufferqueue)->GetState(playerBufferqueue, &bufqstate);
- checkResult(result);
- printf("\rplayIndex=%u\r\n", (unsigned) bufqstate.INDEX);
- printf("count=%u\r\n", (unsigned) bufqstate.count);
- break;
- case 'p':
- state = SL_PLAYSTATE_PAUSED;
- goto setplaystate;
- case 's':
- state = SL_PLAYSTATE_STOPPED;
- goto setplaystate;
- case 'P':
- state = SL_PLAYSTATE_PLAYING;
-setplaystate:
- result = (*playerPlay)->SetPlayState(playerPlay, state);
- checkResult(result);
- SLuint32 newstate;
- result = (*playerPlay)->GetPlayState(playerPlay, &newstate);
- checkResult(result);
- if (newstate != state)
- printf("\rSetPlayState(%u) -> GetPlayState(%u)\r\n", (unsigned) state,
- (unsigned) newstate);
-#if 0
- putchar('\r');
- putchar('\n');
- fflush(stdout);
-#endif
- checkResult(result);
- break;
- case 'x':
- goto out;
- default:
- putchar('?');
- fflush(stdout);
- break;
- }
- in_count = 0;
- }
- }
-
-out:
- (*playerObject)->Destroy(playerObject);
- (*outputmixObject)->Destroy(outputmixObject);
- (*engineObject)->Destroy(engineObject);
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/monkey.c b/wilhelm/tests/sandbox/monkey.c
deleted file mode 100644
index 49193c8..0000000
--- a/wilhelm/tests/sandbox/monkey.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// single-threaded, single-player monkey test
-
-#include <SLES/OpenSLES.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-typedef enum {
- STATE_UNCHANGED,
- STATE_INITIAL,
- STATE_NONEXISTENT,
- STATE_CREATED,
- STATE_REALIZED,
- STATE_PAUSED,
- STATE_PLAYING,
- STATE_STOPPED,
- STATE_ERROR,
-// STATE_IDLE, // after Stop, then sleep for 3 seconds
- STATE_TERMINAL
-} State_t;
-
-typedef struct {
- SLObjectItf mObject;
- SLPlayItf mPlay;
- SLSeekItf mSeek;
-} Player_t, *Player_pt;
-
-typedef State_t (*Action_pt)(Player_pt player);
-
-SLObjectItf engineObject;
-SLEngineItf engineEngine;
-SLObjectItf outputMixObject;
-int countTransitions = 0;
-int maxTransitions = 10;
-
-State_t actionPause(Player_pt p)
-{
- assert(NULL != p->mPlay);
- SLresult result = (*p->mPlay)->SetPlayState(p->mPlay, SL_PLAYSTATE_PAUSED);
- assert(SL_RESULT_SUCCESS == result);
- return STATE_PAUSED;
-}
-
-State_t actionPlay(Player_pt p)
-{
- assert(NULL != p->mPlay);
- SLresult result = (*p->mPlay)->SetPlayState(p->mPlay, SL_PLAYSTATE_PLAYING);
- assert(SL_RESULT_SUCCESS == result);
- return STATE_PLAYING;
-}
-
-State_t actionStop(Player_pt p)
-{
- assert(NULL != p->mPlay);
- SLresult result = (*p->mPlay)->SetPlayState(p->mPlay, SL_PLAYSTATE_STOPPED);
- assert(SL_RESULT_SUCCESS == result);
- return STATE_STOPPED;
-}
-
-State_t actionRewind(Player_pt p)
-{
- assert(NULL != p->mSeek);
- SLresult result = (*p->mSeek)->SetPosition(p->mSeek, (SLmillisecond) 0, SL_SEEKMODE_FAST);
- assert(SL_RESULT_SUCCESS == result);
- return STATE_UNCHANGED;
-}
-
-State_t actionDestroy(Player_pt p)
-{
- assert(NULL != p->mObject);
- (*p->mObject)->Destroy(p->mObject);
- p->mObject = NULL;
- p->mPlay = NULL;
- p->mSeek = NULL;
- return STATE_NONEXISTENT;
-}
-
-State_t actionCreate(Player_pt p)
-{
- // configure audio source
- SLDataLocator_URI loc_uri;
- loc_uri.locatorType = SL_DATALOCATOR_URI;
- loc_uri.URI = (SLchar *) "wav/frog.wav";
- SLDataFormat_MIME format_mime;
- format_mime.formatType = SL_DATAFORMAT_MIME;
- format_mime.mimeType = NULL;
- format_mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
- SLDataSource audioSrc;
- audioSrc.pLocator = &loc_uri;
- audioSrc.pFormat = &format_mime;
- // configure audio sink
- SLDataLocator_OutputMix loc_outmix;
- loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- loc_outmix.outputMix = outputMixObject;
- SLDataSink audioSnk;
- audioSnk.pLocator = &loc_outmix;
- audioSnk.pFormat = NULL;
- // create audio player
- SLInterfaceID ids[1] = {SL_IID_SEEK};
- SLboolean req[1] = {SL_BOOLEAN_TRUE};
- SLresult result = (*engineEngine)->CreateAudioPlayer(engineEngine, &p->mObject, &audioSrc,
- &audioSnk, 1, ids, req);
- if (SL_RESULT_SUCCESS != result)
- return STATE_ERROR;
- return STATE_CREATED;
-}
-
-State_t actionRealize(Player_pt p)
-{
- assert(NULL != p->mObject);
- // realize the player
- SLresult result = (*p->mObject)->Realize(p->mObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- // get interfaces
- result = (*p->mObject)->GetInterface(p->mObject, SL_IID_PLAY, &p->mPlay);
- assert(SL_RESULT_SUCCESS == result);
- result = (*p->mObject)->GetInterface(p->mObject, SL_IID_SEEK, &p->mSeek);
- assert(SL_RESULT_SUCCESS == result);
- return STATE_REALIZED;
-}
-
-State_t actionSleep(Player_pt p)
-{
- unsigned us = 1000 + (rand() & 0xFFFFF);
- usleep(us);
- return STATE_UNCHANGED;
-}
-
-#if 0
-State_t actionSleep3(Player_pt p)
-{
- sleep(3);
- return STATE_IDLE;
-}
-#endif
-
-State_t actionTerminateIfDone(Player_pt p)
-{
- if (countTransitions >= maxTransitions) {
- assert(NULL == p->mObject);
- // clean up output mix and engine
- assert(NULL != outputMixObject);
- (*outputMixObject)->Destroy(outputMixObject);
- outputMixObject = NULL;
- assert(NULL != engineObject);
- (*engineObject)->Destroy(engineObject);
- engineObject = NULL;
- return STATE_TERMINAL;
- } else
- return STATE_UNCHANGED;
-}
-
-State_t actionInitialize(Player_pt p)
-{
- // create engine
- SLresult result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // create output mix
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- return STATE_NONEXISTENT;
-}
-
-typedef struct {
- State_t mEntryState;
- Action_pt mAction;
- unsigned mProbability;
- const char *mActionName;
- unsigned mCount;
-} Transition_t;
-
-Transition_t transitionTable[] = {
-#define _(entryState, action, probability) {entryState, action, probability, #action, 0},
- _(STATE_INITIAL, actionInitialize, 1)
- _(STATE_CREATED, actionDestroy, 1)
- _(STATE_CREATED, actionRealize, 1)
- _(STATE_CREATED, actionSleep, 1)
- _(STATE_NONEXISTENT, actionCreate, 1)
- _(STATE_NONEXISTENT, actionSleep, 1)
- _(STATE_PAUSED, actionDestroy, 1)
- _(STATE_PAUSED, actionPause, 1)
- _(STATE_PAUSED, actionPlay, 1)
- _(STATE_PAUSED, actionRewind, 1)
- _(STATE_PAUSED, actionSleep, 1)
- _(STATE_PAUSED, actionStop, 1)
- _(STATE_PLAYING, actionDestroy, 1)
- _(STATE_PLAYING, actionPause, 1)
- _(STATE_PLAYING, actionPlay, 1)
- _(STATE_PLAYING, actionRewind, 1)
- _(STATE_PLAYING, actionSleep, 1)
- _(STATE_PLAYING, actionStop, 1)
- _(STATE_REALIZED, actionDestroy, 1)
- _(STATE_REALIZED, actionPause, 1)
- _(STATE_REALIZED, actionPlay, 1)
- _(STATE_REALIZED, actionSleep, 1)
- _(STATE_REALIZED, actionStop, 1)
- _(STATE_STOPPED, actionDestroy, 1)
- _(STATE_STOPPED, actionPause, 1)
- _(STATE_STOPPED, actionPlay, 1)
- _(STATE_STOPPED, actionRewind, 1)
- _(STATE_STOPPED, actionSleep, 1)
- _(STATE_STOPPED, actionStop, 1)
-// _(STATE_STOPPED, actionSleep3, 1)
-// _(STATE_IDLE, actionDestroy, 1)
- _(STATE_NONEXISTENT, actionTerminateIfDone, 1)
-};
-
-int main(int argc, char **argv)
-{
- int i;
- for (i = 1; i < argc; ++i) {
- char *arg = argv[i];
- if (arg[0] != '-')
- break;
- if (!strncmp(arg, "-m", 2)) {
- maxTransitions = atoi(&arg[2]);
- } else {
- fprintf(stderr, "Unknown option %s\n", arg);
- }
- }
- unsigned possibleTransitions = sizeof(transitionTable) / sizeof(transitionTable[0]);
- Player_t player;
- player.mObject = NULL;
- player.mPlay = NULL;
- player.mSeek = NULL;
- State_t currentState = STATE_INITIAL;
- while (STATE_TERMINAL != currentState) {
- unsigned matchingTransitions = 0;
- unsigned totalProbability = 0;
- for (i = 0; i < (int) possibleTransitions; ++i) {
- if (currentState != transitionTable[i].mEntryState)
- continue;
- ++matchingTransitions;
- totalProbability += transitionTable[i].mProbability;
- }
- if (matchingTransitions == 0) {
- fprintf(stderr, "No matching transitions in state %d\n", currentState);
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- if (totalProbability == 0) {
- fprintf(stderr, "Found at least one matching transition in state %d, "
- "but with probability 0\n", currentState);
- assert(SL_BOOLEAN_FALSE);
- break;
- }
- unsigned choice = (rand() & 0x7FFFFFFF) % totalProbability;
- totalProbability = 0;
- for (i = 0; i < (int) possibleTransitions; ++i) {
- if (currentState != transitionTable[i].mEntryState)
- continue;
- totalProbability += transitionTable[i].mProbability;
- if (totalProbability <= choice)
- continue;
- ++transitionTable[i].mCount;
- ++countTransitions;
- printf("[%d] Selecting transition %s in state %d for the %u time\n", countTransitions,
- transitionTable[i].mActionName, currentState, transitionTable[i].mCount);
- State_t nextState = (*transitionTable[i].mAction)(&player);
- if (STATE_UNCHANGED != nextState)
- currentState = nextState;
- goto found;
- }
- fprintf(stderr, "This shouldn't happen\n");
- assert(SL_BOOLEAN_FALSE);
-found:
- ;
- }
- for (i = 0; i < (int) possibleTransitions; ++i) {
- printf("state %d action %s count %u\n",
- transitionTable[i].mEntryState,
- transitionTable[i].mActionName,
- transitionTable[i].mCount);
- }
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/multiplay.c b/wilhelm/tests/sandbox/multiplay.c
deleted file mode 100644
index e4f42ce..0000000
--- a/wilhelm/tests/sandbox/multiplay.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// multiplay is a command-line test app that plays multiple files randomly
-
-#include <SLES/OpenSLES.h>
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-// Describes the state of one player
-
-typedef struct {
- SLObjectItf mPlayerObject;
- SLPlayItf mPlayerPlay;
- SLSeekItf mPlayerSeek;
- SLPrefetchStatusItf mPlayerPrefetchStatus;
- SLVolumeItf mPlayerVolume;
- SLmillisecond mPlayerDuration;
- SLboolean mPlayerErrorInCallback;
- SLboolean mPlayerErrorReported;
-} Player;
-
-// Strings corresponding to result codes; FIXME should move to a common test library
-
-static const char *result_strings[] = {
- "SUCCESS",
- "PRECONDITIONS_VIOLATED",
- "PARAMETER_INVALID",
- "MEMORY_FAILURE",
- "RESOURCE_ERROR",
- "RESOURCE_LOST",
- "IO_ERROR",
- "BUFFER_INSUFFICIENT",
- "CONTENT_CORRUPTED",
- "CONTENT_UNSUPPORTED",
- "CONTENT_NOT_FOUND",
- "PERMISSION_DENIED",
- "FEATURE_UNSUPPORTED",
- "INTERNAL_ERROR",
- "UNKNOWN_ERROR",
- "OPERATION_ABORTED",
- "CONTROL_LOST"
-};
-
-// Convert result to string; FIXME should move to common test library
-
-static const char *result_to_string(SLresult result)
-{
- static char buffer[32];
- if ( /* result >= 0 && */ result < sizeof(result_strings) / sizeof(result_strings[0]))
- return result_strings[result];
- sprintf(buffer, "%d", (int) result);
- return buffer;
-}
-
-// Compare result against expected and exit suddenly if wrong
-
-void check2(SLresult result, int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "error %s at line %d\n", result_to_string(result), line);
- exit(EXIT_FAILURE);
- }
-}
-
-// Same as above but automatically adds the source code line number
-
-#define check(result) check2(result, __LINE__)
-
-// Prefetch status callback
-
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-void prefetch_callback(SLPrefetchStatusItf caller, void *context, SLuint32 event)
-{
- SLresult result;
- assert(context != NULL);
- Player *p = (Player *) context;
- assert(p->mPlayerPrefetchStatus == caller);
- SLpermille level;
- result = (*caller)->GetFillLevel(caller, &level);
- check(result);
- SLuint32 status;
- result = (*caller)->GetPrefetchStatus(caller, &status);
- check(result);
- //fprintf(stderr, "PrefetchEventCallback: received event %u, level %u, status %u\n",
- // event, level, status);
- if ((PREFETCHEVENT_ERROR_CANDIDATE == (event & PREFETCHEVENT_ERROR_CANDIDATE))
- && (level == 0) && (status == SL_PREFETCHSTATUS_UNDERFLOW)) {
- p->mPlayerErrorInCallback = SL_BOOLEAN_TRUE;
- }
-}
-
-// Main program
-
-int main(int argc, char **argv)
-{
- int i;
- const char *arg;
- int numPlayers = 0;
- int playTimeInMilliseconds = 0; // default to run forever
- SLmillibel mixVolumeLevel = 0;
- for (i = 1; i < argc; ++i) {
- arg = argv[i];
- if (arg[0] != '-')
- break;
- if (!strncmp(arg, "-n", 2))
- numPlayers = atoi(&arg[2]);
- else if (!strncmp(arg, "-v", 2))
- mixVolumeLevel = atoi(&arg[2]);
- else if (!strncmp(arg, "-t", 2))
- playTimeInMilliseconds = atoi(&arg[2]) * 1000;
- else
- fprintf(stderr, "unknown option: %s\n", arg);
- }
- int numPathnames = argc - i;
- if (numPathnames <= 0) {
- fprintf(stderr, "usage: %s file.wav ...\n", argv[0]);
- return EXIT_FAILURE;
- }
- if (numPlayers <= 0) {
- numPlayers = numPathnames;
- }
- Player *players = (Player *) calloc(numPlayers, sizeof(Player));
- assert(NULL != players);
- char **pathnames = &argv[i];
- SLresult result;
-
- // engine
- const SLInterfaceID engine_ids[] = {SL_IID_ENGINE};
- const SLboolean engine_req[] = {SL_BOOLEAN_TRUE};
- SLObjectItf engineObject;
- result = slCreateEngine(&engineObject, 0, NULL, 1, engine_ids, engine_req);
- check(result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- check(result);
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- check(result);
-
- // mixer
- const SLInterfaceID mix_ids[] = {SL_IID_VOLUME};
- const SLboolean mix_req[] = {SL_BOOLEAN_TRUE};
- SLObjectItf mixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &mixObject, 0, mix_ids, mix_req);
- check(result);
- result = (*mixObject)->Realize(mixObject, SL_BOOLEAN_FALSE);
- check(result);
-#if 0
- SLVolumeItf mixVolume;
- result = (*mixObject)->GetInterface(mixObject, SL_IID_VOLUME, &mixVolume);
- check(result);
- SLmillibel mixVolumeLevelDefault;
- result = (*mixVolume)->GetVolumeLevel(mixVolume, &mixVolumeLevelDefault);
- check(result);
- printf("default mix volume level = %d\n", mixVolumeLevelDefault);
-#endif
-
- printf("numPathnames=%d\n", numPathnames);
- printf("numPlayers=%d\n", numPlayers);
- Player *p;
-
- // create all the players
- for (i = 0; i < numPlayers; ++i) {
- const SLInterfaceID player_ids[] =
- {SL_IID_PLAY, SL_IID_VOLUME, SL_IID_SEEK, SL_IID_PREFETCHSTATUS};
- const SLboolean player_req[] =
- {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
- p = &players[i];
- SLDataLocator_URI locURI = {SL_DATALOCATOR_URI, (SLchar *) pathnames[i % numPathnames]};
- SLDataFormat_MIME dfMIME = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
- SLDataSource audioSrc = {&locURI, &dfMIME};
- SLDataLocator_OutputMix locOutputMix = {SL_DATALOCATOR_OUTPUTMIX, mixObject};
- SLDataSink audioSnk = {&locOutputMix, NULL};
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &p->mPlayerObject, &audioSrc,
- &audioSnk, sizeof(player_ids)/sizeof(player_ids[0]), player_ids, player_req);
- check(result);
- result = (*p->mPlayerObject)->Realize(p->mPlayerObject, SL_BOOLEAN_FALSE);
- check(result);
- result = (*p->mPlayerObject)->GetInterface(p->mPlayerObject, SL_IID_PLAY, &p->mPlayerPlay);
- check(result);
- result = (*p->mPlayerObject)->GetInterface(p->mPlayerObject, SL_IID_VOLUME,
- &p->mPlayerVolume);
- check(result);
- result = (*p->mPlayerObject)->GetInterface(p->mPlayerObject, SL_IID_SEEK, &p->mPlayerSeek);
- check(result);
- result = (*p->mPlayerObject)->GetInterface(p->mPlayerObject, SL_IID_PREFETCHSTATUS,
- &p->mPlayerPrefetchStatus);
- check(result);
- result = (*p->mPlayerPrefetchStatus)->RegisterCallback(p->mPlayerPrefetchStatus,
- prefetch_callback, p);
- check(result);
- result = (*p->mPlayerPrefetchStatus)->SetCallbackEventsMask(p->mPlayerPrefetchStatus,
- SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE);
- check(result);
- }
-
- // now loop randomly doing things to the players
- for (;;) {
- SLmillisecond delay = 100 + (rand() & 1023);
- printf("sleep %u\n", (unsigned) delay);
- usleep(delay * 1000);
- i = (rand() & 0x7FFFFFFF) % numPlayers;
- p = &players[i];
- if (p->mPlayerErrorReported)
- continue;
- printf("player %d (%s): ", i, pathnames[i]);
- if (p->mPlayerErrorInCallback && !p->mPlayerErrorReported) {
- printf("error, ");
- p->mPlayerErrorReported = SL_BOOLEAN_TRUE;
- }
- result = (*p->mPlayerPlay)->GetDuration(p->mPlayerPlay, &p->mPlayerDuration);
- check(result);
- if (p->mPlayerDuration == SL_TIME_UNKNOWN) {
- printf("duration unknown, ");
- } else {
- printf("duration %d ms, ", (int) p->mPlayerDuration);
- }
- SLuint32 state;
- result = (*p->mPlayerPlay)->GetPlayState(p->mPlayerPlay, &state);
- check(result);
- printf("state = ");
- switch (state) {
- case SL_PLAYSTATE_STOPPED:
- printf("STOPPED");
- break;
- case SL_PLAYSTATE_PAUSED:
- printf("PAUSED");
- break;
- case SL_PLAYSTATE_PLAYING:
- printf("PLAYING");
- break;
- default:
- printf("%u", (unsigned) state);
- break;
- }
- printf("\n");
- if (state == SL_PLAYSTATE_STOPPED || state == SL_PLAYSTATE_PAUSED) {
- SLmillibel volumeLevel = -((rand() & 0x7FFFFFFF) % ((SL_MILLIBEL_MIN + 1) / 10));
- printf("volume %d\n", volumeLevel);
- result = (*p->mPlayerVolume)->SetVolumeLevel(p->mPlayerVolume, volumeLevel);
- check(result);
- result = (*p->mPlayerVolume)->EnableStereoPosition(p->mPlayerVolume, SL_BOOLEAN_TRUE);
- check(result);
- SLpermille stereoPosition = ((rand() & 0x7FFFFFFF) % 2001) - 1000;
- printf("position %d\n", stereoPosition);
- result = (*p->mPlayerVolume)->SetStereoPosition(p->mPlayerVolume, stereoPosition);
- check(result);
- if (state != SL_PLAYSTATE_STOPPED) {
- result = (*p->mPlayerSeek)->SetPosition(p->mPlayerSeek, 0, SL_SEEKMODE_FAST);
- check(result);
- }
- result = (*p->mPlayerPlay)->SetPlayState(p->mPlayerPlay, SL_PLAYSTATE_PLAYING);
- check(result);
- }
- if ((playTimeInMilliseconds > 0) && ((playTimeInMilliseconds -= delay) < 0))
- break;
- }
-
- for (i = 0; i < numPlayers; ++i) {
- SLObjectItf playerObject = players[i].mPlayerObject;
- (*playerObject)->Destroy(playerObject);
- }
- (*mixObject)->Destroy(mixObject);
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/multithread.c b/wilhelm/tests/sandbox/multithread.c
deleted file mode 100644
index b161656..0000000
--- a/wilhelm/tests/sandbox/multithread.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Multiple threads create and destroy objects
-
-#include <SLES/OpenSLES.h>
-#include <assert.h>
-#include <pthread.h>
-//#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-typedef struct {
- SLuint32 mObjectID;
- SLchar *mURI;
- SLEngineItf mEngineEngine;
- SLObjectItf mMixObject;
- SLuint32 mCounter;
-} ThreadArgument;
-
-volatile int timeToExit = 0;
-#define MAX_THREAD 10
-pthread_t threads[MAX_THREAD];
-ThreadArgument thread_args[MAX_THREAD];
-
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-
-void *thread_start(void *param)
-{
- //pthread_mutex_lock(&mutex);
- //pthread_mutex_unlock(&mutex);
- ThreadArgument *ta = (ThreadArgument *) param;
-
- while (!timeToExit) {
- SLresult result;
-
- ++ta->mCounter;
- switch (ta->mObjectID) {
- case SL_OBJECTID_OUTPUTMIX:
- {
- SLObjectItf myMixObject;
- result = (*ta->mEngineEngine)->CreateOutputMix(ta->mEngineEngine, &myMixObject, 0, NULL,
- NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*myMixObject)->Realize(myMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- (*myMixObject)->Destroy(myMixObject);
- }
- break;
-
- case SL_OBJECTID_AUDIOPLAYER:
- {
- SLDataLocator_URI locURI = {SL_DATALOCATOR_URI, ta->mURI};
- SLDataFormat_MIME dfMIME = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
- SLDataSource audioSrc = {&locURI, &dfMIME};
- SLDataLocator_OutputMix locOutputMix = {SL_DATALOCATOR_OUTPUTMIX, ta->mMixObject};
- SLDataSink audioSnk = {&locOutputMix, NULL};
- SLObjectItf myPlayerObject;
- result = (*ta->mEngineEngine)->CreateAudioPlayer(ta->mEngineEngine, &myPlayerObject,
- &audioSrc, &audioSnk, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*myPlayerObject)->Realize(myPlayerObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- SLPlayItf playerPlay;
- result = (*myPlayerObject)->GetInterface(myPlayerObject, SL_IID_PLAY, &playerPlay);
- assert(SL_RESULT_SUCCESS == result);
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PAUSED);
- assert(SL_RESULT_SUCCESS == result);
- usleep(1000 + (rand() & 0xFFF));
- //usleep(1000);
- //sleep(1);
- (*myPlayerObject)->Destroy(myPlayerObject);
- }
- break;
-
- default:
- break;
-
- }
- //usleep(100000);
- //break;
- }
-
- return NULL;
-}
-
-
-//const char * const uris[4] = {"wav/frog.wav", "wav/bach.wav", "wav/8days.wav", "wav/help16.wav"};
-const char * const uris[4] = {"wav/frog.wav", "wav/frog.wav", "wav/frog.wav", "wav/frog.wav"};
-
-// Main program
-
-int main(int argc, char **argv)
-{
- SLresult result;
-
- // create engine
- SLObjectItf engineObject;
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // create output mix
- SLObjectItf mixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &mixObject, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*mixObject)->Realize(mixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // create threads
- int i;
- int ok;
- for (i = 0; i < MAX_THREAD; ++i) {
- ThreadArgument *ta = &thread_args[i];
- int r = rand();
- switch (r & 1) {
-#if 0
- case 0:
- ta->mObjectID = SL_OBJECTID_OUTPUTMIX;
- ta->mURI = NULL;
- ta->mEngineEngine = engineEngine;
- ta->mMixObject = NULL;
- ta->mCounter = 0;
- break;
- case 1:
-#endif
- default:
- ta->mObjectID = SL_OBJECTID_AUDIOPLAYER;
- ta->mURI = (SLchar *) uris[(r >> 1) & 3];
- ta->mEngineEngine = engineEngine;
- ta->mMixObject = mixObject;
- ta->mCounter = 0;
- break;
- }
- //pthread_mutex_lock(&mutex);
- //pthread_mutex_unlock(&mutex);
- ok = pthread_create(&threads[i], (const pthread_attr_t *) NULL, thread_start,
- &thread_args[i]);
- assert(0 == ok);
- }
-
- // let it run for a while
- int j;
- for (j = 0; j < 100; ++j) {
- sleep(1);
- for (i = 0; i < MAX_THREAD; ++i) {
- ThreadArgument *ta = &thread_args[i];
- printf("[%d]=%u ", j, ta->mCounter);
- }
- printf("\n");
- }
-
- // signal threads that they should exit
- timeToExit = 1;
-
- for (j = 0; j < 3; ++j) {
- sleep(1);
- for (i = 0; i < MAX_THREAD; ++i) {
- ThreadArgument *ta = &thread_args[i];
- printf("[%d]=%u ", j, ta->mCounter);
- }
- printf("\n");
- }
-
- // now wait for the threads to actually exit
- for (i = 0; i < MAX_THREAD; ++i) {
- ok = pthread_join(threads[i], NULL);
- assert(0 == ok);
- }
-
- // tear down objects
- (*mixObject)->Destroy(mixObject);
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/nativewindow.cpp b/wilhelm/tests/sandbox/nativewindow.cpp
deleted file mode 100644
index 21eb0f3..0000000
--- a/wilhelm/tests/sandbox/nativewindow.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Copied from frameworks/base/cmds/stagefright/stream.cpp
-
-// Note to NDK developers who happen to see this: this module uses Android internal platform APIs
-// that are not part of the NDK supported APIs, and are subject to change at any time.
-
-#include <binder/ProcessState.h>
-#include <surfaceflinger/ISurfaceComposer.h>
-#include <surfaceflinger/SurfaceComposerClient.h>
-#include <utils/String8.h>
-
-#include "nativewindow.h"
-
-#if 1
-#include <assert.h>
-#define CHECK assert
-#define CHECK_EQ(a,b) CHECK((a)==(b))
-#else
-#include <media/stagefright/foundation/ADebug.h>
-#endif
-
-namespace android {
-
-sp<Surface> gSurface;
-sp<SurfaceComposerClient> gComposerClient;
-sp<SurfaceControl> gControl;
-
-ANativeWindow *getNativeWindow_()
-{
-#if 0
- android::ProcessState::self()->startThreadPool();
-#endif
-
- sp<SurfaceComposerClient> composerClient = new SurfaceComposerClient;
- CHECK_EQ(composerClient->initCheck(), (status_t)OK);
-
- sp<SurfaceControl> control =
- composerClient->createSurface(
- String8("A Surface"),
- 0,
- 1280,
- 800,
- PIXEL_FORMAT_RGB_565,
- 0);
-
- CHECK(control != NULL);
- CHECK(control->isValid());
-
- SurfaceComposerClient::openGlobalTransaction();
- CHECK_EQ(control->setLayer(30000), (status_t)OK);
- CHECK_EQ(control->show(), (status_t)OK);
- SurfaceComposerClient::closeGlobalTransaction();
-
- sp<Surface> surface = control->getSurface();
- CHECK(surface != NULL);
-
- gSurface = surface;
- gComposerClient = composerClient;
- gControl = control;
- // composerClient->dispose() at exit
- return surface.get();
-}
-
-} // namespace android
-
-ANativeWindow *getNativeWindow()
-{
- return android::getNativeWindow_();
-}
diff --git a/wilhelm/tests/sandbox/nativewindow.h b/wilhelm/tests/sandbox/nativewindow.h
deleted file mode 100644
index 8903d8e..0000000
--- a/wilhelm/tests/sandbox/nativewindow.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <android/native_window_jni.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern ANativeWindow *getNativeWindow();
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/wilhelm/tests/sandbox/object.c b/wilhelm/tests/sandbox/object.c
deleted file mode 100644
index 6c44700..0000000
--- a/wilhelm/tests/sandbox/object.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <SLES/OpenSLES.h>
-#include "OpenSLESUT.h"
-
-int main(int arg, char **argv)
-{
- SLresult result;
-
- printf("Create engine\n");
- SLObjectItf engineObject;
- // create engine
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
- SLuint32 i;
- // loop through both valid and invalid object IDs
- SLuint32 objectID;
- // Test object IDs from one less than the first valid object
- // ID, up to one more than the last valid object ID. This way
- // we can test for both valid and invalid object IDs at both
- // ends. If more objects are added, be sure to update the macros.
-#define FIRST_VALID SL_OBJECTID_ENGINE
-#define LAST_VALID SL_OBJECTID_METADATAEXTRACTOR
- for (objectID = FIRST_VALID - 1; objectID <= LAST_VALID + 1; ++objectID) {
- printf("object ID %x", objectID);
- const char *string = slesutObjectIDToString(objectID);
- if (NULL != string)
- printf(" (%s)", string);
- printf(":\n");
- result = (*engineEngine)->QueryNumSupportedInterfaces(engineEngine, objectID, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- SLuint32 numSupportedInterfaces = 12345;
- result = (*engineEngine)->QueryNumSupportedInterfaces(engineEngine, objectID,
- &numSupportedInterfaces);
- SLInterfaceID interfaceID;
- if (SL_RESULT_FEATURE_UNSUPPORTED == result) {
- printf(" unsupported\n");
- result = (*engineEngine)->QuerySupportedInterfaces(engineEngine, objectID, 0,
- &interfaceID);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == interfaceID);
- continue;
- }
- assert(SL_RESULT_SUCCESS == result);
- printf("numSupportedInterfaces %u\n", numSupportedInterfaces);
- for (i = 0; i < numSupportedInterfaces + 1; ++i) {
- result = (*engineEngine)->QuerySupportedInterfaces(engineEngine, objectID, i, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- result = (*engineEngine)->QuerySupportedInterfaces(engineEngine, objectID, i,
- &interfaceID);
- if (i < numSupportedInterfaces) {
- assert(SL_RESULT_SUCCESS == result);
- printf(" interface %u ", i);
- slesutPrintIID(interfaceID);
- } else {
- assert(SL_RESULT_PARAMETER_INVALID == result);
- }
- }
- }
- // query number of extensions
- result = (*engineEngine)->QueryNumSupportedExtensions(engineEngine, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- SLuint32 numExtensions = 0x12345;
- result = (*engineEngine)->QueryNumSupportedExtensions(engineEngine, &numExtensions);
- assert(SL_RESULT_SUCCESS == result);
- printf("numExtensions = %u\n", numExtensions);
- // query names of the extensions
- for (i = 0; i < numExtensions + 1; ++i) {
- SLchar extensionName[32];
- result = (*engineEngine)->QuerySupportedExtension(engineEngine, i, extensionName, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- SLint16 nameLength = -1;
- result = (*engineEngine)->QuerySupportedExtension(engineEngine, i, NULL, &nameLength);
- if (i < numExtensions) {
- assert(SL_RESULT_SUCCESS == result);
- printf(" extension[%u] length = %u\n", i, nameLength);
- } else {
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(0 == nameLength);
- }
- memset(extensionName, 'X', sizeof(extensionName));
- nameLength = -1;
- result = (*engineEngine)->QuerySupportedExtension(engineEngine, i, extensionName,
- &nameLength);
- if (i < numExtensions) {
- assert(SL_RESULT_BUFFER_INSUFFICIENT == result);
- } else {
- assert(SL_RESULT_PARAMETER_INVALID == result);
- }
- assert('X' == extensionName[0]);
- nameLength = 0;
- result = (*engineEngine)->QuerySupportedExtension(engineEngine, i, extensionName,
- &nameLength);
- if (i < numExtensions) {
- assert(SL_RESULT_BUFFER_INSUFFICIENT == result);
- } else {
- assert(SL_RESULT_PARAMETER_INVALID == result);
- }
- assert('X' == extensionName[0]);
- nameLength = 1;
- result = (*engineEngine)->QuerySupportedExtension(engineEngine, i, extensionName,
- &nameLength);
- if (i < numExtensions) {
- assert(SL_RESULT_BUFFER_INSUFFICIENT == result);
- assert('\0' == extensionName[0]);
- } else {
- assert(SL_RESULT_PARAMETER_INVALID == result);
- }
- assert('X' == extensionName[1]);
- nameLength = sizeof(extensionName);
- result = (*engineEngine)->QuerySupportedExtension(engineEngine, i, extensionName,
- &nameLength);
- if (i < numExtensions) {
- assert(SL_RESULT_SUCCESS == result);
- assert((1 <= nameLength) && (nameLength <= (SLint16) sizeof(extensionName)));
- printf(" extension[%u] = \"%.*s\"\n", i, nameLength, extensionName);
- } else {
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(0 == nameLength);
- }
- }
- // check if extension is supported
- SLboolean isSupported = SL_BOOLEAN_TRUE;
- result = (*engineEngine)->IsExtensionSupported(engineEngine, NULL, &isSupported);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(SL_BOOLEAN_FALSE == isSupported);
- SLchar *unsupportedExt = (SLchar *) "fish";
- result = (*engineEngine)->IsExtensionSupported(engineEngine, unsupportedExt, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- isSupported = SL_BOOLEAN_TRUE;
- result = (*engineEngine)->IsExtensionSupported(engineEngine, unsupportedExt, &isSupported);
- assert(SL_RESULT_SUCCESS == result);
- assert(SL_BOOLEAN_FALSE == isSupported);
- SLchar *supportedExt;
-#ifdef ANDROID
- // whereas the implementation uses PLATFORM_SDK_VERSION, use a hard-coded value here
- // so that we're actually testing for a particular expected value
- supportedExt = (SLchar *) "ANDROID_SDK_LEVEL_13";
-#else
- supportedExt = (SLchar *) "WILHELM_DESKTOP";
-#endif
- isSupported = SL_BOOLEAN_FALSE;
- result = (*engineEngine)->IsExtensionSupported(engineEngine, supportedExt, &isSupported);
- assert(SL_RESULT_SUCCESS == result);
- assert(SL_BOOLEAN_TRUE == isSupported);
- // create an extension object with no place to put the new object
- result = (*engineEngine)->CreateExtensionObject(engineEngine, NULL, NULL, 0x123, 0, NULL, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- // create an extension object, which is unsupported
- SLObjectItf extensionObject;
- result = (*engineEngine)->CreateExtensionObject(engineEngine, &extensionObject, NULL, 0x123, 0,
- NULL, NULL);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == extensionObject);
- // destroy engine
- (*engineObject)->Destroy(engineObject);
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/outputmix.c b/wilhelm/tests/sandbox/outputmix.c
deleted file mode 100644
index 0e8263e..0000000
--- a/wilhelm/tests/sandbox/outputmix.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// output mix interface tests
-
-#include <SLES/OpenSLES.h>
-#include "OpenSLESUT.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main(int argc, char **argv)
-{
- // create engine
- SLObjectItf engineObject;
- SLresult result;
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- printf("Engine object %p\n", engineObject);
- // realize engine
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- // get engine interface
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
- // query supported interfaces on output mix object ID and display their IDs
- SLuint32 numSupportedInterfaces;
- result = (*engineEngine)->QueryNumSupportedInterfaces(engineEngine, SL_OBJECTID_OUTPUTMIX,
- &numSupportedInterfaces);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix supports %u interfaces:\n", numSupportedInterfaces);
- SLuint32 i;
- for (i = 0; i < numSupportedInterfaces; ++i) {
- SLInterfaceID interfaceID;
- result = (*engineEngine)->QuerySupportedInterfaces(engineEngine, SL_OBJECTID_OUTPUTMIX, i,
- &interfaceID);
- assert(SL_RESULT_SUCCESS == result);
- printf(" [%u] = ", i);
- slesutPrintIID(interfaceID);
- }
- // create output mix, with no place to put the new object
- result = (*engineEngine)->CreateOutputMix(engineEngine, NULL, 0, NULL, NULL);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- // create output mix, requesting no explicit interfaces
- SLObjectItf outputMixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix object %p\n", outputMixObject);
- // get object interface before realization
- SLObjectItf outputMixObject2;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_OBJECT, &outputMixObject2);
- assert(SL_RESULT_SUCCESS == result);
- assert(outputMixObject2 == outputMixObject);
- // get any other interface before realization should fail
- SLOutputMixItf outputMixOutputMix;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_OUTPUTMIX,
- &outputMixOutputMix);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
- // realize the output mix
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- // get each expected implicit interface
- outputMixObject2 = NULL;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_OBJECT, &outputMixObject2);
- assert(SL_RESULT_SUCCESS == result);
- assert(outputMixObject2 == outputMixObject);
- SLDynamicInterfaceManagementItf outputMixDynamicInterfaceManagement;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_DYNAMICINTERFACEMANAGEMENT,
- &outputMixDynamicInterfaceManagement);
- assert((SL_RESULT_SUCCESS == result) || (SL_RESULT_FEATURE_UNSUPPORTED) == result);
- if (SL_RESULT_SUCCESS == result) {
- printf("Output mix supports dynamic interface management\n");
- } else {
- printf("Output mix does not support dynamic interface management\n");
- }
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_OUTPUTMIX,
- &outputMixOutputMix);
- assert(SL_RESULT_SUCCESS == result);
- // get explicit and optional interfaces should fail since not requested at creation
- SLEnvironmentalReverbItf outputMixEnvironmentalReverb;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- SLEqualizerItf outputMixEqualizer;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_EQUALIZER,
- &outputMixEqualizer);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- SLPresetReverbItf outputMixPresetReverb;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_PRESETREVERB,
- &outputMixPresetReverb);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- SLVirtualizerItf outputMixVirtualizer;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_VIRTUALIZER,
- &outputMixVirtualizer);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- SLVolumeItf outputMixVolume;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_VOLUME,
- &outputMixVolume);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- SLBassBoostItf outputMixBassBoost;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_BASSBOOST,
- &outputMixBassBoost);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- SLVisualizationItf outputMixVisualization;
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_VISUALIZATION,
- &outputMixVisualization);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- // destroy output mix
- (*outputMixObject)->Destroy(outputMixObject);
- // re-create output mix, this time requesting implicit interfaces as "hard" requirements (must
- // be there), and explicit interfaces as "soft" requirements (OK if not available)
- SLInterfaceID ids[10] = {SL_IID_OBJECT, SL_IID_DYNAMICINTERFACEMANAGEMENT, SL_IID_OUTPUTMIX,
- SL_IID_ENVIRONMENTALREVERB, SL_IID_EQUALIZER, SL_IID_PRESETREVERB, SL_IID_VIRTUALIZER,
- SL_IID_VOLUME, SL_IID_BASSBOOST, SL_IID_VISUALIZATION};
- SLboolean req[10] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_FALSE /*SL_BOOLEAN_TRUE*/, SL_BOOLEAN_TRUE,
- SL_BOOLEAN_TRUE/*FALSE*/, SL_BOOLEAN_FALSE, SL_BOOLEAN_FALSE, SL_BOOLEAN_FALSE,
- SL_BOOLEAN_FALSE, SL_BOOLEAN_FALSE, SL_BOOLEAN_FALSE};
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 10, ids, req);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix object %p\n", outputMixObject);
- // realize the output mix
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- // get implicit interfaces
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_OBJECT,
- &outputMixObject2);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_DYNAMICINTERFACEMANAGEMENT,
- &outputMixDynamicInterfaceManagement);
- assert((SL_RESULT_SUCCESS == result) || (SL_RESULT_FEATURE_UNSUPPORTED) == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_OUTPUTMIX,
- &outputMixOutputMix);
- assert(SL_RESULT_SUCCESS == result);
- // get explicit and optional interfaces should succeed since they were requested at creation
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_EQUALIZER,
- &outputMixEqualizer);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_PRESETREVERB,
- &outputMixPresetReverb);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_VIRTUALIZER,
- &outputMixVirtualizer);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_VOLUME,
- &outputMixVolume);
- assert((SL_RESULT_SUCCESS == result) || (SL_RESULT_FEATURE_UNSUPPORTED) == result);
- if (SL_RESULT_SUCCESS == result) {
- printf("Output mix supports volume\n");
- } else {
- printf("Output mix does not support volume\n");
- }
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_BASSBOOST,
- &outputMixBassBoost);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_VISUALIZATION,
- &outputMixVisualization);
- assert((SL_RESULT_SUCCESS == result) || (SL_RESULT_FEATURE_UNSUPPORTED) == result);
- if (SL_RESULT_SUCCESS == result) {
- printf("Output mix supports visualization\n");
- } else {
- printf("Output mix does not support visualization\n");
- }
- // use the OutputMix interface on output mix object, in order to get code coverage
- SLint32 numDevices = 1;
- SLuint32 deviceIDs[1];
- result = (*outputMixOutputMix)->GetDestinationOutputDeviceIDs(outputMixOutputMix, &numDevices,
- deviceIDs);
- assert(SL_RESULT_SUCCESS == result);
- assert(1 == numDevices);
- assert(SL_DEFAULTDEVICEID_AUDIOOUTPUT == deviceIDs[0]);
- result = (*outputMixOutputMix)->RegisterDeviceChangeCallback(outputMixOutputMix, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixOutputMix)->ReRoute(outputMixOutputMix, 1, deviceIDs);
- assert(SL_RESULT_SUCCESS == result);
- // destroy output mix
- (*outputMixObject)->Destroy(outputMixObject);
- // destroy engine
- (*engineObject)->Destroy(engineObject);
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/playbq.c b/wilhelm/tests/sandbox/playbq.c
deleted file mode 100644
index aaa72f1..0000000
--- a/wilhelm/tests/sandbox/playbq.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Play an audio file using buffer queue
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include "sndfile.h"
-#else
-#include <sndfile.h>
-#endif
-
-unsigned numBuffers = 2;
-int framesPerBuffer = 512;
-SNDFILE *sndfile;
-SF_INFO sfinfo;
-unsigned which; // which buffer to use next
-SLboolean eof; // whether we have hit EOF on input yet
-short *buffers;
-SLuint32 byteOrder; // desired to use for PCM buffers
-SLuint32 nativeByteOrder; // of platform
-SLuint32 bitsPerSample = 16;
-
-// swap adjacent bytes; this would normally be in <unistd.h> but is missing here
-static void swab(const void *from, void *to, ssize_t n)
-{
- // from and to as char pointers
- const char *from_ch = (const char *) from;
- char *to_ch = (char *) to;
- // note that we don't swap the last odd byte
- while (n >= 2) {
- to_ch[0] = from_ch[1];
- to_ch[1] = from_ch[0];
- to_ch += 2;
- from_ch += 2;
- n -= 2;
- }
-}
-
-// squeeze 16-bit signed PCM samples down to 8-bit unsigned PCM samples by truncation; no dithering
-static void squeeze(const short *from, unsigned char *to, ssize_t n)
-{
- // note that we don't squeeze the last odd byte
- while (n >= 2) {
- *to++ = (*from++ + 32768) >> 8;
- n -= 2;
- }
-}
-
-// This callback is called each time a buffer finishes playing
-
-static void callback(SLBufferQueueItf bufq, void *param)
-{
- assert(NULL == param);
- if (!eof) {
- short *buffer = &buffers[framesPerBuffer * sfinfo.channels * which];
- sf_count_t count;
- count = sf_readf_short(sndfile, buffer, (sf_count_t) framesPerBuffer);
- if (0 >= count) {
- eof = SL_BOOLEAN_TRUE;
- } else {
- SLuint32 nbytes = count * sfinfo.channels * sizeof(short);
- if (byteOrder != nativeByteOrder) {
- swab(buffer, buffer, nbytes);
- }
- if (bitsPerSample == 8) {
- squeeze(buffer, (unsigned char *) buffer, nbytes);
- nbytes /= 2;
- }
- SLresult result = (*bufq)->Enqueue(bufq, buffer, nbytes);
- assert(SL_RESULT_SUCCESS == result);
- if (++which >= numBuffers)
- which = 0;
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- // Determine the native byte order (SL_BYTEORDER_NATIVE not available until 1.1)
- union {
- short s;
- char c[2];
- } u;
- u.s = 0x1234;
- if (u.c[0] == 0x34) {
- nativeByteOrder = SL_BYTEORDER_LITTLEENDIAN;
- } else if (u.c[0] == 0x12) {
- nativeByteOrder = SL_BYTEORDER_BIGENDIAN;
- } else {
- fprintf(stderr, "Unable to determine native byte order\n");
- return EXIT_FAILURE;
- }
- byteOrder = nativeByteOrder;
-
- SLboolean enableReverb = SL_BOOLEAN_FALSE;
- SLpermille rate = 1000;
-
- // process command-line options
- int i;
- for (i = 1; i < argc; ++i) {
- char *arg = argv[i];
- if (arg[0] != '-')
- break;
- if (!strcmp(arg, "-b")) {
- byteOrder = SL_BYTEORDER_BIGENDIAN;
- } else if (!strcmp(arg, "-l")) {
- byteOrder = SL_BYTEORDER_LITTLEENDIAN;
- } else if (!strcmp(arg, "-8")) {
- bitsPerSample = 8;
- } else if (!strncmp(arg, "-f", 2)) {
- framesPerBuffer = atoi(&arg[2]);
- } else if (!strncmp(arg, "-n", 2)) {
- numBuffers = atoi(&arg[2]);
- } else if (!strncmp(arg, "-p", 2)) {
- rate = atoi(&arg[2]);
- } else if (!strcmp(arg, "-r")) {
- enableReverb = SL_BOOLEAN_TRUE;
- } else {
- fprintf(stderr, "option %s ignored\n", arg);
- }
- }
-
- if (argc - i != 1) {
- fprintf(stderr, "usage: [-b/l] [-8] [-f#] [-n#] [-p#] [-r] %s filename\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- const char *filename = argv[i];
- //memset(&sfinfo, 0, sizeof(SF_INFO));
- sfinfo.format = 0;
- sndfile = sf_open(filename, SFM_READ, &sfinfo);
- if (NULL == sndfile) {
- perror(filename);
- return EXIT_FAILURE;
- }
-
- // verify the file format
- switch (sfinfo.channels) {
- case 1:
- case 2:
- break;
- default:
- fprintf(stderr, "unsupported channel count %d\n", sfinfo.channels);
- break;
- }
- switch (sfinfo.samplerate) {
- case 8000:
- case 11025:
- case 12000:
- case 16000:
- case 22050:
- case 24000:
- case 32000:
- case 44100:
- case 48000:
- break;
- default:
- fprintf(stderr, "unsupported sample rate %d\n", sfinfo.samplerate);
- break;
- }
- switch (sfinfo.format & SF_FORMAT_TYPEMASK) {
- case SF_FORMAT_WAV:
- break;
- default:
- fprintf(stderr, "unsupported format type 0x%x\n", sfinfo.format & SF_FORMAT_TYPEMASK);
- break;
- }
- switch (sfinfo.format & SF_FORMAT_SUBMASK) {
- case SF_FORMAT_PCM_16:
- case SF_FORMAT_PCM_U8:
- case SF_FORMAT_ULAW:
- case SF_FORMAT_ALAW:
- case SF_FORMAT_IMA_ADPCM:
- break;
- default:
- fprintf(stderr, "unsupported sub-format 0x%x\n", sfinfo.format & SF_FORMAT_SUBMASK);
- break;
- }
-
- buffers = (short *) malloc(framesPerBuffer * sfinfo.channels * sizeof(short) * numBuffers);
-
- // create engine
- SLresult result;
- SLObjectItf engineObject;
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // create output mix
- SLObjectItf outputMixObject;
- SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB};
- SLboolean req[1] = {SL_BOOLEAN_TRUE};
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, enableReverb ? 1 : 0,
- ids, req);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // configure environmental reverb on output mix
- SLEnvironmentalReverbItf mixEnvironmentalReverb = NULL;
- if (enableReverb) {
- result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
- &mixEnvironmentalReverb);
- assert(SL_RESULT_SUCCESS == result);
- SLEnvironmentalReverbSettings settings = SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;
- result = (*mixEnvironmentalReverb)->SetEnvironmentalReverbProperties(mixEnvironmentalReverb,
- &settings);
- assert(SL_RESULT_SUCCESS == result);
- }
-
- // configure audio source
- SLDataLocator_BufferQueue loc_bufq;
- loc_bufq.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
- loc_bufq.numBuffers = numBuffers;
- SLDataFormat_PCM format_pcm;
- format_pcm.formatType = SL_DATAFORMAT_PCM;
- format_pcm.numChannels = sfinfo.channels;
- format_pcm.samplesPerSec = sfinfo.samplerate * 1000;
- format_pcm.bitsPerSample = bitsPerSample;
- format_pcm.containerSize = format_pcm.bitsPerSample;
- format_pcm.channelMask = 1 == format_pcm.numChannels ? SL_SPEAKER_FRONT_CENTER :
- SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- format_pcm.endianness = byteOrder;
- SLDataSource audioSrc;
- audioSrc.pLocator = &loc_bufq;
- audioSrc.pFormat = &format_pcm;
-
- // configure audio sink
- SLDataLocator_OutputMix loc_outmix;
- loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- loc_outmix.outputMix = outputMixObject;
- SLDataSink audioSnk;
- audioSnk.pLocator = &loc_outmix;
- audioSnk.pFormat = NULL;
-
- // create audio player
- SLInterfaceID ids2[3] = {SL_IID_BUFFERQUEUE, SL_IID_PLAYBACKRATE, SL_IID_EFFECTSEND};
- SLboolean req2[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
- SLObjectItf playerObject;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, enableReverb ? 3 : 2, ids2, req2);
- assert(SL_RESULT_SUCCESS == result);
-
- // realize the player
- result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the effect send interface and enable effect send reverb for this player
- if (enableReverb) {
- SLEffectSendItf playerEffectSend;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_EFFECTSEND, &playerEffectSend);
- assert(SL_RESULT_SUCCESS == result);
- result = (*playerEffectSend)->EnableEffectSend(playerEffectSend, mixEnvironmentalReverb,
- SL_BOOLEAN_TRUE, (SLmillibel) 0);
- assert(SL_RESULT_SUCCESS == result);
- }
-
- // get the playback rate interface and configure the rate
- SLPlaybackRateItf playerPlaybackRate;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAYBACKRATE, &playerPlaybackRate);
- assert(SL_RESULT_SUCCESS == result);
- SLpermille defaultRate;
- result = (*playerPlaybackRate)->GetRate(playerPlaybackRate, &defaultRate);
- assert(SL_RESULT_SUCCESS == result);
- SLuint32 defaultProperties;
- result = (*playerPlaybackRate)->GetProperties(playerPlaybackRate, &defaultProperties);
- assert(SL_RESULT_SUCCESS == result);
- printf("default playback rate %d per mille, properties 0x%x\n", defaultRate, defaultProperties);
- if (rate != defaultRate) {
- result = (*playerPlaybackRate)->SetRate(playerPlaybackRate, rate);
- if (SL_RESULT_FEATURE_UNSUPPORTED == result) {
- fprintf(stderr, "playback rate %d is unsupported\n", rate);
- } else if (SL_RESULT_PARAMETER_INVALID == result) {
- fprintf(stderr, "playback rate %d is invalid", rate);
- } else {
- assert(SL_RESULT_SUCCESS == result);
- }
- }
-
- // get the play interface
- SLPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the buffer queue interface
- SLBufferQueueItf playerBufferQueue;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_BUFFERQUEUE,
- &playerBufferQueue);
- assert(SL_RESULT_SUCCESS == result);
-
- // loop until EOF or no more buffers
- for (which = 0; which < numBuffers; ++which) {
- short *buffer = &buffers[framesPerBuffer * sfinfo.channels * which];
- sf_count_t frames = framesPerBuffer;
- sf_count_t count;
- count = sf_readf_short(sndfile, buffer, frames);
- if (0 >= count) {
- eof = SL_BOOLEAN_TRUE;
- break;
- }
-
- // enqueue a buffer
- SLuint32 nbytes = count * sfinfo.channels * sizeof(short);
- if (byteOrder != nativeByteOrder) {
- swab(buffer, buffer, nbytes);
- }
- if (bitsPerSample == 8) {
- squeeze(buffer, (unsigned char *) buffer, nbytes);
- nbytes /= 2;
- }
- result = (*playerBufferQueue)->Enqueue(playerBufferQueue, buffer, nbytes);
- assert(SL_RESULT_SUCCESS == result);
- }
- if (which >= numBuffers)
- which = 0;
-
- // register a callback on the buffer queue
- result = (*playerBufferQueue)->RegisterCallback(playerBufferQueue, callback, NULL);
- assert(SL_RESULT_SUCCESS == result);
-
- // set the player's state to playing
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
- assert(SL_RESULT_SUCCESS == result);
-
- // wait until the buffer queue is empty
- SLBufferQueueState bufqstate;
- for (;;) {
- result = (*playerBufferQueue)->GetState(playerBufferQueue, &bufqstate);
- assert(SL_RESULT_SUCCESS == result);
- if (0 >= bufqstate.count) {
- break;
- }
- sleep(1);
- }
-
- // destroy audio player
- (*playerObject)->Destroy(playerObject);
-
- // destroy output mix
- (*outputMixObject)->Destroy(outputMixObject);
-
- // destroy engine
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/reverb.c b/wilhelm/tests/sandbox/reverb.c
deleted file mode 100644
index 86ea668..0000000
--- a/wilhelm/tests/sandbox/reverb.c
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Demonstrate environmental reverb and preset reverb on an output mix and audio player
-
-#include <SLES/OpenSLES.h>
-#include <assert.h>
-#include <pthread.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#define bool int
-#define false 0
-#define true 1
-
-// Table of I3DL2 named environmental reverb settings
-
-typedef struct {
- const char *mName;
- SLEnvironmentalReverbSettings mSettings;
-} Pair;
-
-#define _(name) {#name, SL_I3DL2_ENVIRONMENT_PRESET_##name},
-
-Pair pairs[] = {
- _(DEFAULT)
- _(GENERIC)
- _(PADDEDCELL)
- _(ROOM)
- _(BATHROOM)
- _(LIVINGROOM)
- _(STONEROOM)
- _(AUDITORIUM)
- _(CONCERTHALL)
- _(CAVE)
- _(ARENA)
- _(HANGAR)
- _(CARPETEDHALLWAY)
- _(HALLWAY)
- _(STONECORRIDOR)
- _(ALLEY)
- _(FOREST)
- _(CITY)
- _(MOUNTAINS)
- _(QUARRY)
- _(PLAIN)
- _(PARKINGLOT)
- _(SEWERPIPE)
- _(UNDERWATER)
- _(SMALLROOM)
- _(MEDIUMROOM)
- _(LARGEROOM)
- _(MEDIUMHALL)
- _(LARGEHALL)
- _(PLATE)
-};
-
-// Parameters for preset reverb on output mix
-bool outputMixPresetItfRequested = false;
-SLuint16 outputMixPresetNumber = ~0;
-
-// Parameters for environmental reverb on output mix
-bool outputMixEnvironmentalItfRequested = false;
-char *outputMixEnvironmentalName = NULL;
-SLEnvironmentalReverbSettings outputMixEnvironmentalSettings;
-
-// Parameters for preset reverb on audio player (not supported)
-bool playerPresetItfRequested = false;
-SLuint16 playerPresetNumber = ~0;
-
-// Parameters for environmental reverb on audio player (not supported)
-bool playerEnvironmentalItfRequested = false;
-char *playerEnvironmentalName = NULL;
-SLEnvironmentalReverbSettings playerEnvironmentalSettings;
-
-// Compare two environmental reverb settings structures.
-// Returns true if the settings are identical, or false if they are different.
-
-bool slesutCompareEnvironmentalReverbSettings(
- const SLEnvironmentalReverbSettings *settings1,
- const SLEnvironmentalReverbSettings *settings2)
-{
- return
- (settings1->roomLevel == settings2->roomLevel) &&
- (settings1->roomHFLevel == settings2->roomHFLevel) &&
- (settings1->decayTime == settings2->decayTime) &&
- (settings1->decayHFRatio == settings2->decayHFRatio) &&
- (settings1->reflectionsLevel == settings2->reflectionsLevel) &&
- (settings1->reflectionsDelay == settings2->reflectionsDelay) &&
- (settings1->reverbLevel == settings2->reverbLevel) &&
- (settings1->reverbDelay == settings2->reverbDelay) &&
- (settings1->diffusion == settings2->diffusion) &&
- (settings1->density == settings2->density);
-}
-
-// Print an environmental reverb settings structure.
-
-void slesutPrintEnvironmentalReverbSettings(const SLEnvironmentalReverbSettings *settings)
-{
- printf("roomLevel: %d\n", settings->roomLevel);
- printf("roomHFLevel: %d\n", settings->roomHFLevel);
- printf("decayTime: %d\n", settings->decayTime);
- printf("decayHFRatio: %d\n", settings->decayHFRatio);
- printf("reflectionsLevel: %d\n", settings->reflectionsLevel);
- printf("reflectionsDelay: %d\n", settings->reflectionsDelay);
- printf("reverbLevel: %d\n", settings->reverbLevel);
- printf("reverbDelay: %d\n", settings->reverbDelay);
- printf("diffusion: %d\n", settings->diffusion);
- printf("density: %d\n", settings->density);
-}
-
-// Lookup environmental reverb settings by name
-
-const SLEnvironmentalReverbSettings *lookupEnvName(const char *name)
-{
- unsigned j;
- for (j = 0; j < sizeof(pairs) / sizeof(pairs[0]); ++j) {
- if (!strcasecmp(name, pairs[j].mName)) {
- return &pairs[j].mSettings;
- }
- }
- return NULL;
-}
-
-// Print all available environmental reverb names
-
-void printEnvNames(void)
-{
- unsigned j;
- bool needSpace = false;
- bool needNewline = false;
- unsigned lineLen = 0;
- for (j = 0; j < sizeof(pairs) / sizeof(pairs[0]); ++j) {
- const char *name = pairs[j].mName;
- unsigned nameLen = strlen(name);
- if (lineLen + (needSpace ? 1 : 0) + nameLen > 72) {
- putchar('\n');
- needSpace = false;
- needNewline = false;
- lineLen = 0;
- }
- if (needSpace) {
- putchar(' ');
- ++lineLen;
- }
- fputs(name, stdout);
- lineLen += nameLen;
- needSpace = true;
- needNewline = true;
- }
- if (needNewline) {
- putchar('\n');
- }
-}
-
-// These are extensions to OpenSL ES 1.0.1 values
-
-#define SL_PREFETCHSTATUS_UNKNOWN 0
-#define SL_PREFETCHSTATUS_ERROR (-1)
-
-// Mutex and condition shared with main program to protect prefetch_status
-
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-SLuint32 prefetch_status = SL_PREFETCHSTATUS_UNKNOWN;
-
-/* used to detect errors likely to have occured when the OpenSL ES framework fails to open
- * a resource, for instance because a file URI is invalid, or an HTTP server doesn't respond.
- */
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-// Prefetch status callback
-
-void prefetch_callback(SLPrefetchStatusItf caller, void *context, SLuint32 event)
-{
- SLresult result;
- assert(context == NULL);
- SLpermille level;
- result = (*caller)->GetFillLevel(caller, &level);
- assert(SL_RESULT_SUCCESS == result);
- SLuint32 status;
- result = (*caller)->GetPrefetchStatus(caller, &status);
- assert(SL_RESULT_SUCCESS == result);
- SLuint32 new_prefetch_status;
- if ((event & PREFETCHEVENT_ERROR_CANDIDATE) == PREFETCHEVENT_ERROR_CANDIDATE
- && level == 0 && status == SL_PREFETCHSTATUS_UNDERFLOW) {
- new_prefetch_status = SL_PREFETCHSTATUS_ERROR;
- } else if (event == SL_PREFETCHEVENT_STATUSCHANGE &&
- status == SL_PREFETCHSTATUS_SUFFICIENTDATA) {
- new_prefetch_status = status;
- } else {
- return;
- }
- int ok;
- ok = pthread_mutex_lock(&mutex);
- assert(ok == 0);
- prefetch_status = new_prefetch_status;
- ok = pthread_cond_signal(&cond);
- assert(ok == 0);
- ok = pthread_mutex_unlock(&mutex);
- assert(ok == 0);
-}
-
-// Main program
-
-int main(int argc, char **argv)
-{
- SLresult result;
- bool loop = false;
-
- // process command line parameters
- char *prog = argv[0];
- int i;
- for (i = 1; i < argc; ++i) {
- char *arg = argv[i];
- if (arg[0] != '-')
- break;
- bool bad = false; // whether the option string is invalid
- if (!strncmp(arg, "--mix-preset", 12)) {
- if ('\0' == arg[12]) {
- outputMixPresetItfRequested = true;
- } else if ('=' == arg[12]) {
- outputMixPresetNumber = atoi(&arg[13]);
- outputMixPresetItfRequested = true;
- } else {
- bad = true;
- }
- } else if (!strncmp(arg, "--mix-name", 10)) {
- if ('\0' == arg[10]) {
- outputMixEnvironmentalItfRequested = true;
- } else if ('=' == arg[10]) {
- outputMixEnvironmentalName = &arg[11];
- outputMixEnvironmentalItfRequested = true;
- } else {
- bad = true;
- }
- } else if (!strncmp(arg, "--player-preset", 15)) {
- if ('\0' == arg[15]) {
- playerPresetItfRequested = true;
- } else if ('=' == arg[15]) {
- playerPresetNumber = atoi(&arg[16]);
- playerPresetItfRequested = true;
- } else {
- bad = true;
- }
- } else if (!strncmp(arg, "--player-name", 13)) {
- if ('\0' == arg[13]) {
- playerEnvironmentalItfRequested = true;
- } else if ('=' == arg[13]) {
- playerEnvironmentalName = &arg[14];
- playerEnvironmentalItfRequested = true;
- } else {
- bad = true;
- }
- } else if (!strcmp(arg, "--loop")) {
- loop = true;
- } else {
- bad = true;
- }
- if (bad) {
- fprintf(stderr, "%s: unknown option %s ignored\n", prog, arg);
- }
- }
- if (argc - i != 1) {
- fprintf(stderr, "usage: %s --mix-preset=# --mix-name=I3DL2 --player-preset=# "
- "--player-name=I3DL2 --loop filename\n", prog);
- return EXIT_FAILURE;
- }
- char *pathname = argv[i];
-
- const SLEnvironmentalReverbSettings *envSettings;
- if (NULL != outputMixEnvironmentalName) {
- envSettings = lookupEnvName(outputMixEnvironmentalName);
- if (NULL == envSettings) {
- fprintf(stderr, "%s: output mix environmental reverb name %s not found, "
- "available names are:\n", prog, outputMixEnvironmentalName);
- printEnvNames();
- return EXIT_FAILURE;
- }
- outputMixEnvironmentalSettings = *envSettings;
- }
- if (NULL != playerEnvironmentalName) {
- envSettings = lookupEnvName(playerEnvironmentalName);
- if (NULL == envSettings) {
- fprintf(stderr, "%s: player environmental reverb name %s not found, "
- "available names are:\n", prog, playerEnvironmentalName);
- printEnvNames();
- return EXIT_FAILURE;
- }
- playerEnvironmentalSettings = *envSettings;
- }
-
- // create engine
- SLObjectItf engineObject;
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // create output mix
- SLInterfaceID mix_ids[2];
- SLboolean mix_req[2];
- SLuint32 count = 0;
- if (outputMixPresetItfRequested) {
- mix_req[count] = SL_BOOLEAN_TRUE;
- mix_ids[count++] = SL_IID_PRESETREVERB;
- }
- if (outputMixEnvironmentalItfRequested) {
- mix_req[count] = SL_BOOLEAN_TRUE;
- mix_ids[count++] = SL_IID_ENVIRONMENTALREVERB;
- }
- SLObjectItf mixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &mixObject, count, mix_ids, mix_req);
- assert(SL_RESULT_SUCCESS == result);
- result = (*mixObject)->Realize(mixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // configure preset reverb on output mix
- SLPresetReverbItf outputMixPresetReverb;
- if (outputMixPresetItfRequested) {
- result = (*mixObject)->GetInterface(mixObject, SL_IID_PRESETREVERB, &outputMixPresetReverb);
- assert(SL_RESULT_SUCCESS == result);
- SLuint16 getPresetReverb = 12345;
- result = (*outputMixPresetReverb)->GetPreset(outputMixPresetReverb, &getPresetReverb);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix default preset reverb number = %u\n", getPresetReverb);
- if (outputMixPresetNumber != ((SLuint16) ~0)) {
- result = (*outputMixPresetReverb)->SetPreset(outputMixPresetReverb,
- outputMixPresetNumber);
- if (SL_RESULT_SUCCESS == result) {
- result = (*outputMixPresetReverb)->GetPreset(outputMixPresetReverb,
- &getPresetReverb);
- assert(SL_RESULT_SUCCESS == result);
- assert(getPresetReverb == outputMixPresetNumber);
- printf("Output mix preset reverb successfully changed to %u\n",
- outputMixPresetNumber);
- } else {
- printf("Unable to set output mix preset reverb to %u, result=%u\n",
- outputMixPresetNumber, result);
- }
- }
- }
-
- // configure environmental reverb on output mix
- SLEnvironmentalReverbItf outputMixEnvironmentalReverb;
- if (outputMixEnvironmentalItfRequested) {
- result = (*mixObject)->GetInterface(mixObject, SL_IID_ENVIRONMENTALREVERB,
- &outputMixEnvironmentalReverb);
- assert(SL_RESULT_SUCCESS == result);
- SLEnvironmentalReverbSettings getSettings;
- result = (*outputMixEnvironmentalReverb)->GetEnvironmentalReverbProperties(
- outputMixEnvironmentalReverb, &getSettings);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix default environmental reverb settings\n");
- printf("------------------------------------------------\n");
- slesutPrintEnvironmentalReverbSettings(&getSettings);
- printf("\n");
- if (outputMixEnvironmentalName != NULL) {
- result = (*outputMixEnvironmentalReverb)->SetEnvironmentalReverbProperties(
- outputMixEnvironmentalReverb, &outputMixEnvironmentalSettings);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix new environmental reverb settings\n");
- printf("--------------------------------------------\n");
- slesutPrintEnvironmentalReverbSettings(&outputMixEnvironmentalSettings);
- printf("\n");
- result = (*outputMixEnvironmentalReverb)->GetEnvironmentalReverbProperties(
- outputMixEnvironmentalReverb, &getSettings);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix read environmental reverb settings\n");
- printf("--------------------------------------------\n");
- slesutPrintEnvironmentalReverbSettings(&getSettings);
- printf("\n");
- if (!slesutCompareEnvironmentalReverbSettings(&getSettings,
- &outputMixEnvironmentalSettings)) {
- printf("Warning: new and read are different; check details above\n");
- } else {
- printf("New and read match, life is good\n");
- }
- }
- }
-
- // create audio player
- SLDataLocator_URI locURI = {SL_DATALOCATOR_URI, (SLchar *) pathname};
- SLDataFormat_MIME dfMIME = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
- SLDataSource audioSrc = {&locURI, &dfMIME};
- SLDataLocator_OutputMix locOutputMix = {SL_DATALOCATOR_OUTPUTMIX, mixObject};
- SLDataSink audioSnk = {&locOutputMix, NULL};
- SLInterfaceID player_ids[5];
- SLboolean player_req[5];
- count = 0;
- if (playerPresetItfRequested) {
- player_req[count] = SL_BOOLEAN_TRUE;
- player_ids[count++] = SL_IID_PRESETREVERB;
- }
- if (playerEnvironmentalItfRequested) {
- player_req[count] = SL_BOOLEAN_TRUE;
- player_ids[count++] = SL_IID_ENVIRONMENTALREVERB;
- }
- if (outputMixPresetItfRequested || outputMixEnvironmentalItfRequested) {
- player_req[count] = SL_BOOLEAN_TRUE;
- player_ids[count++] = SL_IID_EFFECTSEND;
- }
- if (loop) {
- player_req[count] = SL_BOOLEAN_TRUE;
- player_ids[count++] = SL_IID_SEEK;
- }
- player_req[count] = SL_BOOLEAN_TRUE;
- player_ids[count++] = SL_IID_PREFETCHSTATUS;
- SLObjectItf playerObject;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, count, player_ids, player_req);
- assert(SL_RESULT_SUCCESS == result);
-
- // realize audio player
- result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // if reverb is on output mix (aux effect), then enable it for this player
- if (outputMixPresetItfRequested || outputMixEnvironmentalItfRequested) {
- SLEffectSendItf playerEffectSend;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_EFFECTSEND, &playerEffectSend);
- assert(SL_RESULT_SUCCESS == result);
- SLboolean enabled;
- SLmillibel directLevel;
- SLmillibel sendLevel;
- if (outputMixPresetItfRequested) {
- result = (*playerEffectSend)->IsEnabled(playerEffectSend, outputMixPresetReverb,
- &enabled);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix preset reverb: player effect send default enabled = %s\n",
- enabled ? "true" : "false");
- directLevel = 12345;
- result = (*playerEffectSend)->GetDirectLevel(playerEffectSend, &directLevel);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix preset reverb: player effect send default direct level = %d\n",
- directLevel);
- sendLevel = 12345;
- result = (*playerEffectSend)->GetSendLevel(playerEffectSend, outputMixPresetReverb,
- &sendLevel);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix preset reverb: player effect send default send level = %d\n",
- sendLevel);
- if (outputMixPresetNumber != ((SLuint16) ~0)) {
- result = (*playerEffectSend)->EnableEffectSend(playerEffectSend,
- outputMixPresetReverb, SL_BOOLEAN_TRUE, (SLmillibel) 0);
- assert(SL_RESULT_SUCCESS == result);
- result = (*playerEffectSend)->IsEnabled(playerEffectSend, outputMixPresetReverb,
- &enabled);
- assert(SL_RESULT_SUCCESS == result);
- directLevel = 12345;
- result = (*playerEffectSend)->GetDirectLevel(playerEffectSend, &directLevel);
- assert(SL_RESULT_SUCCESS == result);
- sendLevel = 12345;
- result = (*playerEffectSend)->GetSendLevel(playerEffectSend, outputMixPresetReverb,
- &sendLevel);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix preset reverb: player effect send new enabled = %s, direct level"
- " = %d, send level = %d\n", enabled ? "true" : "false", directLevel, sendLevel);
- }
- }
- if (outputMixEnvironmentalItfRequested) {
- if (outputMixEnvironmentalName != NULL) {
- result = (*playerEffectSend)->IsEnabled(playerEffectSend,
- outputMixEnvironmentalReverb, &enabled);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix environmental reverb: player effect send default enabled = %s\n",
- enabled ? "true" : "false");
- directLevel = 12345;
- result = (*playerEffectSend)->GetDirectLevel(playerEffectSend, &directLevel);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix environmental reverb: player effect send default direct level"
- " = %d\n", directLevel);
- sendLevel = 12345;
- result = (*playerEffectSend)->GetSendLevel(playerEffectSend,
- outputMixEnvironmentalReverb, &sendLevel);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix environmental reverb: player effect send default send level"
- " = %d\n", sendLevel);
- result = (*playerEffectSend)->EnableEffectSend(playerEffectSend,
- outputMixEnvironmentalReverb, SL_BOOLEAN_TRUE, (SLmillibel) 0);
- assert(SL_RESULT_SUCCESS == result);
- result = (*playerEffectSend)->IsEnabled(playerEffectSend,
- outputMixEnvironmentalReverb, &enabled);
- assert(SL_RESULT_SUCCESS == result);
- directLevel = 12345;
- result = (*playerEffectSend)->GetDirectLevel(playerEffectSend, &directLevel);
- assert(SL_RESULT_SUCCESS == result);
- sendLevel = 12345;
- result = (*playerEffectSend)->GetSendLevel(playerEffectSend,
- outputMixEnvironmentalReverb, &sendLevel);
- assert(SL_RESULT_SUCCESS == result);
- printf("Output mix environmental reverb: player effect send new enabled = %s, "
- "direct level = %d, send level = %d\n", enabled ? "true" : "false",
- directLevel, sendLevel);
- }
- }
- }
-
- // configure preset reverb on player
- SLPresetReverbItf playerPresetReverb;
- if (playerPresetItfRequested) {
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PRESETREVERB,
- &playerPresetReverb);
- assert(SL_RESULT_SUCCESS == result);
- SLuint16 getPresetReverb = 12345;
- result = (*playerPresetReverb)->GetPreset(playerPresetReverb, &getPresetReverb);
- if (SL_RESULT_SUCCESS == result) {
- printf("Player default preset reverb %u\n", getPresetReverb);
- if (playerPresetNumber != ((SLuint16) ~0)) {
- result = (*playerPresetReverb)->SetPreset(playerPresetReverb, playerPresetNumber);
- if (SL_RESULT_SUCCESS == result) {
- result = (*playerPresetReverb)->GetPreset(playerPresetReverb, &getPresetReverb);
- assert(SL_RESULT_SUCCESS == result);
- assert(getPresetReverb == playerPresetNumber);
- printf("Player preset reverb successfully changed to %u\n", playerPresetNumber);
- } else {
- printf("Unable to set player preset reverb to %u, result=%u\n",
- playerPresetNumber, result);
- }
- }
- } else {
- printf("Unable to get player default preset reverb, result=%u\n", result);
- }
- }
-
- // configure environmental reverb on player
- SLEnvironmentalReverbItf playerEnvironmentalReverb;
- if (playerEnvironmentalItfRequested) {
- result = (*playerObject)->GetInterface(playerObject, SL_IID_ENVIRONMENTALREVERB,
- &playerEnvironmentalReverb);
- assert(SL_RESULT_SUCCESS == result);
- SLEnvironmentalReverbSettings getSettings;
- memset(&getSettings, 0, sizeof(getSettings));
- result = (*playerEnvironmentalReverb)->GetEnvironmentalReverbProperties(
- playerEnvironmentalReverb, &getSettings);
- if (SL_RESULT_SUCCESS == result) {
- printf("Player default environmental reverb settings\n");
- printf("--------------------------------------------\n");
- slesutPrintEnvironmentalReverbSettings(&getSettings);
- printf("\n");
- if (playerEnvironmentalName != NULL) {
- result = (*playerEnvironmentalReverb)->SetEnvironmentalReverbProperties(
- playerEnvironmentalReverb, &playerEnvironmentalSettings);
- assert(SL_RESULT_SUCCESS == result);
- printf("Player new environmental reverb settings\n");
- printf("----------------------------------------\n");
- slesutPrintEnvironmentalReverbSettings(&playerEnvironmentalSettings);
- printf("\n");
- result = (*playerEnvironmentalReverb)->GetEnvironmentalReverbProperties(
- playerEnvironmentalReverb, &getSettings);
- assert(SL_RESULT_SUCCESS == result);
- printf("Player read environmental reverb settings\n");
- printf("-----------------------------------------\n");
- slesutPrintEnvironmentalReverbSettings(&getSettings);
- printf("\n");
- if (!slesutCompareEnvironmentalReverbSettings(&getSettings,
- &playerEnvironmentalSettings)) {
- printf("Warning: new and read are different; check details above\n");
- } else {
- printf("New and read match, life is good\n");
- }
- }
- } else {
- printf("Unable to get player default environmental reverb properties, result=%u\n",
- result);
- }
- }
-
- // get the play interface
- SLPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the prefetch status interface
- SLPrefetchStatusItf playerPrefetchStatus;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PREFETCHSTATUS,
- &playerPrefetchStatus);
- assert(SL_RESULT_SUCCESS == result);
-
- // enable prefetch status callbacks
- result = (*playerPrefetchStatus)->RegisterCallback(playerPrefetchStatus, prefetch_callback,
- NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*playerPrefetchStatus)->SetCallbackEventsMask(playerPrefetchStatus,
- SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE);
- assert(SL_RESULT_SUCCESS == result);
-
- // set play state to paused to enable pre-fetch so we can get a more reliable duration
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PAUSED);
- assert(SL_RESULT_SUCCESS == result);
-
- // wait for prefetch status callback to indicate either sufficient data or error
- pthread_mutex_lock(&mutex);
- while (prefetch_status == SL_PREFETCHSTATUS_UNKNOWN) {
- pthread_cond_wait(&cond, &mutex);
- }
- pthread_mutex_unlock(&mutex);
- if (prefetch_status == SL_PREFETCHSTATUS_ERROR) {
- fprintf(stderr, "Error during prefetch, exiting\n");
- goto destroyRes;
- }
-
- // get the duration
- SLmillisecond duration;
- result = (*playerPlay)->GetDuration(playerPlay, &duration);
- assert(SL_RESULT_SUCCESS == result);
- if (SL_TIME_UNKNOWN == duration) {
- printf("duration: unknown\n");
- } else {
- printf("duration: %.1f seconds\n", duration / 1000.0);
- }
-
- // enable looping
- if (loop) {
- SLSeekItf playerSeek;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_SEEK, &playerSeek);
- assert(SL_RESULT_SUCCESS == result);
- result = (*playerSeek)->SetLoop(playerSeek, SL_BOOLEAN_TRUE, (SLmillisecond) 0,
- SL_TIME_UNKNOWN);
- assert(SL_RESULT_SUCCESS == result);
- }
-
- // start audio playing
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
- assert(SL_RESULT_SUCCESS == result);
-
- // wait for audio to finish playing
- SLuint32 state;
- for (;;) {
- result = (*playerPlay)->GetPlayState(playerPlay, &state);
- assert(SL_RESULT_SUCCESS == result);
- if (SL_PLAYSTATE_PLAYING != state)
- break;
- usleep(1000000);
- }
- assert(SL_PLAYSTATE_PAUSED == state);
-
-destroyRes:
- // cleanup objects
- (*playerObject)->Destroy(playerObject);
- (*mixObject)->Destroy(mixObject);
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/srcsink.c b/wilhelm/tests/sandbox/srcsink.c
deleted file mode 100644
index 201aa45..0000000
--- a/wilhelm/tests/sandbox/srcsink.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Test various combinations of data sources and sinks
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SLES/OpenSLES.h>
-
-int main(int argc, char **argv)
-{
- SLresult result;
- SLObjectItf engineObject;
-
- // create engine
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // configure a typical audio source of 44.1 kHz stereo 16-bit little endian
- SLDataLocator_BufferQueue loc_bufq;
- loc_bufq.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
- loc_bufq.numBuffers = 1;
- SLDataFormat_PCM format_pcm;
- format_pcm.formatType = SL_DATAFORMAT_PCM;
- format_pcm.numChannels = 2;
- format_pcm.samplesPerSec = SL_SAMPLINGRATE_44_1;
- format_pcm.bitsPerSample = 16;
- format_pcm.containerSize = 16;
- format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
- SLDataSource audioSrc;
- audioSrc.pLocator = &loc_bufq;
- audioSrc.pFormat = &format_pcm;
-
- // configure audio sink
- SLDataLocator_OutputMix loc_outmix;
- loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- loc_outmix.outputMix = NULL;
- SLDataSink audioSnk;
- audioSnk.pLocator = &loc_outmix;
- audioSnk.pFormat = NULL;
-
- // create audio player using a NULL output mix
- SLInterfaceID ids[1] = {SL_IID_BUFFERQUEUE};
- SLboolean req[1] = {SL_BOOLEAN_TRUE};
- SLObjectItf playerObject;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
-
- // create audio player using an engine as the output mix
- loc_outmix.outputMix = engineObject;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
-
- // create output mix but don't realize it yet
- SLObjectItf outputMixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
-
- // create audio player using the unrealized output mix
- loc_outmix.outputMix = outputMixObject;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PRECONDITIONS_VIOLATED == result);
- assert(NULL == playerObject);
-
- // now realize the output mix
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // create audio player using the realized output mix
- // and a bogus data format for the sink (ignored per spec)
- audioSnk.pFormat = (void *) 0xDEADBEEF;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_SUCCESS == result);
- assert(NULL != playerObject);
- audioSnk.pFormat = NULL;
-
- // destroy player
- (*playerObject)->Destroy(playerObject);
-
- // now try to create audio player using various unusual parameters
-
- // number of channels
- format_pcm.numChannels = 0;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.numChannels = 3;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_CONTENT_UNSUPPORTED == result);
- assert(NULL == playerObject);
- format_pcm.numChannels = 2;
-
- // sample rate
- format_pcm.samplesPerSec = 0;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.samplesPerSec = 1000;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_CONTENT_UNSUPPORTED == result);
- assert(NULL == playerObject);
- format_pcm.samplesPerSec = SL_SAMPLINGRATE_44_1;
-
- // bits per sample
- format_pcm.bitsPerSample = 17;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.bitsPerSample = 24;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_CONTENT_UNSUPPORTED == result);
- assert(NULL == playerObject);
- format_pcm.bitsPerSample = 16;
-
- // container size
- format_pcm.containerSize = 8;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.containerSize = 32;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_CONTENT_UNSUPPORTED == result);
- assert(NULL == playerObject);
- format_pcm.containerSize = 16;
-
- // channel mask
- format_pcm.channelMask = 0;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_SUCCESS == result);
- assert(NULL != playerObject);
- (*playerObject)->Destroy(playerObject);
- format_pcm.channelMask = SL_SPEAKER_FRONT_CENTER;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT |
- SL_SPEAKER_FRONT_CENTER;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.numChannels = 1;
- format_pcm.channelMask = 0;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_SUCCESS == result);
- assert(NULL != playerObject);
- (*playerObject)->Destroy(playerObject);
- format_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.numChannels = 2;
-
- // endianness
- format_pcm.endianness = SL_BYTEORDER_BIGENDIAN;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
-#ifdef ANDROID // known bug on SDL
- assert(SL_RESULT_CONTENT_UNSUPPORTED == result);
- assert(NULL == playerObject);
-#else
- if (SL_RESULT_CONTENT_UNSUPPORTED != result) {
- printf("ERROR: expected SL_RESULT_CONTENT_UNSUPPORTED\n");
- if (NULL != playerObject)
- (*playerObject)->Destroy(playerObject);
- }
-#endif
- format_pcm.endianness = 0;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 1, ids, req);
- assert(SL_RESULT_PARAMETER_INVALID == result);
- assert(NULL == playerObject);
- format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
-
- // destroy output mix
- (*outputMixObject)->Destroy(outputMixObject);
-
- // destroy engine
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/streamSource/Android.mk b/wilhelm/tests/sandbox/streamSource/Android.mk
deleted file mode 100644
index b5fdd10..0000000
--- a/wilhelm/tests/sandbox/streamSource/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# slesTest_playStream
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
- system/media/wilhelm/include
-
-LOCAL_SRC_FILES:= \
- slesTestPlayStream.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libOpenSLES
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
-endif
-
-LOCAL_MODULE:= slesTest_playStream
-
-
-include $(BUILD_EXECUTABLE)
diff --git a/wilhelm/tests/sandbox/streamSource/slesTestPlayStream.cpp b/wilhelm/tests/sandbox/streamSource/slesTestPlayStream.cpp
deleted file mode 100644
index 976c116..0000000
--- a/wilhelm/tests/sandbox/streamSource/slesTestPlayStream.cpp
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-//#include <string.h>
-#include <unistd.h>
-//#include <sys/time.h>
-
-#include <SLES/OpenSLES.h>
-#include <SLES/OpenSLES_Android.h>
-
-//#define TEST_DISPLAY_FIRST_BUFFER_ITEM
-//#define TEST_CLEAR
-//#define TEST_PTS
-
-#define MAX_NUMBER_INTERFACES 2
-
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (SL_PREFETCHEVENT_STATUSCHANGE | SL_PREFETCHEVENT_FILLLEVELCHANGE)
-
-#define NB_BUFFERS 16
-#define MPEG2_TS_BLOCK_SIZE 188
-#define BUFFER_SIZE (20*MPEG2_TS_BLOCK_SIZE)
-#define DISCONTINUITY_MAGIC 1977
-
-/* Where we store the data to play */
-char dataCache[BUFFER_SIZE * NB_BUFFERS];
-/* From where we read the data to play */
-FILE *file;
-/* Has the app reached the end of the file */
-bool reachedEof = false;
-/* Special discontinuity buffer context */
-int myDiscBufferContext = DISCONTINUITY_MAGIC;
-
-/* structure to store my discontinuity with PTS command */
-typedef struct {
- SLuint32 discKey; // identifies the item
- SLuint32 discSize;
- SLAuint64 discPts;
-} DiscPts;
-
-//-----------------------------------------------------------------
-/* Exits the application if an error is encountered */
-#define CheckErr(x) ExitOnErrorFunc(x,__LINE__)
-
-void ExitOnErrorFunc( SLresult result , int line)
-{
- if (SL_RESULT_SUCCESS != result) {
- fprintf(stderr, "%u error code encountered at line %d, exiting\n", result, line);
- exit(EXIT_FAILURE);
- }
-}
-
-bool prefetchError = false;
-
-//-----------------------------------------------------------------
-/* AndroidBufferQueueItf callback for an audio player */
-SLresult AndroidBufferQueueCallback(
- SLAndroidBufferQueueItf caller,
- void *pCallbackContext, /* input */
- void *pBufferContext, /* input */
- void *pBufferData, /* input */
- SLuint32 dataSize, /* input */
- SLuint32 dataUsed, /* input */
- const SLAndroidBufferItem *pItems, /* input */
- SLuint32 itemsLength /* input */)
-{
- // assert(BUFFER_SIZE <= dataSize);
-
- //--------------------------------------------------------------------------------
- // this section is for testing only, this is NOT an example of how to use the API
- // to play a .ts file, but rather shows more ways to exercise the API
- //--------------------------------------------------------------------------------
- SLAndroidBufferQueueState state;
- (*caller)->GetState(caller, &state);
- //fprintf(stdout, "ABQ state count=%lu, index=%lu\n", state.count, state.index);
-
- // just to test, clear the queue to see what happens
- if (state.index == 500) {
-#ifdef TEST_CLEAR
- (*caller)->Clear(caller);
- // we've cleared the queue, and have introduced a discontinuity, so signal it
- SLAndroidBufferItem msgDiscontinuity;
- msgDiscontinuity.itemKey = SL_ANDROID_ITEMKEY_DISCONTINUITY;
- msgDiscontinuity.itemSize = 0;
- // message has no parameters, so the total size of the message is the size of the key
- // plus the size if itemSize, both SLuint32
- (*caller)->Enqueue(caller, (void*)&myDiscBufferContext /*pBufferContext*/,
- NULL /*pData*/, 0 /*dataLength*/,
- &msgDiscontinuity /*pMsg*/,
- sizeof(SLuint32)*2 /*msgLength*/);
- // we've cleared the queue, it's now empty: let's rebuffer a bit so playback doesn't starve
- size_t nbRead = fread((void*)dataCache, 1, BUFFER_SIZE*(NB_BUFFERS/2), file);
- if (nbRead == BUFFER_SIZE*(NB_BUFFERS/2)) {
- for (int i=0 ; i < NB_BUFFERS/2 ; i++) {
- SLresult res = (*caller)->Enqueue(caller, NULL /*pBufferContext*/,
- dataCache + i*BUFFER_SIZE,
- BUFFER_SIZE, NULL, 0);
- CheckErr(res);
- }
- }
-#endif
-#ifdef TEST_PTS
- DiscPts msgDiscontinuity = { SL_ANDROID_ITEMKEY_DISCONTINUITY,
- sizeof(SLAuint64), 15*90*1000 /*15s in 90kHz clock */ };
- // enqueue discontinuity message with our PTS
- (*caller)->Enqueue(caller, (void*)&myDiscBufferContext /*pBufferContext*/,
- NULL /*pData*/, 0 /*dataLength*/,
- (SLAndroidBufferItem*)&msgDiscontinuity,
- sizeof(DiscPts) );
- fprintf(stdout, "rendering will resume at 15s mark");
-
-#endif
- return SL_RESULT_SUCCESS;
- }
- //--------------------------------------------------------------------------------
- // end of test only section
- //--------------------------------------------------------------------------------
- else {
-
-#ifdef TEST_DISPLAY_FIRST_BUFFER_ITEM
- // display item data (only parsing first item)
- if (itemsLength !=0) {
- fprintf(stdout, "item key=0x%lx size=%lu data=0x%lx\n",
- pItems->itemKey, pItems->itemSize, *((SLuint32*)&pItems->itemData));
- }
-#endif
-
- // pBufferData can be null if the last consumed buffer contained only a command
- // just like we do for signalling DISCONTINUITY (above) or EOS (below)
- if ((pBufferContext != NULL) && (*((int*)pBufferContext) == DISCONTINUITY_MAGIC)) {
- fprintf(stdout, "Successfully detected my discontinuity buffer having been consumed\n");
- }
- if (pBufferData != NULL) {
- size_t nbRead = fread((void*)pBufferData, 1, BUFFER_SIZE, file);
- if (nbRead > 0) {
- (*caller)->Enqueue(caller, NULL /*pBufferContext*/,
- pBufferData /*pData*/,
- nbRead /*dataLength*/,
- NULL /*pMsg*/,
- 0 /*msgLength*/);
- } else if (!reachedEof) {
- // signal EOS
- SLAndroidBufferItem msgEos;
- msgEos.itemKey = SL_ANDROID_ITEMKEY_EOS;
- msgEos.itemSize = 0;
- // EOS message has no parameters, so the total size of the message is the size of the key
- // plus the size if itemSize, both SLuint32
- (*caller)->Enqueue(caller, NULL /*pBufferContext*/,
- NULL /*pData*/, 0 /*dataLength*/,
- &msgEos /*pMsg*/,
- sizeof(SLuint32)*2 /*msgLength*/);
- reachedEof = true;
- }
- }
-
- return SL_RESULT_SUCCESS;
- }
-}
-
-
-//-----------------------------------------------------------------
-
-/* Play some music from a URI */
-void TestPlayStream( SLObjectItf sl, const char* path)
-{
- SLEngineItf EngineItf;
-
- SLint32 numOutputs = 0;
- SLuint32 deviceID = 0;
-
- SLresult res;
-
- SLDataSource audioSource;
- SLDataLocator_AndroidBufferQueue streamLocator;
- SLDataFormat_MIME mime;
-
- SLDataSink audioSink;
- SLDataLocator_OutputMix locator_outputmix;
-
- SLObjectItf player;
- SLPlayItf playItf;
- SLVolumeItf volItf;
- SLAndroidBufferQueueItf abqItf;
-
- SLObjectItf OutputMix;
-
- SLboolean required[MAX_NUMBER_INTERFACES];
- SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
-
- int playTimeInSec = 60;
-
- file = fopen(path, "rb");
-
- /* Get the SL Engine Interface which is implicit */
- res = (*sl)->GetInterface(sl, SL_IID_ENGINE, (void*)&EngineItf);
- CheckErr(res);
-
- /* Initialize arrays required[] and iidArray[] */
- for (int i=0 ; i < MAX_NUMBER_INTERFACES ; i++) {
- required[i] = SL_BOOLEAN_FALSE;
- iidArray[i] = SL_IID_NULL;
- }
-
- // Set arrays required[] and iidArray[] for VOLUME and PREFETCHSTATUS interface
- required[0] = SL_BOOLEAN_TRUE;
- iidArray[0] = SL_IID_VOLUME;
- required[1] = SL_BOOLEAN_TRUE;
- iidArray[1] = SL_IID_ANDROIDBUFFERQUEUESOURCE;
- // Create Output Mix object to be used by player
- res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0,
- iidArray, required); CheckErr(res);
-
- // Realizing the Output Mix object in synchronous mode.
- res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- /* Setup the data source structure for the URI */
- streamLocator.locatorType = SL_DATALOCATOR_ANDROIDBUFFERQUEUE;
- streamLocator.numBuffers = NB_BUFFERS;
- mime.formatType = SL_DATAFORMAT_MIME;
- mime.mimeType = (SLchar *) "video/mp2ts";//(SLchar*)NULL;
- mime.containerType = SL_CONTAINERTYPE_MPEG_TS;
-
- audioSource.pFormat = (void *)&mime;
- audioSource.pLocator = (void *)&streamLocator;
-
- /* Setup the data sink structure */
- locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- locator_outputmix.outputMix = OutputMix;
- audioSink.pLocator = (void *)&locator_outputmix;
- audioSink.pFormat = NULL;
-
- /* Create the audio player */
- res = (*EngineItf)->CreateAudioPlayer(EngineItf, &player, &audioSource, &audioSink,
- MAX_NUMBER_INTERFACES, iidArray, required); CheckErr(res);
-
- /* Realizing the player in synchronous mode. */
- res = (*player)->Realize(player, SL_BOOLEAN_FALSE); CheckErr(res);
- fprintf(stdout, "URI example: after Realize\n");
-
- /* Get interfaces */
- res = (*player)->GetInterface(player, SL_IID_PLAY, (void*)&playItf); CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_VOLUME, (void*)&volItf); CheckErr(res);
-
- res = (*player)->GetInterface(player, SL_IID_ANDROIDBUFFERQUEUESOURCE, (void*)&abqItf);
- CheckErr(res);
-
- res = (*abqItf)->RegisterCallback(abqItf, AndroidBufferQueueCallback,
- // context is not used in the example, but can be used to track who registered
- // the buffer queue callback
- NULL /*pContext*/); CheckErr(res);
-
- res = (*abqItf)->SetCallbackEventsMask(abqItf, SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED);
- CheckErr(res);
-
- /* Display duration */
- SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
- res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (before starting to prefetch)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (before starting to prefetch)\n",
- durationInMsec);
- }
-
- /* Set the player volume */
- res = (*volItf)->SetVolumeLevel( volItf, 0);//-300);
- CheckErr(res);
-
-
- /* Play the URI */
- /* first cause the player to prefetch the data */
- fprintf(stdout, "Before set to PAUSED\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PAUSED );
- fprintf(stdout, "After set to PAUSED\n");
- CheckErr(res);
-
- /* Fill our cache */
- if (fread(dataCache, 1, BUFFER_SIZE * NB_BUFFERS, file) <= 0) {
- fprintf(stderr, "Error filling cache, exiting\n");
- goto destroyRes;
- }
- /* Enqueue the content of our cache before starting to play,
- * we don't want to starve the player */
- for (int i=0 ; i < NB_BUFFERS ; i++) {
- res = (*abqItf)->Enqueue(abqItf, NULL /*pBufferContext*/,
- dataCache + i*BUFFER_SIZE, BUFFER_SIZE, NULL, 0);
- CheckErr(res);
- }
-
-#if 0 // used to test ABQ starving where only one buffer is enqueued before playback
- /* Fill our cache */
- if (fread(dataCache, 1, BUFFER_SIZE * 1, file) <= 0) {
- fprintf(stderr, "Error filling cache, exiting\n");
- goto destroyRes;
- }
- /* Enqueue the content of our cache before starting to play,
- * we don't want to starve the player */
- for (int i=0 ; i < 1 ; i++) {
- res = (*abqItf)->Enqueue(abqItf, dataCache + i*BUFFER_SIZE, BUFFER_SIZE, NULL, 0);
- CheckErr(res);
- }
-#endif
- /* wait until there's data to play */
- //SLpermille fillLevel = 0;
- /*
- SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
- SLuint32 timeOutIndex = 2;
- while ((prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA) && (timeOutIndex > 0) &&
- !prefetchError) {
- usleep(1 * 1000 * 1000); // 1s
- //(*prefetchItf)->GetPrefetchStatus(prefetchItf, &prefetchStatus);
- timeOutIndex--;
- }
-
- if (timeOutIndex == 0 || prefetchError) {
- fprintf(stderr, "We\'re done waiting, failed to prefetch data in time, exiting\n");
- goto destroyRes;
- }
-*/
-
- /* Display duration again, */
-/* res = (*playItf)->GetDuration(playItf, &durationInMsec);
- CheckErr(res);
- if (durationInMsec == SL_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (after prefetch completed)\n");
- } else {
- fprintf(stdout, "Content duration is %lu ms (after prefetch completed)\n", durationInMsec);
- }
-*/
-
- fprintf(stdout, "URI example: starting to play\n");
- res = (*playItf)->SetPlayState( playItf, SL_PLAYSTATE_PLAYING );
- CheckErr(res);
-
- /* Wait as long as the duration of the content before stopping */
- fprintf(stdout, "Letting playback go on for %d sec\n", playTimeInSec);
- usleep(playTimeInSec /*s*/ * 1000 * 1000);
-
-
- /* Make sure player is stopped */
- fprintf(stdout, "URI example: stopping playback\n");
- res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED);
- CheckErr(res);
-
- fprintf(stdout, "sleeping to verify playback stopped\n");
- usleep(2 /*s*/ * 1000 * 1000);
-
-destroyRes:
-
- /* Destroy the player */
- (*player)->Destroy(player);
-
- /* Destroy Output Mix object */
- (*OutputMix)->Destroy(OutputMix);
-
- fclose(file);
-}
-
-//-----------------------------------------------------------------
-int main(int argc, char* const argv[])
-{
- SLresult res;
- SLObjectItf sl;
-
- fprintf(stdout, "OpenSL ES test %s: exercises SLPlayItf, SLVolumeItf, SLAndroidBufferQueue \n",
- argv[0]);
- fprintf(stdout, "and AudioPlayer with SL_DATALOCATOR_ANDROIDBUFFERQUEUE source / OutputMix sink\n");
- fprintf(stdout, "Plays a sound and stops after its reported duration\n\n");
-
- if (argc == 1) {
- fprintf(stdout, "Usage: %s path \n", argv[0]);
- fprintf(stdout, "Example: \"%s /sdcard/my.ts\n",
- argv[0], argv[0]);
- exit(EXIT_FAILURE);
- }
-
- SLEngineOption EngineOption[] = {
- {(SLuint32) SL_ENGINEOPTION_THREADSAFE,
- (SLuint32) SL_BOOLEAN_TRUE}};
-
- res = slCreateEngine( &sl, 1, EngineOption, 0, NULL, NULL);
- CheckErr(res);
- /* Realizing the SL Engine in synchronous mode. */
- res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE);
- CheckErr(res);
-
- TestPlayStream(sl, argv[1]);
-
- /* Shutdown OpenSL ES */
- (*sl)->Destroy(sl);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/urimime.c b/wilhelm/tests/sandbox/urimime.c
deleted file mode 100644
index 20784bc..0000000
--- a/wilhelm/tests/sandbox/urimime.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Test audio player configurations with URI data source and MIME data format
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <SLES/OpenSLES.h>
-#ifdef ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-int main(int argc, char **argv)
-{
- if (argc != 2) {
- fprintf(stderr, "usage: %s URI\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- SLresult result;
- SLObjectItf engineObject;
-
- // create engine
- result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- SLEngineItf engineEngine;
- result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
- result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
- assert(SL_RESULT_SUCCESS == result);
-
- // create output mix
- SLObjectItf outputMixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
- result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // configure audio source
- SLDataLocator_URI loc_uri;
- loc_uri.locatorType = SL_DATALOCATOR_URI;
- loc_uri.URI = (SLchar *) argv[1];
- SLDataFormat_MIME format_mime;
- format_mime.formatType = SL_DATAFORMAT_MIME;
- format_mime.mimeType = NULL;
- format_mime.containerType = SL_CONTAINERTYPE_UNSPECIFIED;
- SLDataSource audioSrc;
- audioSrc.pLocator = &loc_uri;
- audioSrc.pFormat = &format_mime;
-
- // configure audio sink
- SLDataLocator_OutputMix loc_outmix;
- loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
- loc_outmix.outputMix = outputMixObject;
- SLDataSink audioSnk;
- audioSnk.pLocator = &loc_outmix;
- audioSnk.pFormat = NULL;
-
- // create audio player, requesting a buffer queue interface
- SLuint32 numInterfaces = 1;
- SLInterfaceID ids[1];
- SLboolean req[1];
- ids[0] = SL_IID_BUFFERQUEUE;
- req[0] = SL_BOOLEAN_TRUE;
- SLObjectItf playerObject;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, numInterfaces, ids, req);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == playerObject);
-#ifdef ANDROID
- ids[0] = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, numInterfaces, ids, req);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == playerObject);
-#endif
-
- // create audio player, without requesting a buffer queue interface
- result = (*engineEngine)->CreateAudioPlayer(engineEngine, &playerObject, &audioSrc,
- &audioSnk, 0, NULL, NULL);
- assert(SL_RESULT_SUCCESS == result);
-
- // realize the player
- result = (*playerObject)->Realize(playerObject, SL_BOOLEAN_FALSE);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the play interface
- SLPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAY, &playerPlay);
- assert(SL_RESULT_SUCCESS == result);
-
- // get the buffer queue interface
- SLBufferQueueItf playerBufferQueue;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_BUFFERQUEUE, &playerBufferQueue);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == playerBufferQueue);
-#ifdef ANDROID
- SLAndroidSimpleBufferQueueItf playerAndroidSimpleBufferQueue;
- result = (*playerObject)->GetInterface(playerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
- &playerAndroidSimpleBufferQueue);
- assert(SL_RESULT_FEATURE_UNSUPPORTED == result);
- assert(NULL == playerAndroidSimpleBufferQueue);
-#endif
-
- // get the player duration
- SLmillisecond duration;
- result = (*playerPlay)->GetDuration(playerPlay, &duration);
- assert(SL_RESULT_SUCCESS == result);
- if (SL_TIME_UNKNOWN == duration)
- printf("Duration: unknown\n");
- else
- printf("Duration: %.1f\n", duration / 1000.0f);
-
- // set the player's state to playing
- result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
- assert(SL_RESULT_SUCCESS == result);
-
- // wait for the playback to finish
- for (;;) {
- SLuint32 playState;
- result = (*playerPlay)->GetPlayState(playerPlay, &playState);
- assert(SL_RESULT_SUCCESS == result);
- if (SL_PLAYSTATE_PLAYING != playState) {
- break;
- }
- usleep(10000);
- }
-
- // get the player duration
- result = (*playerPlay)->GetDuration(playerPlay, &duration);
- assert(SL_RESULT_SUCCESS == result);
- if (SL_TIME_UNKNOWN == duration)
- printf("Duration: unknown\n");
- else
- printf("Duration: %.1f\n", duration / 1000.0f);
-
- // destroy audio player
- (*playerObject)->Destroy(playerObject);
-
- // destroy output mix
- (*outputMixObject)->Destroy(outputMixObject);
-
- // destroy engine
- (*engineObject)->Destroy(engineObject);
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/xa.c b/wilhelm/tests/sandbox/xa.c
deleted file mode 100644
index c44191a..0000000
--- a/wilhelm/tests/sandbox/xa.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <OMXAL/OpenMAXAL.h>
-#include <OMXAL/OpenMAXAL_Android.h>
-
-int main(int argc, char **argv)
-{
- XAresult result;
- XAObjectItf engineObject;
- printf("xaCreateEngine\n");
- result = xaCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- printf("result = %d\n", result);
- assert(XA_RESULT_SUCCESS == result);
- printf("engineObject = %p\n", engineObject);
- printf("realize\n");
- result = (*engineObject)->Realize(engineObject, XA_BOOLEAN_FALSE);
- printf("result = %d\n", result);
- printf("GetInterface for ENGINE\n");
- XAEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, XA_IID_ENGINE, &engineEngine);
- printf("result = %d\n", result);
- printf("engineEngine = %p\n", engineEngine);
- assert(XA_RESULT_SUCCESS == result);
-
- XAObjectItf outputMixObject;
- printf("CreateOutputMix");
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- printf("result = %d, outputMixObject=%p\n", result, outputMixObject);
- result = (*outputMixObject)->Realize(outputMixObject, XA_BOOLEAN_FALSE);
- printf("result = %d\n", result);
-
- XAObjectItf deviceObject;
- printf("CreateCameraDevice\n");
- result = (*engineEngine)->CreateCameraDevice(engineEngine, &deviceObject,
- XA_DEFAULTDEVICEID_CAMERA, 0, NULL, NULL);
- printf("result = %d, deviceObject=%p\n", result, deviceObject);
-
- printf("CreateRadioDevice\n");
- result = (*engineEngine)->CreateRadioDevice(engineEngine, &deviceObject, 0, NULL, NULL);
- printf("result = %d, deviceObject=%p\n", result, deviceObject);
-
- printf("CreateLEDDevice\n");
- result = (*engineEngine)->CreateLEDDevice(engineEngine, &deviceObject, XA_DEFAULTDEVICEID_LED,
- 0, NULL, NULL);
- printf("result = %d, deviceObject=%p\n", result, deviceObject);
-
- printf("CreateVibraDevice\n");
- result = (*engineEngine)->CreateVibraDevice(engineEngine, &deviceObject,
- XA_DEFAULTDEVICEID_VIBRA, 0, NULL, NULL);
- printf("result = %d, deviceObject=%p\n", result, deviceObject);
-
- printf("CreateMediaPlayer\n");
- XAObjectItf playerObject;
-#if 1
- XADataLocator_AndroidBufferQueue locABQ;
- memset(&locABQ, 0, sizeof(locABQ));
- locABQ.locatorType = XA_DATALOCATOR_ANDROIDBUFFERQUEUE;
-#else
- XADataLocator_URI locUri;
- locUri.locatorType = XA_DATALOCATOR_URI;
- locUri.URI = (XAchar *) "/sdcard/hello.wav";
-#endif
- XADataFormat_MIME fmtMime;
- fmtMime.formatType = XA_DATAFORMAT_MIME;
- fmtMime.mimeType = NULL;
- fmtMime.containerType = XA_CONTAINERTYPE_UNSPECIFIED;
- XADataSource dataSrc;
-#if 1
- dataSrc.pLocator = &locABQ;
-#else
- dataSrc.pLocator = &locUri;
-#endif
- dataSrc.pFormat = &fmtMime;
- XADataSink audioSnk;
- XADataLocator_OutputMix locOM;
- locOM.locatorType = XA_DATALOCATOR_OUTPUTMIX;
- locOM.outputMix = outputMixObject;
- audioSnk.pLocator = &locOM;
- audioSnk.pFormat = NULL;
- XADataLocator_NativeDisplay locND;
- locND.locatorType = XA_DATALOCATOR_NATIVEDISPLAY;
- locND.hWindow = NULL;
- locND.hDisplay = NULL;
- XADataSink imageVideoSink;
- imageVideoSink.pLocator = &locND;
- imageVideoSink.pFormat = NULL;
- result = (*engineEngine)->CreateMediaPlayer(engineEngine, &playerObject, &dataSrc, NULL,
- &audioSnk, &imageVideoSink, NULL, NULL, 0, NULL, NULL);
- printf("result = %d, playerObject=%p\n", result, playerObject);
- result = (*playerObject)->Realize(playerObject, XA_BOOLEAN_FALSE);
- printf("result = %d\n", result);
-
- printf("GetInterface for PLAY\n");
- XAPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, XA_IID_PLAY, &playerPlay);
- printf("result = %d\n", result);
- printf("playerPlay = %p\n", playerPlay);
- assert(XA_RESULT_SUCCESS == result);
-
- printf("SetPlayState to PLAYING\n");
- result = (*playerPlay)->SetPlayState(playerPlay, XA_PLAYSTATE_PLAYING);
- printf("result = %d\n", result);
- assert(XA_RESULT_SUCCESS == result);
-
- printf("destroying media player\n");
- (*playerObject)->Destroy(playerObject);
-
- printf("destroying output mix\n");
- (*outputMixObject)->Destroy(outputMixObject);
-
- printf("destroying engine\n");
- (*engineObject)->Destroy(engineObject);
- printf("exit\n");
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tests/sandbox/xaplay.c b/wilhelm/tests/sandbox/xaplay.c
deleted file mode 100644
index 82a6e04..0000000
--- a/wilhelm/tests/sandbox/xaplay.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// OpenMAX AL MediaPlayer command-line player
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <OMXAL/OpenMAXAL.h>
-#include <OMXAL/OpenMAXAL_Android.h>
-#include "nativewindow.h"
-
-#define MPEG2TS_PACKET_SIZE 188 // MPEG-2 transport stream packet size in bytes
-#define PACKETS_PER_BUFFER 20 // Number of MPEG-2 transport stream packets per buffer
-
-#define NB_BUFFERS 2 // Number of buffers in Android buffer queue
-
-// MPEG-2 transport stream packet
-typedef struct {
- char data[MPEG2TS_PACKET_SIZE];
-} MPEG2TS_Packet;
-
-#if 0
-// Each buffer in Android buffer queue
-typedef struct {
- MPEG2TS_Packet packets[PACKETS_PER_BUFFER];
-} Buffer;
-#endif
-
-// Globals shared between main thread and buffer queue callback
-MPEG2TS_Packet *packets;
-size_t numPackets;
-size_t curPacket;
-size_t discPacket;
-
-// These are extensions to OpenMAX AL 1.0.1 values
-
-#define PREFETCHSTATUS_UNKNOWN ((XAuint32) 0)
-#define PREFETCHSTATUS_ERROR ((XAuint32) (-1))
-
-// Mutex and condition shared with main program to protect prefetch_status
-
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-XAuint32 prefetch_status = PREFETCHSTATUS_UNKNOWN;
-
-/* used to detect errors likely to have occured when the OpenMAX AL framework fails to open
- * a resource, for instance because a file URI is invalid, or an HTTP server doesn't respond.
- */
-#define PREFETCHEVENT_ERROR_CANDIDATE \
- (XA_PREFETCHEVENT_STATUSCHANGE | XA_PREFETCHEVENT_FILLLEVELCHANGE)
-
-// stream event change callback
-void streamEventChangeCallback(XAStreamInformationItf caller, XAuint32 eventId,
- XAuint32 streamIndex, void *pEventData, void *pContext)
-{
- // context parameter is specified as NULL and is unused here
- assert(NULL == pContext);
- switch (eventId) {
- case XA_STREAMCBEVENT_PROPERTYCHANGE:
- printf("XA_STREAMCBEVENT_PROPERTYCHANGE on stream index %u, pEventData %p\n", streamIndex,
- pEventData);
- break;
- default:
- printf("Unknown stream event ID %u\n", eventId);
- break;
- }
-}
-
-// prefetch status callback
-void prefetchStatusCallback(XAPrefetchStatusItf caller, void *pContext, XAuint32 event)
-{
- // pContext is unused here, so we pass NULL
- assert(pContext == NULL);
- XApermille level = 0;
- XAresult result;
- result = (*caller)->GetFillLevel(caller, &level);
- assert(XA_RESULT_SUCCESS == result);
- XAuint32 status;
- result = (*caller)->GetPrefetchStatus(caller, &status);
- assert(XA_RESULT_SUCCESS == result);
- if (event & XA_PREFETCHEVENT_FILLLEVELCHANGE) {
- printf("PrefetchEventCallback: Buffer fill level is = %d\n", level);
- }
- if (event & XA_PREFETCHEVENT_STATUSCHANGE) {
- printf("PrefetchEventCallback: Prefetch Status is = %u\n", status);
- }
- XAuint32 new_prefetch_status;
- if ((PREFETCHEVENT_ERROR_CANDIDATE == (event & PREFETCHEVENT_ERROR_CANDIDATE))
- && (level == 0) && (status == XA_PREFETCHSTATUS_UNDERFLOW)) {
- printf("PrefetchEventCallback: Error while prefetching data, exiting\n");
- new_prefetch_status = PREFETCHSTATUS_ERROR;
- } else if (event == XA_PREFETCHEVENT_STATUSCHANGE) {
- new_prefetch_status = status;
- } else {
- return;
- }
- int ok;
- ok = pthread_mutex_lock(&mutex);
- assert(ok == 0);
- prefetch_status = new_prefetch_status;
- ok = pthread_cond_signal(&cond);
- assert(ok == 0);
- ok = pthread_mutex_unlock(&mutex);
- assert(ok == 0);
-}
-
-// playback event callback
-void playEventCallback(XAPlayItf caller, void *pContext, XAuint32 event)
-{
- // pContext is unused here, so we pass NULL
- assert(NULL == pContext);
-
- XAmillisecond position;
-
- if (XA_PLAYEVENT_HEADATEND & event) {
- printf("XA_PLAYEVENT_HEADATEND reached\n");
- //SignalEos();
- }
-
- XAresult result;
- if (XA_PLAYEVENT_HEADATNEWPOS & event) {
- result = (*caller)->GetPosition(caller, &position);
- assert(XA_RESULT_SUCCESS == result);
- printf("XA_PLAYEVENT_HEADATNEWPOS current position=%ums\n", position);
- }
-
- if (XA_PLAYEVENT_HEADATMARKER & event) {
- result = (*caller)->GetPosition(caller, &position);
- assert(XA_RESULT_SUCCESS == result);
- printf("XA_PLAYEVENT_HEADATMARKER current position=%ums\n", position);
- }
-}
-
-// Android buffer queue callback
-XAresult bufferQueueCallback(
- XAAndroidBufferQueueItf caller,
- void *pCallbackContext,
- void *pBufferContext,
- void *pBufferData,
- XAuint32 dataSize,
- XAuint32 dataUsed,
- const XAAndroidBufferItem *pItems,
- XAuint32 itemsLength)
-{
- // enqueue the .ts data directly from mapped memory, so ignore the empty buffer pBufferData
- if (curPacket <= numPackets) {
- static const XAAndroidBufferItem discontinuity = {XA_ANDROID_ITEMKEY_DISCONTINUITY, 0};
- static const XAAndroidBufferItem eos = {XA_ANDROID_ITEMKEY_EOS, 0};
- const XAAndroidBufferItem *items;
- XAuint32 itemSize;
- // compute number of packets to be enqueued in this buffer
- XAuint32 packetsThisBuffer = numPackets - curPacket;
- if (packetsThisBuffer > PACKETS_PER_BUFFER) {
- packetsThisBuffer = PACKETS_PER_BUFFER;
- }
- // last packet? this should only happen once
- if (curPacket == numPackets) {
- (void) write(1, "e", 1);
- items = &eos;
- itemSize = sizeof(eos);
- // discontinuity requested?
- } else if (curPacket == discPacket) {
- printf("sending discontinuity, rewinding from beginning of stream\n");
- items = &discontinuity;
- itemSize = sizeof(discontinuity);
- curPacket = 0;
- // pure data with no items
- } else {
- items = NULL;
- itemSize = 0;
- }
- XAresult result;
- // enqueue the optional data and optional items; there is always at least one or the other
- assert(packetsThisBuffer > 0 || itemSize > 0);
- result = (*caller)->Enqueue(caller, NULL, &packets[curPacket],
- sizeof(MPEG2TS_Packet) * packetsThisBuffer, items, itemSize);
- assert(XA_RESULT_SUCCESS == result);
- curPacket += packetsThisBuffer;
- }
- return XA_RESULT_SUCCESS;
-}
-
-// main program
-int main(int argc, char **argv)
-{
- const char *prog = argv[0];
- int i;
-
- XAboolean abq = XA_BOOLEAN_FALSE; // use AndroidBufferQueue, default is URI
- XAboolean looping = XA_BOOLEAN_FALSE;
-#ifdef REINITIALIZE
- int reinit_counter = 0;
-#endif
- for (i = 1; i < argc; ++i) {
- const char *arg = argv[i];
- if (arg[0] != '-')
- break;
- switch (arg[1]) {
- case 'a':
- abq = XA_BOOLEAN_TRUE;
- break;
- case 'd':
- discPacket = atoi(&arg[2]);
- break;
- case 'l':
- looping = XA_BOOLEAN_TRUE;
- break;
-#ifdef REINITIALIZE
- case 'r':
- reinit_counter = atoi(&arg[2]);
- break;
-#endif
- default:
- fprintf(stderr, "%s: unknown option %s\n", prog, arg);
- break;
- }
- }
-
- // check that exactly one URI was specified
- if (argc - i != 1) {
- fprintf(stderr, "usage: %s [-a] [-d#] [-l] uri\n", prog);
- return EXIT_FAILURE;
- }
- const char *uri = argv[i];
-
- // for AndroidBufferQueue, interpret URI as a filename and open
- int fd = -1;
- if (abq) {
- fd = open(uri, O_RDONLY);
- if (fd < 0) {
- perror(uri);
- goto close;
- }
- int ok;
- struct stat statbuf;
- ok = fstat(fd, &statbuf);
- if (ok < 0) {
- perror(uri);
- goto close;
- }
- if (!S_ISREG(statbuf.st_mode)) {
- fprintf(stderr, "%s: not an ordinary file\n", uri);
- goto close;
- }
- void *ptr;
- ptr = mmap(NULL, statbuf.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, (off_t) 0);
- if (ptr == MAP_FAILED) {
- perror(uri);
- goto close;
- }
- size_t filelen = statbuf.st_size;
- if ((filelen % MPEG2TS_PACKET_SIZE) != 0) {
- fprintf(stderr, "%s: warning file length %zu is not a multiple of %d\n", uri, filelen,
- MPEG2TS_PACKET_SIZE);
- }
- packets = (MPEG2TS_Packet *) ptr;
- numPackets = filelen / MPEG2TS_PACKET_SIZE;
- printf("%s has %zu packets\n", uri, numPackets);
- }
-
- ANativeWindow *nativeWindow;
-
-#ifdef REINITIALIZE
-reinitialize: ;
-#endif
-
- XAresult result;
- XAObjectItf engineObject;
-
- // create engine
- result = xaCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
- assert(XA_RESULT_SUCCESS == result);
- result = (*engineObject)->Realize(engineObject, XA_BOOLEAN_FALSE);
- assert(XA_RESULT_SUCCESS == result);
- XAEngineItf engineEngine;
- result = (*engineObject)->GetInterface(engineObject, XA_IID_ENGINE, &engineEngine);
- assert(XA_RESULT_SUCCESS == result);
-
- // create output mix
- XAObjectItf outputMixObject;
- result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 0, NULL, NULL);
- assert(XA_RESULT_SUCCESS == result);
- result = (*outputMixObject)->Realize(outputMixObject, XA_BOOLEAN_FALSE);
- assert(XA_RESULT_SUCCESS == result);
-
- // configure media source
- XADataLocator_URI locUri;
- locUri.locatorType = XA_DATALOCATOR_URI;
- locUri.URI = (XAchar *) uri;
- XADataFormat_MIME fmtMime;
- fmtMime.formatType = XA_DATAFORMAT_MIME;
- if (abq) {
- fmtMime.mimeType = (XAchar *) XA_ANDROID_MIME_MP2TS;
- fmtMime.containerType = XA_CONTAINERTYPE_MPEG_TS;
- } else {
- fmtMime.mimeType = NULL;
- fmtMime.containerType = XA_CONTAINERTYPE_UNSPECIFIED;
- }
- XADataLocator_AndroidBufferQueue locABQ;
- locABQ.locatorType = XA_DATALOCATOR_ANDROIDBUFFERQUEUE;
- locABQ.numBuffers = NB_BUFFERS;
- XADataSource dataSrc;
- if (abq) {
- dataSrc.pLocator = &locABQ;
- } else {
- dataSrc.pLocator = &locUri;
- }
- dataSrc.pFormat = &fmtMime;
-
- // configure audio sink
- XADataLocator_OutputMix locOM;
- locOM.locatorType = XA_DATALOCATOR_OUTPUTMIX;
- locOM.outputMix = outputMixObject;
- XADataSink audioSnk;
- audioSnk.pLocator = &locOM;
- audioSnk.pFormat = NULL;
-
- // configure video sink
- nativeWindow = getNativeWindow();
- XADataLocator_NativeDisplay locND;
- locND.locatorType = XA_DATALOCATOR_NATIVEDISPLAY;
- locND.hWindow = nativeWindow;
- locND.hDisplay = NULL;
- XADataSink imageVideoSink;
- imageVideoSink.pLocator = &locND;
- imageVideoSink.pFormat = NULL;
-
- // create media player
- XAObjectItf playerObject;
- XAInterfaceID ids[4] = {XA_IID_STREAMINFORMATION, XA_IID_PREFETCHSTATUS, XA_IID_SEEK,
- XA_IID_ANDROIDBUFFERQUEUESOURCE};
- XAboolean req[4] = {XA_BOOLEAN_TRUE, XA_BOOLEAN_TRUE, XA_BOOLEAN_TRUE, XA_BOOLEAN_TRUE};
- result = (*engineEngine)->CreateMediaPlayer(engineEngine, &playerObject, &dataSrc, NULL,
- &audioSnk, nativeWindow != NULL ? &imageVideoSink : NULL, NULL, NULL, abq ? 4 : 3, ids,
- req);
- assert(XA_RESULT_SUCCESS == result);
-
- // realize the player
- result = (*playerObject)->Realize(playerObject, XA_BOOLEAN_FALSE);
- assert(XA_RESULT_SUCCESS == result);
-
- if (abq) {
-
- // get the Android buffer queue interface
- XAAndroidBufferQueueItf playerAndroidBufferQueue;
- result = (*playerObject)->GetInterface(playerObject, XA_IID_ANDROIDBUFFERQUEUESOURCE,
- &playerAndroidBufferQueue);
- assert(XA_RESULT_SUCCESS == result);
-
- // register the buffer queue callback
- result = (*playerAndroidBufferQueue)->RegisterCallback(playerAndroidBufferQueue,
- bufferQueueCallback, NULL);
- assert(XA_RESULT_SUCCESS == result);
- result = (*playerAndroidBufferQueue)->SetCallbackEventsMask(playerAndroidBufferQueue,
- XA_ANDROIDBUFFERQUEUEEVENT_PROCESSED);
- assert(XA_RESULT_SUCCESS == result);
-
- // enqueue the initial buffers until buffer queue is full
- XAuint32 packetsThisBuffer;
- for (curPacket = 0; curPacket < numPackets; curPacket += packetsThisBuffer) {
- // handle the unlikely case of a very short .ts
- packetsThisBuffer = numPackets - curPacket;
- if (packetsThisBuffer > PACKETS_PER_BUFFER) {
- packetsThisBuffer = PACKETS_PER_BUFFER;
- }
- result = (*playerAndroidBufferQueue)->Enqueue(playerAndroidBufferQueue, NULL,
- &packets[curPacket], MPEG2TS_PACKET_SIZE * packetsThisBuffer, NULL, 0);
- if (XA_RESULT_BUFFER_INSUFFICIENT == result) {
- printf("Enqueued initial %u packets in %u buffers\n", curPacket, curPacket / PACKETS_PER_BUFFER);
- break;
- }
- assert(XA_RESULT_SUCCESS == result);
- }
-
- }
-
- // get the stream information interface
- XAStreamInformationItf playerStreamInformation;
- result = (*playerObject)->GetInterface(playerObject, XA_IID_STREAMINFORMATION,
- &playerStreamInformation);
- assert(XA_RESULT_SUCCESS == result);
-
- // register the stream event change callback
- result = (*playerStreamInformation)->RegisterStreamChangeCallback(playerStreamInformation,
- streamEventChangeCallback, NULL);
- assert(XA_RESULT_SUCCESS == result);
-
- // get the prefetch status interface
- XAPrefetchStatusItf playerPrefetchStatus;
- result = (*playerObject)->GetInterface(playerObject, XA_IID_PREFETCHSTATUS,
- &playerPrefetchStatus);
- assert(XA_RESULT_SUCCESS == result);
-
- // register prefetch status callback
- result = (*playerPrefetchStatus)->RegisterCallback(playerPrefetchStatus, prefetchStatusCallback,
- NULL);
- assert(XA_RESULT_SUCCESS == result);
- result = (*playerPrefetchStatus)->SetCallbackEventsMask(playerPrefetchStatus,
- XA_PREFETCHEVENT_FILLLEVELCHANGE | XA_PREFETCHEVENT_STATUSCHANGE);
- assert(XA_RESULT_SUCCESS == result);
-
- // get the seek interface
- if (looping) {
- XASeekItf playerSeek;
- result = (*playerObject)->GetInterface(playerObject, XA_IID_SEEK, &playerSeek);
- assert(XA_RESULT_SUCCESS == result);
- result = (*playerSeek)->SetLoop(playerSeek, XA_BOOLEAN_TRUE, (XAmillisecond) 0,
- XA_TIME_UNKNOWN);
- assert(XA_RESULT_SUCCESS == result);
- }
-
- // get the play interface
- XAPlayItf playerPlay;
- result = (*playerObject)->GetInterface(playerObject, XA_IID_PLAY, &playerPlay);
- assert(XA_RESULT_SUCCESS == result);
-
- // register play event callback
- result = (*playerPlay)->RegisterCallback(playerPlay, playEventCallback, NULL);
- assert(XA_RESULT_SUCCESS == result);
-#if 0 // FIXME broken
- result = (*playerPlay)->SetCallbackEventsMask(playerPlay,
- XA_PLAYEVENT_HEADATEND | XA_PLAYEVENT_HEADATMARKER | XA_PLAYEVENT_HEADATNEWPOS);
- assert(XA_RESULT_SUCCESS == result);
-#endif
-
- // set a marker
- result = (*playerPlay)->SetMarkerPosition(playerPlay, 10000);
- assert(XA_RESULT_SUCCESS == result);
-
- // set position update period
- result = (*playerPlay)->SetPositionUpdatePeriod(playerPlay, 1000);
- assert(XA_RESULT_SUCCESS == result);
-
- // get the duration
- XAmillisecond duration;
- result = (*playerPlay)->GetDuration(playerPlay, &duration);
- assert(XA_RESULT_SUCCESS == result);
- if (XA_TIME_UNKNOWN == duration)
- printf("Duration: unknown\n");
- else
- printf("Duration: %.1f\n", duration / 1000.0f);
-
- // set the player's state to paused, to start prefetching
- printf("start prefetch\n");
- result = (*playerPlay)->SetPlayState(playerPlay, XA_PLAYSTATE_PAUSED);
- assert(XA_RESULT_SUCCESS == result);
-
- // wait for prefetch status callback to indicate either sufficient data or error
- pthread_mutex_lock(&mutex);
- while (prefetch_status == PREFETCHSTATUS_UNKNOWN) {
- pthread_cond_wait(&cond, &mutex);
- }
- pthread_mutex_unlock(&mutex);
- if (prefetch_status == PREFETCHSTATUS_ERROR) {
- fprintf(stderr, "Error during prefetch, exiting\n");
- goto destroyRes;
- }
-
- // get duration again, now it should be known
- result = (*playerPlay)->GetDuration(playerPlay, &duration);
- assert(XA_RESULT_SUCCESS == result);
- if (duration == XA_TIME_UNKNOWN) {
- fprintf(stdout, "Content duration is unknown (after prefetch completed)\n");
- } else {
- fprintf(stdout, "Content duration is %u ms (after prefetch completed)\n", duration);
- }
-
- // start playing
- printf("starting to play\n");
- result = (*playerPlay)->SetPlayState(playerPlay, XA_PLAYSTATE_PLAYING);
- assert(XA_RESULT_SUCCESS == result);
-
- // continue playing until end of media
- for (;;) {
- XAuint32 status;
- result = (*playerPlay)->GetPlayState(playerPlay, &status);
- assert(XA_RESULT_SUCCESS == result);
- if (status == XA_PLAYSTATE_PAUSED)
- break;
- assert(status == XA_PLAYSTATE_PLAYING);
- sleep(1);
- }
-
- // wait a bit more in case of additional callbacks
- printf("end of media\n");
- sleep(3);
-
-destroyRes:
-
- // destroy the player
- (*playerObject)->Destroy(playerObject);
-
- // destroy the output mix
- (*outputMixObject)->Destroy(outputMixObject);
-
- // destroy the engine
- (*engineObject)->Destroy(engineObject);
-
-#ifdef REINITIALIZE
- if (--reinit_count > 0) {
- prefetch_status = PREFETCHSTATUS_UNKNOWN;
- goto reinitialize;
- }
-#endif
-
-#if 0
- if (nativeWindow != NULL) {
- ANativeWindow_release(nativeWindow);
- }
-#endif
-
-close:
- if (fd >= 0) {
- (void) close(fd);
- }
-
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tools/hashgen/MPH.h b/wilhelm/tools/hashgen/MPH.h
deleted file mode 120000
index 1411433..0000000
--- a/wilhelm/tools/hashgen/MPH.h
+++ /dev/null
@@ -1 +0,0 @@
-../../src/MPH.h
\ No newline at end of file
diff --git a/wilhelm/tools/hashgen/Makefile b/wilhelm/tools/hashgen/Makefile
deleted file mode 100644
index b9db863..0000000
--- a/wilhelm/tools/hashgen/Makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-all : IID_to_MPH.c
-
-install : IID_to_MPH.c
- cp IID_to_MPH.c ../../src/autogen
-
-CFLAGS = -I../../include -g -DNDEBUG
-
-%.o : %.c
- gcc -c -o $@ $(CFLAGS) $<
-
-IID_to_MPH.c : part1.c part2.c part3.c part4.c part5.c part6.c part7.c part8.c
- $(RM) $@
- cat part1.c part2.c part3.c part4.c part5.c part6.c part7.c part8.c >> $@
-
-# part1.c is human-generated
-
-part2.c : part23in.c
- $(RM) $@
- grep '#define MAX_HASH_VALUE' part23in.c > $@
-
-part3.c : part23in.c
- $(RM) $@
-# was 26,54p
- sed -n '/static const unsigned .* asso_values.. =/,/^ };/p' < part23in.c >> $@
-
-# part4.c is human-generated
-
-part5.c : part5gen
- ./part5gen > $@
-
-# part6.c is human-generated
-
-part7.c : part23in.c hash.sed
-# was 55p
- sed -n '/return.*asso_values/p' < part23in.c | sed -f hash.sed >> $@
-
-# part8.c is human_generated
-
-part23in.c : part23in.gperf
- gperf --null-strings --readonly-tables --compare-lengths part23in.gperf > part23in.c
-
-part23in.gperf : frag1
- ./frag1 > part23in.gperf
-
-frag1 : frag1.o OpenSLES_IID.o
- gcc -o $@ $(CFLAGS) frag1.o OpenSLES_IID.o
-
-part5gen.c : frag2.c part23in.c frag3.c
- $(RM) $@
- cp frag2.c $@
- grep '#define MAX_HASH_VALUE' part23in.c >> $@
-# was 81,156p
- sed -n '/static const char . const wordlist.. =/,/^ };/p' < part23in.c >> $@
- cat frag3.c >> $@
-
-part5gen : part5gen.o OpenSLES_IID.o interfaces.o
- gcc -o $@ $(CFLAGS) part5gen.o OpenSLES_IID.o interfaces.o
-
-clean :
- $(RM) part5gen frag1 *.o
- $(RM) part23in.gperf part5gen.c part23in.c
- $(RM) part2.c part3.c part5.c part7.c
-
-distclean : clean
- $(RM) IID_to_MPH.c
diff --git a/wilhelm/tools/hashgen/OpenSLES_IID.c b/wilhelm/tools/hashgen/OpenSLES_IID.c
deleted file mode 120000
index 01c15cc..0000000
--- a/wilhelm/tools/hashgen/OpenSLES_IID.c
+++ /dev/null
@@ -1 +0,0 @@
-../../src/OpenSLES_IID.c
\ No newline at end of file
diff --git a/wilhelm/tools/hashgen/README.txt b/wilhelm/tools/hashgen/README.txt
deleted file mode 100644
index 8ec523d..0000000
--- a/wilhelm/tools/hashgen/README.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-This re-generates the file IID_to_MPH.c using gperf.
-You need to do this after modifying either OpenSLES_IID.c or MPH.c.
-
-Prerequisites:
- * GNU make
- * GNU gperf perfect hash generator
-
-Usage:
-Type 'make'.
-Diff the old file in ../../src/autogen vs. the newly generated IID_to_MPH.c here.
-If the differences look OK, then copy the new IID_to_MPH.c back to
- its stable location in ../../src/autogen using 'make install'.
-Build and test the usage of the new IID.
-Then do 'make clean' or 'make distclean' here.
-
-hashgen is known to work on Linux with GNU gperf 3.0.3 and GNU sed
-version 4.2.1. There are reports of problems on Mac OS X.
diff --git a/wilhelm/tools/hashgen/frag1.c b/wilhelm/tools/hashgen/frag1.c
deleted file mode 100644
index 5424ed6..0000000
--- a/wilhelm/tools/hashgen/frag1.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This program prepares the input to gperf for hashing IIDs
-
-#include <SLES/OpenSLES.h>
-#include "MPH.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];
-
-int main(int argc, char **argv)
-{
- int MPH;
- const struct SLInterfaceID_ *x = SL_IID_array;
- for (MPH = 0; MPH < MPH_MAX; ++MPH, ++x) {
- unsigned char *y = (unsigned char *) x;
- unsigned k;
- printf("\"");
- for (k = 0; k < sizeof(struct SLInterfaceID_); ++k)
- printf("\\x%02X", y[k]);
- printf("\"\n");
- }
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tools/hashgen/frag2.c b/wilhelm/tools/hashgen/frag2.c
deleted file mode 100644
index 6880f37..0000000
--- a/wilhelm/tools/hashgen/frag2.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <SLES/OpenSLES.h>
-#include "MPH.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
diff --git a/wilhelm/tools/hashgen/frag3.c b/wilhelm/tools/hashgen/frag3.c
deleted file mode 100644
index 99eb3a0..0000000
--- a/wilhelm/tools/hashgen/frag3.c
+++ /dev/null
@@ -1,35 +0,0 @@
-
-extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];
-extern const char * const interface_names[MPH_MAX];
-extern void MPH_to_MPH_string(unsigned MPH, char buffer[40]);
-
-int main(int argc, char **argv)
-{
- int i;
- for (i = 0; i <= MAX_HASH_VALUE; ++i) {
- const char *x = wordlist[i];
- if (!x) {
- printf(" -1");
- } else {
- const struct SLInterfaceID_ *xx = SL_IID_array;
- unsigned MPH;
- for (MPH = 0; MPH < MPH_MAX; ++MPH, ++xx) {
- if (!memcmp(x, xx, 16)) {
- char buffer[40];
- buffer[39] = 'x';
- MPH_to_MPH_string(MPH, buffer);
- assert('x' == buffer[39]);
- printf(" %s", buffer);
- goto out;
- }
- }
- printf(" (-1)");
-out:
- ;
- }
- if (i < MAX_HASH_VALUE)
- printf(",");
- printf("\n");
- }
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tools/hashgen/hash.sed b/wilhelm/tools/hashgen/hash.sed
deleted file mode 100644
index 536e901..0000000
--- a/wilhelm/tools/hashgen/hash.sed
+++ /dev/null
@@ -1,3 +0,0 @@
-s/return/ unsigned key =/
-s/(unsigned char)str/((unsigned char *)iid)/g
-s/ + / +\n /
diff --git a/wilhelm/tools/hashgen/interfaces.c b/wilhelm/tools/hashgen/interfaces.c
deleted file mode 120000
index 4b75b6a..0000000
--- a/wilhelm/tools/hashgen/interfaces.c
+++ /dev/null
@@ -1 +0,0 @@
-../../src/interfaces.c
\ No newline at end of file
diff --git a/wilhelm/tools/hashgen/part1.c b/wilhelm/tools/hashgen/part1.c
deleted file mode 100644
index e4097be..0000000
--- a/wilhelm/tools/hashgen/part1.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// This file is automagically generated by hashgen, do not edit
-
-/** \file IID_to_MPH.c Interface ID to MPH mapping */
-
-#include <SLES/OpenSLES.h>
-#include "MPH.h"
-#include <assert.h>
-#include <string.h>
-
-extern const struct SLInterfaceID_ SL_IID_array[MPH_MAX];
-
-/** \brief Map SLInterfaceID to its minimal perfect hash (MPH), or -1 if unknown */
-
-int IID_to_MPH(const SLInterfaceID iid)
-{
diff --git a/wilhelm/tools/hashgen/part4.c b/wilhelm/tools/hashgen/part4.c
deleted file mode 100644
index 272bcec..0000000
--- a/wilhelm/tools/hashgen/part4.c
+++ /dev/null
@@ -1 +0,0 @@
- static const signed char hash_to_MPH[] = {
diff --git a/wilhelm/tools/hashgen/part6.c b/wilhelm/tools/hashgen/part6.c
deleted file mode 100644
index be40d9f..0000000
--- a/wilhelm/tools/hashgen/part6.c
+++ /dev/null
@@ -1,5 +0,0 @@
- };
- if (&SL_IID_array[0] <= iid && &SL_IID_array[MPH_MAX] > iid)
- return iid - &SL_IID_array[0];
- if (NULL != iid) {
- static const unsigned len = sizeof(struct SLInterfaceID_);
diff --git a/wilhelm/tools/hashgen/part8.c b/wilhelm/tools/hashgen/part8.c
deleted file mode 100644
index 79a88ab..0000000
--- a/wilhelm/tools/hashgen/part8.c
+++ /dev/null
@@ -1,12 +0,0 @@
- if (key <= MAX_HASH_VALUE) {
- int MPH = hash_to_MPH[key];
- if (MPH >= 0) {
- assert(MPH < MPH_MAX);
- SLInterfaceID trial = &SL_IID_array[MPH];
- if (!memcmp(iid, trial, sizeof(struct SLInterfaceID_)))
- return MPH;
- }
- }
- }
- return -1;
-}
diff --git a/wilhelm/tools/mphtogen/MPH.h b/wilhelm/tools/mphtogen/MPH.h
deleted file mode 120000
index 1411433..0000000
--- a/wilhelm/tools/mphtogen/MPH.h
+++ /dev/null
@@ -1 +0,0 @@
-../../src/MPH.h
\ No newline at end of file
diff --git a/wilhelm/tools/mphtogen/MPH_to.c b/wilhelm/tools/mphtogen/MPH_to.c
deleted file mode 120000
index e362396..0000000
--- a/wilhelm/tools/mphtogen/MPH_to.c
+++ /dev/null
@@ -1 +0,0 @@
-../../src/MPH_to.c
\ No newline at end of file
diff --git a/wilhelm/tools/mphtogen/MPH_to.h b/wilhelm/tools/mphtogen/MPH_to.h
deleted file mode 120000
index 9513f11..0000000
--- a/wilhelm/tools/mphtogen/MPH_to.h
+++ /dev/null
@@ -1 +0,0 @@
-../../src/MPH_to.h
\ No newline at end of file
diff --git a/wilhelm/tools/mphtogen/Makefile b/wilhelm/tools/mphtogen/Makefile
deleted file mode 100644
index 329292a..0000000
--- a/wilhelm/tools/mphtogen/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-DIR = ../../src/autogen
-ALL = $(DIR)/MPH_to_3DGroup.h $(DIR)/MPH_to_AudioPlayer.h $(DIR)/MPH_to_AudioRecorder.h \
- $(DIR)/MPH_to_Engine.h $(DIR)/MPH_to_LEDDevice.h $(DIR)/MPH_to_Listener.h \
- $(DIR)/MPH_to_MetadataExtractor.h $(DIR)/MPH_to_MidiPlayer.h $(DIR)/MPH_to_OutputMix.h \
- $(DIR)/MPH_to_Vibra.h
-
-$(ALL) : mphtogen
- ./mphtogen
-
-mphtogen : mphtogen.c MPH_to.c MPH.h MPH_to.h
- gcc -o $@ -DUSE_DESIGNATED_INITIALIZERS mphtogen.c MPH_to.c
-
-clean :
- $(RM) mphtogen
diff --git a/wilhelm/tools/mphtogen/README.txt b/wilhelm/tools/mphtogen/README.txt
deleted file mode 100644
index 4ff0a09..0000000
--- a/wilhelm/tools/mphtogen/README.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-This re-generates the file MPH_to_*.h.
-You need to do this after modifying any of the MPH-related files.
-
-Prerequisites:
- * GNU make
-
-Usage:
-Type 'make'.
-Diff the new files in ../../src/autogen vs. the new ones as sanity check.
-Build and test using the new header files.
-Then do 'make clean' here.
diff --git a/wilhelm/tools/mphtogen/mphtogen.c b/wilhelm/tools/mphtogen/mphtogen.c
deleted file mode 100644
index 9149202..0000000
--- a/wilhelm/tools/mphtogen/mphtogen.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Generate the MPH_to_*.h tables for C compilers that don't support designated initializers
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "MPH.h"
-#include "MPH_to.h"
-
-static void convert(const signed char MPH_to[MPH_MAX], const char *filename)
-{
- FILE *fp = fopen(filename, "w");
- assert(NULL != fp);
- fputs("// This file is automagically generated by mphtogen, do not edit\n", fp);
- unsigned i;
- unsigned len = 0;
- for (i = 0; i < MPH_MAX; ++i) {
- if (len > 0) {
- fputc(',', fp);
- ++len;
- }
- if (len > 78) {
- fputc('\n', fp);
- len = 0;
- }
- fprintf(fp, "%3d", MPH_to[i]);
- len += 3;
- }
- if (len > 0) {
- fputc('\n', fp);
- }
- fclose(fp);
-}
-
-#define _(x) convert(MPH_to_##x, "../../src/autogen/MPH_to_" #x ".h");
-
-int main(int argc, char **argv)
-{
- _(3DGroup)
- _(AudioPlayer)
- _(AudioRecorder)
- _(Engine)
- _(LEDDevice)
- _(Listener)
- _(MetadataExtractor)
- _(MidiPlayer)
- _(OutputMix)
- _(Vibra)
- _(MediaPlayer)
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tools/permute/Makefile b/wilhelm/tools/permute/Makefile
deleted file mode 100644
index 65ed44d..0000000
--- a/wilhelm/tools/permute/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-permute : permute.c
- gcc -o $@ -Wall permute.c -lsndfile
-
-clean :
- $(RM) $@
diff --git a/wilhelm/tools/permute/permute.c b/wilhelm/tools/permute/permute.c
deleted file mode 100644
index 4b6522e..0000000
--- a/wilhelm/tools/permute/permute.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Permute is a host tool to randomly permute an audio file.
- * It takes as input an ordinary .wav file and produces as output a
- * permuted .wav file and .map which can be given the seek torture test
- * located in seekTorture.c. A build prerequisite is libsndfile;
- * see installation instructions at http://www.mega-nerd.com/libsndfile/
- * The format of the .map file is a sequence of lines, each of which is:
- * seek_position_in_ms duration_in_ms
- */
-
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sndfile.h>
-
-
-/** Global variables */
-
-// command line options
-
-// mean length of each segment of the permutation, in seconds
-static double meanSegmentLengthSeconds = 5.0;
-// minimum length of each segment of the permutation, in seconds
-static double minSegmentLengthSeconds = 1.0;
-
-
-/** Describes each contiguous segment generated */
-
-typedef struct {
- unsigned mFrameStart;
- unsigned mFrameLength;
- unsigned mPermutedStart;
-} Segment;
-
-
-/** Global state during the split phase */
-
-typedef struct {
- // derived from command line options combined with file properties
- unsigned mMinSegmentLengthFrames;
- //unsigned mMeanSegmentLengthFrames;
- unsigned mSegmentMax; // maximum number of segments allowed
- unsigned mSegmentCount; // number of segments generated so far
- Segment *mSegmentArray; // storage for the segments [max]
-} State;
-
-
-/** Called by qsort as the comparison handler */
-
-static int qsortCompare(const void *x, const void *y)
-{
- const Segment *x_ = (Segment *) x;
- const Segment *y_ = (Segment *) y;
- return x_->mFrameStart - y_->mFrameStart;
-}
-
-
-/** Split the specified range of frames, using the allowed budget of segments.
- * Returns the actual number of segments consumed.
- */
-
-static unsigned split(State *s, unsigned frameStart, unsigned frameLength, unsigned segmentBudget)
-{
- if (frameLength <= 0)
- return 0;
- assert(segmentBudget > 0);
- if ((frameLength <= s->mMinSegmentLengthFrames*2) || (segmentBudget <= 1)) {
- assert(s->mSegmentCount < s->mSegmentMax);
- Segment *seg = &s->mSegmentArray[s->mSegmentCount++];
- seg->mFrameStart = frameStart;
- seg->mFrameLength = frameLength;
- seg->mPermutedStart = ~0;
- return 1;
- }
- // slop is how much wiggle room we have to play with
- unsigned slop = frameLength - s->mMinSegmentLengthFrames*2;
- assert(slop > 0);
- // choose a random cut point within the slop region
- unsigned r = rand() & 0x7FFFFFFF;
- unsigned cut = r % slop;
- unsigned leftStart = frameStart;
- unsigned leftLength = s->mMinSegmentLengthFrames + cut;
- unsigned rightStart = frameStart + leftLength;
- unsigned rightLength = s->mMinSegmentLengthFrames + (slop - cut);
- assert(leftLength + rightLength == frameLength);
- // process the two sides in random order
- assert(segmentBudget >= 2);
- unsigned used;
- if (leftLength <= rightLength) {
- used = split(s, leftStart, leftLength, segmentBudget / 2);
- used += split(s, rightStart, rightLength, segmentBudget - used);
- } else {
- used = split(s, rightStart, rightLength, segmentBudget / 2);
- used += split(s, leftStart, leftLength, segmentBudget - used);
- }
- assert(used >= 2);
- assert(used <= segmentBudget);
- return used;
-}
-
-
-/** Permute the specified input file */
-
-void permute(char *path_in)
-{
-
- // Open the file using libsndfile
- SNDFILE *sf_in;
- SF_INFO sfinfo_in;
- sfinfo_in.format = 0;
- sf_in = sf_open(path_in, SFM_READ, &sfinfo_in);
- if (NULL == sf_in) {
- perror(path_in);
- return;
- }
-
- // Check if it is a supported file format: must be WAV
- unsigned type = sfinfo_in.format & SF_FORMAT_TYPEMASK;
- switch (type) {
- case SF_FORMAT_WAV:
- break;
- default:
- fprintf(stderr, "%s: unsupported type 0x%X\n", path_in, type);
- goto out;
- }
-
- // Must be 16-bit signed or 8-bit unsigned PCM
- unsigned subtype = sfinfo_in.format & SF_FORMAT_SUBMASK;
- unsigned sampleSizeIn = 0;
- switch (subtype) {
- case SF_FORMAT_PCM_16:
- sampleSizeIn = 2;
- break;
- case SF_FORMAT_PCM_U8:
- sampleSizeIn = 1;
- break;
- default:
- fprintf(stderr, "%s: unsupported subtype 0x%X\n", path_in, subtype);
- goto out;
- }
- // always read shorts
- unsigned sampleSizeRead = 2;
-
- // Must be little-endian
- unsigned endianness = sfinfo_in.format & SF_FORMAT_ENDMASK;
- switch (endianness) {
- case SF_ENDIAN_FILE:
- case SF_ENDIAN_LITTLE:
- break;
- default:
- fprintf(stderr, "%s: unsupported endianness 0x%X\n", path_in, endianness);
- goto out;
- }
-
- // Must be a known sample rate
- switch (sfinfo_in.samplerate) {
- case 8000:
- case 11025:
- case 16000:
- case 22050:
- case 32000:
- case 44100:
- case 48000:
- break;
- default:
- fprintf(stderr, "%s: unsupported sample rate %d\n", path_in, sfinfo_in.samplerate);
- goto out;
- }
-
- // Must be either stereo or mono
- unsigned frameSizeIn = 0;
- unsigned frameSizeRead = 0;
- switch (sfinfo_in.channels) {
- case 1:
- case 2:
- frameSizeIn = sampleSizeIn * sfinfo_in.channels;
- frameSizeRead = sampleSizeRead * sfinfo_in.channels;
- break;
- default:
- fprintf(stderr, "%s: unsupported channels %d\n", path_in, sfinfo_in.channels);
- goto out;
- }
-
- // Duration must be known
- switch (sfinfo_in.frames) {
- case (sf_count_t) 0:
- case (sf_count_t) ~0:
- fprintf(stderr, "%s: unsupported frames %d\n", path_in, (int) sfinfo_in.frames);
- goto out;
- default:
- break;
- }
-
- // Allocate space to hold the audio data, based on duration
- double durationSeconds = (double) sfinfo_in.frames / (double) sfinfo_in.samplerate;
- State s;
- s.mMinSegmentLengthFrames = minSegmentLengthSeconds * sfinfo_in.samplerate;
- if (s.mMinSegmentLengthFrames <= 0)
- s.mMinSegmentLengthFrames = 1;
- s.mSegmentMax = durationSeconds / meanSegmentLengthSeconds;
- if (s.mSegmentMax <= 0)
- s.mSegmentMax = 1;
- s.mSegmentCount = 0;
- s.mSegmentArray = (Segment *) malloc(sizeof(Segment) * s.mSegmentMax);
- assert(s.mSegmentArray != NULL);
- unsigned used;
- used = split(&s, 0, sfinfo_in.frames, s.mSegmentMax);
- assert(used <= s.mSegmentMax);
- assert(used == s.mSegmentCount);
-
- // now permute the segments randomly using a bad algorithm
- unsigned i;
- for (i = 0; i < used; ++i) {
- unsigned r = rand() & 0x7FFFFFFF;
- unsigned j = r % used;
- if (j != i) {
- Segment temp = s.mSegmentArray[i];
- s.mSegmentArray[i] = s.mSegmentArray[j];
- s.mSegmentArray[j] = temp;
- }
- }
-
- // read the entire file into memory
- void *ptr = malloc(sfinfo_in.frames * frameSizeRead);
- assert(NULL != ptr);
- sf_count_t count;
- count = sf_readf_short(sf_in, ptr, sfinfo_in.frames);
- if (count != sfinfo_in.frames) {
- fprintf(stderr, "%s: expected to read %d frames but actually read %d frames\n", path_in,
- (int) sfinfo_in.frames, (int) count);
- goto out;
- }
-
- // Create a permuted output file
- char *path_out = malloc(strlen(path_in) + 8);
- assert(path_out != NULL);
- strcpy(path_out, path_in);
- strcat(path_out, ".wav");
- SNDFILE *sf_out;
- SF_INFO sfinfo_out;
- memset(&sfinfo_out, 0, sizeof(SF_INFO));
- sfinfo_out.samplerate = sfinfo_in.samplerate;
- sfinfo_out.channels = sfinfo_in.channels;
- sfinfo_out.format = sfinfo_in.format;
- sf_out = sf_open(path_out, SFM_WRITE, &sfinfo_out);
- if (sf_out == NULL) {
- perror(path_out);
- goto out;
- }
- unsigned permutedStart = 0;
- for (i = 0; i < used; ++i) {
- s.mSegmentArray[i].mPermutedStart = permutedStart;
- count = sf_writef_short(sf_out, &((short *) ptr)[sfinfo_in.channels * s.mSegmentArray[i]
- .mFrameStart], s.mSegmentArray[i].mFrameLength);
- if (count != s.mSegmentArray[i].mFrameLength) {
- fprintf(stderr, "%s: expected to write %d frames but actually wrote %d frames\n",
- path_out, (int) s.mSegmentArray[i].mFrameLength, (int) count);
- break;
- }
- permutedStart += s.mSegmentArray[i].mFrameLength;
- }
- assert(permutedStart == sfinfo_in.frames);
- sf_close(sf_out);
-
- // now create a seek map to let us play this back in a reasonable order
- qsort((void *) s.mSegmentArray, used, sizeof(Segment), qsortCompare);
- char *path_map = malloc(strlen(path_in) + 8);
- assert(path_map != NULL);
- strcpy(path_map, path_in);
- strcat(path_map, ".map");
- FILE *fp_map = fopen(path_map, "w");
- if (fp_map == NULL) {
- perror(path_map);
- } else {
- for (i = 0; i < used; ++i)
- fprintf(fp_map, "%u %u\n", (unsigned) ((s.mSegmentArray[i].mPermutedStart * 1000.0) /
- sfinfo_in.samplerate), (unsigned) ((s.mSegmentArray[i].mFrameLength * 1000.0) /
- sfinfo_in.samplerate));
- fclose(fp_map);
- }
-
-out:
- // Close the input file
- sf_close(sf_in);
-}
-
-
-// main program
-
-int main(int argc, char **argv)
-{
- int i;
- for (i = 1; i < argc; ++i) {
- char *arg = argv[i];
-
- // process command line options
- if (!strncmp(arg, "-m", 2)) {
- double mval = atof(&arg[2]);
- if (mval >= 0.1 && mval <= 1000.0)
- minSegmentLengthSeconds = mval;
- else
- fprintf(stderr, "%s: invalid value %s\n", argv[0], arg);
- continue;
- }
- if (!strncmp(arg, "-s", 2)) {
- double sval = atof(&arg[2]);
- if (sval >= 0.1 && sval <= 1000.0)
- meanSegmentLengthSeconds = sval;
- else
- fprintf(stderr, "%s: invalid value %s\n", argv[0], arg);
- continue;
- }
- if (!strncmp(arg, "-r", 2)) {
- srand(atoi(&arg[2]));
- continue;
- }
- if (meanSegmentLengthSeconds < minSegmentLengthSeconds)
- meanSegmentLengthSeconds = minSegmentLengthSeconds * 2.0;
-
- // Permute the file
- permute(arg);
-
- }
- return EXIT_SUCCESS;
-}
diff --git a/wilhelm/tools/permute/readme.txt b/wilhelm/tools/permute/readme.txt
deleted file mode 100644
index 44f4159..0000000
--- a/wilhelm/tools/permute/readme.txt
+++ /dev/null
@@ -1 +0,0 @@
-See comments at top of permute.c for information on how to build and use.