Home | History | Annotate | Download | only in Bundle

Lines Matching refs:pContext

146 int  LvmBundle_init            (EffectContext *pContext);
147 int LvmEffect_enable (EffectContext *pContext);
148 int LvmEffect_disable (EffectContext *pContext);
149 void LvmEffect_free (EffectContext *pContext);
150 int Effect_setConfig (EffectContext *pContext, effect_config_t *pConfig);
151 void Effect_getConfig (EffectContext *pContext, effect_config_t *pConfig);
152 int BassBoost_setParameter (EffectContext *pContext,
157 int BassBoost_getParameter (EffectContext *pContext,
162 int Virtualizer_setParameter (EffectContext *pContext,
167 int Virtualizer_getParameter (EffectContext *pContext,
172 int Equalizer_setParameter (EffectContext *pContext,
177 int Equalizer_getParameter (EffectContext *pContext,
182 int Volume_setParameter (EffectContext *pContext,
187 int Volume_getParameter (EffectContext *pContext,
192 int Effect_setEnabled(EffectContext *pContext, bool enabled);
203 EffectContext *pContext = NULL;
237 pContext = new EffectContext;
248 pContext->pBundledContext = GlobalSessionMemory[sessionNo].pBundledContext;
249 pContext->pBundledContext->SessionNo = sessionNo;
250 pContext->pBundledContext->SessionId = sessionId;
251 pContext->pBundledContext->hInstance = NULL;
252 pContext->pBundledContext->bVolumeEnabled = LVM_FALSE;
253 pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE;
254 pContext->pBundledContext->bBassEnabled = LVM_FALSE;
255 pContext->pBundledContext->bBassTempDisabled = LVM_FALSE;
256 pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE;
257 pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE;
258 pContext->pBundledContext->nOutputDevice = AUDIO_DEVICE_NONE;
259 pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_NONE;
260 pContext->pBundledContext->NumberEffectsEnabled = 0;
261 pContext->pBundledContext->NumberEffectsCalled = 0;
262 pContext->pBundledContext->firstVolume = LVM_TRUE;
263 pContext->pBundledContext->volume = 0;
267 snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_in.pcm", pContext->pBundledContext);
268 pContext->pBundledContext->PcmInPtr = fopen(fileName, "w");
269 if (pContext->pBundledContext->PcmInPtr == NULL) {
275 snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_out.pcm", pContext->pBundledContext);
276 pContext->pBundledContext->PcmOutPtr = fopen(fileName, "w");
277 if (pContext->pBundledContext->PcmOutPtr == NULL) {
279 fclose(pContext->pBundledContext->PcmInPtr);
280 pContext->pBundledContext->PcmInPtr = NULL;
290 pContext->pBundledContext->BassStrengthSaved = 0;
291 pContext->pBundledContext->VirtStrengthSaved = 0;
292 pContext->pBundledContext->CurPreset = PRESET_CUSTOM;
293 pContext->pBundledContext->levelSaved = 0;
294 pContext->pBundledContext->bMuteEnabled = LVM_FALSE;
295 pContext->pBundledContext->bStereoPositionEnabled = LVM_FALSE;
296 pContext->pBundledContext->positionSaved = 0;
297 pContext->pBundledContext->workBuffer = NULL;
298 pContext->pBundledContext->frameCount = -1;
299 pContext->pBundledContext->SamplesToExitCountVirt = 0;
300 pContext->pBundledContext->SamplesToExitCountBb = 0;
301 pContext->pBundledContext->SamplesToExitCountEq = 0;
303 pContext->pBundledContext->pInputBuffer = NULL;
304 pContext->pBundledContext->pOutputBuffer = NULL;
307 pContext->pBundledContext->bandGaindB[i] = EQNB_5BandSoftPresets[i];
311 ret = LvmBundle_init(pContext);
321 pContext->pBundledContext =
324 ALOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext);
326 pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo];
333 pContext->pBundledContext->SamplesToExitCountBb = 0;
335 pContext->itfe = &gLvmEffectInterface;
336 pContext->EffectType = LVM_BASS_BOOST;
341 pContext->pBundledContext->SamplesToExitCountVirt = 0;
343 pContext->itfe = &gLvmEffectInterface;
344 pContext->EffectType = LVM_VIRTUALIZER;
349 pContext->pBundledContext->SamplesToExitCountEq = 0;
351 pContext->itfe = &gLvmEffectInterface;
352 pContext->EffectType = LVM_EQUALIZER;
358 pContext->itfe = &gLvmEffectInterface;
359 pContext->EffectType = LVM_VOLUME;
369 if (pContext != NULL) {
373 delete pContext->pBundledContext;
375 delete pContext;
381 *pHandle = (effect_handle_t)pContext;
389 EffectContext * pContext = (EffectContext *)handle;
391 ALOGV("\tEffectRelease start handle: %p, context %p", handle, pContext->pBundledContext);
392 if (pContext == NULL){
397 SessionContext *pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo];
401 if(pContext->EffectType == LVM_BASS_BOOST) {
404 if(pContext->pBundledContext->SamplesToExitCountBb > 0){
405 pContext->pBundledContext->NumberEffectsEnabled--;
407 pContext->pBundledContext->SamplesToExitCountBb = 0;
408 } else if(pContext->EffectType == LVM_VIRTUALIZER) {
411 if(pContext->pBundledContext->SamplesToExitCountVirt > 0){
412 pContext->pBundledContext->NumberEffectsEnabled--;
414 pContext->pBundledContext->SamplesToExitCountVirt = 0;
415 } else if(pContext->EffectType == LVM_EQUALIZER) {
418 if(pContext->pBundledContext->SamplesToExitCountEq > 0){
419 pContext->pBundledContext->NumberEffectsEnabled--;
421 pContext->pBundledContext->SamplesToExitCountEq = 0;
422 } else if(pContext->EffectType == LVM_VOLUME) {
425 if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){
426 pContext->pBundledContext->NumberEffectsEnabled--;
434 Effect_setEnabled(pContext, LVM_FALSE);
443 if (pContext->pBundledContext->PcmInPtr != NULL) {
444 fclose(pContext->pBundledContext->PcmInPtr);
445 pContext->pBundledContext->PcmInPtr = NULL;
447 if (pContext->pBundledContext->PcmOutPtr != NULL) {
448 fclose(pContext->pBundledContext->PcmOutPtr);
449 pContext->pBundledContext->PcmOutPtr = NULL;
456 if(SessionIndex[i] == pContext->pBundledContext->SessionId){
459 i, pContext->pBundledContext->SessionId);
468 LvmEffect_free(pContext);
469 ALOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext);
470 if (pContext->pBundledContext->workBuffer != NULL) {
471 free(pContext->pBundledContext->workBuffer);
474 if (pContext->pBundledContext->pInputBuffer != NULL) {
475 free(pContext->pBundledContext->pInputBuffer);
477 if (pContext->pBundledContext->pOutputBuffer != NULL) {
478 free(pContext->pBundledContext->pOutputBuffer);
481 delete pContext->pBundledContext;
482 pContext->pBundledContext = LVM_NULL;
485 delete pContext;
541 // pContext: effect engine context
547 int LvmBundle_init(EffectContext *pContext){
550 pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
551 pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
552 pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
553 pContext->config.inputCfg.samplingRate = 44100;
554 pContext->config.inputCfg.bufferProvider.getBuffer = NULL;
555 pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL;
556 pContext->config.inputCfg.bufferProvider.cookie = NULL;
557 pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL;
558 pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
559 pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
560 pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
561 pContext->config.outputCfg.samplingRate = 44100;
562 pContext->config.outputCfg.bufferProvider.getBuffer = NULL;
563 pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
564 pContext->config.outputCfg.bufferProvider.cookie = NULL;
565 pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL;
567 CHECK_ARG(pContext != NULL);
569 if (pContext->pBundledContext->hInstance != NULL){
570 ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
571 "-> Calling pContext->pBassBoost->free()");
573 LvmEffect_free(pContext);
575 ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL "
576 "-> Called pContext->pBassBoost->free()");
641 pContext->pBundledContext->hInstance = LVM_NULL;
644 LvmStatus = LVM_GetInstanceHandle(&pContext->pBundledContext->hInstance,
660 pContext->pBundledContext->SampleRate = LVM_FS_44100;
707 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance,
726 LvmStatus = LVM_SetHeadroomParams(pContext->pBundledContext->hInstance,
788 // pContext: effect engine context
799 EffectContext *pContext){
808 if (pContext->pBundledContext->pInputBuffer == NULL ||
809 pContext->pBundledContext->frameCount < frameCount) {
810 if (pContext->pBundledContext->pInputBuffer != NULL) {
811 free(pContext->pBundledContext->pInputBuffer);
813 pContext->pBundledContext->pInputBuffer = (LVM_FLOAT *)malloc(frameCount * \
817 if (pContext->pBundledContext->pOutputBuffer == NULL ||
818 pContext->pBundledContext->frameCount < frameCount) {
819 if (pContext->pBundledContext->pOutputBuffer != NULL) {
820 free(pContext->pBundledContext->pOutputBuffer);
822 pContext->pBundledContext->pOutputBuffer = (LVM_FLOAT *)malloc(frameCount * \
826 if ((pContext->pBundledContext->pInputBuffer == NULL) ||
827 (pContext->pBundledContext->pOutputBuffer == NULL)) {
832 pInputBuff = pContext->pBundledContext->pInputBuffer;
833 pOutputBuff = pContext->pBundledContext->pOutputBuffer;
835 if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){
837 } else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
838 if (pContext->pBundledContext->frameCount != frameCount) {
839 if (pContext->pBundledContext->workBuffer != NULL) {
840 free(pContext->pBundledContext->workBuffer);
842 pContext->pBundledContext->workBuffer =
844 if (pContext->pBundledContext->workBuffer == NULL) {
847 pContext->pBundledContext->frameCount = frameCount;
849 pOutTmp = pContext->pBundledContext->workBuffer;
856 fwrite(pIn, frameCount*sizeof(LVM_INT16) * FCC_2, 1, pContext->pBundledContext->PcmInPtr);
857 fflush(pContext->pBundledContext->PcmInPtr);
864 LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */
876 fwrite(pOutTmp, frameCount*sizeof(LVM_INT16) * FCC_2, 1, pContext->pBundledContext->PcmOutPtr);
877 fflush(pContext->pBundledContext->PcmOutPtr);
880 if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
891 EffectContext *pContext){
896 if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){
898 } else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
899 if (pContext->pBundledContext->frameCount != frameCount) {
900 if (pContext->pBundledContext->workBuffer != NULL) {
901 free(pContext->pBundledContext->workBuffer);
903 pContext->pBundledContext->workBuffer =
905 if (pContext->pBundledContext->workBuffer == NULL) {
908 pContext->pBundledContext->frameCount = frameCount;
910 pOutTmp = pContext->pBundledContext->workBuffer;
917 fwrite(pIn, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmInPtr);
918 fflush(pContext->pBundledContext->PcmInPtr);
924 LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */
934 fwrite(pOutTmp, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmOutPtr);
935 fflush(pContext->pBundledContext->PcmOutPtr);
938 if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
953 // pContext: effect engine context
958 void EqualizerUpdateActiveParams(EffectContext *pContext) {
963 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
973 ActiveParams.pEQNB_BandDefinition[i].Gain = pContext->pBundledContext->bandGaindB[i];
977 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
991 // pContext: effect engine context
996 void LvmEffect_limitLevel(EffectContext *pContext) {
1001 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1014 bool eqEnabled = pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE;
1015 bool bbEnabled = pContext->pBundledContext->bBassEnabled == LVM_TRUE;
1016 bool viEnabled = pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE;
1021 float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0;
1031 float bandFactor1 = pContext->pBundledContext->bandGaindB[i]/15.0;
1032 float bandFactor2 = pContext->pBundledContext->bandGaindB[i+1]/15.0;
1050 float boostFactor = (pContext->pBundledContext->BassStrengthSaved)/1000.0;
1057 float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0;
1079 if (maxLevelRound + pContext->pBundledContext->volume > 0) {
1080 gainCorrection = maxLevelRound + pContext->pBundledContext->volume;
1083 ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection;
1087 ALOGV("\tVol:%d, GainCorrection: %d, Actual vol: %d", pContext->pBundledContext->volume,
1091 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1099 if (pContext->pBundledContext->firstVolume == LVM_TRUE){
1100 LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams);
1103 pContext->pBundledContext->firstVolume = LVM_FALSE;
1113 // pContext: effect engine context
1119 int LvmEffect_enable(EffectContext *pContext){
1126 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
1133 if(pContext->EffectType == LVM_BASS_BOOST) {
1137 if(pContext->EffectType == LVM_VIRTUALIZER) {
1141 if(pContext->EffectType == LVM_EQUALIZER) {
1145 if(pContext->EffectType == LVM_VOLUME) {
1149 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1155 LvmEffect_limitLevel(pContext);
1165 // pContext: effect engine context
1171 int LvmEffect_disable(EffectContext *pContext){
1177 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
1184 if(pContext->EffectType == LVM_BASS_BOOST) {
1188 if(pContext->EffectType == LVM_VIRTUALIZER) {
1192 if(pContext->EffectType == LVM_EQUALIZER) {
1196 if(pContext->EffectType == LVM_VOLUME) {
1200 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1206 LvmEffect_limitLevel(pContext);
1216 // pContext: effect engine context
1222 void LvmEffect_free(EffectContext *pContext){
1227 LvmStatus = LVM_GetMemoryTable(pContext->pBundledContext->hInstance,
1258 // pContext: effect engine context
1266 int Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){
1270 CHECK_ARG(pContext != NULL);
1281 pContext->config = *pConfig;
1286 pContext->pBundledContext->SamplesPerSecond = 8000*2; // 2 secs Stereo
1290 pContext->pBundledContext->SamplesPerSecond = 16000*2; // 2 secs Stereo
1294 pContext->pBundledContext->SamplesPerSecond = 22050*2; // 2 secs Stereo
1298 pContext->pBundledContext->SamplesPerSecond = 32000*2; // 2 secs Stereo
1302 pContext->pBundledContext->SamplesPerSecond = 44100*2; // 2 secs Stereo
1306 pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo
1311 pContext->pBundledContext->SamplesPerSecond = 96000*2; // 2 secs Stereo
1315 pContext->pBundledContext->SamplesPerSecond = 192000*2; // 2 secs Stereo
1323 if(pContext->pBundledContext->SampleRate != SampleRate){
1331 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
1339 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1343 pContext->pBundledContext->SampleRate = SampleRate;
1345 LvmEffect_limitLevel(pContext);
1361 // pContext: effect engine context
1369 void Effect_getConfig(EffectContext *pContext, effect_config_t *pConfig)
1371 *pConfig = pContext->config;
1384 // pContext: effect engine context
1388 uint32_t BassGetStrength(EffectContext *pContext){
1389 //ALOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved);
1394 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
1404 (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){
1406 ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved);
1411 //ALOGV("\tBassGetStrength() (saved) -> %d\n", pContext->pBundledContext->BassStrengthSaved );
1412 return pContext->pBundledContext->BassStrengthSaved;
1422 // pContext: effect engine context
1427 void BassSetStrength(EffectContext *pContext, uint32_t strength){
1430 pContext->pBundledContext->BassStrengthSaved = (int)strength;
1436 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
1449 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1454 LvmEffect_limitLevel(pContext);
1467 // pContext: effect engine context
1471 uint32_t VirtualizerGetStrength(EffectContext *pContext){
1472 //ALOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved);
1477 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1484 return pContext->pBundledContext->VirtStrengthSaved;
1494 // pContext: effect engine context
1499 void VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){
1504 pContext->pBundledContext->VirtStrengthSaved = (int)strength;
1507 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams);
1519 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
1522 LvmEffect_limitLevel(pContext);
1579 // pContext effect engine context
1586 int VirtualizerForceVirtualizationMode(EffectContext *pContext, audio_devices_t forcedDevice) {
1588 forcedDevice, pContext->pBundledContext->bVirtualizerEnabled,
1589 pContext->pBundledContext->bVirtualizerTempDisabled);
1605 if (VirtualizerIsDeviceSupported(pContext->pBundledContext->nOutputDevice) == 0) {
1606 useVirtualizer = (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE);
1608 pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_NONE;
1611 pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
1613 useVirtualizer = (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE);
1617 if (pContext->pBundledContext->bVirtualizerTempDisabled == LVM_TRUE) {
1619 android::LvmEffect_enable(pContext);
1620 pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE;
1625 if (pContext->pBundledContext->bVirtualizerTempDisabled == LVM_FALSE) {
1627 android::LvmEffect_disable(pContext);
1628 pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE;
1635 pContext->pBundledContext->bVirtualizerEnabled,
1636 pContext->pBundledContext->bVirtualizerTempDisabled);
1692 audio_devices_t VirtualizerGetVirtualizationMode(EffectContext *pContext) {
1694 if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE)
1695 && (pContext->pBundledContext->bVirtualizerTempDisabled == LVM_FALSE)) {
1696 if (pContext->pBundledContext->nVirtualizerForcedDevice != AUDIO_DEVICE_NONE) {
1698 virtDevice = pContext->pBundledContext->nVirtualizerForcedDevice;
1701 virtDevice = pContext->pBundledContext->nOutputDevice;
1715 // pContext: effect engine context
1720 int32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){
1721 //ALOGV("\tEqualizerGetBandLevel -> %d\n", pContext->pBundledContext->bandGaindB[band] );
1722 return pContext->pBundledContext->bandGaindB[band] * 100;
1734 // pContext: effect engine context
1739 void EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){
1747 pContext->pBundledContext->bandGaindB[band] = gainRounded;
1748 pContext->pBundledContext->CurPreset = PRESET_CUSTOM;
1750 EqualizerUpdateActiveParams(pContext);
1751 LvmEffect_limitLevel(pContext);
1761 // pContext: effect engine context
1766 int32_t EqualizerGetCentreFrequency(EffectContext *pContext, int32_t band){
1773 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
1798 // pContext: effect engine context
1804 int32_t EqualizerGetBandFreqRange(EffectContext *pContext __unused, int32_t band, uint32_t *pLow,
1822 // pContext: effect engine context
1828 int32_t EqualizerGetBand(EffectContext *pContext __unused, uint32_t targetFreq){
1854 // pContext: effect engine context
1857 int32_t EqualizerGetPreset(EffectContext *pContext){
1858 return pContext->pBundledContext->CurPreset;
1870 // pContext: effect engine context
1874 void EqualizerSetPreset(EffectContext *pContext, int preset){
1877 pContext->pBundledContext->CurPreset = preset;
1882 pContext->pBundledContext->bandGaindB[i] =
1886 EqualizerUpdateActiveParams(pContext);
1887 LvmEffect_limitLevel(pContext);
1925 // pContext: effect engine context
1930 int VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){
1936 if (pContext->pBundledContext->bMuteEnabled == LVM_TRUE) {
1937 pContext->pBundledContext->levelSaved = level / 100;
1939 pContext->pBundledContext->volume = level / 100;
1942 LvmEffect_limitLevel(pContext);
1953 // pContext: effect engine context
1957 int VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){
1959 if (pContext->pBundledContext->bMuteEnabled == LVM_TRUE) {
1960 *level = pContext->pBundledContext->levelSaved * 100;
1962 *level = pContext->pBundledContext->volume * 100;
1973 // pContext: effect engine context
1978 int32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){
1981 pContext->pBundledContext->bMuteEnabled = mute;
1984 if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){
1985 pContext->pBundledContext->levelSaved = pContext->pBundledContext->volume;
1986 pContext->pBundledContext->volume = -96;
1988 pContext->pBundledContext->volume = pContext->pBundledContext->levelSaved;
1991 LvmEffect_limitLevel(pContext);
2002 // pContext: effect engine context
2008 int32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){
2010 if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)||
2011 (pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){
2012 *mute = pContext->pBundledContext->bMuteEnabled;
2016 pContext->pBundledContext->bMuteEnabled);
2036 // pContext: effect engine context
2042 int VolumeSetStereoPosition(EffectContext *pContext, int16_t position){
2050 pContext->pBundledContext->positionSaved = position;
2051 Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved);
2053 //ALOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d",
2054 //pContext->pBundledContext->positionSaved);
2056 if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){
2059 pContext->pBundledContext->positionSaved = position;
2061 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
2072 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
2079 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
2089 //ALOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n",
2090 //pContext->pBundledContext->positionSaved);
2101 // pContext: effect engine context
2107 int32_t VolumeGetStereoPosition(EffectContext *pContext, int16_t *position){
2114 //ALOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d",
2115 //pContext->pBundledContext->positionSaved);
2117 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
2124 balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved);
2126 if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){
2131 *position = (LVM_INT16)pContext->pBundledContext->positionSaved; // Convert dB to millibels
2132 //ALOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved =%d\n",
2133 //pContext->pBundledContext->positionSaved);
2143 // pContext: effect engine context
2148 int32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){
2151 pContext->pBundledContext->bStereoPositionEnabled = enabled;
2157 LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
2166 if(pContext->pBundledContext->bStereoPositionEnabled == LVM_FALSE){
2170 VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved);
2174 LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
2204 int BassBoost_getParameter(EffectContext *pContext,
2241 *(int16_t *)pValue = BassGetStrength(pContext);
2270 int BassBoost_setParameter(EffectContext *pContext,
2295 BassSetStrength(pContext, (int32_t)strength);
2330 int Virtualizer_getParameter(EffectContext *pContext,
2367 *(int16_t *)pValue = VirtualizerGetStrength(pContext);
2411 *(uint32_t *)pValue = (uint32_t) VirtualizerGetVirtualizationMode(pContext);
2439 int Virtualizer_setParameter(EffectContext *pContext,
2464 VirtualizerSetStrength(pContext, (int32_t)strength);
2478 status = VirtualizerForceVirtualizationMode(pContext, deviceType);
2513 int Equalizer_getParameter(EffectContext *pContext,
2548 *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext);
2578 *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, frequency);
2605 *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, band);
2647 EqualizerGetBandFreqRange(pContext, band, (uint32_t *)pValue, ((uint32_t *)pValue + 1));
2675 *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, band);
2722 p[0] = (int16_t)EqualizerGetPreset(pContext);
2725 p[2 + i] = (int16_t)EqualizerGetBandLevel(pContext, i);
2755 int Equalizer_setParameter(EffectContext *pContext,
2784 EqualizerSetPreset(pContext, preset);
2809 EqualizerSetBandLevel(pContext, band, level);
2826 EqualizerSetPreset(pContext, (int)p[0]);
2842 EqualizerSetBandLevel(pContext, i, (int)p[2 + i]);
2878 int Volume_getParameter(EffectContext *pContext,
2901 status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue));
2927 VolumeGetStereoPosition(pContext, (int16_t *)pValue);
2939 status = VolumeGetMute(pContext, (uint32_t *)pValue);
2952 *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled;
2983 int Volume_setParameter(EffectContext *pContext,
3008 status = VolumeSetVolumeLevel(pContext, level);
3023 status = VolumeSetMute(pContext, mute);
3036 status = VolumeEnableStereoPosition(pContext, positionEnabled)
3037 ?: VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved);
3052 status = VolumeSetStereoPosition(pContext, position);
3120 // pContext - pointer to effect context
3127 int Effect_setEnabled(EffectContext *pContext, bool enabled)
3129 ALOGV("\tEffect_setEnabled() type %d, enabled %d", pContext->EffectType, enabled);
3135 switch (pContext->EffectType) {
3137 if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
3141 if(pContext->pBundledContext->SamplesToExitCountBb <= 0){
3142 pContext->pBundledContext->NumberEffectsEnabled++;
3144 pContext->pBundledContext->SamplesToExitCountBb =
3145 (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
3146 pContext->pBundledContext->bBassEnabled = LVM_TRUE;
3147 tempDisabled = pContext->pBundledContext->bBassTempDisabled;
3150 if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) {
3154 if(pContext->pBundledContext->SamplesToExitCountEq <= 0){
3155 pContext->pBundledContext->NumberEffectsEnabled++;
3157 pContext->pBundledContext->SamplesToExitCountEq =
3158 (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
3159 pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE;
3162 if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) {
3166 if(pContext->pBundledContext->SamplesToExitCountVirt <= 0){
3167 pContext->pBundledContext->NumberEffectsEnabled++;
3169 pContext->pBundledContext->SamplesToExitCountVirt =
3170 (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
3171 pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE;
3172 tempDisabled = pContext->pBundledContext->bVirtualizerTempDisabled;
3175 if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE) {
3179 pContext->pBundledContext->NumberEffectsEnabled++;
3180 pContext->pBundledContext->bVolumeEnabled = LVM_TRUE;
3187 LvmEffect_enable(pContext);
3190 switch (pContext->EffectType) {
3192 if (pContext->pBundledContext->bBassEnabled == LVM_FALSE) {
3196 pContext->pBundledContext->bBassEnabled = LVM_FALSE;
3199 if (pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE) {
3203 pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE;
3206 if (pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE) {
3210 pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE;
3213 if (pContext->pBundledContext->bVolumeEnabled == LVM_FALSE) {
3217 pContext->pBundledContext->bVolumeEnabled = LVM_FALSE;
3223 LvmEffect_disable(pContext);
3258 EffectContext * pContext = (EffectContext *) self;
3263 //pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled,
3264 // pContext
3265 // pContext->pBundledContext->SamplesToExitCountVirt,
3266 // pContext->pBundledContext->SamplesToExitCountEq);
3268 if (pContext == NULL){
3269 ALOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL");
3273 //if(pContext->EffectType == LVM_BASS_BOOST){
3275 //}else if(pContext->EffectType == LVM_EQUALIZER){
3277 //}else if(pContext->EffectType == LVM_VIRTUALIZER){
3287 if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&&
3288 (pContext->EffectType == LVM_BASS_BOOST)){
3290 if(pContext->pBundledContext->SamplesToExitCountBb > 0){
3291 pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO
3293 // pContext->pBundledContext->SamplesToExitCountBb);
3295 if(pContext->pBundledContext->SamplesToExitCountBb <= 0) {
3297 pContext->pBundledContext->NumberEffectsEnabled--;
3301 if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&&
3302 (pContext->EffectType == LVM_VOLUME)){
3305 pContext->pBundledContext->NumberEffectsEnabled--;
3307 if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&&
3308 (pContext->EffectType == LVM_EQUALIZER)){
3310 if(pContext->pBundledContext->SamplesToExitCountEq > 0){
3311 pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO
3313 // pContext->pBundledContext->SamplesToExitCountEq);
3315 if(pContext->pBundledContext->SamplesToExitCountEq <= 0) {
3317 pContext->pBundledContext->NumberEffectsEnabled--;
3321 if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&&
3322 (pContext->EffectType == LVM_VIRTUALIZER)){
3324 if(pContext->pBundledContext->SamplesToExitCountVirt > 0){
3325 pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO
3327 // pContext->pBundledContext->SamplesToExitCountVirt);
3329 if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) {
3331 pContext->pBundledContext->NumberEffectsEnabled--;
3337 pContext->pBundledContext->NumberEffectsCalled++;
3340 if(pContext->pBundledContext->NumberEffectsCalled ==
3341 pContext->pBundledContext->NumberEffectsEnabled){
3343 //pContext->pBundledContext->NumberEffectsEnabled,
3344 //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
3349 pContext->pBundledContext->NumberEffectsCalled = 0;
3355 pContext);
3365 //pContext->pBundledContext->NumberEffectsEnabled,
3366 //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
3368 if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) {
3395 EffectContext * pContext = (EffectContext *) self;
3399 if(pContext->EffectType == LVM_BASS_BOOST){
3402 if(pContext->EffectType == LVM_VIRTUALIZER){
3405 if(pContext->EffectType == LVM_EQUALIZER){
3408 if(pContext->EffectType == LVM_VOLUME){
3412 if (pContext == NULL){
3413 ALOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL");
3421 // pContext->pBundledContext->NumberEffectsCalled = 0;
3424 // pContext->pBundledContext->NumberEffectsCalled,
3425 // pContext->pBundledContext->NumberEffectsEnabled);
3431 pContext->EffectType);
3436 if(pContext->EffectType == LVM_BASS_BOOST){
3438 android::BassSetStrength(pContext, 0);
3440 if(pContext->EffectType == LVM_VIRTUALIZER){
3442 android::VirtualizerSetStrength(pContext, 0);
3444 if(pContext->EffectType == LVM_EQUALIZER){
3446 android::EqualizerSetPreset(pContext, 0);
3448 if(pContext->EffectType == LVM_VOLUME){
3450 *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0);
3462 *(int *) pReplyData = android::Effect_setConfig(pContext, (effect_config_t *) pCmdData);
3473 android::Effect_getConfig(pContext, (effect_config_t *)pReplyData);
3478 android::Effect_setConfig(pContext, &pContext->config);
3518 if(pContext->EffectType == LVM_BASS_BOOST){
3519 p->status = android::BassBoost_getParameter(pContext,
3531 if(pContext->EffectType == LVM_VIRTUALIZER){
3532 p->status = android::Virtualizer_getParameter(pContext,
3544 if(pContext->EffectType == LVM_EQUALIZER){
3547 p->status = android::Equalizer_getParameter(pContext,
3560 if(pContext->EffectType == LVM_VOLUME){
3562 p->status = android::Volume_getParameter(pContext,
3580 if(pContext->EffectType == LVM_BASS_BOOST){
3604 *(int *)pReplyData = android::BassBoost_setParameter(pContext,
3610 if(pContext->EffectType == LVM_VIRTUALIZER){
3637 *(int *)pReplyData = android::Virtualizer_setParameter(pContext,
3643 if(pContext->EffectType == LVM_EQUALIZER){
3661 *(int *)pReplyData = android::Equalizer_setParameter(pContext,
3667 if(pContext->EffectType == LVM_VOLUME){
3686 *(int *)pReplyData = android::Volume_setParameter(pContext,
3702 *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_TRUE);
3711 *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_FALSE);
3723 pContext->pBundledContext->nOutputDevice = (audio_devices_t) device;
3725 if (pContext->EffectType == LVM_BASS_BOOST) {
3737 if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
3740 android::LvmEffect_disable(pContext);
3742 pContext->pBundledContext->bBassTempDisabled = LVM_TRUE;
3750 if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
3753 android::LvmEffect_enable(pContext);
3755 pContext->pBundledContext->bBassTempDisabled = LVM_FALSE;
3758 if (pContext->EffectType == LVM_VIRTUALIZER) {
3759 if (pContext->pBundledContext->nVirtualizerForcedDevice == AUDIO_DEVICE_NONE) {
3770 if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) {
3773 android::LvmEffect_disable(pContext);
3775 pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE;
3783 if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){
3786 android::LvmEffect_enable(pContext);
3788 pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE;
3839 //pContext->pBundledContext->SessionNo, pContext->pBundledContext->SessionId,
3840 //(int32_t)maxdB, pContext->EffectType);
3846 android::VolumeSetVolumeLevel(pContext, (int16_t)(maxdB*100));
3849 LvmStatus =LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams);
3858 LvmStatus =LVM_SetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams);
3877 EffectContext * pContext = (EffectContext *) self;
3880 if (pContext == NULL || pDescriptor == NULL) {
3885 switch(pContext->EffectType) {