EffectBundle.cpp revision 3856b090cd04ba5dd4a59a12430ed724d5995909
12c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* 22c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2010-2010 NXP Software 32c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2009 The Android Open Source Project 42c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 52c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 62c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * you may not use this file except in compliance with the License. 72c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * You may obtain a copy of the License at 82c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 92c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Unless required by applicable law or agreed to in writing, software 122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * See the License for the specific language governing permissions and 152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * limitations under the License. 162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define LOG_TAG "Bundle" 192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) 2097344f1d8e8e95fd07d5deee2ae2492a7e4c24b0Eric Laurent//#define LOG_NDEBUG 0 212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <cutils/log.h> 232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <assert.h> 242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <stdlib.h> 252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <string.h> 262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <new> 272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <EffectBundle.h> 282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent// effect_handle_t interface implementation for bass boost 312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" const struct effect_interface_s gLvmEffectInterface; 322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\ 342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_NULLADDRESS){\ 353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_ALIGNMENTERROR){\ 393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad alignment returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_INVALIDNUMSAMPLES){\ 433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_OUTOFRANGE){\ 473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "out of range returned by %s in %s\n", callingFunc, calledFunc);\ 492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Namespaces 532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace android { 542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace { 552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 56d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent// Flag to allow a one time init of global memory, only happens on first call ever 57d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurentint LvmInitFlag = LVM_FALSE; 58d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric LaurentSessionContext GlobalSessionMemory[LVM_MAX_SESSIONS]; 59d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurentint SessionIndex[LVM_MAX_SESSIONS]; 60d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent 612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* local functions */ 622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define CHECK_ARG(cond) { \ 632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (!(cond)) { \ 643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Invalid argument: "#cond); \ 652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; \ 662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } \ 672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW BassBoost UUID 712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gBassBoostDescriptor = { 722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x8631f300, 0x72e2, 0x11df, 0xb57e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid 74e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 75163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 76163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 77d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BASS_BOOST_CUP_LOAD_ARM9E, 78d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Dynamic Bass Boost", 802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Virtualizer UUID 842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVirtualizerDescriptor = { 85163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 86163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 87e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 88163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 89163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 90d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VIRTUALIZER_CUP_LOAD_ARM9E, 91d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Virtualizer", 932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Equalizer UUID 972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gEqualizerDescriptor = { 982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type 992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0xce772f20, 0x847d, 0x11df, 0xbb17, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid Eq NXP 100e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 101163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 102d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent EQUALIZER_CUP_LOAD_ARM9E, 103d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Equalizer", 1052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Volume UUID 1092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVolumeDescriptor = { 1102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 1112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x119341a0, 0x8469, 0x11df, 0x81f9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, //uuid VOL NXP 112e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 113163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 114d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VOLUME_CUP_LOAD_ARM9E, 115d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Volume", 1172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--- local function prototypes 1212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init (void); 1222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init (EffectContext *pContext); 1232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable (EffectContext *pContext); 1242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable (EffectContext *pContext); 1252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free (EffectContext *pContext); 126163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint Effect_configure (EffectContext *pContext, effect_config_t *pConfig); 127c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue); 128163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint BassBoost_getParameter (EffectContext *pContext, 129c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 132c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter (EffectContext *pContext, 134c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 136163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue); 137c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter (EffectContext *pContext, 139c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 142c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter (EffectContext *pContext, 144c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 14729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurentint Effect_setEnabled(EffectContext *pContext, bool enabled); 1482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Library Interface Implementation */ 1502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){ 1513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectQueryNumberEffects start"); 1522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pNumEffects = 4; 1533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects); 1543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryNumberEffects end\n"); 1552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryNumberEffects */ 1572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){ 1593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectQueryEffect start"); 1603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing index %d", index); 161163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pDescriptor == NULL){ 1633856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer"); 1642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 1652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (index > 3){ 1673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index); 1682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -ENOENT; 1692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(index == LVM_BASS_BOOST){ 1713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_BASS_BOOST"); 1722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gBassBoostDescriptor, sizeof(effect_descriptor_t)); 1732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else if(index == LVM_VIRTUALIZER){ 1743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER"); 1752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gVirtualizerDescriptor, sizeof(effect_descriptor_t)); 1762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_EQUALIZER){ 1773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_EQUALIZER"); 1782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t)); 1792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_VOLUME){ 1803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_VOLUME"); 1812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gVolumeDescriptor, sizeof(effect_descriptor_t)); 182163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect end\n"); 1842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryEffect */ 1862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectCreate(effect_uuid_t *uuid, 1882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t sessionId, 1892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t ioId, 190e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_handle_t *pHandle){ 191dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int ret = 0; 192c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int sessionNo; 1932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int i; 194dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent EffectContext *pContext = NULL; 195dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent bool newBundle = false; 196dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent SessionContext *pSessionContext; 1972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectCreate start session %d", sessionId); 1992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 200e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pHandle == NULL || uuid == NULL){ 2013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer"); 202dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 203dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 2042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmInitFlag == LVM_FALSE){ 2072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmInitFlag = LVM_TRUE; 2083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Initializing all global memory"); 2092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmGlobalBundle_init(); 2102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 212c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Find next available sessionNo 213c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(i=0; i<LVM_MAX_SESSIONS; i++){ 214e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent if((SessionIndex[i] == LVM_UNUSED_SESSION)||(SessionIndex[i] == sessionId)){ 215c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo = i; 216c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent SessionIndex[i] = sessionId; 2173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId); 218c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 219c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 220c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 221c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 222c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(i==LVM_MAX_SESSIONS){ 2233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Cannot find memory to allocate for current session"); 224dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 225dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 226c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 227dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 228dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext = new EffectContext; 229dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // If this is the first create in this session 231c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(GlobalSessionMemory[sessionNo].bBundledEffectsEnabled == LVM_FALSE){ 2323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d", 233c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionId, sessionNo); 234c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 235c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_TRUE; 236c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext = new BundledEffectContext; 237dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent newBundle = true; 2382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 239c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = GlobalSessionMemory[sessionNo].pBundledContext; 240c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionNo = sessionNo; 241c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionId = sessionId; 242163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = NULL; 243163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 244163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 245163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 246163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 247163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 248163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 249163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled = 0; 250163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 251d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->firstVolume = LVM_TRUE; 252163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 253163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 2548f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent char fileName[256]; 2558f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_in.pcm", pContext->pBundledContext); 2568f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = fopen(fileName, "w"); 2578f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmInPtr == NULL) { 2583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("cannot open %s", fileName); 259dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 260dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 2618f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2638f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_out.pcm", pContext->pBundledContext); 2648f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmOutPtr = fopen(fileName, "w"); 2658f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmOutPtr == NULL) { 2663856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("cannot open %s", fileName); 2678f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmInPtr); 2688f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = NULL; 269dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 270dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 271163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 272163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 273163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Saved strength is used to return the exact strength that was used in the set to the get 2752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * because we map the original strength range of 0:1000 to 1:15, and this will avoid 2762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * quantisation like effect when returning 2772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 278163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->BassStrengthSaved = 0; 279163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = 0; 280163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 281163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = 0; 282163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled = LVM_FALSE; 283163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = LVM_FALSE; 284163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = 0; 285dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->workBuffer = NULL; 286dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->frameCount = -1; 287dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 288dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 289dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 290163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Calling LvmBundle_init"); 2922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ret = LvmBundle_init(pContext); 2932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (ret < 0){ 2953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() Bundle init failed"); 296dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 2972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 3003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d", 301c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo); 302c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = 303c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext; 3042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3053856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext); 3062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 307dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo]; 30829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 3092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create each Effect 3102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Bass Boost 3123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST"); 31329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bBassInstantiated = LVM_TRUE; 314dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 315163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 316163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->itfe = &gLvmEffectInterface; 3172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_BASS_BOOST; 3182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Virtualizer 3203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER"); 32129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVirtualizerInstantiated=LVM_TRUE; 322dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 323163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VIRTUALIZER; 3262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Equalizer 3283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER"); 32929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bEqualizerInstantiated = LVM_TRUE; 330dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_EQUALIZER; 3342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Volume 3363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_VOLUME"); 33729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVolumeInstantiated = LVM_TRUE; 338163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VOLUME; 341163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 3433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() invalid UUID"); 344dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 345dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 3462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 348dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurentexit: 349dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (ret != 0) { 350dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext != NULL) { 351dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (newBundle) { 352dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_FALSE; 353dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent SessionIndex[sessionNo] = LVM_UNUSED_SESSION; 354dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent delete pContext->pBundledContext; 355dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 356dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent delete pContext; 357dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 358e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent *pHandle = (effect_handle_t)NULL; 359dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } else { 360e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent *pHandle = (effect_handle_t)pContext; 361dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate end..\n\n"); 363dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return ret; 3642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectCreate */ 3652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 366e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentextern "C" int EffectRelease(effect_handle_t handle){ 3673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectRelease start %p", handle); 368e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EffectContext * pContext = (EffectContext *)handle; 3692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease start handle: %p, context %p", handle, pContext->pBundledContext); 3712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 3723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectRelease called with NULL pointer"); 3732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 374163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 37629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent SessionContext *pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo]; 37729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 3782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Clear the instantiated flag for the effect 379dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // protect agains the case where an effect is un-instantiated without being disabled 3802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 3813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag"); 38229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bBassInstantiated = LVM_FALSE; 383dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb > 0){ 384dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 385dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 386dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 3872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VIRTUALIZER) { 3883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag"); 38929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVirtualizerInstantiated = LVM_FALSE; 390dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ 391dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 392dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 393dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 3942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_EQUALIZER) { 3953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag"); 39629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bEqualizerInstantiated =LVM_FALSE; 397dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq > 0){ 398dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 399dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 400dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 4012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VOLUME) { 4023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag"); 40329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVolumeInstantiated = LVM_FALSE; 404dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){ 405dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 406dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 4072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 4083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n"); 4092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 410163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 411dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Disable effect, in this case ignore errors (return codes) 412dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // if an effect has already been disabled 413dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent Effect_setEnabled(pContext, LVM_FALSE); 414dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 4152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // if all effects are no longer instantiaed free the lvm memory and delete BundledEffectContext 41629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if ((pSessionContext->bBassInstantiated == LVM_FALSE) && 41729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bVolumeInstantiated == LVM_FALSE) && 41829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bEqualizerInstantiated ==LVM_FALSE) && 41929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bVirtualizerInstantiated==LVM_FALSE)) 4202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 421163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 4228f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmInPtr != NULL) { 4238f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmInPtr); 4248f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = NULL; 4258f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 4268f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmOutPtr != NULL) { 4278f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmOutPtr); 4288f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmOutPtr = NULL; 4298f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 430163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 431c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 432c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 433c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Clear the SessionIndex 434c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 435c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(SessionIndex[i] == pContext->pBundledContext->SessionId){ 436e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent SessionIndex[i] = LVM_UNUSED_SESSION; 4373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n", 438c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent i, pContext->pBundledContext->SessionId); 439c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 440c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 441c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 442c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 4433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: All effects are no longer instantiated\n"); 444dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pSessionContext->bBundledEffectsEnabled = LVM_FALSE; 44529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->pBundledContext = LVM_NULL; 4463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Freeing LVM Bundle memory\n"); 447163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmEffect_free(pContext); 4483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext); 449dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->workBuffer != NULL) { 450dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent free(pContext->pBundledContext->workBuffer); 451dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 452163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent delete pContext->pBundledContext; 453c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = LVM_NULL; 4542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // free the effect context for current effect 4562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext; 4572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease end\n"); 4592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 4602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectRelease */ 4622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 463e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentextern "C" int EffectGetDescriptor(effect_uuid_t *uuid, 464e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_descriptor_t *pDescriptor) { 465e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent const effect_descriptor_t *desc = NULL; 466e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 467e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pDescriptor == NULL || uuid == NULL){ 4683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("EffectGetDescriptor() called with NULL pointer"); 469e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 470e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 471e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 472e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 473e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gBassBoostDescriptor; 474e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 475e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gVirtualizerDescriptor; 476e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 477e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gEqualizerDescriptor; 478e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 479e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gVolumeDescriptor; 480e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 481e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 482e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (desc == NULL) { 483e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 484e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 485e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 486e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent memcpy(pDescriptor, desc, sizeof(effect_descriptor_t)); 487e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 488e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return 0; 489e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} /* end EffectGetDescriptor */ 490e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 4912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init(){ 4923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmGlobalBundle_init start"); 4932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 4942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBundledEffectsEnabled = LVM_FALSE; 4952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVolumeInstantiated = LVM_FALSE; 4962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bEqualizerInstantiated = LVM_FALSE; 4972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBassInstantiated = LVM_FALSE; 4982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE; 4992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].pBundledContext = LVM_NULL; 500c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 501e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent SessionIndex[i] = LVM_UNUSED_SESSION; 5022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 5042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 5052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_init() 5072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Initialize engine with default configuration, creates instance 5092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// with all effects disabled. 5102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 5122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 5132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 5152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init(EffectContext *pContext){ 5192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status; 5202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init start"); 5222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 523163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; 524e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 525e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 526163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.samplingRate = 44100; 527163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.getBuffer = NULL; 528163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL; 529163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.cookie = NULL; 530163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL; 531163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; 532e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 533e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.samplingRate = 44100; 535163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.getBuffer = NULL; 536163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL; 537163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.cookie = NULL; 538163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL; 5392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 5412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext->pBundledContext->hInstance != NULL){ 5433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 5442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Calling pContext->pBassBoost->free()"); 5452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmEffect_free(pContext); 5472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 5492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Called pContext->pBassBoost->free()"); 5502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 5532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 5542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_InstParams_t InstParams; /* Instance parameters */ 5552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_EQNB_BandDef_t BandDefs[MAX_NUM_BANDS]; /* Equaliser band definitions */ 5562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ 5572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomBandDef_t HeadroomBandDef[LVM_HEADROOM_MAX_NBANDS]; 5582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; /* Memory allocation table */ 5592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bool bMallocFailure = LVM_FALSE; 5602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the capabilities */ 562163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent InstParams.BufferMode = LVM_UNMANAGED_BUFFERS; 5632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.MaxBlockSize = MAX_CALL_SIZE; 5642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.EQNB_NumBands = MAX_NUM_BANDS; 5652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.PSA_Included = LVM_PSA_ON; 5662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory, forcing alignment */ 5682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(LVM_NULL, 5692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 5702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 5712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmBundle_init") 5732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 5742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n"); 5762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory */ 5782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 5792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 5802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size); 5812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 5833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes " 584d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent "for region %u\n", MemTab.Region[i].Size, i ); 5852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bMallocFailure = LVM_TRUE; 5862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 5873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance allocated %ld bytes for region %u at %p\n", 5882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 5892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* If one or more of the memory regions failed to allocate, free the regions that were 5942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * succesfully allocated and return with an error 5952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 5962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(bMallocFailure == LVM_TRUE){ 5972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 5982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 5993856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes " 600d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent "for region %u Not freeing\n", MemTab.Region[i].Size, i ); 6012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 6023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed: but allocated %ld bytes " 603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent "for region %u at %p- free\n", 604163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 6052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 6062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 6092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully malloc'd memory\n"); 6112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Initialise */ 613163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = LVM_NULL; 6142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Init sets the instance handle */ 616163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetInstanceHandle(&pContext->pBundledContext->hInstance, 6172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 6182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 6192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "LvmBundle_init") 6212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_GetInstanceHandle\n"); 6242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the initial process parameters */ 6262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* General parameters */ 6272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.OperatingMode = LVM_MODE_ON; 6282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SampleRate = LVM_FS_44100; 6292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SourceFormat = LVM_STEREO; 6302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SpeakerType = LVM_HEADPHONES; 6312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->SampleRate = LVM_FS_44100; 633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Concert Sound parameters */ 6352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerOperatingMode = LVM_MODE_OFF; 6362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerType = LVM_CONCERTSOUND; 6372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerReverbLevel = 100; 638d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.CS_EffectLevel = LVM_CS_EFFECT_NONE; 6392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* N-Band Equaliser parameters */ 6412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_OperatingMode = LVM_EQNB_OFF; 6422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_NBands = FIVEBAND_NUMBANDS; 6432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.pEQNB_BandDefinition = &BandDefs[0]; 644163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 6462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 6472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 6482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].QFactor = EQNB_5BandPresetsQFactors[i]; 649163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDefs[i].Gain = EQNB_5BandSoftPresets[i]; 6502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume Control parameters */ 6532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_EffectLevel = 0; 6542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_Balance = 0; 6552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Treble Enhancement parameters */ 6572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_OperatingMode = LVM_TE_OFF; 6582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_EffectLevel = 0; 6592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 6612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 6622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = (LVM_PSA_DecaySpeed_en)0; 6632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 6652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_OperatingMode = LVM_BE_OFF; 6662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_EffectLevel = 0; 6672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 6682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_HPF = LVM_BE_HPF_ON; 6692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 6712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 6722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM; 6732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 674d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent /* TE Control parameters */ 675d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_OperatingMode = LVM_TE_OFF; 676d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_EffectLevel = 0; 677d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 678163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 679163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, 6802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ¶ms); 6812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmBundle_init") 6832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetControlParameters\n"); 6862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the headroom parameters */ 6882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_Low = 20; 6892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_High = 4999; 6902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Headroom_Offset = 3; 6912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_Low = 5000; 6922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_High = 24000; 6932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Headroom_Offset = 4; 6942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.pHeadroomDefinition = &HeadroomBandDef[0]; 6952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON; 6962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.NHeadroomBands = 2; 6972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetHeadroomParams(pContext->pBundledContext->hInstance, 6992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &HeadroomParams); 7002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetHeadroomParams", "LvmBundle_init") 7022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 7032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetHeadroomParams\n"); 7053856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init End"); 7062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_init */ 7082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 709dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 710dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurentstatic inline int16_t clamp16(int32_t sample) 711dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent{ 712dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if ((sample>>15) ^ (sample>>31)) 713dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent sample = 0x7FFF ^ (sample>>31); 714dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return sample; 715dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent} 716dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 7172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_process() 7192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 7212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply LVM Bundle effects 7222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pIn: pointer to stereo 16 bit input data 7252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to stereo 16 bit output data 7262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// frameCount: Frames to process 7272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 7292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 7312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to updated stereo 16 bit output data 7322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_process(LVM_INT16 *pIn, 736163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOut, 737163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int frameCount, 738163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent EffectContext *pContext){ 7392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 7412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 742163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOutTmp; 743dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 744163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){ 745163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOutTmp = pOut; 746163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 747dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->frameCount != frameCount) { 748dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->workBuffer != NULL) { 749dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent free(pContext->pBundledContext->workBuffer); 750dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 751dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->workBuffer = 752dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent (LVM_INT16 *)malloc(frameCount * sizeof(LVM_INT16) * 2); 753dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->frameCount = frameCount; 754163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 755dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pOutTmp = pContext->pBundledContext->workBuffer; 756163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 7573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("LVM_ERROR : LvmBundle_process invalid access mode"); 758163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 759163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 7602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 761163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 762163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pIn, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmInPtr); 763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmInPtr); 764163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 765163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7663856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("Calling LVM_Process"); 767d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 768163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process the samples */ 7692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */ 7702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pIn, /* Input buffer */ 7712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pOutTmp, /* Output buffer */ 7722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_UINT16)frameCount, /* Number of samples to read */ 7732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0); /* Audo Time */ 774163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_Process", "LvmBundle_process") 7762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 7772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 778163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 779163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pOutTmp, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmOutPtr); 780163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmOutPtr); 781163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 782163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 783163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 784163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (int i=0; i<frameCount*2; i++){ 785dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pOut[i] = clamp16((LVM_INT32)pOut[i] + (LVM_INT32)pOutTmp[i]); 786163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 787163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 7882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_process */ 7902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_enable() 7932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Enable the effect in the bundle 7952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 8002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable(EffectContext *pContext){ 8043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable start"); 805163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 8072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 8082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 809163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 810163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 8112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 8122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable") 8142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 8153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n"); 8162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 8183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST"); 8192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_ON; 8202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 8223856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER"); 8232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_ON; 8242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 8263856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER"); 8272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_ON; 8282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 8303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_VOLUME"); 831163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 832163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 8342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_enable") 8352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 836163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n"); 8383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable end"); 8392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 8402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 8412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_disable() 8442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Disable the effect in the bundle 8462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 8482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 8492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 8512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable(EffectContext *pContext){ 8553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable start"); 856163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 8582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 859163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 8612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 8622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_disable") 8642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 8653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n"); 8662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 8683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST"); 8692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_OFF; 8702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 8723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_VIRTUALIZER"); 8732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_OFF; 8742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 8763856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_EQUALIZER"); 8772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_OFF; 8782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 8803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_VOLUME"); 881163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 882163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 8842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_disable") 8852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 886163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n"); 8883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable end"); 8892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 8902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 8912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_free() 8942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Free all memory associated with the Bundle. 8962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 8982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 8992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 9012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free(EffectContext *pContext){ 9052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 9062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 9072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; 9082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Free the algorithm memory */ 9102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(pContext->pBundledContext->hInstance, 9112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 9122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_NULL); 9132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmEffect_free") 9152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 9172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 9182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress != NULL){ 9193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_free - START freeing %ld bytes for region %u at %p\n", 9202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 9212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 9232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9243856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_free - END freeing %ld bytes for region %u at %p\n", 9252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 9262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 9273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : LvmEffect_free - trying to free with NULL pointer %ld bytes " 9282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "for region %u at %p ERROR\n", 9292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 9302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmEffect_free */ 9342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Effect_configure() 9372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Set input and output audio configuration. 9392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pConfig: pointer to effect_config_t structure holding input and output 9432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// configuration parameters 9442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 9462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Effect_configure(EffectContext *pContext, effect_config_t *pConfig){ 950163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_Fs_en SampleRate; 9513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_configure start"); 9522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 9542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig != NULL); 9552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate); 9572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels); 9582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format); 959e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent CHECK_ARG(pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO); 9602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE 9612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE); 962e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT); 9632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(&pContext->config, pConfig, sizeof(effect_config_t)); 9652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 966163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent switch (pConfig->inputCfg.samplingRate) { 967163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 8000: 968163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_8000; 969c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 8000*2; // 2 secs Stereo 970163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 971163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 16000: 972163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_16000; 973c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 16000*2; // 2 secs Stereo 974163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 975163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 22050: 976163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_22050; 977c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 22050*2; // 2 secs Stereo 978163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 979163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 32000: 980163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_32000; 981c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 32000*2; // 2 secs Stereo 982163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 983163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 44100: 984163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_44100; 985c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 44100*2; // 2 secs Stereo 986163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 987163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 48000: 988163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_48000; 989c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo 990163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 991163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent default: 9923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate); 993163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 994163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 9952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 996163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->SampleRate != SampleRate){ 9972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 998163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; 999163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; 10002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_configure change sampling rate to %d", SampleRate); 10022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1003163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1004163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1005163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 10062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1007163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_configure") 1008163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 10092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1010163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 10112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1012163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_configure") 10133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_configure Succesfully called LVM_SetControlParameters\n"); 1014c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SampleRate = SampleRate; 10152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1016163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 10173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_configure keep sampling rate at %d", SampleRate); 1018163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 10192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_configure End...."); 1021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1022163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end Effect_configure */ 10232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassGetStrength() 10262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 10292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 10302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// the bassboost uses 1-15, so to avoid a quantisation the original set value is used. However the 10312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 10322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t BassGetStrength(EffectContext *pContext){ 10393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved); 10402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1043163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1044163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 10452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 10462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassGetStrength") 10482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 10492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n"); 10512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Check that the strength returned matches the strength that was set earlier */ 1053163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(ActiveParams.BE_EffectLevel != 1054163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){ 10553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n", 10562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved); 10572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 10582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 10613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (saved) -> %d\n", pContext->pBundledContext->BassStrengthSaved ); 10622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return pContext->pBundledContext->BassStrengthSaved; 10632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassGetStrength */ 10642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassSetStrength() 10672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the BassBosst. Must first be converted from the range 0-1000 to 1-15 10702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 10742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid BassSetStrength(EffectContext *pContext, uint32_t strength){ 10783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength(%d)", strength); 10792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->BassStrengthSaved = (int)strength; 10812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 10842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 10862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 10872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 10882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassSetStrength") 10903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength Succesfully returned from LVM_GetControlParameters\n"); 10912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 10932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel = (LVM_INT16)((15*strength)/1000); 10942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 10952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 10972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 10992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 11002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength") 11023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n"); 11032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassSetStrength */ 11042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerGetStrength() 11072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 11102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 1111163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// the Virtualizer uses 1-100, so to avoid a quantisation the original set value is used.However the 11122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 11132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t VirtualizerGetStrength(EffectContext *pContext){ 11203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved); 11212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 11232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 11242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 11262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerGetStrength") 11282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 11292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n"); 11313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength() (0-100) -> %d\n", ActiveParams.VirtualizerReverbLevel*10); 1132d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent return pContext->pBundledContext->VirtStrengthSaved; 11332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getStrength */ 11342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerSetStrength() 11372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the Virtualizer. Must first be converted from the range 0-1000 to 1-15 11402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 11442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){ 11483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength(%d)", strength); 11492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 11502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 11512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1152163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = (int)strength; 1153163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 11542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 11552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 11562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerSetStrength") 11583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n"); 11592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Virtualizer parameters */ 1161d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent ActiveParams.CS_EffectLevel = (int)((strength*32767)/1000); 11622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11633856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength ); 11643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel ); 11652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 11672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 11682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength") 11693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n"); 11702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setStrength */ 11712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandLevel() 11742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the gain currently being used for the band passed in 11762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 11792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 11822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){ 11852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1186163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Gain =0; 1187163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1188163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1189163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1190163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1191163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1192163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 11932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1194163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetBandLevel") 11952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1196163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1197163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Gain = (int32_t)BandDef[band].Gain*100; // Convert to millibels 11982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11993856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetBandLevel -> %d\n", Gain ); 12003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 1201163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Gain; 12022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetBandLevel() 12062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets gain value for the given band. 12092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 12122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gain: Gain to be applied in millibels 12132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--------------------------------------------------------------------------- 1218d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentvoid EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){ 1219163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int gainRounded; 1220163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(Gain > 0){ 1221163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain+50)/100); 1222163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1223163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain-50)/100); 1224163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 12253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded); 1226163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1227163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 12282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 12292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1230163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 12312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 12332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1234163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetBandLevel") 12353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 12363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel just Got -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain); 12372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set local EQ parameters */ 1239163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1240163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[band].Gain = gainRounded; 12412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 12432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1244163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetBandLevel") 12453856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel just Set -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain); 12462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 12482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 12492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetCentreFrequency() 12522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the frequency being used for the band passed in 12542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 12572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetCentreFrequency(EffectContext *pContext, int32_t band){ 1263163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Frequency =0; 12642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1265163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1266163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1268163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1269163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1270163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 12712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1272163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetCentreFrequency") 12732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1274163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1275163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Frequency = (int32_t)BandDef[band].Frequency*1000; // Convert to millibels 12762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetCentreFrequency -> %d\n", Frequency ); 12783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetCentreFrequency Succesfully returned from LVM_GetControlParameters\n"); 1279163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Frequency; 12802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandFreqRange( 12842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets lower and upper boundaries of a band. 12882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the high shelf, the low bound is the band frequency and the high 12892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// bound is Nyquist. 12902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the peaking filters, they are the gain[dB]/2 points. 12912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 12942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 12982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 12992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1300163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t EqualizerGetBandFreqRange(EffectContext *pContext, int32_t band, uint32_t *pLow, 1301163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t *pHi){ 1302163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pLow = bandFreqRange[band][0]; 1303163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pHi = bandFreqRange[band][1]; 1304163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 13052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBand( 13092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Returns the band with the maximum influence on a given frequency. 13132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Result is unaffected by whether EQ is enabled or not, or by whether 13142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// changes have been committed or not. 13152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// targetFreq The target frequency, in millihertz. 13182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 13212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 13222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 13232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBand(EffectContext *pContext, uint32_t targetFreq){ 13252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int band = 0; 13262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(targetFreq < bandFreqRange[0][0]){ 1328163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1329163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if(targetFreq == bandFreqRange[0][0]){ 1330163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1332163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for(int i=0; i<FIVEBAND_NUMBANDS;i++){ 1333163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((targetFreq > bandFreqRange[i][0])&&(targetFreq <= bandFreqRange[i][1])){ 1334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent band = i; 1335163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1336163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 13372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return band; 13382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPreset( 13422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets the currently set preset ID. 13462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Will return PRESET_CUSTOM in case the EQ parameters have been modified 13472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// manually since a preset was set. 13482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetPreset(EffectContext *pContext){ 1354163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return pContext->pBundledContext->CurPreset; 13552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetPreset( 13592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets the current preset by ID. 13632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// All the band parameters will be overridden. 13642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. 13682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid EqualizerSetPreset(EffectContext *pContext, int preset){ 13712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset(%d)", preset); 13732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = preset; 13742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 13772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 13792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1380163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetPreset") 13813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset Succesfully returned from LVM_GetControlParameters\n"); 13822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //ActiveParams.pEQNB_BandDefinition = &BandDefs[0]; 13842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 13852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 1386163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 1387163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i]; 1388163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Gain 1389163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent = EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS]; 13902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 13912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the new settings */ 13922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1393163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetPreset") 13942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n"); 13962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 13972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 1398163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 13992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetNumPresets(){ 1400163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return sizeof(gEqualizerPresets) / sizeof(PresetConfig); 14012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 14022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPresetName( 14052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets a human-readable name for a preset ID. Will return "Custom" if 14082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// PRESET_CUSTOM is passed. 14092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. Must be less than number of presets. 14122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//------------------------------------------------------------------------- 14142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst char * EqualizerGetPresetName(int32_t preset){ 14153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetPresetName start(%d)", preset); 14162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (preset == PRESET_CUSTOM) { 14172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return "Custom"; 14182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 14192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return gEqualizerPresets[preset].name; 14202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 14213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetPresetName end(%d)", preset); 1422163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 14232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 14242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetVolumeLevel() 14272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 14322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// level level to be applied 14332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){ 14372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 14392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 14402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14413856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel Level to be set is %d %d\n", level, (LVM_INT16)(level/100)); 14422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 14432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 14452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters got: %d\n", 1447163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.VC_EffectLevel); 14482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume parameters */ 14502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VC_EffectLevel = (LVM_INT16)(level/100); 14513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 14522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 14542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetVolumeLevel") 14562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n"); 1459163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1460163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1461163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1462163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 1463163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1464163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 14653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel ); 1466d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent if(pContext->pBundledContext->firstVolume == LVM_TRUE){ 1467d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); 1468d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process") 14693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks"); 1470d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->firstVolume = LVM_FALSE; 1471d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent } 14722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 14732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setVolumeLevel */ 14742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeGetVolumeLevel() 14772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 14822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){ 14862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel start"); 1488163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 14892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 14902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 14912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetVolumeLevel") 14942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 14973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n"); 14982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *level = ActiveParams.VC_EffectLevel*100; // Convert dB to millibels 15003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel end"); 15012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 15022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end VolumeGetVolumeLevel */ 15032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetMute() 15062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 15122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){ 15163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute start(%d)", mute); 15172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bMuteEnabled = mute; 15192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 15212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 15222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 15242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 15252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetMute") 15262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 15272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n"); 15293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute to %d, level was %d\n", mute, ActiveParams.VC_EffectLevel ); 15302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set appropriate volume level */ 15322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){ 1533163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = ActiveParams.VC_EffectLevel; 1534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = -96; 15352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 1536163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = pContext->pBundledContext->levelSaved; 15372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 15382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 15402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 15412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetMute") 15422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 15432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n"); 15453856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute end"); 15462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 15472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setMute */ 15482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1550163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetMute() 15512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Ourputs: 15582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 15592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){ 15623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetMute start"); 1563163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)|| 1564163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){ 1565163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *mute = pContext->pBundledContext->bMuteEnabled; 1566163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 15672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 15683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d", 1569163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled); 1570163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 15712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 15723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetMute end"); 15732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getMute */ 15742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1575163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint16_t VolumeConvertStereoPosition(int16_t position){ 1576163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t convertedPosition = 0; 1577163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1578163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent convertedPosition = (int16_t)(((float)position/1000)*96); 1579163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return convertedPosition; 1580163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1581163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 1582163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1583163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1584163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeSetStereoPosition() 1585163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1586163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1587163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1588163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1589163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1590163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1591163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1592163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1593163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1594163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1595163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint VolumeSetStereoPosition(EffectContext *pContext, int16_t position){ 1596163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1597163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1598163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1599163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Balance = 0; 1600163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1601c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 1602163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1604163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1605163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1607d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1608163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1609163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1610163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16113856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Position to be set is %d %d\n", position, Balance); 1612163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1613163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1616163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 16173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got:" 1618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // " %d\n", ActiveParams.VC_Balance); 1619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1620163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Volume parameters */ 1621163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = Balance; 16223856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition() (-96dB -> +96dB) -> %d\n", ActiveParams.VC_Balance ); 1623163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1624163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1625163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1626163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 1627163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1628163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully called LVM_SetControlParameters\n"); 16302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1631163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1634163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 16353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got: " 1636163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "%d\n", ActiveParams.VC_Balance); 1637163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1638163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent else{ 16393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Position attempting to set, but not enabled %d %d\n", 1640163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //position, Balance); 1641163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 16423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n", 1643d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1644163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1645163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeSetStereoPosition */ 16462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1648163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1649163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetStereoPosition() 1650163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1651163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1652163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1655163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1656163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1657163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1658163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 16592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeGetStereoPosition(EffectContext *pContext, int16_t *position){ 16613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition start"); 16622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1665163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 balance; 1666163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1668d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1669163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1670163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1671163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition") 1672163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1673163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition -> %d\n", ActiveParams.VC_Balance); 16753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 1676163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1677163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1678163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1679163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1680163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(balance != ActiveParams.VC_Balance){ 1681163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1682163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1683163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1684163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *position = (LVM_INT16)pContext->pBundledContext->positionSaved; // Convert dB to millibels 16853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved =%d\n", 1686d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1687163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1688163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeGetStereoPosition */ 16892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1690163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeEnableStereoPosition() 1692163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1694163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1695163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1696163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1697163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// mute: enable/disable flag 1698163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1699163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 17002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1701163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){ 17023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition start()"); 17032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1704163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = enabled; 17052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1706163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1707163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 17082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1709163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1710163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1711163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeEnableStereoPosition") 1712163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 17132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 17153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition to %d, position was %d\n", 1716163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // enabled, ActiveParams.VC_Balance ); 17172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1718163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Set appropriate stereo position */ 1719163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_FALSE){ 1720163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 0; 1721163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1722163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 1723163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1724163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 17252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1726163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1727163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1728163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeEnableStereoPosition") 1729163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 17302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition Succesfully called LVM_SetControlParameters\n"); 17323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition end()\n"); 1733163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1734163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeEnableStereoPosition */ 17352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_getParameter() 17382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a BassBoost parameter 17412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 17442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 17452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 17462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 17472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 17492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 17502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 17512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 17542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint BassBoost_getParameter(EffectContext *pContext, 1758c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1759163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent size_t *pValueSize, 1760163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue){ 17612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 1762c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1763c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 17642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 17652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 17662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter start"); 17682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 177023e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 17717fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 17723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize1 %d", *pValueSize); 17737fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 17747fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 17757fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 17767fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 17772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 17782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 17793856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize); 17802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 17812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 17832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 17863856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 17872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 17882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 179123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 17922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 17932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED Value is %d", 1795163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 17962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 17992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = BassGetStrength(pContext); 18002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d", 1802163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 18032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 18072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 18082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18113856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter end"); 18122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 18132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_getParameter */ 18142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_setParameter() 18172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 18192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a BassBoost parameter 18202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 18222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 18232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 18242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 18252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 18272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1830c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 18312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 18322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 1833c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 18342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter start"); 18362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1837c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (*pParamTemp){ 18382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 18392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 18403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength); 18413856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength"); 18422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BassSetStrength(pContext, (int32_t)strength); 18433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength"); 18442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp); 18472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter end"); 18512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 18522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_setParameter */ 18532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_getParameter() 18562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 18582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Virtualizer parameter 18592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 18612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 18622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 18632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 18642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 18652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 18672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 18682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 18692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 18722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter(EffectContext *pContext, 1876c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 18772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 18782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 18792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 1880c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1881c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 18822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 18832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 18842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter start"); 18862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 188823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 18897fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 18903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize); 18917fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 18927fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 18937fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 18947fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 18952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 18962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 18973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize); 18982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 19012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 19052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 19062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 190923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 19102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 19112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED Value is %d", 1913163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 19142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 19172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = VirtualizerGetStrength(pContext); 19182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d", 1920163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 19212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19243856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 19252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter end"); 19302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 19312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_getParameter */ 19322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_setParameter() 19352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 19372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Virtualizer parameter 19382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 19402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 19412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 19422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 19432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 19452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1948c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 19492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 19502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 1951c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1952c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 19532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter start"); 19552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1956c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 19572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 19582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 19593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength); 19603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength"); 19612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent VirtualizerSetStrength(pContext, (int32_t)strength); 19623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength"); 19632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param); 19662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter end"); 19702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 19712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_setParameter */ 19722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_getParameter() 19752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 19772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Equalizer parameter 19782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 19802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 19812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 19822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 19832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 19842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 19862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 19872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 19882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 19912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter(EffectContext *pContext, 1994c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 19952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 19962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 19972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 19982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 1999c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2000c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 20012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 20022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 20032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter start"); 20052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 20072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 20082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 20092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 20103be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_BAND_LEVEL: 20113be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_GET_BAND: 20122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int16_t)) { 20133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 20142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 20172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 20203be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (*pValueSize < 2 * sizeof(int16_t)) { 20213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize); 20223be9523784cc4038f601e510faee595117cdacb3Eric Laurent return -EINVAL; 20233be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 20243be9523784cc4038f601e510faee595117cdacb3Eric Laurent *pValueSize = 2 * sizeof(int16_t); 20253be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 20262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 20272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < 2 * sizeof(int32_t)) { 20283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 3 %d", *pValueSize); 20292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = 2 * sizeof(int32_t); 20322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20333be9523784cc4038f601e510faee595117cdacb3Eric Laurent 20342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 20352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)) { 20363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 5 %d", *pValueSize); 20372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 20402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 20432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 204523e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: 204623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent if (*pValueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t)) { 20473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 204823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent return -EINVAL; 204923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 205023e1de74359f4bb1763aef0adfebe073122b032cEric Laurent *pValueSize = (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t); 205123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent break; 205223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 20532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param); 20552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 20592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 20603be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)FIVEBAND_NUMBANDS; 20613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue); 20622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 20653be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = -1500; 20663be9523784cc4038f601e510faee595117cdacb3Eric Laurent *((int16_t *)pValue + 1) = 1500; 20673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", 2068d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue, *((int16_t *)pValue + 1)); 20692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2072c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 20742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20773be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2); 20783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", 2079163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 20802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 2083c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 20852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2); 20893856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", 2090163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 20912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 2094c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 20962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1)); 21003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", 2101163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue, *((int32_t *)pValue + 1)); 21022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_BAND: 2105c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 21063be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2); 21073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", 2108d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // param2, *(uint16_t *)pValue); 21092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 21123be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext); 21133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue); 21142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 21173be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetNumPresets(); 21183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue); 21192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 2122c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 21232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= EqualizerGetNumPresets()) { 21242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //if (param2 >= 20) { // AGO FIX 21252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name = (char *)pValue; 21292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1); 21302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name[*pValueSize - 1] = 0; 21312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = strlen(name) + 1; 21323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", 2133163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, gEqualizerPresets[param2].name, *pValueSize); 21342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 213623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: { 21373be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 21383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES"); 21393be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[0] = (int16_t)EqualizerGetPreset(pContext); 21403be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[1] = (int16_t)FIVEBAND_NUMBANDS; 214123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 21423be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[2 + i] = (int16_t)EqualizerGetBandLevel(pContext, i); 214323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 214423e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } break; 214523e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 21462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 21473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param); 21482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2152d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //GV("\tEqualizer_getParameter end\n"); 21532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 21542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_getParameter */ 21552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_setParameter() 21582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 21602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Equalizer parameter 21612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 21632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 21642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 21652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 21662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 21682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 2170c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 21712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 21722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t preset; 21732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t band; 21742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t level; 2175c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2176c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 2177c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 21782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21793856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter start"); 21802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 21812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 21823be9523784cc4038f601e510faee595117cdacb3Eric Laurent preset = (int32_t)(*(uint16_t *)pValue); 21832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset); 21852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ((preset >= EqualizerGetNumPresets())||(preset < 0)) { 21862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetPreset(pContext, preset); 21902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2192c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent band = *pParamTemp; 21933be9523784cc4038f601e510faee595117cdacb3Eric Laurent level = (int32_t)(*(int16_t *)pValue); 21943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level); 21952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (band >= FIVEBAND_NUMBANDS) { 21962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetBandLevel(pContext, band, level); 22002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22013be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_PROPERTIES: { 22023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES"); 22033be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 22043be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[0] >= EqualizerGetNumPresets()) { 22053be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 22063be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 22073be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22083be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (p[0] >= 0) { 22093be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetPreset(pContext, (int)p[0]); 22103be9523784cc4038f601e510faee595117cdacb3Eric Laurent } else { 22113be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[1] != FIVEBAND_NUMBANDS) { 22123be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 22133be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 22143be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22153be9523784cc4038f601e510faee595117cdacb3Eric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 22163be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetBandLevel(pContext, i, (int)p[2 + i]); 22173be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22183be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22193be9523784cc4038f601e510faee595117cdacb3Eric Laurent } break; 22202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 22213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_setParameter() invalid param %d", param); 22223be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 22232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22263856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter end"); 22272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 22282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_setParameter */ 22292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_getParameter() 22322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 22342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Volume parameter 22352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 22372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 22382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 22392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 22402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 22412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 22432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 22442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 22452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 22482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter(EffectContext *pContext, 2252c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 22532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 22542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 22552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 22562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 2257c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2258c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++;; 22592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 22602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter start"); 22622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 22642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 22652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 22662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (*pValueSize != sizeof(int16_t)){ 22683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1 %d", *pValueSize); 22692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 22722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 22752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 22762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)){ 22773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2 %d", *pValueSize); 22782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 22812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 22843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param); 22852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 22892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 22902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue)); 22913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d", 2292d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 22932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 22962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = 0; 22973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d", 2298d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 22992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2302163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeGetStereoPosition(pContext, (int16_t *)pValue); 23033856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d", 2304d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 23052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2308163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeGetMute(pContext, (uint32_t *)pValue); 23093856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d", 2310163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(uint32_t *)pValue); 23112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2314163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled; 23153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d", 2316d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(uint32_t *)pValue); 23172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 23203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param); 23212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 23222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter end"); 23262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 23272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_getParameter */ 23282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 23312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_setParameter() 23322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 23332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 23342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Volume parameter 23352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 23362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 23372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 23382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 23392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 23402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 23412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 23422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 23432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 23442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2345c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 23462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 23472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t level; 2348163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t position; 23492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent uint32_t mute; 2350163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t positionEnabled; 2351c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2352c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 23532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter start"); 23552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2356c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 23572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 23582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent level = *(int16_t *)pValue; 23593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level); 23603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel"); 23612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeSetVolumeLevel(pContext, (int16_t)level); 23623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel"); 23632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2366163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent mute = *(uint32_t *)pValue; 23673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute); 23683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setMute"); 2369163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetMute(pContext, mute); 23703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->setMute"); 2371163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 23722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2374163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent positionEnabled = *(uint32_t *)pValue; 2375163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeEnableStereoPosition(pContext, positionEnabled); 2376163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved); 23773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called"); 2378163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 23792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2381163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent position = *(int16_t *)pValue; 23823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position); 23833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition"); 2384163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, (int16_t)position); 23853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition"); 2386163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 23872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 23893856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param); 23902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23933856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter end"); 23942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 23952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_setParameter */ 23962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2397163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent/**************************************************************************************** 2398163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Name : LVC_ToDB_s32Tos16() 2399163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Input : Signed 32-bit integer 2400163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Output : Signed 16-bit integer 2401163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * MSB (16) = sign bit 2402163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (15->05) = integer part 2403163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (04->01) = decimal part 2404163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Returns : Db value with respect to full scale 2405163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Description : 2406163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Remarks : 2407163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ****************************************************************************************/ 2408163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2409163fbcf84010b98e0374110454d85b804bc8d13bEric LaurentLVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) 2410163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent{ 2411163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 db_fix; 2412163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Shift; 2413163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 SmallRemainder; 2414163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_UINT32 Remainder = (LVM_UINT32)Lin_fix; 2415163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2416163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Count leading bits, 1 cycle in assembly*/ 2417163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (Shift = 0; Shift<32; Shift++) 2418163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2419163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((Remainder & 0x80000000U)!=0) 2420163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2421163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2422163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2423163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Remainder = Remainder << 1; 2424163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2426163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* 2427163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Based on the approximation equation (for Q11.4 format): 2428163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * 2429163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * dB = -96 * Shift + 16 * (8 * Remainder - 2 * Remainder^2) 2430163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent */ 2431163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(-96 * Shift); /* Six dB steps in Q11.4 format*/ 2432163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)((Remainder & 0x7fffffff) >> 24); 2433163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix + SmallRemainder ); 2434163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)(SmallRemainder * SmallRemainder); 2435163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - (LVM_INT16)((LVM_UINT16)SmallRemainder >> 9)); 24362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2437163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Correct for small offset */ 2438163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - 5); 24392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2440163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return db_fix; 2441163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 24422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 244329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 244429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Effect_setEnabled() 244529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 244629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Purpose: 244729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Enable or disable effect 244829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 244929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Inputs: 245029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// pContext - pointer to effect context 245129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// enabled - true if enabling the effect, false otherwise 245229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 245329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Outputs: 245429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 245529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 245629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 245729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurentint Effect_setEnabled(EffectContext *pContext, bool enabled) 245829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent{ 24593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() type %d, enabled %d", pContext->EffectType, enabled); 246029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 246129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (enabled) { 246229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent switch (pContext->EffectType) { 246329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_BASS_BOOST: 246429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 24653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already enabled"); 246629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 246729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2468dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb <= 0){ 2469dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2470dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 247129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 247229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 247329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bBassEnabled = LVM_TRUE; 247429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 247529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_EQUALIZER: 247629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) { 24773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already enabled"); 247829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 247929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2480dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq <= 0){ 2481dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2482dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 248329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 248429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 248529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE; 248629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 248729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VIRTUALIZER: 248829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { 24893856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already enabled"); 249029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 249129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2492dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt <= 0){ 2493dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2494dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 249529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 249629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 249729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE; 249829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 249929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VOLUME: 250029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE) { 25013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VOLUME is already enabled"); 250229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 250329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2504dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 250529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_TRUE; 250629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 250729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent default: 25083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() invalid effect type"); 250929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 251029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 251129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent LvmEffect_enable(pContext); 251229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } else { 251329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent switch (pContext->EffectType) { 251429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_BASS_BOOST: 251529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_FALSE) { 25163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already disabled"); 251729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 251829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 251929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 252029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 252129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_EQUALIZER: 252229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE) { 25233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already disabled"); 252429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 252529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 252629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 252729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 252829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VIRTUALIZER: 252929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE) { 25303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already disabled"); 253129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 253229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 253329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 253429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 253529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VOLUME: 253629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_FALSE) { 25373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VOLUME is already disabled"); 253829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 253929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 254029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 254129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 254229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent default: 25433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() invalid effect type"); 254429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 254529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 254629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent LvmEffect_disable(pContext); 254729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 254829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 254929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return 0; 255029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent} 255129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 2552dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//---------------------------------------------------------------------------- 2553dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// LVC_Convert_VolToDb() 2554dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//---------------------------------------------------------------------------- 2555dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Purpose: 2556dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Convery volume in Q24 to dB 2557dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// 2558dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Inputs: 2559dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// vol: Q.24 volume dB 2560dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// 2561dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//----------------------------------------------------------------------- 2562dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2563dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurentint16_t LVC_Convert_VolToDb(uint32_t vol){ 2564dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t dB; 2565dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2566dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = LVC_ToDB_s32Tos16(vol <<7); 2567dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = (dB +8)>>4; 2568dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = (dB <-96) ? -96 : dB ; 2569dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2570dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return dB; 2571dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent} 2572dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2573163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 2574163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 25752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2576e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentextern "C" { 25772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Process */ 2578e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_process(effect_handle_t self, 2579163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *inBuffer, 2580163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *outBuffer){ 25812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 2582c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 25832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 2584163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int lvmStatus = 0; 2585163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *in = (LVM_INT16 *)inBuffer->raw; 2586163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw; 25872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block//ALOGV("\tEffect_process Start : Enabled = %d Called = %d (%8d %8d %8d)", 2589dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled, 2590c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountBb, 2591c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountVirt, 2592c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountEq); 2593c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 25942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 25953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL"); 25962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2598dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2599dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //if(pContext->EffectType == LVM_BASS_BOOST){ 26003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is BASS_BOOST"); 2601dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //}else if(pContext->EffectType == LVM_EQUALIZER){ 26023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is LVM_EQUALIZER"); 2603dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //}else if(pContext->EffectType == LVM_VIRTUALIZER){ 26043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is LVM_VIRTUALIZER"); 2605dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //} 2606dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 26072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (inBuffer == NULL || inBuffer->raw == NULL || 26082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer == NULL || outBuffer->raw == NULL || 26092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent inBuffer->frameCount != outBuffer->frameCount){ 26103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG"); 26112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2613163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&& 2614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_BASS_BOOST)){ 26153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled"); 2616c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb > 0){ 2617c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO 26183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting to turn off BASS_BOOST, %d samples left", 2619c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountBb); 2620d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2621d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb <= 0) { 262229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent status = -ENODATA; 2623dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 26243856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_BASS_BOOST"); 2625c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 2626163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2627163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&& 2628163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VOLUME)){ 26293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_VOLUME Effect is not enabled"); 2630163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2631dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 2632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&& 2634163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_EQUALIZER)){ 26353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled"); 2636c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq > 0){ 2637c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO 26383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting to turn off EQUALIZER, %d samples left", 2639c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountEq); 2640d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2641d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq <= 0) { 2642c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2643dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 26443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_EQUALIZER"); 2645c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 26462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2647163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&& 2648163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VIRTUALIZER)){ 26493856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled"); 2650c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ 2651c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO 26523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting for to turn off VIRTUALIZER, %d samples left", 2653c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountVirt); 2654d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2655d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) { 2656c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2657dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 26583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_VIRTUALIZER"); 2659c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 26602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2661163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2662dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(status != -ENODATA){ 2663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled++; 26642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2666163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->NumberEffectsCalled == 2667163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled){ 26683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d", 2669163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2670163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 26712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2672163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 26733856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() processing last frame"); 2674163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 26752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 2676163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process all the available frames, block processing is 2677163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent handled internalLY by the LVM bundle */ 2678163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent lvmStatus = android::LvmBundle_process( (LVM_INT16 *)inBuffer->raw, 26792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_INT16 *)outBuffer->raw, 26802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer->frameCount, 26812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext); 2682163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(lvmStatus != LVM_SUCCESS){ 26833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus); 2684163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return lvmStatus; 2685163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 26862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 26873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d", 2688163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2689163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 2690163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // 2 is for stereo input 2691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2); 26922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 26942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 26952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_process */ 26962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Command */ 2698e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_command(effect_handle_t self, 269925f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdCode, 270025f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdSize, 2701163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pCmdData, 270225f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t *replySize, 2703163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pReplyData){ 27042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 27052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int retsize; 27062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\t\nEffect_command start"); 27082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 27103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_BASS_BOOST"); 27112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 27133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_VIRTUALIZER"); 2714163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 27163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_EQUALIZER"); 2717163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 27193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_VOLUME"); 2720163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 27233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL"); 27242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize); 27282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2729163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Incase we disable an effect, next time process is 2730163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // called the number of effect called could be greater 2731163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled = 0; 27322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27333856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", 2734163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled, 2735163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 27362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (cmdCode){ 27382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_INIT: 2739010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 27403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d", 2741010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent pContext->EffectType); 2742010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent return -EINVAL; 2743010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent } 2744010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = 0; 27453856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start"); 27462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 27473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST"); 27482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::BassSetStrength(pContext, 0); 27492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 27513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER"); 2752163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VirtualizerSetStrength(pContext, 0); 2753163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 27553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER"); 2756163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::EqualizerSetPreset(pContext, 0); 2757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 27593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VOLUME"); 2760010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0); 2761163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 27642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_CONFIGURE: 27653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE start"); 27662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL|| 27672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize != sizeof(effect_config_t)|| 27682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 27692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int)){ 27703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 27712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_CONFIGURE: ERROR"); 27722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *) pReplyData = android::Effect_configure(pContext, (effect_config_t *) pCmdData); 27753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE end"); 27762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_RESET: 27793856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start"); 27802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::Effect_configure(pContext, &pContext->config); 27813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end"); 27822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_GET_PARAM:{ 27853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2786163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 27872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2788163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2789163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2790163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2791163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 27923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 27932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 27942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 27972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 27992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 28012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 28032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::BassBoost_getParameter(pContext, 2805c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 28062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 28072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 28082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 28102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28113856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM " 2812163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2813163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2814163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2815163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 28162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2817163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2819163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2820163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2821163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2822163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 28233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 28242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 28252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 28282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 28302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 28322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 28342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Virtualizer_getParameter(pContext, 2836c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 28372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 28382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 28392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 28412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM " 2843163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2844163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2845163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2846163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 28472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 28493856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command cmdCode Case: " 2850163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 2851163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2852163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2853163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2854163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) { 28553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 28562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM"); 28572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 2860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 2862163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 2864163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 2866163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2867c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->status = android::Equalizer_getParameter(pContext, 2868c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 2869c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent &p->vsize, 2870c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data + voffset); 2871163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 2873163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, " 2875163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pReplyData %08x %08x", 2876163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize, 2877163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset), 2878163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + 2879163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // sizeof(int32_t))); 28802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 28823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2883163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2884163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2885163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2886163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 28873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 28882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 28892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 28922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 28942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 28962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 28982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Volume_getParameter(pContext, 2900c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 29012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 29022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 29032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 29052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command EFFECT_CMD_GET_PARAM " 2907163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2908163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2909163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2910163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 2911163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 29123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end"); 29132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 29142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_PARAM:{ 29153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 29162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 29173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 2918dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2919dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *replySize, 2920dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2921163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2922163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2923163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2924163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2925163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 29263856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 29272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 29282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 29312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 29333856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 29342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 29352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tnBassBoost_command cmdSize is %d\n" 2939163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2940163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2941163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2942163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2943163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 29442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::BassBoost_setParameter(pContext, 2946c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 29472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + p->psize); 29482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 29503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 2951d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2952d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 2953d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2954163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2955163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2956163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2957163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2958163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 29593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 29602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 29612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 29642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 29663856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 29672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 29682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tnVirtualizer_command cmdSize is %d\n" 2972163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2973163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2974163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2975163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2976163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 29772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Virtualizer_setParameter(pContext, 2979c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 2980163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 29812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 29833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command cmdCode Case: " 2984d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // "EFFECT_CMD_SET_PARAM start"); 29853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2986d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2987d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 2988d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 29892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 29912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL || *replySize != sizeof(int32_t)) { 29923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 29932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 29942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 29972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Equalizer_setParameter(pContext, 2999c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3000163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 30012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 30033856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 30043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 3005163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3006163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 3007d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) +sizeof(int32_t))); 30082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ( pCmdData == NULL|| 30102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))|| 30112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 30122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int32_t)){ 30133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 30142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 30152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 30182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Volume_setParameter(pContext, 3020c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 3022163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end"); 30242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 30252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_ENABLE: 30273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start"); 30282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 30293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR"); 30302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 3031163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 303229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 303329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_TRUE); 30342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3035163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 30362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_DISABLE: 30373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start"); 30382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 30393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR"); 30402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 3041163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 304229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_FALSE); 30432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 30442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_DEVICE: 3046163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 30473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start"); 3048e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent uint32_t device = *(uint32_t *)pCmdData; 3049163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3050163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 3051e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if((device == AUDIO_DEVICE_OUT_SPEAKER)||(device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)|| 3052e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){ 30533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d", 3054163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 30553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST"); 3056163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3057163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device doesnt support bassboost the effect must be temporarily disabled 3058163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 3059163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 3060163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3061163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){ 30623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d", 3063163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3064163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 3065163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_TRUE; 3066163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3067163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 30683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d", 3069163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3070163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3071163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports bassboost and the effect has been temporarily disabled 3072163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 3073163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3074163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassTempDisabled == LVM_TRUE){ 30753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d", 3076163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3077163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 3078163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 3079163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3080163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3081163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3082163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 3083e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if((device == AUDIO_DEVICE_OUT_SPEAKER)||(device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)|| 3084e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){ 30853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d", 3086163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 30873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER"); 3088163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3089163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //If a device doesnt support virtualizer the effect must be temporarily disabled 3090163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 3091163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 3092163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3093163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 30943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d", 3095163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3096163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 3097163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE; 3098163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3099163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 31003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d", 3101163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3102163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3103163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports virtualizer and the effect has been temporarily disabled 3104163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 3105163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3106163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerTempDisabled == LVM_TRUE){ 31073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d", 3108163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3109163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 3110163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 3111163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3112163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3113163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 31143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end"); 31152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3116163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3117163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_VOLUME: 3118163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 3119dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent uint32_t leftVolume, rightVolume; 3120dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t leftdB, rightdB; 3121dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t maxdB, pandB; 3122dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume 3123dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int status = 0; 3124dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 3125dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 3126163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3127163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // if pReplyData is NULL, VOL_CTRL is delegated to another effect 3128163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pReplyData == LVM_NULL){ 3129163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3130163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 31312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3132dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pCmdData == NULL || 3133dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent cmdSize != 2 * sizeof(uint32_t)) { 31343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 3135dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent "EFFECT_CMD_SET_VOLUME: ERROR"); 3136dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return -EINVAL; 3137163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3138163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3139dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftVolume = ((*(uint32_t *)pCmdData)); 3140dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightVolume = ((*((uint32_t *)pCmdData + 1))); 3141dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3142dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(leftVolume == 0x1000000){ 3143dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftVolume -= 1; 3144dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3145dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(rightVolume == 0x1000000){ 3146dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightVolume -= 1; 3147dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3148dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3149dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Convert volume to dB 3150dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftdB = android::LVC_Convert_VolToDb(leftVolume); 3151dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightdB = android::LVC_Convert_VolToDb(rightVolume); 3152dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3153dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pandB = rightdB - leftdB; 3154dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3155dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Calculate max volume in dB 3156dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent maxdB = leftdB; 3157dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(rightdB > maxdB){ 3158dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent maxdB = rightdB; 3159dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 31603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME Session: %d, SessionID: %d VOLUME is %d dB (%d), " 3161dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // "effect is %d", 3162dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //pContext->pBundledContext->SessionNo, pContext->pBundledContext->SessionId, 3163dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //(int32_t)maxdB, maxVol<<7, pContext->EffectType); 31643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left is %d, Right is %d", leftVolume, rightVolume); 31653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left %ddB, Right %ddB, Position %ddB", 3166dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // leftdB, rightdB, pandB); 3167d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 3168163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(pReplyData, vol_ret, sizeof(int32_t)*2); 3169dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent android::VolumeSetVolumeLevel(pContext, (int16_t)(maxdB*100)); 3170dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3171dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Get the current settings */ 3172dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LvmStatus =LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 3173dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 3174dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 3175dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3176dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Volume parameters */ 3177dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ActiveParams.VC_Balance = pandB; 31783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\t\tVolumeSetStereoPosition() (-96dB -> +96dB)-> %d\n", ActiveParams.VC_Balance ); 3179dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3180dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Activate the initial settings */ 3181dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LvmStatus =LVM_SetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 3182dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 3183dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 3184163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3185163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3186163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_AUDIO_MODE: 3187163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 31882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 31892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 31902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 31912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command end...\n\n"); 31932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 31942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_command */ 31952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3196e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent/* Effect Control Interface Implementation: get_descriptor */ 3197e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_getDescriptor(effect_handle_t self, 3198e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_descriptor_t *pDescriptor) 3199e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent{ 3200e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EffectContext * pContext = (EffectContext *) self; 3201e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent const effect_descriptor_t *desc; 3202e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3203e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pContext == NULL || pDescriptor == NULL) { 32043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("Effect_getDescriptor() invalid param"); 3205e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 3206e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 3207e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3208e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent switch(pContext->EffectType) { 3209e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_BASS_BOOST: 3210e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gBassBoostDescriptor; 3211e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3212e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_VIRTUALIZER: 3213e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gVirtualizerDescriptor; 3214e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3215e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_EQUALIZER: 3216e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gEqualizerDescriptor; 3217e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3218e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_VOLUME: 3219e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gVolumeDescriptor; 3220e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3221e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent default: 3222e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 3223e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 3224e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3225e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent memcpy(pDescriptor, desc, sizeof(effect_descriptor_t)); 3226e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3227e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return 0; 3228e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} /* end Effect_getDescriptor */ 3229e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3230e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent// effect_handle_t interface implementation for effect 32312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst struct effect_interface_s gLvmEffectInterface = { 32322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_process, 3233e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent Effect_command, 3234ba7b8f881a9b6b21803752326d2932a3bd42d7cfEric Laurent Effect_getDescriptor, 3235ba7b8f881a9b6b21803752326d2932a3bd42d7cfEric Laurent NULL, 32362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; /* end gLvmEffectInterface */ 32372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3238e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentaudio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = { 3239e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent tag : AUDIO_EFFECT_LIBRARY_TAG, 3240e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent version : EFFECT_LIBRARY_API_VERSION, 3241e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent name : "Effect Bundle Library", 3242e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent implementor : "NXP Software Ltd.", 3243e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent query_num_effects : android::EffectQueryNumberEffects, 3244e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent query_effect : android::EffectQueryEffect, 3245e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent create_effect : android::EffectCreate, 3246e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent release_effect : android::EffectRelease, 3247e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent get_descriptor : android::EffectGetDescriptor, 3248e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent}; 3249e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3250e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} 3251