diff options
Diffstat (limited to 'media/libeffects')
-rw-r--r-- | media/libeffects/downmix/EffectDownmix.c | 9 | ||||
-rw-r--r-- | media/libeffects/factory/EffectsFactory.c | 4 | ||||
-rw-r--r-- | media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp | 55 | ||||
-rw-r--r-- | media/libeffects/lvm/wrapper/Bundle/EffectBundle.h | 2 |
4 files changed, 44 insertions, 26 deletions
diff --git a/media/libeffects/downmix/EffectDownmix.c b/media/libeffects/downmix/EffectDownmix.c index 4a41037..18059b2 100644 --- a/media/libeffects/downmix/EffectDownmix.c +++ b/media/libeffects/downmix/EffectDownmix.c @@ -624,9 +624,12 @@ int Downmix_Configure(downmix_module_t *pDwmModule, effect_config_t *pConfig, bo pDownmixer->apply_volume_correction = false; pDownmixer->input_channel_count = 8; // matches default input of AUDIO_CHANNEL_OUT_7POINT1 } else { - // when configuring the effect, do not allow a blank channel mask - if (pConfig->inputCfg.channels == 0) { - ALOGE("Downmix_Configure error: input channel mask can't be 0"); + // when configuring the effect, do not allow a blank or unsupported channel mask + if ((pConfig->inputCfg.channels == 0) || + (Downmix_foldGeneric(pConfig->inputCfg.channels, + NULL, NULL, 0, false) == false)) { + ALOGE("Downmix_Configure error: input channel mask(0x%x) not supported", + pConfig->inputCfg.channels); return -EINVAL; } pDownmixer->input_channel_count = diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c index db7865a..c0a1c57 100644 --- a/media/libeffects/factory/EffectsFactory.c +++ b/media/libeffects/factory/EffectsFactory.c @@ -456,7 +456,9 @@ int init() { if (ignoreFxConfFiles) { ALOGI("Audio effects in configuration files will be ignored"); } else { - if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) { + if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE2, R_OK) == 0) { + loadEffectConfigFile(AUDIO_EFFECT_VENDOR_CONFIG_FILE2); + } else if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) { loadEffectConfigFile(AUDIO_EFFECT_VENDOR_CONFIG_FILE); } else if (access(AUDIO_EFFECT_DEFAULT_CONFIG_FILE, R_OK) == 0) { loadEffectConfigFile(AUDIO_EFFECT_DEFAULT_CONFIG_FILE); diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp index 14a1a74..f0afd39 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp @@ -29,6 +29,7 @@ #include "EffectBundle.h" #include "math.h" +#include <media/stagefright/foundation/ADebug.h> // effect_handle_t interface implementation for bass boost extern "C" const struct effect_interface_s gLvmEffectInterface; @@ -226,7 +227,7 @@ extern "C" int EffectCreate(const effect_uuid_t *uuid, pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; pContext->pBundledContext->nOutputDevice = AUDIO_DEVICE_NONE; pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_NONE; - pContext->pBundledContext->NumberEffectsEnabled = 0; + pContext->pBundledContext->EffectsBitMap = 0; pContext->pBundledContext->NumberEffectsCalled = 0; pContext->pBundledContext->firstVolume = LVM_TRUE; pContext->pBundledContext->volume = 0; @@ -366,28 +367,28 @@ extern "C" int EffectRelease(effect_handle_t handle){ ALOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag"); pSessionContext->bBassInstantiated = LVM_FALSE; if(pContext->pBundledContext->SamplesToExitCountBb > 0){ - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_BASS_BOOST); } pContext->pBundledContext->SamplesToExitCountBb = 0; } else if(pContext->EffectType == LVM_VIRTUALIZER) { ALOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag"); pSessionContext->bVirtualizerInstantiated = LVM_FALSE; if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VIRTUALIZER); } pContext->pBundledContext->SamplesToExitCountVirt = 0; } else if(pContext->EffectType == LVM_EQUALIZER) { ALOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag"); pSessionContext->bEqualizerInstantiated =LVM_FALSE; if(pContext->pBundledContext->SamplesToExitCountEq > 0){ - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_EQUALIZER); } pContext->pBundledContext->SamplesToExitCountEq = 0; } else if(pContext->EffectType == LVM_VOLUME) { ALOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag"); pSessionContext->bVolumeInstantiated = LVM_FALSE; if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){ - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VOLUME); } } else { ALOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n"); @@ -563,6 +564,7 @@ int LvmBundle_init(EffectContext *pContext){ for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ if (MemTab.Region[i].Size != 0){ MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size); + CHECK(MemTab.Region[i].pBaseAddress != NULL); if (MemTab.Region[i].pBaseAddress == LVM_NULL){ ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %" PRIu32 @@ -729,6 +731,7 @@ int LvmBundle_process(LVM_INT16 *pIn, } pContext->pBundledContext->workBuffer = (LVM_INT16 *)malloc(frameCount * sizeof(LVM_INT16) * 2); + CHECK(pContext->pBundledContext->workBuffer != NULL); pContext->pBundledContext->frameCount = frameCount; } pOutTmp = pContext->pBundledContext->workBuffer; @@ -2753,7 +2756,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) return -EINVAL; } if(pContext->pBundledContext->SamplesToExitCountBb <= 0){ - pContext->pBundledContext->NumberEffectsEnabled++; + pContext->pBundledContext->EffectsBitMap |= (1 << LVM_BASS_BOOST); } pContext->pBundledContext->SamplesToExitCountBb = (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); @@ -2766,7 +2769,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) return -EINVAL; } if(pContext->pBundledContext->SamplesToExitCountEq <= 0){ - pContext->pBundledContext->NumberEffectsEnabled++; + pContext->pBundledContext->EffectsBitMap |= (1 << LVM_EQUALIZER); } pContext->pBundledContext->SamplesToExitCountEq = (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); @@ -2778,7 +2781,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) return -EINVAL; } if(pContext->pBundledContext->SamplesToExitCountVirt <= 0){ - pContext->pBundledContext->NumberEffectsEnabled++; + pContext->pBundledContext->EffectsBitMap |= (1 << LVM_VIRTUALIZER); } pContext->pBundledContext->SamplesToExitCountVirt = (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); @@ -2790,7 +2793,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) ALOGV("\tEffect_setEnabled() LVM_VOLUME is already enabled"); return -EINVAL; } - pContext->pBundledContext->NumberEffectsEnabled++; + pContext->pBundledContext->EffectsBitMap |= (1 << LVM_VOLUME); pContext->pBundledContext->bVolumeEnabled = LVM_TRUE; break; default: @@ -2807,6 +2810,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already disabled"); return -EINVAL; } + if(pContext->pBundledContext->SamplesToExitCountBb <= 0) { + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_BASS_BOOST); + } pContext->pBundledContext->bBassEnabled = LVM_FALSE; break; case LVM_EQUALIZER: @@ -2814,6 +2820,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already disabled"); return -EINVAL; } + if(pContext->pBundledContext->SamplesToExitCountEq <= 0) { + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_EQUALIZER); + } pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; break; case LVM_VIRTUALIZER: @@ -2821,6 +2830,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already disabled"); return -EINVAL; } + if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) { + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VIRTUALIZER); + } pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; break; case LVM_VOLUME: @@ -2828,6 +2840,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled) ALOGV("\tEffect_setEnabled() LVM_VOLUME is already disabled"); return -EINVAL; } + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VOLUME); pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; break; default: @@ -2877,7 +2890,7 @@ int Effect_process(effect_handle_t self, LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw; //ALOGV("\tEffect_process Start : Enabled = %d Called = %d (%8d %8d %8d)", -//pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled, +//popcount(pContext->pBundledContext->EffectsBitMap), pContext->pBundledContext->NumberEffectsCalled, // pContext->pBundledContext->SamplesToExitCountBb, // pContext->pBundledContext->SamplesToExitCountVirt, // pContext->pBundledContext->SamplesToExitCountEq); @@ -2911,7 +2924,7 @@ int Effect_process(effect_handle_t self, } if(pContext->pBundledContext->SamplesToExitCountBb <= 0) { status = -ENODATA; - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_BASS_BOOST); ALOGV("\tEffect_process() this is the last frame for LVM_BASS_BOOST"); } } @@ -2919,7 +2932,7 @@ int Effect_process(effect_handle_t self, (pContext->EffectType == LVM_VOLUME)){ //ALOGV("\tEffect_process() LVM_VOLUME Effect is not enabled"); status = -ENODATA; - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VOLUME); } if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&& (pContext->EffectType == LVM_EQUALIZER)){ @@ -2931,7 +2944,7 @@ int Effect_process(effect_handle_t self, } if(pContext->pBundledContext->SamplesToExitCountEq <= 0) { status = -ENODATA; - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_EQUALIZER); ALOGV("\tEffect_process() this is the last frame for LVM_EQUALIZER"); } } @@ -2945,7 +2958,7 @@ int Effect_process(effect_handle_t self, } if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) { status = -ENODATA; - pContext->pBundledContext->NumberEffectsEnabled--; + pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VIRTUALIZER); ALOGV("\tEffect_process() this is the last frame for LVM_VIRTUALIZER"); } } @@ -2955,9 +2968,9 @@ int Effect_process(effect_handle_t self, } if(pContext->pBundledContext->NumberEffectsCalled == - pContext->pBundledContext->NumberEffectsEnabled){ + popcount(pContext->pBundledContext->EffectsBitMap)){ //ALOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d", - //pContext->pBundledContext->NumberEffectsEnabled, + //popcount(pContext->pBundledContext->EffectsBitMap), //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); if(status == -ENODATA){ @@ -2976,7 +2989,7 @@ int Effect_process(effect_handle_t self, } } else { //ALOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d", - //pContext->pBundledContext->NumberEffectsEnabled, + //popcount(pContext->pBundledContext->EffectsBitMap), //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); // 2 is for stereo input if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) { @@ -3028,9 +3041,9 @@ int Effect_command(effect_handle_t self, // called the number of effect called could be greater // pContext->pBundledContext->NumberEffectsCalled = 0; - //ALOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", - // pContext->pBundledContext->NumberEffectsCalled, - // pContext->pBundledContext->NumberEffectsEnabled); + //ALOGV("\tEffect_command: Enabled = %d Called = %d", + // popcount(pContext->pBundledContext->EffectsBitMap), + // pContext->pBundledContext->NumberEffectsCalled); switch (cmdCode){ case EFFECT_CMD_INIT: @@ -3314,7 +3327,7 @@ int Effect_command(effect_handle_t self, (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){ ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d", *(int32_t *)pCmdData); - ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST"); + ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BASS_BOOST"); // If a device doesnt support bassboost the effect must be temporarily disabled // the effect must still report its original state as this can only be changed diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h index 9459b87..5fa5668 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h @@ -75,8 +75,8 @@ struct BundledEffectContext{ bool bVirtualizerTempDisabled; /* Flag for effect to be re-enabled */ audio_devices_t nOutputDevice; /* Output device for the effect */ audio_devices_t nVirtualizerForcedDevice; /* Forced device virtualization mode*/ - int NumberEffectsEnabled; /* Effects in this session */ int NumberEffectsCalled; /* Effects called so far */ + uint32_t EffectsBitMap; /* Effects enable bit mask */ bool firstVolume; /* No smoothing on first Vol change */ // Saved parameters for each effect */ // Bass Boost |