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 <assert.h> 237b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn#include <inttypes.h> 247b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn#include <new> 252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <stdlib.h> 262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <string.h> 277b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn 287b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn#include <cutils/log.h> 29b4d307481960b6b348fae4b4e8edefd003c3d36cGlenn Kasten#include "EffectBundle.h" 307f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia#include "math.h" 312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 33e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent// effect_handle_t interface implementation for bass boost 342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" const struct effect_interface_s gLvmEffectInterface; 352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\ 372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_NULLADDRESS){\ 383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_ALIGNMENTERROR){\ 423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad alignment returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_INVALIDNUMSAMPLES){\ 463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_OUTOFRANGE){\ 503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "out of range returned by %s in %s\n", callingFunc, calledFunc);\ 522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 555dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent 565dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurentstatic inline int16_t clamp16(int32_t sample) 575dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent{ 585dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent // check overflow for both positive and negative values: 595dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent // all bits above short range must me equal to sign bit 605dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent if ((sample>>15) ^ (sample>>31)) 615dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent sample = 0x7FFF ^ (sample>>31); 625dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent return sample; 635dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent} 645dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent 652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Namespaces 662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace android { 672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace { 682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 69d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent// Flag to allow a one time init of global memory, only happens on first call ever 70d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurentint LvmInitFlag = LVM_FALSE; 71d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric LaurentSessionContext GlobalSessionMemory[LVM_MAX_SESSIONS]; 72d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurentint SessionIndex[LVM_MAX_SESSIONS]; 73d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent 742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* local functions */ 752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define CHECK_ARG(cond) { \ 762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (!(cond)) { \ 773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Invalid argument: "#cond); \ 782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; \ 792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } \ 802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW BassBoost UUID 842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gBassBoostDescriptor = { 852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x8631f300, 0x72e2, 0x11df, 0xb57e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid 87e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 88209bbbcf4190231f9dede758cbe77d109919f9f1Jean-Michel Trivi (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST | EFFECT_FLAG_DEVICE_IND 89163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 90d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BASS_BOOST_CUP_LOAD_ARM9E, 91d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Dynamic Bass Boost", 932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Virtualizer UUID 972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVirtualizerDescriptor = { 98163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 99163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 100e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 101163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 102163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 103d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VIRTUALIZER_CUP_LOAD_ARM9E, 104d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Virtualizer", 1062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Equalizer UUID 1102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gEqualizerDescriptor = { 1112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type 1122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0xce772f20, 0x847d, 0x11df, 0xbb17, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid Eq NXP 113e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 114209bbbcf4190231f9dede758cbe77d109919f9f1Jean-Michel Trivi (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST | EFFECT_FLAG_VOLUME_CTRL), 115d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent EQUALIZER_CUP_LOAD_ARM9E, 116d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Equalizer", 1182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Volume UUID 1222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVolumeDescriptor = { 1232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 1242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x119341a0, 0x8469, 0x11df, 0x81f9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, //uuid VOL NXP 125e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 126163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 127d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VOLUME_CUP_LOAD_ARM9E, 128d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Volume", 1302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--- local function prototypes 1342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init (void); 1352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init (EffectContext *pContext); 1362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable (EffectContext *pContext); 1372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable (EffectContext *pContext); 1382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free (EffectContext *pContext); 1393d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentint Effect_setConfig (EffectContext *pContext, effect_config_t *pConfig); 1403d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentvoid Effect_getConfig (EffectContext *pContext, effect_config_t *pConfig); 141c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue); 142163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint BassBoost_getParameter (EffectContext *pContext, 143c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 144377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 1452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 146c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter (EffectContext *pContext, 148c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 149377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 150163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue); 151c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter (EffectContext *pContext, 153c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 154377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 1552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 156c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter (EffectContext *pContext, 158c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 159377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 1602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 16129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurentint Effect_setEnabled(EffectContext *pContext, bool enabled); 1622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Library Interface Implementation */ 1642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1655e92a7861196ddae14638d4b7a63fc4892b7ef59Glenn Kastenextern "C" int EffectCreate(const effect_uuid_t *uuid, 1662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t sessionId, 1677618c5cb2fd60e944307e46afa051987d1e016c6Jean-Michel Trivi int32_t ioId __unused, 168e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_handle_t *pHandle){ 169dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int ret = 0; 170c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int sessionNo; 1712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int i; 172dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent EffectContext *pContext = NULL; 173dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent bool newBundle = false; 174dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent SessionContext *pSessionContext; 1752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1763856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectCreate start session %d", sessionId); 1772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 178e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pHandle == NULL || uuid == NULL){ 1793856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer"); 180dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 181dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 1822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmInitFlag == LVM_FALSE){ 1852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmInitFlag = LVM_TRUE; 1863856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Initializing all global memory"); 1872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmGlobalBundle_init(); 1882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 190c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Find next available sessionNo 191c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(i=0; i<LVM_MAX_SESSIONS; i++){ 192e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent if((SessionIndex[i] == LVM_UNUSED_SESSION)||(SessionIndex[i] == sessionId)){ 193c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo = i; 194c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent SessionIndex[i] = sessionId; 1953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId); 196c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 197c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 198c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 199c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 200c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(i==LVM_MAX_SESSIONS){ 2013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Cannot find memory to allocate for current session"); 202dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 203dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 204c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 205dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 206dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext = new EffectContext; 207dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // If this is the first create in this session 209c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(GlobalSessionMemory[sessionNo].bBundledEffectsEnabled == LVM_FALSE){ 2103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d", 211c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionId, sessionNo); 212c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 213c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_TRUE; 214c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext = new BundledEffectContext; 215dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent newBundle = true; 2162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 217c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = GlobalSessionMemory[sessionNo].pBundledContext; 218c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionNo = sessionNo; 219c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionId = sessionId; 220163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = NULL; 221163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 222163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 223163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 224163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 225163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 226163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 227333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->nOutputDevice = AUDIO_DEVICE_NONE; 228333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_NONE; 229163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled = 0; 230163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 231d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->firstVolume = LVM_TRUE; 2326a5c6ed13e3ea1b19835e08624125c9b1505b32cMarco Nelissen pContext->pBundledContext->volume = 0; 233163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 234163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 2358f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent char fileName[256]; 2368f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_in.pcm", pContext->pBundledContext); 2378f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = fopen(fileName, "w"); 2388f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmInPtr == NULL) { 2393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("cannot open %s", fileName); 240dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 241dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 2428f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 243163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2448f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_out.pcm", pContext->pBundledContext); 2458f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmOutPtr = fopen(fileName, "w"); 2468f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmOutPtr == NULL) { 2473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("cannot open %s", fileName); 2488f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmInPtr); 2498f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = NULL; 250dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 251dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 252163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 253163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 254163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Saved strength is used to return the exact strength that was used in the set to the get 2562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * because we map the original strength range of 0:1000 to 1:15, and this will avoid 2572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * quantisation like effect when returning 2582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 259163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->BassStrengthSaved = 0; 260163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = 0; 261163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = 0; 263163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled = LVM_FALSE; 264163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = LVM_FALSE; 265163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = 0; 266dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->workBuffer = NULL; 267dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->frameCount = -1; 268dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 269dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 270dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 271163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2729b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 2739b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent pContext->pBundledContext->bandGaindB[i] = EQNB_5BandSoftPresets[i]; 2749b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent } 2759b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent 2763856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Calling LvmBundle_init"); 2772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ret = LvmBundle_init(pContext); 2782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (ret < 0){ 2803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() Bundle init failed"); 281dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 2822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 2853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d", 286c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo); 287c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = 288c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext; 2892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext); 2912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 292dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo]; 29329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 2942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create each Effect 2952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 2962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Bass Boost 2973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST"); 29829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bBassInstantiated = LVM_TRUE; 299dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 300163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 301163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->itfe = &gLvmEffectInterface; 3022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_BASS_BOOST; 3032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Virtualizer 3053856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER"); 30629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVirtualizerInstantiated=LVM_TRUE; 307dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 308163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VIRTUALIZER; 3112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Equalizer 3133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER"); 31429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bEqualizerInstantiated = LVM_TRUE; 315dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 316163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_EQUALIZER; 3192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Volume 3213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_VOLUME"); 32229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVolumeInstantiated = LVM_TRUE; 323163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VOLUME; 326163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 3283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() invalid UUID"); 329dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 330dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 3312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 333dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurentexit: 334dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (ret != 0) { 335dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext != NULL) { 336dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (newBundle) { 337dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_FALSE; 338dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent SessionIndex[sessionNo] = LVM_UNUSED_SESSION; 339dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent delete pContext->pBundledContext; 340dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 341dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent delete pContext; 342dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 343e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent *pHandle = (effect_handle_t)NULL; 344dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } else { 345e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent *pHandle = (effect_handle_t)pContext; 346dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate end..\n\n"); 348dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return ret; 3492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectCreate */ 3502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 351e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentextern "C" int EffectRelease(effect_handle_t handle){ 3523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectRelease start %p", handle); 353e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EffectContext * pContext = (EffectContext *)handle; 3542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease start handle: %p, context %p", handle, pContext->pBundledContext); 3562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 3573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectRelease called with NULL pointer"); 3582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 359163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 36129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent SessionContext *pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo]; 36229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 3632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Clear the instantiated flag for the effect 364dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // protect agains the case where an effect is un-instantiated without being disabled 3652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 3663856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag"); 36729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bBassInstantiated = LVM_FALSE; 368dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb > 0){ 369dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 370dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 371dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 3722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VIRTUALIZER) { 3733856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag"); 37429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVirtualizerInstantiated = LVM_FALSE; 375dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ 376dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 377dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 378dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 3792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_EQUALIZER) { 3803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag"); 38129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bEqualizerInstantiated =LVM_FALSE; 382dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq > 0){ 383dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 384dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 385dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 3862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VOLUME) { 3873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag"); 38829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVolumeInstantiated = LVM_FALSE; 389dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){ 390dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 391dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 3933856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n"); 3942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 395163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 396dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Disable effect, in this case ignore errors (return codes) 397dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // if an effect has already been disabled 398dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent Effect_setEnabled(pContext, LVM_FALSE); 399dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 4002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // if all effects are no longer instantiaed free the lvm memory and delete BundledEffectContext 40129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if ((pSessionContext->bBassInstantiated == LVM_FALSE) && 40229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bVolumeInstantiated == LVM_FALSE) && 40329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bEqualizerInstantiated ==LVM_FALSE) && 40429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bVirtualizerInstantiated==LVM_FALSE)) 4052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 406163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 4078f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmInPtr != NULL) { 4088f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmInPtr); 4098f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = NULL; 4108f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 4118f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmOutPtr != NULL) { 4128f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmOutPtr); 4138f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmOutPtr = NULL; 4148f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 415163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 416c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 417c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 418c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Clear the SessionIndex 419c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 420c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(SessionIndex[i] == pContext->pBundledContext->SessionId){ 421e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent SessionIndex[i] = LVM_UNUSED_SESSION; 4223856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n", 423c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent i, pContext->pBundledContext->SessionId); 424c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 425c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 426c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 427c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 4283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: All effects are no longer instantiated\n"); 429dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pSessionContext->bBundledEffectsEnabled = LVM_FALSE; 43029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->pBundledContext = LVM_NULL; 4313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Freeing LVM Bundle memory\n"); 432163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmEffect_free(pContext); 4333856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext); 434dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->workBuffer != NULL) { 435dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent free(pContext->pBundledContext->workBuffer); 436dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 437163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent delete pContext->pBundledContext; 438c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = LVM_NULL; 4392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // free the effect context for current effect 4412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext; 4422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease end\n"); 4442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 4452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectRelease */ 4472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4485e92a7861196ddae14638d4b7a63fc4892b7ef59Glenn Kastenextern "C" int EffectGetDescriptor(const effect_uuid_t *uuid, 449e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_descriptor_t *pDescriptor) { 450e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent const effect_descriptor_t *desc = NULL; 451e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 452e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pDescriptor == NULL || uuid == NULL){ 4533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("EffectGetDescriptor() called with NULL pointer"); 454e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 455e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 456e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 457e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 458e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gBassBoostDescriptor; 459e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 460e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gVirtualizerDescriptor; 461e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 462e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gEqualizerDescriptor; 463e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 464e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gVolumeDescriptor; 465e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 466e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 467e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (desc == NULL) { 468e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 469e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 470e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 471a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = *desc; 472e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 473e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return 0; 474e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} /* end EffectGetDescriptor */ 475e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 4762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init(){ 4773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmGlobalBundle_init start"); 4782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 4792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBundledEffectsEnabled = LVM_FALSE; 4802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVolumeInstantiated = LVM_FALSE; 4812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bEqualizerInstantiated = LVM_FALSE; 4822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBassInstantiated = LVM_FALSE; 4832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE; 4842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].pBundledContext = LVM_NULL; 485c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 486e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent SessionIndex[i] = LVM_UNUSED_SESSION; 4872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 4892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 4902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 4912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_init() 4922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 4932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Initialize engine with default configuration, creates instance 4942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// with all effects disabled. 4952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 4962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 4972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 4982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 4992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 5002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init(EffectContext *pContext){ 5042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status; 5052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init start"); 5072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 508163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; 509e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 510e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 511163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.samplingRate = 44100; 512163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.getBuffer = NULL; 513163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL; 514163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.cookie = NULL; 515163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL; 516163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; 517e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 518e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 519163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.samplingRate = 44100; 520163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.getBuffer = NULL; 521163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL; 522163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.cookie = NULL; 523163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL; 5242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 5262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext->pBundledContext->hInstance != NULL){ 5283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 5292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Calling pContext->pBassBoost->free()"); 5302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmEffect_free(pContext); 5322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5333856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 5342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Called pContext->pBassBoost->free()"); 5352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 5382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 5392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_InstParams_t InstParams; /* Instance parameters */ 5402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_EQNB_BandDef_t BandDefs[MAX_NUM_BANDS]; /* Equaliser band definitions */ 5412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ 5422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomBandDef_t HeadroomBandDef[LVM_HEADROOM_MAX_NBANDS]; 5432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; /* Memory allocation table */ 5442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bool bMallocFailure = LVM_FALSE; 5452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the capabilities */ 547163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent InstParams.BufferMode = LVM_UNMANAGED_BUFFERS; 5482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.MaxBlockSize = MAX_CALL_SIZE; 5492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.EQNB_NumBands = MAX_NUM_BANDS; 5502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.PSA_Included = LVM_PSA_ON; 5512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory, forcing alignment */ 5532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(LVM_NULL, 5542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 5552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 5562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmBundle_init") 5582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 5592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n"); 5612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory */ 5632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 5642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 5652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size); 5662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 5687b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %" PRIu32 5697b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn " bytes for region %u\n", MemTab.Region[i].Size, i ); 5702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bMallocFailure = LVM_TRUE; 5712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 5727b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn ALOGV("\tLvmBundle_init CreateInstance allocated %" PRIu32 5737b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn " bytes for region %u at %p\n", 5742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 5752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* If one or more of the memory regions failed to allocate, free the regions that were 5802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * succesfully allocated and return with an error 5812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 5822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(bMallocFailure == LVM_TRUE){ 5832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 5842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 5857b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %" PRIu32 5867b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn " bytes for region %u Not freeing\n", MemTab.Region[i].Size, i ); 5872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 5887b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed: but allocated %" PRIu32 5897b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn " bytes for region %u at %p- free\n", 590163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 5912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 5922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 5952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully malloc'd memory\n"); 5972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Initialise */ 599163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = LVM_NULL; 6002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 601163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Init sets the instance handle */ 602163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetInstanceHandle(&pContext->pBundledContext->hInstance, 6032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 6042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 6052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "LvmBundle_init") 6072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6093856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_GetInstanceHandle\n"); 6102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the initial process parameters */ 6122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* General parameters */ 6132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.OperatingMode = LVM_MODE_ON; 6142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SampleRate = LVM_FS_44100; 6152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SourceFormat = LVM_STEREO; 6162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SpeakerType = LVM_HEADPHONES; 6172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->SampleRate = LVM_FS_44100; 619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Concert Sound parameters */ 6212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerOperatingMode = LVM_MODE_OFF; 6222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerType = LVM_CONCERTSOUND; 6232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerReverbLevel = 100; 624d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.CS_EffectLevel = LVM_CS_EFFECT_NONE; 6252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* N-Band Equaliser parameters */ 6272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_OperatingMode = LVM_EQNB_OFF; 6282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_NBands = FIVEBAND_NUMBANDS; 6292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.pEQNB_BandDefinition = &BandDefs[0]; 630163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 6322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 6332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 6342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].QFactor = EQNB_5BandPresetsQFactors[i]; 635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDefs[i].Gain = EQNB_5BandSoftPresets[i]; 6362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume Control parameters */ 6392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_EffectLevel = 0; 6402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_Balance = 0; 6412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Treble Enhancement parameters */ 6432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_OperatingMode = LVM_TE_OFF; 6442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_EffectLevel = 0; 6452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 6472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 6482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = (LVM_PSA_DecaySpeed_en)0; 6492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 6512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_OperatingMode = LVM_BE_OFF; 6522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_EffectLevel = 0; 6532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 6542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_HPF = LVM_BE_HPF_ON; 6552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 6572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 6582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM; 6592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 660d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent /* TE Control parameters */ 661d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_OperatingMode = LVM_TE_OFF; 662d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_EffectLevel = 0; 663d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 665163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, 6662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ¶ms); 6672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmBundle_init") 6692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetControlParameters\n"); 6722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the headroom parameters */ 6742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_Low = 20; 6752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_High = 4999; 676e44615ff6022239850a3ea459ad6e07b44c37544Eric Laurent HeadroomBandDef[0].Headroom_Offset = 0; 6772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_Low = 5000; 6782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_High = 24000; 679e44615ff6022239850a3ea459ad6e07b44c37544Eric Laurent HeadroomBandDef[1].Headroom_Offset = 0; 6802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.pHeadroomDefinition = &HeadroomBandDef[0]; 6812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON; 6822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.NHeadroomBands = 2; 6832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetHeadroomParams(pContext->pBundledContext->hInstance, 6852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &HeadroomParams); 6862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetHeadroomParams", "LvmBundle_init") 6882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetHeadroomParams\n"); 6913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init End"); 6922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 6932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_init */ 6942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 695dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 6962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_process() 6982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 7002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply LVM Bundle effects 7012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pIn: pointer to stereo 16 bit input data 7042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to stereo 16 bit output data 7052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// frameCount: Frames to process 7062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 7082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 7102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to updated stereo 16 bit output data 7112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_process(LVM_INT16 *pIn, 715163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOut, 716163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int frameCount, 717163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent EffectContext *pContext){ 7182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 7202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 721163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOutTmp; 722dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 723163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){ 724163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOutTmp = pOut; 7252a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent } else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 726dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->frameCount != frameCount) { 727dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->workBuffer != NULL) { 728dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent free(pContext->pBundledContext->workBuffer); 729dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 730dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->workBuffer = 7312a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent (LVM_INT16 *)calloc(frameCount, sizeof(LVM_INT16) * 2); 7322a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent if (pContext->pBundledContext->workBuffer == NULL) { 7332a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent return -ENOMEM; 7342a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent } 735dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->frameCount = frameCount; 736163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 737dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pOutTmp = pContext->pBundledContext->workBuffer; 7382a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent } else { 7393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("LVM_ERROR : LvmBundle_process invalid access mode"); 740163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 741163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 7422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 743163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 744163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pIn, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmInPtr); 745163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmInPtr); 746163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 747163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("Calling LVM_Process"); 749d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 750163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process the samples */ 7512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */ 7522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pIn, /* Input buffer */ 7532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pOutTmp, /* Output buffer */ 7542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_UINT16)frameCount, /* Number of samples to read */ 7552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0); /* Audo Time */ 756163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_Process", "LvmBundle_process") 7582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 7592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 760163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 761163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pOutTmp, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmOutPtr); 762163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmOutPtr); 763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 764163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 765163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 766163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (int i=0; i<frameCount*2; i++){ 767dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pOut[i] = clamp16((LVM_INT32)pOut[i] + (LVM_INT32)pOutTmp[i]); 768163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 769163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 7702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_process */ 7722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 77302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 77402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia//---------------------------------------------------------------------------- 77502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// EqualizerUpdateActiveParams() 77602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia//---------------------------------------------------------------------------- 77702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// Purpose: Update ActiveParams for Equalizer 77802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// 77902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// Inputs: 78002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// pContext: effect engine context 78102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// 78202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// Outputs: 78302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// 78402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia//---------------------------------------------------------------------------- 78502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garciavoid EqualizerUpdateActiveParams(EffectContext *pContext) { 78602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 78702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 78802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 78902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia /* Get the current settings */ 79002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 79102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerUpdateActiveParams") 79202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //ALOGV("\tEqualizerUpdateActiveParams Succesfully returned from LVM_GetControlParameters\n"); 79302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //ALOGV("\tEqualizerUpdateActiveParams just Got -> %d\n", 79402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia // ActiveParams.pEQNB_BandDefinition[band].Gain); 79502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 79602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 79702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 79802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 79902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i]; 80002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ActiveParams.pEQNB_BandDefinition[i].Gain = pContext->pBundledContext->bandGaindB[i]; 80102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia } 80202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 80302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia /* Activate the initial settings */ 80402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 80502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerUpdateActiveParams") 80602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //ALOGV("\tEqualizerUpdateActiveParams just Set -> %d\n", 80702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia // ActiveParams.pEQNB_BandDefinition[band].Gain); 80802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 80902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia} 81002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 81102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia//---------------------------------------------------------------------------- 81202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// LvmEffect_limitLevel() 81302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia//---------------------------------------------------------------------------- 81402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// Purpose: limit the overall level to a value less than 0 dB preserving 81502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// the overall EQ band gain and BassBoost relative levels. 81602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// 81702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// Inputs: 81802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// pContext: effect engine context 81902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// 82002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// Outputs: 82102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia// 82202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia//---------------------------------------------------------------------------- 82302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garciavoid LvmEffect_limitLevel(EffectContext *pContext) { 82402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 82502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 82602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 82702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia /* Get the current settings */ 82802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 82902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_limitLevel") 83002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //ALOGV("\tLvmEffect_limitLevel Succesfully returned from LVM_GetControlParameters\n"); 83102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //ALOGV("\tLvmEffect_limitLevel just Got -> %d\n", 83202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia // ActiveParams.pEQNB_BandDefinition[band].Gain); 83302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 83402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia int gainCorrection = 0; 83502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //Count the energy contribution per band for EQ and BassBoost only if they are active. 83602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia float energyContribution = 0; 8377f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float energyCross = 0; 8387f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float energyBassBoost = 0; 8397f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float crossCorrection = 0; 84002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 84102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //EQ contribution 84202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) { 84302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 8447f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0; 8457f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandCoefficient = LimitLevel_bandEnergyCoefficient[i]; 8467f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandEnergy = bandFactor * bandCoefficient * bandCoefficient; 84702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia if (bandEnergy > 0) 84802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia energyContribution += bandEnergy; 84902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia } 8507f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia 8517f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia //cross EQ coefficients 8527f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandFactorSum = 0; 8537f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia for (int i = 0; i < FIVEBAND_NUMBANDS-1; i++) { 8547f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandFactor1 = pContext->pBundledContext->bandGaindB[i]/15.0; 8557f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandFactor2 = pContext->pBundledContext->bandGaindB[i+1]/15.0; 8567f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia 8577f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia if (bandFactor1 > 0 && bandFactor2 > 0) { 8587f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float crossEnergy = bandFactor1 * bandFactor2 * 8597f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia LimitLevel_bandEnergyCrossCoefficient[i]; 8607f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia bandFactorSum += bandFactor1 * bandFactor2; 8617f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia 8627f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia if (crossEnergy > 0) 8637f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia energyCross += crossEnergy; 8647f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia } 8657f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia } 8667f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia bandFactorSum -= 1.0; 8677f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia if (bandFactorSum > 0) 8687f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia crossCorrection = bandFactorSum * 0.7; 86902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia } 87002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 87102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //BassBoost contribution 87202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 8737f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float boostFactor = (pContext->pBundledContext->BassStrengthSaved)/1000.0; 8747f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float boostCoefficient = LimitLevel_bassBoostEnergyCoefficient; 8757f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia 8767f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia energyContribution += boostFactor * boostCoefficient * boostCoefficient; 8777f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia 8787f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 8797f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandFactor = pContext->pBundledContext->bandGaindB[i]/15.0; 8807f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandCrossCoefficient = LimitLevel_bassBoostEnergyCrossCoefficient[i]; 8817f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia float bandEnergy = boostFactor * bandFactor * 8827f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia bandCrossCoefficient; 8837f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia if (bandEnergy > 0) 8847f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia energyBassBoost += bandEnergy; 8857f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia } 88602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia } 88702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 88802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //Virtualizer contribution 88902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { 8907f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia energyContribution += LimitLevel_virtualizerContribution * 8917f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia LimitLevel_virtualizerContribution; 8927f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia } 8937f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia 8947f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia double totalEnergyEstimation = sqrt(energyContribution + energyCross + energyBassBoost) - 8957f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia crossCorrection; 8967f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia ALOGV(" TOTAL energy estimation: %0.2f", totalEnergyEstimation); 89702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 89802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //roundoff 8997f0e16e391b0bd243005cc1049d3b6799f0692ecRicardo Garcia int maxLevelRound = (int)(totalEnergyEstimation + 0.99); 90002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia if (maxLevelRound + pContext->pBundledContext->volume > 0) { 90102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia gainCorrection = maxLevelRound + pContext->pBundledContext->volume; 90202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia } 90302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 90402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection; 90502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia if (ActiveParams.VC_EffectLevel < -96) { 90602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ActiveParams.VC_EffectLevel = -96; 90702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia } 90802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ALOGV("\tVol:%d, GainCorrection: %d, Actual vol: %d", pContext->pBundledContext->volume, 90902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia gainCorrection, ActiveParams.VC_EffectLevel); 91002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 91102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia /* Activate the initial settings */ 91202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 91302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_limitLevel") 91402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //ALOGV("\tLvmEffect_limitLevel just Set -> %d\n", 91502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia // ActiveParams.pEQNB_BandDefinition[band].Gain); 91602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 91702521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia //ALOGV("\tLvmEffect_limitLevel just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel ); 91802521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia if (pContext->pBundledContext->firstVolume == LVM_TRUE){ 91902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); 92002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process") 92102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks"); 92202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia pContext->pBundledContext->firstVolume = LVM_FALSE; 92302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia } 92402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia} 92502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 9262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_enable() 9282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Enable the effect in the bundle 9302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 9352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable(EffectContext *pContext){ 9393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable start"); 940163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 9412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 9422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 9432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 944163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 945163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 9462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 9472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable") 9492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 9503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n"); 9512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 9533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST"); 9542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_ON; 9552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 9573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER"); 9582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_ON; 9592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 9613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER"); 9622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_ON; 9632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 9653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_VOLUME"); 966163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 967163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 9682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 9692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_enable") 9702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 971163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 9723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n"); 9733856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable end"); 97402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 9752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 9762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 9772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_disable() 9802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Disable the effect in the bundle 9822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 9872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable(EffectContext *pContext){ 9913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable start"); 992163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 9932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 9942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 995163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 996163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 9972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 9982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_disable") 10002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 10013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n"); 10022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 10043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST"); 10052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_OFF; 10062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 10083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_VIRTUALIZER"); 10092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_OFF; 10102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 10123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_EQUALIZER"); 10132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_OFF; 10142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 10163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_VOLUME"); 1017163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1018163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 10192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 10202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_disable") 10212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1022163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 10233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n"); 10243856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable end"); 102502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 10262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 10272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 10282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_free() 10312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Free all memory associated with the Bundle. 10332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 10382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free(EffectContext *pContext){ 10422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 10432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 10442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; 10452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Free the algorithm memory */ 10472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(pContext->pBundledContext->hInstance, 10482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 10492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_NULL); 10502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmEffect_free") 10522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 10542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 10552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress != NULL){ 10567b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn ALOGV("\tLvmEffect_free - START freeing %" PRIu32 " bytes for region %u at %p\n", 10572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 10582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 10602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10617b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn ALOGV("\tLvmEffect_free - END freeing %" PRIu32 " bytes for region %u at %p\n", 10622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 10632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 10647b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn ALOGV("\tLVM_ERROR : LvmEffect_free - trying to free with NULL pointer %" PRIu32 10657b6c7b89241397261d52602cbeaa559962efbfecMark Salyzyn " bytes for region %u at %p ERROR\n", 10662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 10672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmEffect_free */ 10712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10733d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Effect_setConfig() 10742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Set input and output audio configuration. 10762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pConfig: pointer to effect_config_t structure holding input and output 10802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// configuration parameters 10812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 10832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10863d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentint Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){ 1087163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_Fs_en SampleRate; 10883d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_setConfig start"); 10892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 10912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig != NULL); 10922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate); 10942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels); 10952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format); 1096e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent CHECK_ARG(pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO); 10972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE 10982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE); 1099e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT); 11002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1101a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten pContext->config = *pConfig; 11022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1103163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent switch (pConfig->inputCfg.samplingRate) { 1104163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 8000: 1105163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_8000; 1106c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 8000*2; // 2 secs Stereo 1107163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 1108163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 16000: 1109163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_16000; 1110c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 16000*2; // 2 secs Stereo 1111163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 1112163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 22050: 1113163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_22050; 1114c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 22050*2; // 2 secs Stereo 1115163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 1116163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 32000: 1117163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_32000; 1118c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 32000*2; // 2 secs Stereo 1119163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 1120163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 44100: 1121163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_44100; 1122c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 44100*2; // 2 secs Stereo 1123163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 1124163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 48000: 1125163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_48000; 1126c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo 1127163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 1128163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent default: 11293d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tEffect_setConfig invalid sampling rate %d", pConfig->inputCfg.samplingRate); 1130163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1131163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 11322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1133163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->SampleRate != SampleRate){ 11342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1135163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; 1136163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; 11372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11383d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tEffect_setConfig change sampling rate to %d", SampleRate); 11392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1140163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1141163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1142163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 11432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11443d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_setConfig") 1145163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 11462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11479f6f0a7eb1d7f2c35f3547779364a1a8d6d4a24cEric Laurent ActiveParams.SampleRate = SampleRate; 11489f6f0a7eb1d7f2c35f3547779364a1a8d6d4a24cEric Laurent 1149163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 11502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11513d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_setConfig") 11523d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tEffect_setConfig Succesfully called LVM_SetControlParameters\n"); 1153c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SampleRate = SampleRate; 11542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1155163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 11563d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_setConfig keep sampling rate at %d", SampleRate); 1157163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 11582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11593d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_setConfig End...."); 1160163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 11613d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent} /* end Effect_setConfig */ 11623d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 11633d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent//---------------------------------------------------------------------------- 11643d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Effect_getConfig() 11653d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent//---------------------------------------------------------------------------- 11663d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Purpose: Get input and output audio configuration. 11673d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// 11683d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Inputs: 11693d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// pContext: effect engine context 11703d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// pConfig: pointer to effect_config_t structure holding input and output 11713d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// configuration parameters 11723d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// 11733d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Outputs: 11743d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// 11753d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent//---------------------------------------------------------------------------- 11763d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 11773d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentvoid Effect_getConfig(EffectContext *pContext, effect_config_t *pConfig) 11783d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent{ 1179a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pConfig = pContext->config; 11803d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent} /* end Effect_getConfig */ 11812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassGetStrength() 11842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 11872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 11882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// the bassboost uses 1-15, so to avoid a quantisation the original set value is used. However the 11892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 11902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t BassGetStrength(EffectContext *pContext){ 11973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved); 11982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 12002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1201163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1202163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 12032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 12042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassGetStrength") 12062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 12072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n"); 12092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Check that the strength returned matches the strength that was set earlier */ 1211163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(ActiveParams.BE_EffectLevel != 1212163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){ 12133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n", 12142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved); 12152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 12162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 12172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 12193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (saved) -> %d\n", pContext->pBundledContext->BassStrengthSaved ); 12202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return pContext->pBundledContext->BassStrengthSaved; 12212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassGetStrength */ 12222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassSetStrength() 12252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the BassBosst. Must first be converted from the range 0-1000 to 1-15 12282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 12322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid BassSetStrength(EffectContext *pContext, uint32_t strength){ 12363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength(%d)", strength); 12372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->BassStrengthSaved = (int)strength; 12392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 12412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 12422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 12442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 12452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 12462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassSetStrength") 12483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength Succesfully returned from LVM_GetControlParameters\n"); 12492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 12512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel = (LVM_INT16)((15*strength)/1000); 12522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 12532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 12552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 12572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 12582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength") 12603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n"); 126102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia 126202521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 12632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassSetStrength */ 12642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerGetStrength() 12672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 12702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 1271163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// the Virtualizer uses 1-100, so to avoid a quantisation the original set value is used.However the 12722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 12732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t VirtualizerGetStrength(EffectContext *pContext){ 12803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved); 12812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 12832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 12842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 12862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerGetStrength") 12882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 12892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n"); 12913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength() (0-100) -> %d\n", ActiveParams.VirtualizerReverbLevel*10); 1292d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent return pContext->pBundledContext->VirtStrengthSaved; 12932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getStrength */ 12942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerSetStrength() 12972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the Virtualizer. Must first be converted from the range 0-1000 to 1-15 13002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 13042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){ 13083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength(%d)", strength); 13092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 13112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1312163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = (int)strength; 1313163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 13142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 13152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 13162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerSetStrength") 13183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n"); 13192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Virtualizer parameters */ 1321d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent ActiveParams.CS_EffectLevel = (int)((strength*32767)/1000); 13222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 132302521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ALOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength ); 132402521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia ALOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel ); 13252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 13272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 13282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength") 13293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n"); 133002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 13312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setStrength */ 13322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1333333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1334333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// VirtualizerIsDeviceSupported() 1335333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1336333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Purpose: 1337333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Check if an audio device type is supported by this implementation 1338333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 1339333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Inputs: 1340333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// deviceType the type of device that affects the processing (e.g. for binaural vs transaural) 1341333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Output: 1342333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// -EINVAL if the configuration is not supported or it is unknown 1343333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 0 if the configuration is supported 1344333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1345333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Triviint VirtualizerIsDeviceSupported(audio_devices_t deviceType) { 1346333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi switch (deviceType) { 1347333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case AUDIO_DEVICE_OUT_WIRED_HEADSET: 1348333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case AUDIO_DEVICE_OUT_WIRED_HEADPHONE: 1349333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES: 1350333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return 0; 1351333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi default : 1352333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return -EINVAL; 1353333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1354333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi} 1355333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1356333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1357333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// VirtualizerIsConfigurationSupported() 1358333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1359333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Purpose: 1360333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Check if a channel mask + audio device type is supported by this implementation 1361333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 1362333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Inputs: 1363333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// channelMask the channel mask of the input to virtualize 1364333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// deviceType the type of device that affects the processing (e.g. for binaural vs transaural) 1365333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Output: 1366333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// -EINVAL if the configuration is not supported or it is unknown 1367333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 0 if the configuration is supported 1368333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1369333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Triviint VirtualizerIsConfigurationSupported(audio_channel_mask_t channelMask, 1370333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi audio_devices_t deviceType) { 1371333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi uint32_t channelCount = audio_channel_count_from_out_mask(channelMask); 1372333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if ((channelCount == 0) || (channelCount > 2)) { 1373333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return -EINVAL; 1374333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1375333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1376333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return VirtualizerIsDeviceSupported(deviceType); 1377333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi} 1378333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1379333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1380333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// VirtualizerForceVirtualizationMode() 1381333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1382333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Purpose: 1383333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Force the virtualization mode to that of the given audio device 1384333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 1385333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Inputs: 1386333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// pContext effect engine context 1387333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// forcedDevice the type of device whose virtualization mode we'll always use 1388333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Output: 1389333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// -EINVAL if the device is not supported or is unknown 1390333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 0 if the device is supported and the virtualization mode forced 1391333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 1392333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1393333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Triviint VirtualizerForceVirtualizationMode(EffectContext *pContext, audio_devices_t forcedDevice) { 1394333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("VirtualizerForceVirtualizationMode: forcedDev=0x%x enabled=%d tmpDisabled=%d", 1395333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi forcedDevice, pContext->pBundledContext->bVirtualizerEnabled, 1396333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->bVirtualizerTempDisabled); 1397333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi int status = 0; 1398333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi bool useVirtualizer = false; 1399333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1400333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (VirtualizerIsDeviceSupported(forcedDevice) != 0) { 140147d4c9a4d53ed014b520edbda2edc3e280efb8a5Ricardo Garcia if (forcedDevice != AUDIO_DEVICE_NONE) { 140247d4c9a4d53ed014b520edbda2edc3e280efb8a5Ricardo Garcia //forced device is not supported, make it behave as a reset of forced mode 140347d4c9a4d53ed014b520edbda2edc3e280efb8a5Ricardo Garcia forcedDevice = AUDIO_DEVICE_NONE; 140447d4c9a4d53ed014b520edbda2edc3e280efb8a5Ricardo Garcia // but return an error 140547d4c9a4d53ed014b520edbda2edc3e280efb8a5Ricardo Garcia status = -EINVAL; 140647d4c9a4d53ed014b520edbda2edc3e280efb8a5Ricardo Garcia } 1407333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1408333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1409333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (forcedDevice == AUDIO_DEVICE_NONE) { 1410333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // disabling forced virtualization mode: 1411333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // verify whether the virtualization should be enabled or disabled 1412333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (VirtualizerIsDeviceSupported(pContext->pBundledContext->nOutputDevice) == 0) { 1413333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi useVirtualizer = (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE); 1414333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1415333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_NONE; 1416333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } else { 1417333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // forcing virtualization mode: here we already know the device is supported 1418333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_OUT_WIRED_HEADPHONE; 1419333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // only enable for a supported mode, when the effect is enabled 1420333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi useVirtualizer = (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE); 1421333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1422333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1423333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (useVirtualizer) { 1424333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (pContext->pBundledContext->bVirtualizerTempDisabled == LVM_TRUE) { 1425333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tVirtualizerForceVirtualizationMode re-enable LVM_VIRTUALIZER"); 1426333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi android::LvmEffect_enable(pContext); 1427333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 1428333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } else { 1429333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tVirtualizerForceVirtualizationMode leaving LVM_VIRTUALIZER enabled"); 1430333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1431333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } else { 1432333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (pContext->pBundledContext->bVirtualizerTempDisabled == LVM_FALSE) { 1433333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tVirtualizerForceVirtualizationMode disable LVM_VIRTUALIZER"); 1434333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi android::LvmEffect_disable(pContext); 1435333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE; 1436333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } else { 1437333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tVirtualizerForceVirtualizationMode leaving LVM_VIRTUALIZER disabled"); 1438333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1439333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1440333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1441333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tafter VirtualizerForceVirtualizationMode: enabled=%d tmpDisabled=%d", 1442333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->bVirtualizerEnabled, 1443333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->bVirtualizerTempDisabled); 1444333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1445333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return status; 1446333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi} 1447333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1448333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// VirtualizerGetSpeakerAngles() 1449333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1450333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Purpose: 1451333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Get the virtual speaker angles for a channel mask + audio device type 1452333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// configuration which is guaranteed to be supported by this implementation 1453333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 1454333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Inputs: 1455333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// channelMask: the channel mask of the input to virtualize 1456333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// deviceType the type of device that affects the processing (e.g. for binaural vs transaural) 1457333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Input/Output: 1458333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// pSpeakerAngles the array of integer where each speaker angle is written as a triplet in the 1459333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// following format: 1460333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// int32_t a bit mask with a single value selected for each speaker, following 1461333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// the convention of the audio_channel_mask_t type 1462333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// int32_t a value in degrees expressing the speaker azimuth, where 0 is in front 1463333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// of the user, 180 behind, -90 to the left, 90 to the right of the user 1464333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// int32_t a value in degrees expressing the speaker elevation, where 0 is the 1465333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// horizontal plane, +90 is directly above the user, -90 below 1466333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 1467333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1468333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivivoid VirtualizerGetSpeakerAngles(audio_channel_mask_t channelMask __unused, 1469333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi audio_devices_t deviceType __unused, int32_t *pSpeakerAngles) { 1470333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // the channel count is guaranteed to be 1 or 2 1471333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // the device is guaranteed to be of type headphone 1472333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // this virtualizer is always 2in with speakers at -90 and 90deg of azimuth, 0deg of elevation 1473333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *pSpeakerAngles++ = (int32_t) AUDIO_CHANNEL_OUT_FRONT_LEFT; 1474333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *pSpeakerAngles++ = -90; // azimuth 1475333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *pSpeakerAngles++ = 0; // elevation 1476333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *pSpeakerAngles++ = (int32_t) AUDIO_CHANNEL_OUT_FRONT_RIGHT; 1477333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *pSpeakerAngles++ = 90; // azimuth 1478333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *pSpeakerAngles = 0; // elevation 1479333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi} 1480333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 1481333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1482333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// VirtualizerGetVirtualizationMode() 1483333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1484333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Purpose: 1485333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Retrieve the current device whose processing mode is used by this effect 1486333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// 1487333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// Output: 1488333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// AUDIO_DEVICE_NONE if the effect is not virtualizing 1489333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi// or the device type if the effect is virtualizing 1490333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi//---------------------------------------------------------------------------- 1491333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Triviaudio_devices_t VirtualizerGetVirtualizationMode(EffectContext *pContext) { 1492333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi audio_devices_t virtDevice = AUDIO_DEVICE_NONE; 1493333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) 1494333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi && (pContext->pBundledContext->bVirtualizerTempDisabled == LVM_FALSE)) { 1495333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (pContext->pBundledContext->nVirtualizerForcedDevice != AUDIO_DEVICE_NONE) { 1496333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // virtualization mode is forced, return that device 1497333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi virtDevice = pContext->pBundledContext->nVirtualizerForcedDevice; 1498333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } else { 1499333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // no forced mode, return the current device 1500333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi virtDevice = pContext->pBundledContext->nOutputDevice; 1501333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1502333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 1503333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("VirtualizerGetVirtualizationMode() returning 0x%x", virtDevice); 1504333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return virtDevice; 1505333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi} 15069b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent 15072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15089b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// EqualizerGetBandLevel() 15099b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent//---------------------------------------------------------------------------- 15109b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// Purpose: Retrieve the gain currently being used for the band passed in 15119b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// 15129b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// Inputs: 15139b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// band: band number 15149b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// pContext: effect engine context 15159b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// 15169b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// Outputs: 15179b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent// 15189b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent//---------------------------------------------------------------------------- 15199b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurentint32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){ 15209b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent //ALOGV("\tEqualizerGetBandLevel -> %d\n", pContext->pBundledContext->bandGaindB[band] ); 15219b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent return pContext->pBundledContext->bandGaindB[band] * 100; 15222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 15232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetBandLevel() 15262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets gain value for the given band. 15292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 15322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gain: Gain to be applied in millibels 15332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 15362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--------------------------------------------------------------------------- 1538d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentvoid EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){ 1539163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int gainRounded; 1540163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(Gain > 0){ 1541163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain+50)/100); 1542163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1543163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain-50)/100); 1544163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 15453856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded); 15469b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent pContext->pBundledContext->bandGaindB[band] = gainRounded; 15472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 15489b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent 154902521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia EqualizerUpdateActiveParams(pContext); 155002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 15512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 15529b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent 15532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetCentreFrequency() 15552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the frequency being used for the band passed in 15572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 15602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 15632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetCentreFrequency(EffectContext *pContext, int32_t band){ 1566163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Frequency =0; 15672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1568163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1569163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1570163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1571163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1572163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1573163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 15742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1575163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetCentreFrequency") 15762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1577163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1578163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Frequency = (int32_t)BandDef[band].Frequency*1000; // Convert to millibels 15792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetCentreFrequency -> %d\n", Frequency ); 15813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetCentreFrequency Succesfully returned from LVM_GetControlParameters\n"); 1582163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Frequency; 15832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 15842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandFreqRange( 15872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets lower and upper boundaries of a band. 15912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the high shelf, the low bound is the band frequency and the high 15922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// bound is Nyquist. 15932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the peaking filters, they are the gain[dB]/2 points. 15942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 15972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 16002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 16012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 16022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16037618c5cb2fd60e944307e46afa051987d1e016c6Jean-Michel Triviint32_t EqualizerGetBandFreqRange(EffectContext *pContext __unused, int32_t band, uint32_t *pLow, 1604163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t *pHi){ 1605163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pLow = bandFreqRange[band][0]; 1606163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pHi = bandFreqRange[band][1]; 1607163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 16082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 16092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBand( 16122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 16142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Returns the band with the maximum influence on a given frequency. 16162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Result is unaffected by whether EQ is enabled or not, or by whether 16172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// changes have been committed or not. 16182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 16202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// targetFreq The target frequency, in millihertz. 16212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 16222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 16242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 16252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 16262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16277618c5cb2fd60e944307e46afa051987d1e016c6Jean-Michel Triviint32_t EqualizerGetBand(EffectContext *pContext __unused, uint32_t targetFreq){ 16282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int band = 0; 16292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1630163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(targetFreq < bandFreqRange[0][0]){ 1631163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if(targetFreq == bandFreqRange[0][0]){ 1633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1634163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for(int i=0; i<FIVEBAND_NUMBANDS;i++){ 1636163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((targetFreq > bandFreqRange[i][0])&&(targetFreq <= bandFreqRange[i][1])){ 1637163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent band = i; 1638163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1639163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 16402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return band; 16412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 16422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPreset( 16452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 16472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets the currently set preset ID. 16492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Will return PRESET_CUSTOM in case the EQ parameters have been modified 16502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// manually since a preset was set. 16512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 16532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 16542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetPreset(EffectContext *pContext){ 1657163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return pContext->pBundledContext->CurPreset; 16582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 16592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetPreset( 16622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 16642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets the current preset by ID. 16662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// All the band parameters will be overridden. 16672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 16692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 16702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. 16712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid EqualizerSetPreset(EffectContext *pContext, int preset){ 16742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset(%d)", preset); 16762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = preset; 16772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //ActiveParams.pEQNB_BandDefinition = &BandDefs[0]; 16792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 16802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 16819b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent pContext->pBundledContext->bandGaindB[i] = 16829b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS]; 16832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 16842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 168502521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia EqualizerUpdateActiveParams(pContext); 168602521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 16879b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent 16883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n"); 16892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 16902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 1691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetNumPresets(){ 1693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return sizeof(gEqualizerPresets) / sizeof(PresetConfig); 16942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 16952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPresetName( 16982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets a human-readable name for a preset ID. Will return "Custom" if 17012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// PRESET_CUSTOM is passed. 17022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. Must be less than number of presets. 17052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//------------------------------------------------------------------------- 17072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst char * EqualizerGetPresetName(int32_t preset){ 17083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetPresetName start(%d)", preset); 17092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (preset == PRESET_CUSTOM) { 17102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return "Custom"; 17112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 17122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return gEqualizerPresets[preset].name; 17132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetPresetName end(%d)", preset); 1715163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 17162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 17172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetVolumeLevel() 17202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 17252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// level level to be applied 17262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){ 17302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17310ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent if (level > 0 || level < -9600) { 17320ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent return -EINVAL; 17330ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent } 1734163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 17350ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent if (pContext->pBundledContext->bMuteEnabled == LVM_TRUE) { 17360ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent pContext->pBundledContext->levelSaved = level / 100; 17370ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent } else { 17380ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent pContext->pBundledContext->volume = level / 100; 1739d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent } 17409b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent 174102521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 17429b3c701bbdbf3e4655758e995d467b325f8f366dEric Laurent 17432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 174417a736c3e1d062d7fc916329eb32aef8935614afGlenn Kasten} /* end VolumeSetVolumeLevel */ 17452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeGetVolumeLevel() 17482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 17532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){ 17572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17580ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent if (pContext->pBundledContext->bMuteEnabled == LVM_TRUE) { 17590ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent *level = pContext->pBundledContext->levelSaved * 100; 17600ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent } else { 17610ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent *level = pContext->pBundledContext->volume * 100; 17620ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent } 17632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 17642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end VolumeGetVolumeLevel */ 17652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetMute() 17682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 17732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 17742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){ 17783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute start(%d)", mute); 17792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bMuteEnabled = mute; 17812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set appropriate volume level */ 17832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){ 17840ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent pContext->pBundledContext->levelSaved = pContext->pBundledContext->volume; 17850ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent pContext->pBundledContext->volume = -96; 17862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 17870ee916f1f69c2d69e02a8de1e5cd5a2e9d0a0782Eric Laurent pContext->pBundledContext->volume = pContext->pBundledContext->levelSaved; 17882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 179002521e37c0494b83947c35160f3669de8adc9e5bRicardo Garcia LvmEffect_limitLevel(pContext); 17912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 17932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setMute */ 17942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1796163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetMute() 17972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 18012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 18022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Ourputs: 18042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 18052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){ 18083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetMute start"); 1809163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)|| 1810163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){ 1811163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *mute = pContext->pBundledContext->bMuteEnabled; 1812163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 18132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 18143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d", 1815163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled); 1816163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 18172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetMute end"); 18192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getMute */ 18202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1821163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint16_t VolumeConvertStereoPosition(int16_t position){ 1822163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t convertedPosition = 0; 1823163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1824163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent convertedPosition = (int16_t)(((float)position/1000)*96); 1825163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return convertedPosition; 1826163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1827163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 1828163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1829163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1830163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeSetStereoPosition() 1831163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1832163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1833163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1834163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1835163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1836163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1837163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1838163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1839163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1840163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1841163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint VolumeSetStereoPosition(EffectContext *pContext, int16_t position){ 1842163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1843163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1844163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1845163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Balance = 0; 1846163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1847c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 1848163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1849163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1850163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1851163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 18523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1853d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1854163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1855163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1856163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 18573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Position to be set is %d %d\n", position, Balance); 1858163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1859163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1861163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1862163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 18633856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got:" 1864163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // " %d\n", ActiveParams.VC_Balance); 1865163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1866163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Volume parameters */ 1867163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = Balance; 18683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition() (-96dB -> +96dB) -> %d\n", ActiveParams.VC_Balance ); 1869163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1870163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1871163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1872163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 1873163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1874163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 18753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully called LVM_SetControlParameters\n"); 18762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1877163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1878163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1879163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1880163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 18813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got: " 1882163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "%d\n", ActiveParams.VC_Balance); 1883163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1884163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent else{ 18853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Position attempting to set, but not enabled %d %d\n", 1886163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //position, Balance); 1887163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 18883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n", 1889d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1890163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1891163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeSetStereoPosition */ 18922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1894163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1895163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetStereoPosition() 1896163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1897163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1898163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1899163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1900163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1901163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1902163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1903163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1904163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 19052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1906163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeGetStereoPosition(EffectContext *pContext, int16_t *position){ 19073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition start"); 19082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1909163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1910163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1911163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 balance; 1912163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 19133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1914d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1915163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1916163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1917163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition") 1918163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1919163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 19203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition -> %d\n", ActiveParams.VC_Balance); 19213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 1922163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1923163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1924163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1925163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1926163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(balance != ActiveParams.VC_Balance){ 1927163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1928163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1929163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1930163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *position = (LVM_INT16)pContext->pBundledContext->positionSaved; // Convert dB to millibels 19313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved =%d\n", 1932d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1933163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1934163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeGetStereoPosition */ 19352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1936163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1937163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeEnableStereoPosition() 1938163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1939163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1940163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1941163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1942163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1943163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// mute: enable/disable flag 1944163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1945163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 19462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1947163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){ 19483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition start()"); 19492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1950163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = enabled; 19512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1952163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1953163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 19542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1955163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1956163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1957163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeEnableStereoPosition") 1958163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 19592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 19613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition to %d, position was %d\n", 1962163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // enabled, ActiveParams.VC_Balance ); 19632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1964163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Set appropriate stereo position */ 1965163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_FALSE){ 1966163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 0; 1967163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1968163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 1969163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1970163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 19712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1972163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1973163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1974163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeEnableStereoPosition") 1975163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 19762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition Succesfully called LVM_SetControlParameters\n"); 19783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition end()\n"); 1979163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1980163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeEnableStereoPosition */ 19812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_getParameter() 19842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 19862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a BassBoost parameter 19872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 19892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 19902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 19912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 19922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 19932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 19952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 19962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 19972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 20002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint BassBoost_getParameter(EffectContext *pContext, 2004c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 2005377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 2006163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue){ 20072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 2008c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2009c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 20102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 20112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 20122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter start"); 20142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 201623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 20177fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 20183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize1 %d", *pValueSize); 20197fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 20207fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 20217fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 20227fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 20232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 20242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 20253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize); 20262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 20292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 20332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 203723e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 20382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 20392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED Value is %d", 2041163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 20422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 20452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = BassGetStrength(pContext); 20462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d", 2048163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 20492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 20532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter end"); 20582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 20592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_getParameter */ 20602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_setParameter() 20632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 20652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a BassBoost parameter 20662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 20682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 20692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 20702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 20712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 20732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2076c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 20772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 20782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 2079c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 20802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter start"); 20822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2083c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (*pParamTemp){ 20842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 20852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 20863856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength); 20873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength"); 20882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BassSetStrength(pContext, (int32_t)strength); 20893856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength"); 20902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp); 20932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter end"); 20972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 20982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_setParameter */ 20992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_getParameter() 21022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 21042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Virtualizer parameter 21052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 21072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 21082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 21092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 21102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 21112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 21132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 21142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 21152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 21182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter(EffectContext *pContext, 2122c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 2123377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 21242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 21252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 2126c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2127c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 21282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 21292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter start"); 21312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 213323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 21347fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 21353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize); 21367fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 21377fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 21387fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 21397fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 21402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 21412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 21423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize); 21432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 21442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 21462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2147333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES: 2148333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // return value size can only be interpreted as relative to input value, 2149333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // deferring validity check to below 2150333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi break; 2151333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case VIRTUALIZER_PARAM_VIRTUALIZATION_MODE: 2152333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (*pValueSize != sizeof(uint32_t)){ 2153333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize); 2154333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return -EINVAL; 2155333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 2156333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *pValueSize = sizeof(uint32_t); 2157333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi break; 21582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 21593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 21602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 21612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 216423e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 21652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 21662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED Value is %d", 2168163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 21692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 21722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = VirtualizerGetStrength(pContext); 21732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d", 2175163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 21762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2178333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES: { 2179333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi const audio_channel_mask_t channelMask = (audio_channel_mask_t) *pParamTemp++; 2180333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi const audio_devices_t deviceType = (audio_devices_t) *pParamTemp; 2181333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi uint32_t nbChannels = audio_channel_count_from_out_mask(channelMask); 2182333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (*pValueSize < 3 * nbChannels * sizeof(int32_t)){ 2183333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize); 2184333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi return -EINVAL; 2185333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 2186333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // verify the configuration is supported 2187333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi status = VirtualizerIsConfigurationSupported(channelMask, deviceType); 2188333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (status == 0) { 2189333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES supports mask=0x%x device=0x%x", 2190333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi channelMask, deviceType); 2191333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // configuration is supported, get the angles 2192333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi VirtualizerGetSpeakerAngles(channelMask, deviceType, (int32_t *)pValue); 2193333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 2194333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 2195333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi break; 2196333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 2197333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case VIRTUALIZER_PARAM_VIRTUALIZATION_MODE: 2198333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *(uint32_t *)pValue = (uint32_t) VirtualizerGetVirtualizationMode(pContext); 2199333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi break; 2200333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 22012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 22023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 22032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 22042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2207333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tVirtualizer_getParameter end returning status=%d", status); 22082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 22092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_getParameter */ 22102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_setParameter() 22132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 22152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Virtualizer parameter 22162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 22182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 22192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 22202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 22212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 22232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2226c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 22272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 22282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 2229c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2230c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 22312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter start"); 22332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2234c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 22352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 22362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 22373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength); 22383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength"); 22392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent VirtualizerSetStrength(pContext, (int32_t)strength); 22403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength"); 22412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2242333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 2243333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi case VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE: { 2244333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi const audio_devices_t deviceType = *(audio_devices_t *) pValue; 2245333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi status = VirtualizerForceVirtualizationMode(pContext, deviceType); 2246333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi //ALOGV("VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE device=0x%x result=%d", 2247333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // deviceType, status); 2248333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 2249333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi break; 2250333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 22512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 22523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param); 22532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22563856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter end"); 22572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 22582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_setParameter */ 22592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_getParameter() 22622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 22642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Equalizer parameter 22652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 22672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 22682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 22692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 22702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 22712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 22732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 22742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 22752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 22782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter(EffectContext *pContext, 2281c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 2282377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 22832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 22842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 22852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 2286c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2287c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 22882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 22892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 22902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter start"); 22922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 22942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 22952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 22962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 22973be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_BAND_LEVEL: 22983be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_GET_BAND: 22992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int16_t)) { 23003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 23012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 23042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 23073be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (*pValueSize < 2 * sizeof(int16_t)) { 23083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize); 23093be9523784cc4038f601e510faee595117cdacb3Eric Laurent return -EINVAL; 23103be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 23113be9523784cc4038f601e510faee595117cdacb3Eric Laurent *pValueSize = 2 * sizeof(int16_t); 23123be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 23132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 23142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < 2 * sizeof(int32_t)) { 23153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 3 %d", *pValueSize); 23162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = 2 * sizeof(int32_t); 23192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23203be9523784cc4038f601e510faee595117cdacb3Eric Laurent 23212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 23222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)) { 23233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 5 %d", *pValueSize); 23242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 23272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 23302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 233223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: 233323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent if (*pValueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t)) { 23343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 233523e1de74359f4bb1763aef0adfebe073122b032cEric Laurent return -EINVAL; 233623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 233723e1de74359f4bb1763aef0adfebe073122b032cEric Laurent *pValueSize = (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t); 233823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent break; 233923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 23402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 23413856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param); 23422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 23462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 23473be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)FIVEBAND_NUMBANDS; 23483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue); 23492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 23523be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = -1500; 23533be9523784cc4038f601e510faee595117cdacb3Eric Laurent *((int16_t *)pValue + 1) = 1500; 23543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", 2355d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue, *((int16_t *)pValue + 1)); 23562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2359c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 23602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 23612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 23622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23643be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2); 23653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", 2366163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 23672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 2370c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 23712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 23722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 23732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2); 23763856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", 2377163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 23782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 2381c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 23822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 23832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 23842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1)); 23873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", 2388163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue, *((int32_t *)pValue + 1)); 23892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_BAND: 2392c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 23933be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2); 23943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", 2395d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // param2, *(uint16_t *)pValue); 23962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 23993be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext); 24003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue); 24012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 24043be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetNumPresets(); 24053856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue); 24062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 2409c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 24102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= EqualizerGetNumPresets()) { 24112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //if (param2 >= 20) { // AGO FIX 24122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 24132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name = (char *)pValue; 24162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1); 24172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name[*pValueSize - 1] = 0; 24182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = strlen(name) + 1; 24193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", 2420163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, gEqualizerPresets[param2].name, *pValueSize); 24212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 242323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: { 24243be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 24253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES"); 24263be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[0] = (int16_t)EqualizerGetPreset(pContext); 24273be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[1] = (int16_t)FIVEBAND_NUMBANDS; 242823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 24293be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[2 + i] = (int16_t)EqualizerGetBandLevel(pContext, i); 243023e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 243123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } break; 243223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 24332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 24343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param); 24352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 24362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2439d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //GV("\tEqualizer_getParameter end\n"); 24402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 24412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_getParameter */ 24422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 24442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_setParameter() 24452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 24462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 24472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Equalizer parameter 24482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 24492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 24502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 24512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 24522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 24532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 24542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 24552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 24562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 2457c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 24582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 24592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t preset; 24602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t band; 24612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t level; 2462c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2463c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 2464c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 24652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24663856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter start"); 24672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 24682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 24693be9523784cc4038f601e510faee595117cdacb3Eric Laurent preset = (int32_t)(*(uint16_t *)pValue); 24702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset); 24722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ((preset >= EqualizerGetNumPresets())||(preset < 0)) { 24732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 24742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetPreset(pContext, preset); 24772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2479c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent band = *pParamTemp; 24803be9523784cc4038f601e510faee595117cdacb3Eric Laurent level = (int32_t)(*(int16_t *)pValue); 24813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level); 24822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (band >= FIVEBAND_NUMBANDS) { 24832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 24842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetBandLevel(pContext, band, level); 24872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24883be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_PROPERTIES: { 24893856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES"); 24903be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 24913be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[0] >= EqualizerGetNumPresets()) { 24923be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 24933be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 24943be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 24953be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (p[0] >= 0) { 24963be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetPreset(pContext, (int)p[0]); 24973be9523784cc4038f601e510faee595117cdacb3Eric Laurent } else { 24983be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[1] != FIVEBAND_NUMBANDS) { 24993be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 25003be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 25013be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 25023be9523784cc4038f601e510faee595117cdacb3Eric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 25033be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetBandLevel(pContext, i, (int)p[2 + i]); 25043be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 25053be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 25063be9523784cc4038f601e510faee595117cdacb3Eric Laurent } break; 25072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 25083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_setParameter() invalid param %d", param); 25093be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 25102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter end"); 25142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 25152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_setParameter */ 25162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 25182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_getParameter() 25192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 25202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 25212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Volume parameter 25222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 25232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 25242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 25252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 25262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 25272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 25282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 25292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 25302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 25312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 25322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 25332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 25342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 25352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 25362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 25372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter(EffectContext *pContext, 2539c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 2540377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT uint32_t *pValueSize, 25412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 25422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 25432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 2544c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2545c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++;; 25462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 25472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter start"); 25492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 25512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 25522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 25532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2554163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (*pValueSize != sizeof(int16_t)){ 25553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1 %d", *pValueSize); 25562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 25592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 25622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 25632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)){ 25643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2 %d", *pValueSize); 25652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 25682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 25713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param); 25722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 25762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 25772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue)); 25783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d", 2579d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 25802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 25832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = 0; 25843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d", 2585d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 25862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2589163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeGetStereoPosition(pContext, (int16_t *)pValue); 25903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d", 2591d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 25922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2595163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeGetMute(pContext, (uint32_t *)pValue); 25963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d", 2597163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(uint32_t *)pValue); 25982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2601163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled; 26023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d", 2603d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(uint32_t *)pValue); 26042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 26052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 26073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param); 26082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 26092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 26102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter end"); 26132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 26142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_getParameter */ 26152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 26182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_setParameter() 26192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 26202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 26212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Volume parameter 26222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 26232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 26242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 26252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 26262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 26272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 26282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 26292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 26302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 26312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2632c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 26332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 26342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t level; 2635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t position; 26362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent uint32_t mute; 2637163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t positionEnabled; 2638c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2639c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 26402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26413856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter start"); 26422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2643c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 26442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 26452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent level = *(int16_t *)pValue; 26463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level); 26473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel"); 26482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeSetVolumeLevel(pContext, (int16_t)level); 26493856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel"); 26502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 26512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent mute = *(uint32_t *)pValue; 26543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute); 26553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setMute"); 2656163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetMute(pContext, mute); 26573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->setMute"); 2658163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 26592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2661163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent positionEnabled = *(uint32_t *)pValue; 2662163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeEnableStereoPosition(pContext, positionEnabled); 2663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved); 26643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called"); 2665163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 26662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2668163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent position = *(int16_t *)pValue; 26693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position); 26703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition"); 2671163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, (int16_t)position); 26723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition"); 2673163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 26742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 26763856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param); 26772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 26782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter end"); 26812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 26822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_setParameter */ 26832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2684163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent/**************************************************************************************** 2685163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Name : LVC_ToDB_s32Tos16() 2686163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Input : Signed 32-bit integer 2687163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Output : Signed 16-bit integer 2688163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * MSB (16) = sign bit 2689163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (15->05) = integer part 2690163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (04->01) = decimal part 2691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Returns : Db value with respect to full scale 2692163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Description : 2693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Remarks : 2694163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ****************************************************************************************/ 2695163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2696163fbcf84010b98e0374110454d85b804bc8d13bEric LaurentLVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) 2697163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent{ 2698163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 db_fix; 2699163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Shift; 2700163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 SmallRemainder; 2701163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_UINT32 Remainder = (LVM_UINT32)Lin_fix; 2702163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2703163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Count leading bits, 1 cycle in assembly*/ 2704163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (Shift = 0; Shift<32; Shift++) 2705163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2706163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((Remainder & 0x80000000U)!=0) 2707163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2708163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2709163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2710163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Remainder = Remainder << 1; 2711163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2713163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* 2714163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Based on the approximation equation (for Q11.4 format): 2715163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * 2716163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * dB = -96 * Shift + 16 * (8 * Remainder - 2 * Remainder^2) 2717163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent */ 2718163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(-96 * Shift); /* Six dB steps in Q11.4 format*/ 2719163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)((Remainder & 0x7fffffff) >> 24); 2720163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix + SmallRemainder ); 2721163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)(SmallRemainder * SmallRemainder); 2722163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - (LVM_INT16)((LVM_UINT16)SmallRemainder >> 9)); 27232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2724163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Correct for small offset */ 2725163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - 5); 27262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2727163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return db_fix; 2728163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 27292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 273029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 273129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Effect_setEnabled() 273229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 273329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Purpose: 273429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Enable or disable effect 273529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 273629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Inputs: 273729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// pContext - pointer to effect context 273829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// enabled - true if enabling the effect, false otherwise 273929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 274029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Outputs: 274129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 274229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 274329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 274429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurentint Effect_setEnabled(EffectContext *pContext, bool enabled) 274529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent{ 27463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() type %d, enabled %d", pContext->EffectType, enabled); 274729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 274829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (enabled) { 2749b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent // Bass boost or Virtualizer can be temporarily disabled if playing over device speaker due 2750b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent // to their nature. 2751b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent bool tempDisabled = false; 275229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent switch (pContext->EffectType) { 275329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_BASS_BOOST: 275429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 27553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already enabled"); 275629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 275729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2758dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb <= 0){ 2759dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2760dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 276129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 276229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 276329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bBassEnabled = LVM_TRUE; 2764b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent tempDisabled = pContext->pBundledContext->bBassTempDisabled; 276529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 276629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_EQUALIZER: 276729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) { 27683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already enabled"); 276929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 277029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2771dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq <= 0){ 2772dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2773dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 277429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 277529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 277629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE; 277729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 277829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VIRTUALIZER: 277929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { 27803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already enabled"); 278129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 278229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2783dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt <= 0){ 2784dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2785dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 278629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 278729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 278829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE; 2789b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent tempDisabled = pContext->pBundledContext->bVirtualizerTempDisabled; 279029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 279129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VOLUME: 279229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE) { 27933856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VOLUME is already enabled"); 279429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 279529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2796dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 279729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_TRUE; 279829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 279929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent default: 28003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() invalid effect type"); 280129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 280229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2803b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (!tempDisabled) { 2804b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent LvmEffect_enable(pContext); 2805b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent } 280629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } else { 280729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent switch (pContext->EffectType) { 280829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_BASS_BOOST: 280929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_FALSE) { 28103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already disabled"); 281129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 281229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 281329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 281429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 281529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_EQUALIZER: 281629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE) { 28173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already disabled"); 281829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 281929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 282029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 282129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 282229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VIRTUALIZER: 282329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE) { 28243856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already disabled"); 282529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 282629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 282729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 282829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 282929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VOLUME: 283029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_FALSE) { 28313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VOLUME is already disabled"); 283229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 283329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 283429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 283529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 283629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent default: 28373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() invalid effect type"); 283829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 283929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 284029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent LvmEffect_disable(pContext); 284129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 284229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 284329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return 0; 284429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent} 284529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 2846dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//---------------------------------------------------------------------------- 2847dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// LVC_Convert_VolToDb() 2848dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//---------------------------------------------------------------------------- 2849dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Purpose: 2850dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Convery volume in Q24 to dB 2851dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// 2852dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Inputs: 2853dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// vol: Q.24 volume dB 2854dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// 2855dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//----------------------------------------------------------------------- 2856dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2857dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurentint16_t LVC_Convert_VolToDb(uint32_t vol){ 2858dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t dB; 2859dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2860dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = LVC_ToDB_s32Tos16(vol <<7); 2861dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = (dB +8)>>4; 2862dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = (dB <-96) ? -96 : dB ; 2863dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2864dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return dB; 2865dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent} 2866dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2867163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 2868163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 28692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2870e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentextern "C" { 28712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Process */ 2872e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_process(effect_handle_t self, 2873163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *inBuffer, 2874163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *outBuffer){ 28752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 2876c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 28772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 28782a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent int processStatus = 0; 2879163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *in = (LVM_INT16 *)inBuffer->raw; 2880163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw; 28812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block//ALOGV("\tEffect_process Start : Enabled = %d Called = %d (%8d %8d %8d)", 2883dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled, 2884c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountBb, 2885c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountVirt, 2886c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountEq); 2887c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 28882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 28893856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL"); 28902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2892dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2893dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //if(pContext->EffectType == LVM_BASS_BOOST){ 28943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is BASS_BOOST"); 2895dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //}else if(pContext->EffectType == LVM_EQUALIZER){ 28963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is LVM_EQUALIZER"); 2897dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //}else if(pContext->EffectType == LVM_VIRTUALIZER){ 28983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is LVM_VIRTUALIZER"); 2899dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //} 2900dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 29012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (inBuffer == NULL || inBuffer->raw == NULL || 29022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer == NULL || outBuffer->raw == NULL || 29032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent inBuffer->frameCount != outBuffer->frameCount){ 29043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG"); 29052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2907163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&& 2908163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_BASS_BOOST)){ 29093856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled"); 2910c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb > 0){ 2911c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO 29123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting to turn off BASS_BOOST, %d samples left", 2913c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountBb); 2914d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2915d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb <= 0) { 291629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent status = -ENODATA; 2917dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 29183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_BASS_BOOST"); 2919c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 2920163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2921163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&& 2922163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VOLUME)){ 29233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_VOLUME Effect is not enabled"); 2924163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2925dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 2926163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2927163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&& 2928163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_EQUALIZER)){ 29293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled"); 2930c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq > 0){ 2931c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO 29323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting to turn off EQUALIZER, %d samples left", 2933c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountEq); 2934d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2935d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq <= 0) { 2936c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2937dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 29383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_EQUALIZER"); 2939c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 29402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2941163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&& 2942163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VIRTUALIZER)){ 29433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled"); 2944c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ 2945c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO 29463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting for to turn off VIRTUALIZER, %d samples left", 2947c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountVirt); 2948d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2949d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) { 2950c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2951dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 29523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_VIRTUALIZER"); 2953c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 29542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2955163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2956dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(status != -ENODATA){ 2957163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled++; 29582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2960163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->NumberEffectsCalled == 2961163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled){ 29623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d", 2963163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2964163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 29652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29662a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent if (status == -ENODATA){ 29673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() processing last frame"); 2968163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 29692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 2970163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process all the available frames, block processing is 2971163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent handled internalLY by the LVM bundle */ 29722a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent processStatus = android::LvmBundle_process( (LVM_INT16 *)inBuffer->raw, 29732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_INT16 *)outBuffer->raw, 29742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer->frameCount, 29752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext); 29762a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent if (processStatus != 0){ 29772a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent ALOGV("\tLVM_ERROR : LvmBundle_process returned error %d", processStatus); 29782a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent if (status == 0) { 29792a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent status = processStatus; 29802a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent } 29812a5afed82fd4edd220551ce5565d89ac976f6720Eric Laurent return status; 2982163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 29835dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent } else { 29843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d", 2985163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2986163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 2987163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // 2 is for stereo input 29885dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) { 29895dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent for (size_t i=0; i < outBuffer->frameCount*2; i++){ 29905dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent outBuffer->s16[i] = 29915dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent clamp16((LVM_INT32)outBuffer->s16[i] + (LVM_INT32)inBuffer->s16[i]); 29925dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent } 299397bb6e89845cb6d85f4d34a4efcc1de2ce585336Marco Nelissen } else if (outBuffer->raw != inBuffer->raw) { 29945dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2); 29955dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent } 29962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2997163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 29982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 29992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_process */ 30002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Command */ 3002e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_command(effect_handle_t self, 300325f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdCode, 300425f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdSize, 3005163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pCmdData, 300625f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t *replySize, 3007163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pReplyData){ 30082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 30092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int retsize; 30102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30113856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\t\nEffect_command start"); 30122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 30143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_BASS_BOOST"); 30152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 30173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_VIRTUALIZER"); 3018163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 30203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_EQUALIZER"); 3021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 30233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_VOLUME"); 3024163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 30273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL"); 30282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize); 30322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3033163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Incase we disable an effect, next time process is 3034163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // called the number of effect called could be greater 3035163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled = 0; 30362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", 3038163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled, 3039163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 30402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (cmdCode){ 30422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_INIT: 30430f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)){ 30443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d", 3045010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent pContext->EffectType); 3046010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent return -EINVAL; 3047010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent } 3048010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = 0; 30493856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start"); 30502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 30513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST"); 30522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::BassSetStrength(pContext, 0); 30532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 30553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER"); 3056163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VirtualizerSetStrength(pContext, 0); 3057163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 30593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER"); 3060163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::EqualizerSetPreset(pContext, 0); 3061163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 30633856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VOLUME"); 3064010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0); 3065163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3067163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 30683d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent case EFFECT_CMD_SET_CONFIG: 30693d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_CONFIG start"); 30700f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pCmdData == NULL || cmdSize != sizeof(effect_config_t) || 30710f714a464d2425afe00d6450535e763131b40844Eric Laurent pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)) { 30723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 30733d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent "EFFECT_CMD_SET_CONFIG: ERROR"); 30743d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent return -EINVAL; 30753d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent } 30763d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent *(int *) pReplyData = android::Effect_setConfig(pContext, (effect_config_t *) pCmdData); 30773d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_CONFIG end"); 30783d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent break; 30793d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 30803d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent case EFFECT_CMD_GET_CONFIG: 30810f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(effect_config_t)) { 30823d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 30833d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent "EFFECT_CMD_GET_CONFIG: ERROR"); 30842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30863d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 30873d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent android::Effect_getConfig(pContext, (effect_config_t *)pReplyData); 30882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 30892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_RESET: 30913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start"); 30923d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent android::Effect_setConfig(pContext, &pContext->config); 30933856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end"); 30942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 30952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_GET_PARAM:{ 30973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 3098163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 30990f714a464d2425afe00d6450535e763131b40844Eric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 3100ad1bd92a49d78df6bc6e75bee68c517c1326f3cfEric Laurent if (SIZE_MAX - sizeof(effect_param_t) < (size_t)p->psize) { 3101ad1bd92a49d78df6bc6e75bee68c517c1326f3cfEric Laurent android_errorWriteLog(0x534e4554, "26347509"); 3102ad1bd92a49d78df6bc6e75bee68c517c1326f3cfEric Laurent return -EINVAL; 3103ad1bd92a49d78df6bc6e75bee68c517c1326f3cfEric Laurent } 31040f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pCmdData == NULL || cmdSize < sizeof(effect_param_t) || 31050f714a464d2425afe00d6450535e763131b40844Eric Laurent cmdSize < (sizeof(effect_param_t) + p->psize) || 31060f714a464d2425afe00d6450535e763131b40844Eric Laurent pReplyData == NULL || replySize == NULL || 31070f714a464d2425afe00d6450535e763131b40844Eric Laurent *replySize < (sizeof(effect_param_t) + p->psize)) { 31080f714a464d2425afe00d6450535e763131b40844Eric Laurent ALOGV("\tLVM_ERROR : EFFECT_CMD_GET_PARAM: ERROR"); 31090f714a464d2425afe00d6450535e763131b40844Eric Laurent return -EINVAL; 31100f714a464d2425afe00d6450535e763131b40844Eric Laurent } 31112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31120f714a464d2425afe00d6450535e763131b40844Eric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 31132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31140f714a464d2425afe00d6450535e763131b40844Eric Laurent p = (effect_param_t *)pReplyData; 31152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31160f714a464d2425afe00d6450535e763131b40844Eric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 31172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31180f714a464d2425afe00d6450535e763131b40844Eric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 31192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::BassBoost_getParameter(pContext, 3120c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 3121377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT &p->vsize, 31222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 31233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM " 3124163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 3125163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3126163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 3127163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 31282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3129163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 31302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 31312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Virtualizer_getParameter(pContext, 3132377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT (void *)p->data, 3133377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT &p->vsize, 31342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 31352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM " 3137163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 3138163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3139163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 3140163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 31412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 31422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 31433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command cmdCode Case: " 3144163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 3145c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->status = android::Equalizer_getParameter(pContext, 3146c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 3147c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent &p->vsize, 3148c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data + voffset); 3149163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 31503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, " 3151163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pReplyData %08x %08x", 3152163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize, 3153163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset), 3154163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + 3155163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // sizeof(int32_t))); 31562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 31572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 31583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 31592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Volume_getParameter(pContext, 3160c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3161377b2ec9a2885f9b6405b07ba900a9e3f4349c38Kévin PETIT &p->vsize, 31622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 31632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command EFFECT_CMD_GET_PARAM " 3165163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 3166163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3167163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 3168163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 3169163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 31700f714a464d2425afe00d6450535e763131b40844Eric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 31710f714a464d2425afe00d6450535e763131b40844Eric Laurent 31723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end"); 31732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 31742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_PARAM:{ 31753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 31762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 31773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 3178dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3179dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *replySize, 3180dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 3181163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 31820f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pCmdData == NULL || 31830f714a464d2425afe00d6450535e763131b40844Eric Laurent cmdSize != (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t)) || 31840f714a464d2425afe00d6450535e763131b40844Eric Laurent pReplyData == NULL || replySize == NULL || *replySize != sizeof(int32_t)) { 31853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 31862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 31872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 31882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 31892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 31902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 31923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 31932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 31942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 31952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 31962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 31973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tnBassBoost_command cmdSize is %d\n" 3198163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 3199163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 3200163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 3201163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 3202163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 32032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::BassBoost_setParameter(pContext, 3205c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 32062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + p->psize); 32072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 3209333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // Warning this log will fail to properly read an int32_t value, assumes int16_t 32103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 3211d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3212d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 3213d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 3214163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3215333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (pCmdData == NULL || 32160f714a464d2425afe00d6450535e763131b40844Eric Laurent // legal parameters are int16_t or int32_t 32170f714a464d2425afe00d6450535e763131b40844Eric Laurent cmdSize > (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int32_t)) || 32180f714a464d2425afe00d6450535e763131b40844Eric Laurent cmdSize < (sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t)) || 32190f714a464d2425afe00d6450535e763131b40844Eric Laurent pReplyData == NULL || replySize == NULL || *replySize != sizeof(int32_t)) { 32203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 32212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 32222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 32232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 32252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 32273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 32282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 32292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 32302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tnVirtualizer_command cmdSize is %d\n" 3233163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 3234163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 3235163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 3236163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 3237163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 32382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Virtualizer_setParameter(pContext, 3240c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3241163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 32422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 32443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command cmdCode Case: " 3245d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // "EFFECT_CMD_SET_PARAM start"); 32463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 3247d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3248d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 3249d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 32502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3251b302bd5d288be2d3363b80053ca2392560b00b25Ashok Bhat if (pCmdData == NULL || cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || 32520f714a464d2425afe00d6450535e763131b40844Eric Laurent pReplyData == NULL || replySize == NULL || *replySize != sizeof(int32_t)) { 32533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 32542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 32552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 32562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 32582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Equalizer_setParameter(pContext, 3260c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3261163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 32622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 32643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 32653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 3266163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 3268d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) +sizeof(int32_t))); 32692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32700f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pCmdData == NULL || 32710f714a464d2425afe00d6450535e763131b40844Eric Laurent cmdSize < (sizeof(effect_param_t) + sizeof(int32_t)) || 32720f714a464d2425afe00d6450535e763131b40844Eric Laurent pReplyData == NULL || replySize == NULL || 32730f714a464d2425afe00d6450535e763131b40844Eric Laurent *replySize != sizeof(int32_t)) { 32743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 32752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 32762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 32772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 32792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Volume_setParameter(pContext, 3281c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3282163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 3283163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 32843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end"); 32852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 32862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_ENABLE: 32883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start"); 32890f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)) { 32903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR"); 32912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 3292163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 329329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 329429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_TRUE); 32952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3296163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 32972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_DISABLE: 32983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start"); 32990f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pReplyData == NULL || replySize == NULL || *replySize != sizeof(int)) { 33003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR"); 33012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 3302163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 330329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_FALSE); 33042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 33052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 33062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_DEVICE: 3307163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 33083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start"); 33090f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pCmdData == NULL){ 33100f714a464d2425afe00d6450535e763131b40844Eric Laurent ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_SET_DEVICE: ERROR"); 33110f714a464d2425afe00d6450535e763131b40844Eric Laurent return -EINVAL; 33120f714a464d2425afe00d6450535e763131b40844Eric Laurent } 33130f714a464d2425afe00d6450535e763131b40844Eric Laurent 3314e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent uint32_t device = *(uint32_t *)pCmdData; 3315333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->nOutputDevice = (audio_devices_t) device; 3316163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3317b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->EffectType == LVM_BASS_BOOST) { 3318b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if((device == AUDIO_DEVICE_OUT_SPEAKER) || 3319b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) || 3320b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){ 33213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d", 3322163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 33233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST"); 3324163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3325163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device doesnt support bassboost the effect must be temporarily disabled 3326163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 3327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 3328163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3329b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 33303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d", 3331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3332163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 3333163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3334b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_TRUE; 3335b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent } else { 33363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d", 3337163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3338163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3339163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports bassboost and the effect has been temporarily disabled 3340163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 3341163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3342b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 33433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d", 3344163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3345163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 3346163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3347b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 3348163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3349163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3350b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->EffectType == LVM_VIRTUALIZER) { 3351333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (pContext->pBundledContext->nVirtualizerForcedDevice == AUDIO_DEVICE_NONE) { 3352333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // default case unless configuration is forced 3353333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (android::VirtualizerIsDeviceSupported(device) != 0) { 3354333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d", 3355333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *(int32_t *)pCmdData); 3356333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER"); 3357333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 3358333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi //If a device doesnt support virtualizer the effect must be temporarily 3359333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // disabled the effect must still report its original state as this can 3360333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // only be changed by the ENABLE/DISABLE command 3361333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 3362333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { 3363333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d", 3364333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *(int32_t *)pCmdData); 3365333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi android::LvmEffect_disable(pContext); 3366333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 3367333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE; 3368333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } else { 3369333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d", 3370333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *(int32_t *)pCmdData); 3371333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 3372333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // If a device supports virtualizer and the effect has been temporarily 3373333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi // disabled previously then re-enable it 3374333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi 3375333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 3376333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d", 3377333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi *(int32_t *)pCmdData); 3378333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi android::LvmEffect_enable(pContext); 3379333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } 3380333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 3381163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3382333f66d4642ddd36b42668da2767551ba25f0248Jean-Michel Trivi } // else virtualization mode is forced to a certain device, nothing to do 3383163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 33843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end"); 33852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3386163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3387163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_VOLUME: 3388163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 3389dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent uint32_t leftVolume, rightVolume; 3390dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t leftdB, rightdB; 3391dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t maxdB, pandB; 3392dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume 3393dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int status = 0; 3394dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 3395dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 3396163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3397163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // if pReplyData is NULL, VOL_CTRL is delegated to another effect 3398163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pReplyData == LVM_NULL){ 3399163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3400163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 34012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 34020f714a464d2425afe00d6450535e763131b40844Eric Laurent if (pCmdData == NULL || cmdSize != 2 * sizeof(uint32_t) || pReplyData == NULL || 34030f714a464d2425afe00d6450535e763131b40844Eric Laurent replySize == NULL || *replySize < 2*sizeof(int32_t)) { 34043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 3405dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent "EFFECT_CMD_SET_VOLUME: ERROR"); 3406dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return -EINVAL; 3407163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3408163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3409dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftVolume = ((*(uint32_t *)pCmdData)); 3410dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightVolume = ((*((uint32_t *)pCmdData + 1))); 3411dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3412dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(leftVolume == 0x1000000){ 3413dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftVolume -= 1; 3414dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3415dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(rightVolume == 0x1000000){ 3416dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightVolume -= 1; 3417dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3418dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3419dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Convert volume to dB 3420dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftdB = android::LVC_Convert_VolToDb(leftVolume); 3421dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightdB = android::LVC_Convert_VolToDb(rightVolume); 3422dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3423dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pandB = rightdB - leftdB; 3424dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3425dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Calculate max volume in dB 3426dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent maxdB = leftdB; 3427dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(rightdB > maxdB){ 3428dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent maxdB = rightdB; 3429dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 34303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME Session: %d, SessionID: %d VOLUME is %d dB (%d), " 3431dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // "effect is %d", 3432dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //pContext->pBundledContext->SessionNo, pContext->pBundledContext->SessionId, 3433dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //(int32_t)maxdB, maxVol<<7, pContext->EffectType); 34343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left is %d, Right is %d", leftVolume, rightVolume); 34353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left %ddB, Right %ddB, Position %ddB", 3436dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // leftdB, rightdB, pandB); 3437d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 3438163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(pReplyData, vol_ret, sizeof(int32_t)*2); 3439dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent android::VolumeSetVolumeLevel(pContext, (int16_t)(maxdB*100)); 3440dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3441dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Get the current settings */ 3442dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LvmStatus =LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 3443dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 3444dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 3445dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3446dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Volume parameters */ 3447dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ActiveParams.VC_Balance = pandB; 34483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\t\tVolumeSetStereoPosition() (-96dB -> +96dB)-> %d\n", ActiveParams.VC_Balance ); 3449dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3450dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Activate the initial settings */ 3451dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LvmStatus =LVM_SetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 3452dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 3453dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 3454163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3455163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3456163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_AUDIO_MODE: 3457163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 34582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 34592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 34602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 34612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 34623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command end...\n\n"); 34632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 34642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_command */ 34652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3466e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent/* Effect Control Interface Implementation: get_descriptor */ 3467e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_getDescriptor(effect_handle_t self, 3468e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_descriptor_t *pDescriptor) 3469e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent{ 3470e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EffectContext * pContext = (EffectContext *) self; 3471e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent const effect_descriptor_t *desc; 3472e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3473e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pContext == NULL || pDescriptor == NULL) { 34743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("Effect_getDescriptor() invalid param"); 3475e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 3476e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 3477e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3478e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent switch(pContext->EffectType) { 3479e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_BASS_BOOST: 3480e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gBassBoostDescriptor; 3481e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3482e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_VIRTUALIZER: 3483e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gVirtualizerDescriptor; 3484e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3485e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_EQUALIZER: 3486e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gEqualizerDescriptor; 3487e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3488e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_VOLUME: 3489e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gVolumeDescriptor; 3490e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3491e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent default: 3492e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 3493e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 3494e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3495a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = *desc; 3496e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3497e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return 0; 3498e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} /* end Effect_getDescriptor */ 3499e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3500e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent// effect_handle_t interface implementation for effect 35012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst struct effect_interface_s gLvmEffectInterface = { 35022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_process, 3503e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent Effect_command, 3504ba7b8f881a9b6b21803752326d2932a3bd42d7cfEric Laurent Effect_getDescriptor, 3505ba7b8f881a9b6b21803752326d2932a3bd42d7cfEric Laurent NULL, 35062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; /* end gLvmEffectInterface */ 35072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 35087f16b197c76fbae9399242f055a7ee16dcd0fd6dMarco Nelissen// This is the only symbol that needs to be exported 35097f16b197c76fbae9399242f055a7ee16dcd0fd6dMarco Nelissen__attribute__ ((visibility ("default"))) 3510e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentaudio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = { 3511c9d8ea7f8f9a1ca8ecd266695e3cac423790b2f9synergydev .tag = AUDIO_EFFECT_LIBRARY_TAG, 3512c9d8ea7f8f9a1ca8ecd266695e3cac423790b2f9synergydev .version = EFFECT_LIBRARY_API_VERSION, 3513c9d8ea7f8f9a1ca8ecd266695e3cac423790b2f9synergydev .name = "Effect Bundle Library", 3514c9d8ea7f8f9a1ca8ecd266695e3cac423790b2f9synergydev .implementor = "NXP Software Ltd.", 3515c9d8ea7f8f9a1ca8ecd266695e3cac423790b2f9synergydev .create_effect = android::EffectCreate, 3516c9d8ea7f8f9a1ca8ecd266695e3cac423790b2f9synergydev .release_effect = android::EffectRelease, 3517c9d8ea7f8f9a1ca8ecd266695e3cac423790b2f9synergydev .get_descriptor = android::EffectGetDescriptor, 3518e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent}; 3519e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3520e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} 3521