summaryrefslogtreecommitdiffstats
path: root/media/libeffects/testlibs
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-05-17 19:16:02 -0700
committerEric Laurent <elaurent@google.com>2011-05-27 15:15:00 -0700
commite1315cf0b63b4c14a77046519e6b01f6f60d74b0 (patch)
treec10fd288fd0d0d85c619e7e635a249765202fabc /media/libeffects/testlibs
parenta3e73df3b402f1ebdbef7c8a8e3111d852e7bd35 (diff)
downloadframeworks_av-e1315cf0b63b4c14a77046519e6b01f6f60d74b0.zip
frameworks_av-e1315cf0b63b4c14a77046519e6b01f6f60d74b0.tar.gz
frameworks_av-e1315cf0b63b4c14a77046519e6b01f6f60d74b0.tar.bz2
New effect library API
Moved and renamed media/EffectApi.h to hardware/audio_effect.h Modified the effect library API to expose a library info structure containing an interface functions table. Also removed enums for audio channels, audio format and devices from effect API and use values from system/audio.h instead. Modified effects factory to support new library interface format and load libraries and efffects listed in audio_effects.conf file. The file audio_effects.conf is first loaded from /vendor/etc and then from /system/etc/audio_effects.conf if not found. Modified existing effect libraries to implement the new library interface. Change-Id: Ie52351e071b6d352fa2fbc06c3846686f8c45df9
Diffstat (limited to 'media/libeffects/testlibs')
-rw-r--r--media/libeffects/testlibs/Android.mk_4
-rw-r--r--media/libeffects/testlibs/AudioFormatAdapter.h8
-rw-r--r--media/libeffects/testlibs/EffectEqualizer.cpp117
-rw-r--r--media/libeffects/testlibs/EffectReverb.c122
-rw-r--r--media/libeffects/testlibs/EffectReverb.h15
5 files changed, 194 insertions, 72 deletions
diff --git a/media/libeffects/testlibs/Android.mk_ b/media/libeffects/testlibs/Android.mk_
index 9ba71ed..98d477b 100644
--- a/media/libeffects/testlibs/Android.mk_
+++ b/media/libeffects/testlibs/Android.mk_
@@ -25,7 +25,7 @@ endif
LOCAL_C_INCLUDES := \
$(call include-path-for, graphics corecg)
-LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
@@ -60,7 +60,7 @@ endif
LOCAL_C_INCLUDES := \
$(call include-path-for, graphics corecg)
-LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libeffects/testlibs/AudioFormatAdapter.h b/media/libeffects/testlibs/AudioFormatAdapter.h
index d93ebe9..41f1810 100644
--- a/media/libeffects/testlibs/AudioFormatAdapter.h
+++ b/media/libeffects/testlibs/AudioFormatAdapter.h
@@ -18,7 +18,7 @@
#ifndef AUDIOFORMATADAPTER_H_
#define AUDIOFORMATADAPTER_H_
-#include <media/EffectApi.h>
+#include <hardware/audio_effect.h>
#define min(x,y) (((x) < (y)) ? (x) : (y))
@@ -75,7 +75,7 @@ public:
while (numSamples > 0) {
uint32_t numSamplesIter = min(numSamples, mMaxSamplesPerCall);
uint32_t nSamplesChannels = numSamplesIter * mNumChannels;
- if (mPcmFormat == SAMPLE_FORMAT_PCM_S7_24) {
+ if (mPcmFormat == AUDIO_FORMAT_PCM_8_24_BIT) {
if (mBehavior == EFFECT_BUFFER_ACCESS_WRITE) {
mpProcessor->process(
reinterpret_cast<const audio_sample_t *> (pIn),
@@ -125,7 +125,7 @@ private:
// sample.
// numSamples The number of single-channel samples to process.
void ConvertInput(const void *& pIn, uint32_t numSamples) {
- if (mPcmFormat == SAMPLE_FORMAT_PCM_S15) {
+ if (mPcmFormat == AUDIO_FORMAT_PCM_16_BIT) {
const int16_t * pIn16 = reinterpret_cast<const int16_t *>(pIn);
audio_sample_t * pOut = mBuffer;
while (numSamples-- > 0) {
@@ -143,7 +143,7 @@ private:
// When function exist will point to the next output sample.
// numSamples The number of single-channel samples to process.
void ConvertOutput(void *& pOut, uint32_t numSamples) {
- if (mPcmFormat == SAMPLE_FORMAT_PCM_S15) {
+ if (mPcmFormat == AUDIO_FORMAT_PCM_16_BIT) {
const audio_sample_t * pIn = mBuffer;
int16_t * pOut16 = reinterpret_cast<int16_t *>(pOut);
if (mBehavior == EFFECT_BUFFER_ACCESS_WRITE) {
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index f8e4357..43dfa82 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -28,7 +28,7 @@
#include "AudioFormatAdapter.h"
#include <media/EffectEqualizerApi.h>
-// effect_interface_t interface implementation for equalizer effect
+// effect_handle_t interface implementation for equalizer effect
extern "C" const struct effect_interface_s gEqualizerInterface;
enum equalizer_state_e {
@@ -44,12 +44,12 @@ namespace {
const effect_descriptor_t gEqualizerDescriptor = {
{0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type
{0xe25aa840, 0x543b, 0x11df, 0x98a5, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
(EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST),
0, // TODO
1,
"Graphic Equalizer",
- "Google Inc.",
+ "The Android Open Source Project",
};
/////////////////// BEGIN EQ PRESETS ///////////////////////////////////////////
@@ -127,7 +127,8 @@ extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects) {
return 0;
} /* end EffectQueryNumberEffects */
-extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
+extern "C" int EffectQueryEffect(uint32_t index,
+ effect_descriptor_t *pDescriptor) {
if (pDescriptor == NULL) {
return -EINVAL;
}
@@ -139,15 +140,15 @@ extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescripto
} /* end EffectQueryNext */
extern "C" int EffectCreate(effect_uuid_t *uuid,
- int32_t sessionId,
- int32_t ioId,
- effect_interface_t *pInterface) {
+ int32_t sessionId,
+ int32_t ioId,
+ effect_handle_t *pHandle) {
int ret;
int i;
LOGV("EffectLibCreateEffect start");
- if (pInterface == NULL || uuid == NULL) {
+ if (pHandle == NULL || uuid == NULL) {
return -EINVAL;
}
@@ -168,19 +169,20 @@ extern "C" int EffectCreate(effect_uuid_t *uuid,
return ret;
}
- *pInterface = (effect_interface_t)pContext;
+ *pHandle = (effect_handle_t)pContext;
pContext->state = EQUALIZER_STATE_INITIALIZED;
- LOGV("EffectLibCreateEffect %p, size %d", pContext, AudioEqualizer::GetInstanceSize(kNumBands)+sizeof(EqualizerContext));
+ LOGV("EffectLibCreateEffect %p, size %d",
+ pContext, AudioEqualizer::GetInstanceSize(kNumBands)+sizeof(EqualizerContext));
return 0;
} /* end EffectCreate */
-extern "C" int EffectRelease(effect_interface_t interface) {
- EqualizerContext * pContext = (EqualizerContext *)interface;
+extern "C" int EffectRelease(effect_handle_t handle) {
+ EqualizerContext * pContext = (EqualizerContext *)handle;
- LOGV("EffectLibReleaseEffect %p", interface);
+ LOGV("EffectLibReleaseEffect %p", handle);
if (pContext == NULL) {
return -EINVAL;
}
@@ -192,6 +194,22 @@ extern "C" int EffectRelease(effect_interface_t interface) {
return 0;
} /* end EffectRelease */
+extern "C" int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor) {
+
+ if (pDescriptor == NULL || uuid == NULL){
+ LOGV("EffectGetDescriptor() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
+ memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
+ return 0;
+ }
+
+ return -EINVAL;
+} /* end EffectGetDescriptor */
+
//
//--- local functions
@@ -228,14 +246,15 @@ int Equalizer_configure(EqualizerContext *pContext, effect_config_t *pConfig)
CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels);
CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
- CHECK_ARG((pConfig->inputCfg.channels == CHANNEL_MONO) || (pConfig->inputCfg.channels == CHANNEL_STEREO));
+ CHECK_ARG((pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_MONO) ||
+ (pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO));
CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
|| pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
- CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S7_24
- || pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
+ CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_8_24_BIT
+ || pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT);
int channelCount;
- if (pConfig->inputCfg.channels == CHANNEL_MONO) {
+ if (pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_MONO) {
channelCount = 1;
} else {
channelCount = 2;
@@ -281,16 +300,16 @@ int Equalizer_init(EqualizerContext *pContext)
}
pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
- pContext->config.inputCfg.channels = CHANNEL_STEREO;
- pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.inputCfg.samplingRate = 44100;
pContext->config.inputCfg.bufferProvider.getBuffer = NULL;
pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL;
pContext->config.inputCfg.bufferProvider.cookie = NULL;
pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL;
pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
- pContext->config.outputCfg.channels = CHANNEL_STEREO;
- pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pContext->config.outputCfg.samplingRate = 44100;
pContext->config.outputCfg.bufferProvider.getBuffer = NULL;
pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
@@ -402,7 +421,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
case EQ_PARAM_LEVEL_RANGE:
*(int16_t *)pValue = -9600;
*((int16_t *)pValue + 1) = 4800;
- LOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", *(int32_t *)pValue, *((int32_t *)pValue + 1));
+ LOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d",
+ *(int32_t *)pValue, *((int32_t *)pValue + 1));
break;
case EQ_PARAM_BAND_LEVEL:
@@ -412,7 +432,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
break;
}
*(int16_t *)pValue = (int16_t)pEqualizer->getGain(param2);
- LOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", param2, *(int32_t *)pValue);
+ LOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d",
+ param2, *(int32_t *)pValue);
break;
case EQ_PARAM_CENTER_FREQ:
@@ -422,7 +443,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
break;
}
*(int32_t *)pValue = pEqualizer->getFrequency(param2);
- LOGV("Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", param2, *(int32_t *)pValue);
+ LOGV("Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d",
+ param2, *(int32_t *)pValue);
break;
case EQ_PARAM_BAND_FREQ_RANGE:
@@ -432,13 +454,15 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
break;
}
pEqualizer->getBandRange(param2, *(uint32_t *)pValue, *((uint32_t *)pValue + 1));
- LOGV("Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
+ LOGV("Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d",
+ param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
break;
case EQ_PARAM_GET_BAND:
param2 = *pParam;
*(uint16_t *)pValue = (uint16_t)pEqualizer->getMostRelevantBand(param2);
- LOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", param2, *(int32_t *)pValue);
+ LOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
+ param2, *(int32_t *)pValue);
break;
case EQ_PARAM_CUR_PRESET:
@@ -461,7 +485,8 @@ int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t
strncpy(name, pEqualizer->getPresetName(param2), *pValueSize - 1);
name[*pValueSize - 1] = 0;
*pValueSize = strlen(name) + 1;
- LOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", param2, gEqualizerPresets[param2].name, *pValueSize);
+ LOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d",
+ param2, gEqualizerPresets[param2].name, *pValueSize);
break;
case EQ_PARAM_PROPERTIES: {
@@ -571,7 +596,7 @@ int Equalizer_setParameter (AudioEqualizer * pEqualizer, int32_t *pParam, void *
//--- Effect Control Interface Implementation
//
-extern "C" int Equalizer_process(effect_interface_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
+extern "C" int Equalizer_process(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
{
android::EqualizerContext * pContext = (android::EqualizerContext *) self;
@@ -596,7 +621,7 @@ extern "C" int Equalizer_process(effect_interface_t self, audio_buffer_t *inBuff
return 0;
} // end Equalizer_process
-extern "C" int Equalizer_command(effect_interface_t self, uint32_t cmdCode, uint32_t cmdSize,
+extern "C" int Equalizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize,
void *pCmdData, uint32_t *replySize, void *pReplyData) {
android::EqualizerContext * pContext = (android::EqualizerContext *) self;
@@ -647,7 +672,8 @@ extern "C" int Equalizer_command(effect_interface_t self, uint32_t cmdCode, uint
} break;
case EFFECT_CMD_SET_PARAM: {
- LOGV("Equalizer_command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p", cmdSize, pCmdData, *replySize, pReplyData);
+ LOGV("Equalizer_command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p",
+ cmdSize, pCmdData, *replySize, pReplyData);
if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
pReplyData == NULL || *replySize != sizeof(int32_t)) {
return -EINVAL;
@@ -690,10 +716,37 @@ extern "C" int Equalizer_command(effect_interface_t self, uint32_t cmdCode, uint
return 0;
}
-// effect_interface_t interface implementation for equalizer effect
+extern "C" int Equalizer_getDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor)
+{
+ android::EqualizerContext * pContext = (android::EqualizerContext *) self;
+
+ if (pContext == NULL || pDescriptor == NULL) {
+ LOGV("Equalizer_getDescriptor() invalid param");
+ return -EINVAL;
+ }
+
+ memcpy(pDescriptor, &android::gEqualizerDescriptor, sizeof(effect_descriptor_t));
+
+ return 0;
+}
+
+// effect_handle_t interface implementation for equalizer effect
const struct effect_interface_s gEqualizerInterface = {
Equalizer_process,
- Equalizer_command
+ Equalizer_command,
+ Equalizer_getDescriptor
};
+audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
+ tag : AUDIO_EFFECT_LIBRARY_TAG,
+ version : EFFECT_LIBRARY_API_VERSION,
+ name : "Test Equalizer Library",
+ implementor : "The Android Open Source Project",
+ query_num_effects : android::EffectQueryNumberEffects,
+ query_effect : android::EffectQueryEffect,
+ create_effect : android::EffectCreate,
+ release_effect : android::EffectRelease,
+ get_descriptor : android::EffectGetDescriptor,
+};
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index 3eb8b2c..02762c9 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -23,59 +23,60 @@
#include "EffectReverb.h"
#include "EffectsMath.h"
-// effect_interface_t interface implementation for reverb effect
+// effect_handle_t interface implementation for reverb effect
const struct effect_interface_s gReverbInterface = {
Reverb_Process,
- Reverb_Command
+ Reverb_Command,
+ Reverb_GetDescriptor
};
// Google auxiliary environmental reverb UUID: 1f0ae2e0-4ef7-11df-bc09-0002a5d5c51b
static const effect_descriptor_t gAuxEnvReverbDescriptor = {
{0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, {0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e}},
{0x1f0ae2e0, 0x4ef7, 0x11df, 0xbc09, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
// flags other than EFFECT_FLAG_TYPE_AUXILIARY set for test purpose
EFFECT_FLAG_TYPE_AUXILIARY | EFFECT_FLAG_DEVICE_IND | EFFECT_FLAG_AUDIO_MODE_IND,
0, // TODO
33,
"Aux Environmental Reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// Google insert environmental reverb UUID: aa476040-6342-11df-91a4-0002a5d5c51b
static const effect_descriptor_t gInsertEnvReverbDescriptor = {
{0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, {0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e}},
{0xaa476040, 0x6342, 0x11df, 0x91a4, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST,
0, // TODO
33,
"Insert Environmental reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// Google auxiliary preset reverb UUID: 63909320-53a6-11df-bdbd-0002a5d5c51b
static const effect_descriptor_t gAuxPresetReverbDescriptor = {
{0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
{0x63909320, 0x53a6, 0x11df, 0xbdbd, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_AUXILIARY,
0, // TODO
33,
"Aux Preset Reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// Google insert preset reverb UUID: d93dc6a0-6342-11df-b128-0002a5d5c51b
static const effect_descriptor_t gInsertPresetReverbDescriptor = {
{0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
{0xd93dc6a0, 0x6342, 0x11df, 0xb128, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}},
- EFFECT_API_VERSION,
+ EFFECT_CONTROL_API_VERSION,
EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST,
0, // TODO
33,
"Insert Preset Reverb",
- "Google Inc."
+ "The Android Open Source Project"
};
// gDescriptors contains pointers to all defined effect descriptor in this library
@@ -112,7 +113,7 @@ int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
int EffectCreate(effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
- effect_interface_t *pInterface) {
+ effect_handle_t *pHandle) {
int ret;
int i;
reverb_module_t *module;
@@ -122,7 +123,7 @@ int EffectCreate(effect_uuid_t *uuid,
LOGV("EffectLibCreateEffect start");
- if (pInterface == NULL || uuid == NULL) {
+ if (pHandle == NULL || uuid == NULL) {
return -EINVAL;
}
@@ -157,7 +158,7 @@ int EffectCreate(effect_uuid_t *uuid,
return ret;
}
- *pInterface = (effect_interface_t) module;
+ *pHandle = (effect_handle_t) module;
module->context.mState = REVERB_STATE_INITIALIZED;
@@ -166,11 +167,11 @@ int EffectCreate(effect_uuid_t *uuid,
return 0;
}
-int EffectRelease(effect_interface_t interface) {
- reverb_module_t *pRvbModule = (reverb_module_t *)interface;
+int EffectRelease(effect_handle_t handle) {
+ reverb_module_t *pRvbModule = (reverb_module_t *)handle;
- LOGV("EffectLibReleaseEffect %p", interface);
- if (interface == NULL) {
+ LOGV("EffectLibReleaseEffect %p", handle);
+ if (handle == NULL) {
return -EINVAL;
}
@@ -180,10 +181,31 @@ int EffectRelease(effect_interface_t interface) {
return 0;
}
+int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor) {
+ int i;
+ int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
+
+ if (pDescriptor == NULL || uuid == NULL){
+ LOGV("EffectGetDescriptor() called with NULL pointer");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < length; i++) {
+ if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
+ memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t));
+ LOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
+ i, gDescriptors[i]->uuid.timeLow);
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+} /* end EffectGetDescriptor */
/*--- Effect Control Interface Implementation ---*/
-static int Reverb_Process(effect_interface_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) {
+static int Reverb_Process(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) {
reverb_object_t *pReverb;
int16_t *pSrc, *pDst;
reverb_module_t *pRvbModule = (reverb_module_t *)self;
@@ -270,7 +292,7 @@ static int Reverb_Process(effect_interface_t self, audio_buffer_t *inBuffer, aud
}
-static int Reverb_Command(effect_interface_t self, uint32_t cmdCode, uint32_t cmdSize,
+static int Reverb_Command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize,
void *pCmdData, uint32_t *replySize, void *pReplyData) {
reverb_module_t *pRvbModule = (reverb_module_t *) self;
reverb_object_t *pReverb;
@@ -383,6 +405,38 @@ static int Reverb_Command(effect_interface_t self, uint32_t cmdCode, uint32_t cm
return 0;
}
+int Reverb_GetDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor)
+{
+ reverb_module_t *pRvbModule = (reverb_module_t *) self;
+ reverb_object_t *pReverb;
+ const effect_descriptor_t *desc;
+
+ if (pRvbModule == NULL ||
+ pRvbModule->context.mState == REVERB_STATE_UNINITIALIZED) {
+ return -EINVAL;
+ }
+
+ pReverb = (reverb_object_t*) &pRvbModule->context;
+
+ if (pReverb->m_Aux) {
+ if (pReverb->m_Preset) {
+ desc = &gAuxPresetReverbDescriptor;
+ } else {
+ desc = &gAuxEnvReverbDescriptor;
+ }
+ } else {
+ if (pReverb->m_Preset) {
+ desc = &gInsertPresetReverbDescriptor;
+ } else {
+ desc = &gInsertEnvReverbDescriptor;
+ }
+ }
+
+ memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+
+ return 0;
+} /* end Reverb_getDescriptor */
/*----------------------------------------------------------------------------
* Reverb internal functions
@@ -418,19 +472,19 @@ int Reverb_Init(reverb_module_t *pRvbModule, int aux, int preset) {
pRvbModule->config.inputCfg.samplingRate = 44100;
if (aux) {
- pRvbModule->config.inputCfg.channels = CHANNEL_MONO;
+ pRvbModule->config.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO;
} else {
- pRvbModule->config.inputCfg.channels = CHANNEL_STEREO;
+ pRvbModule->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
}
- pRvbModule->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pRvbModule->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pRvbModule->config.inputCfg.bufferProvider.getBuffer = NULL;
pRvbModule->config.inputCfg.bufferProvider.releaseBuffer = NULL;
pRvbModule->config.inputCfg.bufferProvider.cookie = NULL;
pRvbModule->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
pRvbModule->config.inputCfg.mask = EFFECT_CONFIG_ALL;
pRvbModule->config.outputCfg.samplingRate = 44100;
- pRvbModule->config.outputCfg.channels = CHANNEL_STEREO;
- pRvbModule->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
+ pRvbModule->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
+ pRvbModule->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
pRvbModule->config.outputCfg.bufferProvider.getBuffer = NULL;
pRvbModule->config.outputCfg.bufferProvider.releaseBuffer = NULL;
pRvbModule->config.outputCfg.bufferProvider.cookie = NULL;
@@ -474,13 +528,13 @@ int Reverb_Configure(reverb_module_t *pRvbModule, effect_config_t *pConfig,
if (pConfig->inputCfg.samplingRate
!= pConfig->outputCfg.samplingRate
|| pConfig->outputCfg.channels != OUTPUT_CHANNELS
- || pConfig->inputCfg.format != SAMPLE_FORMAT_PCM_S15
- || pConfig->outputCfg.format != SAMPLE_FORMAT_PCM_S15) {
+ || pConfig->inputCfg.format != AUDIO_FORMAT_PCM_16_BIT
+ || pConfig->outputCfg.format != AUDIO_FORMAT_PCM_16_BIT) {
LOGV("Reverb_Configure invalid config");
return -EINVAL;
}
- if ((pReverb->m_Aux && (pConfig->inputCfg.channels != CHANNEL_MONO)) ||
- (!pReverb->m_Aux && (pConfig->inputCfg.channels != CHANNEL_STEREO))) {
+ if ((pReverb->m_Aux && (pConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_MONO)) ||
+ (!pReverb->m_Aux && (pConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO))) {
LOGV("Reverb_Configure invalid config");
return -EINVAL;
}
@@ -2133,3 +2187,15 @@ static int ReverbReadInPresets(reverb_object_t *pReverb) {
return 0;
}
+
+audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
+ .tag = AUDIO_EFFECT_LIBRARY_TAG,
+ .version = EFFECT_LIBRARY_API_VERSION,
+ .name = "Test Equalizer Library",
+ .implementor = "The Android Open Source Project",
+ .query_num_effects = EffectQueryNumberEffects,
+ .query_effect = EffectQueryEffect,
+ .create_effect = EffectCreate,
+ .release_effect = EffectRelease,
+ .get_descriptor = EffectGetDescriptor,
+};
diff --git a/media/libeffects/testlibs/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h
index dbcd192..a239814 100644
--- a/media/libeffects/testlibs/EffectReverb.h
+++ b/media/libeffects/testlibs/EffectReverb.h
@@ -40,7 +40,7 @@ if the buffer size is a power of two.
)
#define NUM_OUTPUT_CHANNELS 2
-#define OUTPUT_CHANNELS CHANNEL_STEREO
+#define OUTPUT_CHANNELS AUDIO_CHANNEL_OUT_STEREO
#define REVERB_BUFFER_SIZE_IN_SAMPLES_MAX 16384
@@ -306,19 +306,22 @@ int EffectQueryEffect(uint32_t index,
int EffectCreate(effect_uuid_t *effectUID,
int32_t sessionId,
int32_t ioId,
- effect_interface_t *pInterface);
-int EffectRelease(effect_interface_t interface);
+ effect_handle_t *pHandle);
+int EffectRelease(effect_handle_t handle);
+int EffectGetDescriptor(effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor);
-static int Reverb_Process(effect_interface_t self,
+static int Reverb_Process(effect_handle_t self,
audio_buffer_t *inBuffer,
audio_buffer_t *outBuffer);
-static int Reverb_Command(effect_interface_t self,
+static int Reverb_Command(effect_handle_t self,
uint32_t cmdCode,
uint32_t cmdSize,
void *pCmdData,
uint32_t *replySize,
void *pReplyData);
-
+static int Reverb_GetDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor);
/*------------------------------------
* internal functions