EffectBundle.cpp revision a189a6883ee55cf62da1d7bf5bf5a8ab501938a4
12c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* 22c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2010-2010 NXP Software 32c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2009 The Android Open Source Project 42c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 52c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 62c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * you may not use this file except in compliance with the License. 72c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * You may obtain a copy of the License at 82c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 92c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Unless required by applicable law or agreed to in writing, software 122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * See the License for the specific language governing permissions and 152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * limitations under the License. 162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define LOG_TAG "Bundle" 192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) 2097344f1d8e8e95fd07d5deee2ae2492a7e4c24b0Eric Laurent//#define LOG_NDEBUG 0 212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <cutils/log.h> 232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <assert.h> 242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <stdlib.h> 252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <string.h> 262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <new> 27b4d307481960b6b348fae4b4e8edefd003c3d36cGlenn Kasten#include "EffectBundle.h" 282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent// effect_handle_t interface implementation for bass boost 312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" const struct effect_interface_s gLvmEffectInterface; 322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\ 342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_NULLADDRESS){\ 353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_ALIGNMENTERROR){\ 393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad alignment returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_INVALIDNUMSAMPLES){\ 433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_OUTOFRANGE){\ 473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Parameter error - "\ 482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "out of range returned by %s in %s\n", callingFunc, calledFunc);\ 492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 525dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent 535dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurentstatic inline int16_t clamp16(int32_t sample) 545dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent{ 555dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent // check overflow for both positive and negative values: 565dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent // all bits above short range must me equal to sign bit 575dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent if ((sample>>15) ^ (sample>>31)) 585dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent sample = 0x7FFF ^ (sample>>31); 595dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent return sample; 605dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent} 615dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent 622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Namespaces 632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace android { 642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace { 652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 66d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent// Flag to allow a one time init of global memory, only happens on first call ever 67d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurentint LvmInitFlag = LVM_FALSE; 68d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric LaurentSessionContext GlobalSessionMemory[LVM_MAX_SESSIONS]; 69d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurentint SessionIndex[LVM_MAX_SESSIONS]; 70d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent 712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* local functions */ 722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define CHECK_ARG(cond) { \ 732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (!(cond)) { \ 743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Invalid argument: "#cond); \ 752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; \ 762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } \ 772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW BassBoost UUID 812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gBassBoostDescriptor = { 822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x8631f300, 0x72e2, 0x11df, 0xb57e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid 84e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 85163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 86163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 87d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BASS_BOOST_CUP_LOAD_ARM9E, 88d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Dynamic Bass Boost", 902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Virtualizer UUID 942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVirtualizerDescriptor = { 95163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 96163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 97e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 98163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 99163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 100d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VIRTUALIZER_CUP_LOAD_ARM9E, 101d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Virtualizer", 1032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Equalizer UUID 1072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gEqualizerDescriptor = { 1082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type 1092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0xce772f20, 0x847d, 0x11df, 0xbb17, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid Eq NXP 110e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 111163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 112d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent EQUALIZER_CUP_LOAD_ARM9E, 113d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Equalizer", 1152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Volume UUID 1192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVolumeDescriptor = { 1202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 1212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x119341a0, 0x8469, 0x11df, 0x81f9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, //uuid VOL NXP 122e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EFFECT_CONTROL_API_VERSION, 123163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 124d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VOLUME_CUP_LOAD_ARM9E, 125d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Volume", 1272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--- local function prototypes 1312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init (void); 1322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init (EffectContext *pContext); 1332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable (EffectContext *pContext); 1342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable (EffectContext *pContext); 1352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free (EffectContext *pContext); 1363d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentint Effect_setConfig (EffectContext *pContext, effect_config_t *pConfig); 1373d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentvoid Effect_getConfig (EffectContext *pContext, effect_config_t *pConfig); 138c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue); 139163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint BassBoost_getParameter (EffectContext *pContext, 140c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 143c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter (EffectContext *pContext, 145c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 147163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue); 148c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter (EffectContext *pContext, 150c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 153c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter (EffectContext *pContext, 155c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 15829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurentint Effect_setEnabled(EffectContext *pContext, bool enabled); 1592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Library Interface Implementation */ 1612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){ 1623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectQueryNumberEffects start"); 1632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pNumEffects = 4; 1643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects); 1653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryNumberEffects end\n"); 1662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryNumberEffects */ 1682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){ 1703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectQueryEffect start"); 1713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing index %d", index); 172163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pDescriptor == NULL){ 1743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer"); 1752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 1762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (index > 3){ 1783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index); 1792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -ENOENT; 1802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(index == LVM_BASS_BOOST){ 1823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_BASS_BOOST"); 183a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = gBassBoostDescriptor; 1842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else if(index == LVM_VIRTUALIZER){ 1853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER"); 186a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = gVirtualizerDescriptor; 1872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_EQUALIZER){ 1883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_EQUALIZER"); 189a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = gEqualizerDescriptor; 1902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_VOLUME){ 1913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect processing LVM_VOLUME"); 192a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = gVolumeDescriptor; 193163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectQueryEffect end\n"); 1952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryEffect */ 1972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1985e92a7861196ddae14638d4b7a63fc4892b7ef59Glenn Kastenextern "C" int EffectCreate(const effect_uuid_t *uuid, 1992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t sessionId, 2002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t ioId, 201e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_handle_t *pHandle){ 202dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int ret = 0; 203c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int sessionNo; 2042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int i; 205dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent EffectContext *pContext = NULL; 206dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent bool newBundle = false; 207dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent SessionContext *pSessionContext; 2082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2093856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectCreate start session %d", sessionId); 2102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 211e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pHandle == NULL || uuid == NULL){ 2123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer"); 213dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 214dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 2152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmInitFlag == LVM_FALSE){ 2182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmInitFlag = LVM_TRUE; 2193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Initializing all global memory"); 2202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmGlobalBundle_init(); 2212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 223c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Find next available sessionNo 224c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(i=0; i<LVM_MAX_SESSIONS; i++){ 225e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent if((SessionIndex[i] == LVM_UNUSED_SESSION)||(SessionIndex[i] == sessionId)){ 226c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo = i; 227c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent SessionIndex[i] = sessionId; 2283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId); 229c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 230c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 231c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 232c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 233c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(i==LVM_MAX_SESSIONS){ 2343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Cannot find memory to allocate for current session"); 235dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 236dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 237c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 238dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 239dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext = new EffectContext; 240dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // If this is the first create in this session 242c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(GlobalSessionMemory[sessionNo].bBundledEffectsEnabled == LVM_FALSE){ 2433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d", 244c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionId, sessionNo); 245c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 246c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_TRUE; 247c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext = new BundledEffectContext; 248dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent newBundle = true; 2492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 250c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = GlobalSessionMemory[sessionNo].pBundledContext; 251c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionNo = sessionNo; 252c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionId = sessionId; 253163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = NULL; 254163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 255163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 256163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 257163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 258163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 259163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 260163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled = 0; 261163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 262d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->firstVolume = LVM_TRUE; 263163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 264163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 2658f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent char fileName[256]; 2668f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_in.pcm", pContext->pBundledContext); 2678f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = fopen(fileName, "w"); 2688f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmInPtr == NULL) { 2693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("cannot open %s", fileName); 270dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 271dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 2728f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 273163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2748f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent snprintf(fileName, 256, "/data/tmp/bundle_%p_pcm_out.pcm", pContext->pBundledContext); 2758f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmOutPtr = fopen(fileName, "w"); 2768f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmOutPtr == NULL) { 2773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("cannot open %s", fileName); 2788f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmInPtr); 2798f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = NULL; 280dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 281dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 282163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 283163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 284163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Saved strength is used to return the exact strength that was used in the set to the get 2862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * because we map the original strength range of 0:1000 to 1:15, and this will avoid 2872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * quantisation like effect when returning 2882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 289163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->BassStrengthSaved = 0; 290163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = 0; 291163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 292163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = 0; 293163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled = LVM_FALSE; 294163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = LVM_FALSE; 295163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = 0; 296dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->workBuffer = NULL; 297dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->frameCount = -1; 298dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 299dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 300dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 301163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Calling LvmBundle_init"); 3032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ret = LvmBundle_init(pContext); 3042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (ret < 0){ 3063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() Bundle init failed"); 307dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 3082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 3113856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d", 312c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo); 313c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = 314c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext; 3152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext); 3172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 318dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo]; 31929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 3202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create each Effect 3212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Bass Boost 3233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST"); 32429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bBassInstantiated = LVM_TRUE; 325dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 326163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->itfe = &gLvmEffectInterface; 3282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_BASS_BOOST; 3292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Virtualizer 3313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER"); 33229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVirtualizerInstantiated=LVM_TRUE; 333dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VIRTUALIZER; 3372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Equalizer 3393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER"); 34029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bEqualizerInstantiated = LVM_TRUE; 341dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 342163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_EQUALIZER; 3452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Volume 3473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate - Effect to be created is LVM_VOLUME"); 34829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVolumeInstantiated = LVM_TRUE; 349163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VOLUME; 352163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 3543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectCreate() invalid UUID"); 355dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ret = -EINVAL; 356dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent goto exit; 3572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 359dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurentexit: 360dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (ret != 0) { 361dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext != NULL) { 362dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (newBundle) { 363dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_FALSE; 364dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent SessionIndex[sessionNo] = LVM_UNUSED_SESSION; 365dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent delete pContext->pBundledContext; 366dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 367dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent delete pContext; 368dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 369e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent *pHandle = (effect_handle_t)NULL; 370dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } else { 371e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent *pHandle = (effect_handle_t)pContext; 372dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3733856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectCreate end..\n\n"); 374dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return ret; 3752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectCreate */ 3762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 377e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentextern "C" int EffectRelease(effect_handle_t handle){ 3783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\n\tEffectRelease start %p", handle); 379e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EffectContext * pContext = (EffectContext *)handle; 3802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease start handle: %p, context %p", handle, pContext->pBundledContext); 3822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 3833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectRelease called with NULL pointer"); 3842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 385163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 38729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent SessionContext *pSessionContext = &GlobalSessionMemory[pContext->pBundledContext->SessionNo]; 38829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 3892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Clear the instantiated flag for the effect 390dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // protect agains the case where an effect is un-instantiated without being disabled 3912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 3923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag"); 39329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bBassInstantiated = LVM_FALSE; 394dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb > 0){ 395dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 396dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 397dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 0; 3982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VIRTUALIZER) { 3993856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag"); 40029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVirtualizerInstantiated = LVM_FALSE; 401dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ 402dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 403dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 404dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 0; 4052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_EQUALIZER) { 4063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag"); 40729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bEqualizerInstantiated =LVM_FALSE; 408dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq > 0){ 409dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 410dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 411dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 0; 4122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VOLUME) { 4133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag"); 41429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->bVolumeInstantiated = LVM_FALSE; 415dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){ 416dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 417dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 4182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 4193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n"); 4202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 421163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 422dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Disable effect, in this case ignore errors (return codes) 423dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // if an effect has already been disabled 424dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent Effect_setEnabled(pContext, LVM_FALSE); 425dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 4262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // if all effects are no longer instantiaed free the lvm memory and delete BundledEffectContext 42729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if ((pSessionContext->bBassInstantiated == LVM_FALSE) && 42829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bVolumeInstantiated == LVM_FALSE) && 42929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bEqualizerInstantiated ==LVM_FALSE) && 43029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (pSessionContext->bVirtualizerInstantiated==LVM_FALSE)) 4312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 432163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 4338f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmInPtr != NULL) { 4348f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmInPtr); 4358f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmInPtr = NULL; 4368f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 4378f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent if (pContext->pBundledContext->PcmOutPtr != NULL) { 4388f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent fclose(pContext->pBundledContext->PcmOutPtr); 4398f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent pContext->pBundledContext->PcmOutPtr = NULL; 4408f45bd725549436eeacd12ee69349e2332ed8da5Eric Laurent } 441163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 442c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 443c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 444c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Clear the SessionIndex 445c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 446c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(SessionIndex[i] == pContext->pBundledContext->SessionId){ 447e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent SessionIndex[i] = LVM_UNUSED_SESSION; 4483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n", 449c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent i, pContext->pBundledContext->SessionId); 450c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 451c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 452c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 453c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 4543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: All effects are no longer instantiated\n"); 455dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pSessionContext->bBundledEffectsEnabled = LVM_FALSE; 45629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pSessionContext->pBundledContext = LVM_NULL; 4573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Freeing LVM Bundle memory\n"); 458163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmEffect_free(pContext); 4593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext); 460dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->workBuffer != NULL) { 461dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent free(pContext->pBundledContext->workBuffer); 462dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 463163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent delete pContext->pBundledContext; 464c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = LVM_NULL; 4652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // free the effect context for current effect 4672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext; 4682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffectRelease end\n"); 4702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 4712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectRelease */ 4732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4745e92a7861196ddae14638d4b7a63fc4892b7ef59Glenn Kastenextern "C" int EffectGetDescriptor(const effect_uuid_t *uuid, 475e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_descriptor_t *pDescriptor) { 476e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent const effect_descriptor_t *desc = NULL; 477e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 478e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pDescriptor == NULL || uuid == NULL){ 4793856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("EffectGetDescriptor() called with NULL pointer"); 480e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 481e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 482e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 483e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 484e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gBassBoostDescriptor; 485e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 486e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gVirtualizerDescriptor; 487e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 488e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gEqualizerDescriptor; 489e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0) { 490e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &gVolumeDescriptor; 491e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 492e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 493e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (desc == NULL) { 494e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 495e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 496e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 497a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = *desc; 498e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 499e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return 0; 500e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} /* end EffectGetDescriptor */ 501e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 5022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init(){ 5033856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmGlobalBundle_init start"); 5042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 5052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBundledEffectsEnabled = LVM_FALSE; 5062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVolumeInstantiated = LVM_FALSE; 5072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bEqualizerInstantiated = LVM_FALSE; 5082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBassInstantiated = LVM_FALSE; 5092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE; 5102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].pBundledContext = LVM_NULL; 511c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 512e0aed6ddcb4e3c301b80aa26706b6052dab42c41Eric Laurent SessionIndex[i] = LVM_UNUSED_SESSION; 5132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 5152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 5162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_init() 5182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Initialize engine with default configuration, creates instance 5202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// with all effects disabled. 5212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 5232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 5242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 5262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init(EffectContext *pContext){ 5302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status; 5312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init start"); 5332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; 535e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 536e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 537163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.samplingRate = 44100; 538163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.getBuffer = NULL; 539163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL; 540163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.cookie = NULL; 541163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL; 542163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; 543e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; 544e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent pContext->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; 545163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.samplingRate = 44100; 546163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.getBuffer = NULL; 547163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL; 548163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.cookie = NULL; 549163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL; 5502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 5522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext->pBundledContext->hInstance != NULL){ 5543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 5552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Calling pContext->pBassBoost->free()"); 5562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmEffect_free(pContext); 5582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 5602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Called pContext->pBassBoost->free()"); 5612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 5642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 5652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_InstParams_t InstParams; /* Instance parameters */ 5662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_EQNB_BandDef_t BandDefs[MAX_NUM_BANDS]; /* Equaliser band definitions */ 5672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ 5682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomBandDef_t HeadroomBandDef[LVM_HEADROOM_MAX_NBANDS]; 5692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; /* Memory allocation table */ 5702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bool bMallocFailure = LVM_FALSE; 5712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the capabilities */ 573163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent InstParams.BufferMode = LVM_UNMANAGED_BUFFERS; 5742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.MaxBlockSize = MAX_CALL_SIZE; 5752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.EQNB_NumBands = MAX_NUM_BANDS; 5762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.PSA_Included = LVM_PSA_ON; 5772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory, forcing alignment */ 5792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(LVM_NULL, 5802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 5812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 5822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmBundle_init") 5842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 5852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5863856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n"); 5872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory */ 5892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 5902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 5912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size); 5922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 5943856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes " 595d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent "for region %u\n", MemTab.Region[i].Size, i ); 5962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bMallocFailure = LVM_TRUE; 5972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 5983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance allocated %ld bytes for region %u at %p\n", 5992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 6002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* If one or more of the memory regions failed to allocate, free the regions that were 6052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * succesfully allocated and return with an error 6062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 6072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(bMallocFailure == LVM_TRUE){ 6082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 6092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 6103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes " 611d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent "for region %u Not freeing\n", MemTab.Region[i].Size, i ); 6122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 6133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed: but allocated %ld bytes " 614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent "for region %u at %p- free\n", 615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 6162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 6172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 6202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6213856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully malloc'd memory\n"); 6222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Initialise */ 624163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = LVM_NULL; 6252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 626163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Init sets the instance handle */ 627163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetInstanceHandle(&pContext->pBundledContext->hInstance, 6282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 6292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 6302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "LvmBundle_init") 6322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_GetInstanceHandle\n"); 6352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the initial process parameters */ 6372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* General parameters */ 6382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.OperatingMode = LVM_MODE_ON; 6392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SampleRate = LVM_FS_44100; 6402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SourceFormat = LVM_STEREO; 6412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SpeakerType = LVM_HEADPHONES; 6422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 643163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->SampleRate = LVM_FS_44100; 644163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Concert Sound parameters */ 6462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerOperatingMode = LVM_MODE_OFF; 6472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerType = LVM_CONCERTSOUND; 6482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerReverbLevel = 100; 649d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.CS_EffectLevel = LVM_CS_EFFECT_NONE; 6502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* N-Band Equaliser parameters */ 6522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_OperatingMode = LVM_EQNB_OFF; 6532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_NBands = FIVEBAND_NUMBANDS; 6542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.pEQNB_BandDefinition = &BandDefs[0]; 655163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 6572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 6582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 6592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].QFactor = EQNB_5BandPresetsQFactors[i]; 660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDefs[i].Gain = EQNB_5BandSoftPresets[i]; 6612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume Control parameters */ 6642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_EffectLevel = 0; 6652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_Balance = 0; 6662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Treble Enhancement parameters */ 6682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_OperatingMode = LVM_TE_OFF; 6692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_EffectLevel = 0; 6702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 6722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 6732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = (LVM_PSA_DecaySpeed_en)0; 6742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 6762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_OperatingMode = LVM_BE_OFF; 6772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_EffectLevel = 0; 6782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 6792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_HPF = LVM_BE_HPF_ON; 6802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 6822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 6832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM; 6842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 685d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent /* TE Control parameters */ 686d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_OperatingMode = LVM_TE_OFF; 687d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_EffectLevel = 0; 688d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 689163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 690163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, 6912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ¶ms); 6922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmBundle_init") 6942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetControlParameters\n"); 6972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the headroom parameters */ 6992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_Low = 20; 7002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_High = 4999; 7012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Headroom_Offset = 3; 7022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_Low = 5000; 7032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_High = 24000; 7042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Headroom_Offset = 4; 7052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.pHeadroomDefinition = &HeadroomBandDef[0]; 7062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON; 7072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.NHeadroomBands = 2; 7082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetHeadroomParams(pContext->pBundledContext->hInstance, 7102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &HeadroomParams); 7112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetHeadroomParams", "LvmBundle_init") 7132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 7142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetHeadroomParams\n"); 7163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmBundle_init End"); 7172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_init */ 7192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 720dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 7212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_process() 7232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 7252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply LVM Bundle effects 7262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pIn: pointer to stereo 16 bit input data 7292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to stereo 16 bit output data 7302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// frameCount: Frames to process 7312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 7332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 7352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to updated stereo 16 bit output data 7362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_process(LVM_INT16 *pIn, 740163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOut, 741163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int frameCount, 742163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent EffectContext *pContext){ 7432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 7452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 746163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOutTmp; 747dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 748163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){ 749163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOutTmp = pOut; 750163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 751dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->frameCount != frameCount) { 752dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pContext->pBundledContext->workBuffer != NULL) { 753dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent free(pContext->pBundledContext->workBuffer); 754dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 755dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->workBuffer = 756dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent (LVM_INT16 *)malloc(frameCount * sizeof(LVM_INT16) * 2); 757dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->frameCount = frameCount; 758163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 759dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pOutTmp = pContext->pBundledContext->workBuffer; 760163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 7613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("LVM_ERROR : LvmBundle_process invalid access mode"); 762163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 7642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 765163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 766163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pIn, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmInPtr); 767163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmInPtr); 768163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 769163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("Calling LVM_Process"); 771d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 772163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process the samples */ 7732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */ 7742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pIn, /* Input buffer */ 7752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pOutTmp, /* Output buffer */ 7762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_UINT16)frameCount, /* Number of samples to read */ 7772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0); /* Audo Time */ 778163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_Process", "LvmBundle_process") 7802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 7812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 782163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 783163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pOutTmp, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmOutPtr); 784163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmOutPtr); 785163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 786163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 787163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 788163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (int i=0; i<frameCount*2; i++){ 789dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pOut[i] = clamp16((LVM_INT32)pOut[i] + (LVM_INT32)pOutTmp[i]); 790163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 791163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 7922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_process */ 7942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_enable() 7972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Enable the effect in the bundle 7992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 8012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 8022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 8042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable(EffectContext *pContext){ 8083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable start"); 809163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 8112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 8122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 813163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 814163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 8152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 8162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable") 8182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 8193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n"); 8202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 8223856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST"); 8232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_ON; 8242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 8263856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER"); 8272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_ON; 8282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 8303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER"); 8312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_ON; 8322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 8343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_enable : Enabling LVM_VOLUME"); 835163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 836163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 8382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_enable") 8392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 840163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8413856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n"); 8423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_enable end"); 8432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 8442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 8452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_disable() 8482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Disable the effect in the bundle 8502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 8522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 8532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 8552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable(EffectContext *pContext){ 8593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable start"); 860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 8622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 863163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 864163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 8652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 8662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_disable") 8682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 8693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n"); 8702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 8723856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST"); 8732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_OFF; 8742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 8763856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_VIRTUALIZER"); 8772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_OFF; 8782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 8803856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_EQUALIZER"); 8812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_OFF; 8822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 8843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_disable : Disabling LVM_VOLUME"); 885163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 886163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 8882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_disable") 8892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 890163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n"); 8923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tLvmEffect_disable end"); 8932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 8942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 8952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_free() 8982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Free all memory associated with the Bundle. 9002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 9052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free(EffectContext *pContext){ 9092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 9102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 9112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; 9122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Free the algorithm memory */ 9142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(pContext->pBundledContext->hInstance, 9152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 9162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_NULL); 9172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmEffect_free") 9192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 9212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 9222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress != NULL){ 9233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_free - START freeing %ld bytes for region %u at %p\n", 9242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 9252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 9272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLvmEffect_free - END freeing %ld bytes for region %u at %p\n", 9292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 9302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 9313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : LvmEffect_free - trying to free with NULL pointer %ld bytes " 9322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "for region %u at %p ERROR\n", 9332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 9342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmEffect_free */ 9382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9403d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Effect_setConfig() 9412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Set input and output audio configuration. 9432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pConfig: pointer to effect_config_t structure holding input and output 9472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// configuration parameters 9482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 9502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9533d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentint Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){ 954163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_Fs_en SampleRate; 9553d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_setConfig start"); 9562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 9582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig != NULL); 9592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate); 9612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels); 9622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format); 963e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent CHECK_ARG(pConfig->inputCfg.channels == AUDIO_CHANNEL_OUT_STEREO); 9642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE 9652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE); 966e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT); 9672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 968a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten pContext->config = *pConfig; 9692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 970163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent switch (pConfig->inputCfg.samplingRate) { 971163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 8000: 972163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_8000; 973c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 8000*2; // 2 secs Stereo 974163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 975163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 16000: 976163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_16000; 977c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 16000*2; // 2 secs Stereo 978163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 979163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 22050: 980163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_22050; 981c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 22050*2; // 2 secs Stereo 982163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 983163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 32000: 984163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_32000; 985c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 32000*2; // 2 secs Stereo 986163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 987163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 44100: 988163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_44100; 989c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 44100*2; // 2 secs Stereo 990163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 991163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 48000: 992163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_48000; 993c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo 994163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 995163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent default: 9963d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tEffect_setConfig invalid sampling rate %d", pConfig->inputCfg.samplingRate); 997163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 998163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 9992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1000163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->SampleRate != SampleRate){ 10012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1002163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; 1003163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; 10042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10053d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tEffect_setConfig change sampling rate to %d", SampleRate); 10062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1007163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1008163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1009163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 10102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10113d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_setConfig") 1012163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 10132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1014163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 10152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10163d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_setConfig") 10173d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tEffect_setConfig Succesfully called LVM_SetControlParameters\n"); 1018c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SampleRate = SampleRate; 10192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1020163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 10213d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_setConfig keep sampling rate at %d", SampleRate); 1022163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 10232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10243d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_setConfig End...."); 1025163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 10263d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent} /* end Effect_setConfig */ 10273d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 10283d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent//---------------------------------------------------------------------------- 10293d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Effect_getConfig() 10303d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent//---------------------------------------------------------------------------- 10313d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Purpose: Get input and output audio configuration. 10323d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// 10333d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Inputs: 10343d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// pContext: effect engine context 10353d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// pConfig: pointer to effect_config_t structure holding input and output 10363d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// configuration parameters 10373d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// 10383d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// Outputs: 10393d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent// 10403d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent//---------------------------------------------------------------------------- 10413d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 10423d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurentvoid Effect_getConfig(EffectContext *pContext, effect_config_t *pConfig) 10433d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent{ 1044a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pConfig = pContext->config; 10453d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent} /* end Effect_getConfig */ 10462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassGetStrength() 10492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 10522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 10532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// the bassboost uses 1-15, so to avoid a quantisation the original set value is used. However the 10542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 10552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t BassGetStrength(EffectContext *pContext){ 10623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved); 10632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1066163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1067163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 10682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 10692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassGetStrength") 10712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 10722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10733856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n"); 10742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Check that the strength returned matches the strength that was set earlier */ 1076163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(ActiveParams.BE_EffectLevel != 1077163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){ 10783856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n", 10792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved); 10802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 10812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 10822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 10843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassGetStrength() (saved) -> %d\n", pContext->pBundledContext->BassStrengthSaved ); 10852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return pContext->pBundledContext->BassStrengthSaved; 10862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassGetStrength */ 10872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassSetStrength() 10902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the BassBosst. Must first be converted from the range 0-1000 to 1-15 10932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 10972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid BassSetStrength(EffectContext *pContext, uint32_t strength){ 11013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength(%d)", strength); 11022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->BassStrengthSaved = (int)strength; 11042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 11062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 11072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 11092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 11102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 11112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassSetStrength") 11133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength Succesfully returned from LVM_GetControlParameters\n"); 11142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 11162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel = (LVM_INT16)((15*strength)/1000); 11172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 11182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 11202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 11222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 11232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength") 11253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n"); 11262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassSetStrength */ 11272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerGetStrength() 11302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 11332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 1134163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// the Virtualizer uses 1-100, so to avoid a quantisation the original set value is used.However the 11352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 11362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t VirtualizerGetStrength(EffectContext *pContext){ 11433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved); 11442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 11462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 11472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 11492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerGetStrength") 11512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 11522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n"); 11543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerGetStrength() (0-100) -> %d\n", ActiveParams.VirtualizerReverbLevel*10); 1155d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent return pContext->pBundledContext->VirtStrengthSaved; 11562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getStrength */ 11572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerSetStrength() 11602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the Virtualizer. Must first be converted from the range 0-1000 to 1-15 11632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 11672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){ 11713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength(%d)", strength); 11722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 11732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 11742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1175163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = (int)strength; 1176163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 11772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 11782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 11792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerSetStrength") 11813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n"); 11822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Virtualizer parameters */ 1184d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent ActiveParams.CS_EffectLevel = (int)((strength*32767)/1000); 11852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11863856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength ); 11873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel ); 11882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 11902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 11912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength") 11923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n"); 11932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setStrength */ 11942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandLevel() 11972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the gain currently being used for the band passed in 11992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 12022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){ 12082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1209163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Gain =0; 1210163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1211163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1212163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1213163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1214163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1215163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 12162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1217163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetBandLevel") 12182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1219163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1220163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Gain = (int32_t)BandDef[band].Gain*100; // Convert to millibels 12212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12223856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetBandLevel -> %d\n", Gain ); 12233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 1224163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Gain; 12252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetBandLevel() 12292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets gain value for the given band. 12322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 12352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gain: Gain to be applied in millibels 12362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--------------------------------------------------------------------------- 1241d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentvoid EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){ 1242163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int gainRounded; 1243163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(Gain > 0){ 1244163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain+50)/100); 1245163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1246163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain-50)/100); 1247163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 12483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded); 1249163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1250163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 12512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 12522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1253163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 12542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 12562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1257163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetBandLevel") 12583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 12593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel just Got -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain); 12602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set local EQ parameters */ 1262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1263163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[band].Gain = gainRounded; 12642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 12662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetBandLevel") 12683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetBandLevel just Set -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain); 12692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 12712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 12722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetCentreFrequency() 12752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the frequency being used for the band passed in 12772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 12802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetCentreFrequency(EffectContext *pContext, int32_t band){ 1286163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Frequency =0; 12872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1288163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1289163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1290163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1291163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1292163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1293163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 12942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1295163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetCentreFrequency") 12962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1297163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1298163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Frequency = (int32_t)BandDef[band].Frequency*1000; // Convert to millibels 12992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetCentreFrequency -> %d\n", Frequency ); 13013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetCentreFrequency Succesfully returned from LVM_GetControlParameters\n"); 1302163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Frequency; 13032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandFreqRange( 13072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets lower and upper boundaries of a band. 13112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the high shelf, the low bound is the band frequency and the high 13122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// bound is Nyquist. 13132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the peaking filters, they are the gain[dB]/2 points. 13142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 13172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 13202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 13212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 13222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1323163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t EqualizerGetBandFreqRange(EffectContext *pContext, int32_t band, uint32_t *pLow, 1324163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t *pHi){ 1325163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pLow = bandFreqRange[band][0]; 1326163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pHi = bandFreqRange[band][1]; 1327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 13282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBand( 13322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Returns the band with the maximum influence on a given frequency. 13362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Result is unaffected by whether EQ is enabled or not, or by whether 13372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// changes have been committed or not. 13382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// targetFreq The target frequency, in millihertz. 13412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 13442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 13452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 13462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBand(EffectContext *pContext, uint32_t targetFreq){ 13482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int band = 0; 13492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1350163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(targetFreq < bandFreqRange[0][0]){ 1351163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1352163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if(targetFreq == bandFreqRange[0][0]){ 1353163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1354163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1355163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for(int i=0; i<FIVEBAND_NUMBANDS;i++){ 1356163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((targetFreq > bandFreqRange[i][0])&&(targetFreq <= bandFreqRange[i][1])){ 1357163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent band = i; 1358163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1359163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 13602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return band; 13612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPreset( 13652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets the currently set preset ID. 13692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Will return PRESET_CUSTOM in case the EQ parameters have been modified 13702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// manually since a preset was set. 13712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetPreset(EffectContext *pContext){ 1377163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return pContext->pBundledContext->CurPreset; 13782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetPreset( 13822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets the current preset by ID. 13862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// All the band parameters will be overridden. 13872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. 13912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid EqualizerSetPreset(EffectContext *pContext, int preset){ 13942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset(%d)", preset); 13962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = preset; 13972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 14002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 14022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1403163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetPreset") 14043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset Succesfully returned from LVM_GetControlParameters\n"); 14052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //ActiveParams.pEQNB_BandDefinition = &BandDefs[0]; 14072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 14082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 1409163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 1410163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i]; 1411163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Gain 1412163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent = EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS]; 14132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 14142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the new settings */ 14152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1416163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetPreset") 14172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n"); 14192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 14202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 1421163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 14222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetNumPresets(){ 1423163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return sizeof(gEqualizerPresets) / sizeof(PresetConfig); 14242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 14252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPresetName( 14282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets a human-readable name for a preset ID. Will return "Custom" if 14312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// PRESET_CUSTOM is passed. 14322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. Must be less than number of presets. 14352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//------------------------------------------------------------------------- 14372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst char * EqualizerGetPresetName(int32_t preset){ 14383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetPresetName start(%d)", preset); 14392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (preset == PRESET_CUSTOM) { 14402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return "Custom"; 14412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 14422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return gEqualizerPresets[preset].name; 14432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 14443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizerGetPresetName end(%d)", preset); 1445163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 14462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 14472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetVolumeLevel() 14502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 14552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// level level to be applied 14562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){ 14602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 14622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 14632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel Level to be set is %d %d\n", level, (LVM_INT16)(level/100)); 14652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 14662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 14682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters got: %d\n", 1470163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.VC_EffectLevel); 14712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume parameters */ 14732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VC_EffectLevel = (LVM_INT16)(level/100); 14743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 14752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 14772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetVolumeLevel") 14792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n"); 1482163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1483163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1484163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1485163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 1486163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1487163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 14883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetVolumeLevel just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel ); 1489d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent if(pContext->pBundledContext->firstVolume == LVM_TRUE){ 1490d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); 1491d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process") 14923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks"); 1493d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->firstVolume = LVM_FALSE; 1494d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent } 14952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 149617a736c3e1d062d7fc916329eb32aef8935614afGlenn Kasten} /* end VolumeSetVolumeLevel */ 14972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeGetVolumeLevel() 15002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){ 15092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel start"); 1511163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 15122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 15132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 15142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 15162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetVolumeLevel") 15172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 15182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 15203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n"); 15212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *level = ActiveParams.VC_EffectLevel*100; // Convert dB to millibels 15233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetVolumeLevel end"); 15242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 15252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end VolumeGetVolumeLevel */ 15262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetMute() 15292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 15352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){ 15393856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute start(%d)", mute); 15402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bMuteEnabled = mute; 15422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 15442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 15452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 15472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 15482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetMute") 15492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 15502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n"); 15523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute to %d, level was %d\n", mute, ActiveParams.VC_EffectLevel ); 15532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set appropriate volume level */ 15552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){ 1556163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = ActiveParams.VC_EffectLevel; 1557163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = -96; 15582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 1559163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = pContext->pBundledContext->levelSaved; 15602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 15612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 15632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 15642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetMute") 15652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 15662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n"); 15683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetMute end"); 15692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 15702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setMute */ 15712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1573163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetMute() 15742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 15782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 15792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 15802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Ourputs: 15812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 15822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){ 15853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetMute start"); 1586163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)|| 1587163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){ 1588163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *mute = pContext->pBundledContext->bMuteEnabled; 1589163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 15902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 15913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d", 1592163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled); 1593163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 15942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 15953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetMute end"); 15962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getMute */ 15972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1598163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint16_t VolumeConvertStereoPosition(int16_t position){ 1599163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t convertedPosition = 0; 1600163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1601163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent convertedPosition = (int16_t)(((float)position/1000)*96); 1602163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return convertedPosition; 1603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1604163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 1605163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1606163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1607163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeSetStereoPosition() 1608163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1609163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1610163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1611163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1612163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1613163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1616163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1617163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint VolumeSetStereoPosition(EffectContext *pContext, int16_t position){ 1619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1620163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1621163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1622163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Balance = 0; 1623163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1624c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 1625163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1626163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1627163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1628163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1630d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1631163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Position to be set is %d %d\n", position, Balance); 1635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1636163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1637163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1638163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1639163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 16403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got:" 1641163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // " %d\n", ActiveParams.VC_Balance); 1642163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1643163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Volume parameters */ 1644163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = Balance; 16453856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition() (-96dB -> +96dB) -> %d\n", ActiveParams.VC_Balance ); 1646163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1647163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1648163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1649163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 1650163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1651163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully called LVM_SetControlParameters\n"); 16532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1655163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1656163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1657163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 16583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got: " 1659163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "%d\n", ActiveParams.VC_Balance); 1660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1661163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent else{ 16623856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition Position attempting to set, but not enabled %d %d\n", 1663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //position, Balance); 1664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 16653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n", 1666d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1667163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1668163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeSetStereoPosition */ 16692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1671163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1672163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetStereoPosition() 1673163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1674163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1675163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1676163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1677163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1678163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1679163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1680163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1681163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 16822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1683163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeGetStereoPosition(EffectContext *pContext, int16_t *position){ 16843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition start"); 16852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1686163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1687163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1688163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 balance; 1689163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1691d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1692163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1694163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition") 1695163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1696163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 16973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition -> %d\n", ActiveParams.VC_Balance); 16983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 1699163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1700163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1701163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1702163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1703163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(balance != ActiveParams.VC_Balance){ 1704163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1705163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1706163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1707163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *position = (LVM_INT16)pContext->pBundledContext->positionSaved; // Convert dB to millibels 17083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved =%d\n", 1709d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1710163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1711163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeGetStereoPosition */ 17122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1713163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1714163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeEnableStereoPosition() 1715163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1716163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1717163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1718163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1719163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1720163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// mute: enable/disable flag 1721163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1722163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 17232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1724163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){ 17253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition start()"); 17262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1727163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = enabled; 17282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1729163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1730163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 17312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1732163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1733163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1734163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeEnableStereoPosition") 1735163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 17362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 17383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition to %d, position was %d\n", 1739163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // enabled, ActiveParams.VC_Balance ); 17402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1741163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Set appropriate stereo position */ 1742163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_FALSE){ 1743163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 0; 1744163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1745163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 1746163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1747163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 17482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1749163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1750163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1751163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeEnableStereoPosition") 1752163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 17532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition Succesfully called LVM_SetControlParameters\n"); 17553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolumeEnableStereoPosition end()\n"); 1756163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeEnableStereoPosition */ 17582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_getParameter() 17612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a BassBoost parameter 17642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 17672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 17682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 17692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 17702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 17722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 17732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 17742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 17772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint BassBoost_getParameter(EffectContext *pContext, 1781c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1782163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent size_t *pValueSize, 1783163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue){ 17842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 1785c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1786c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 17872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 17882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 17892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter start"); 17912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 179323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 17947fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 17953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize1 %d", *pValueSize); 17967fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 17977fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 17987fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 17997fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 18002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 18012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 18023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize); 18032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 18062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18093856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 18102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 181423e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 18152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 18162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED Value is %d", 1818163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 18192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 18222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = BassGetStrength(pContext); 18232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18243856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d", 1825163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 18262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 18302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 18312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_getParameter end"); 18352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 18362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_getParameter */ 18372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_setParameter() 18402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 18422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a BassBoost parameter 18432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 18452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 18462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 18472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 18482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 18502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1853c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 18542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 18552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 1856c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 18572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18583856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter start"); 18592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1860c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (*pParamTemp){ 18612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 18622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 18633856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength); 18643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength"); 18652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BassSetStrength(pContext, (int32_t)strength); 18663856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength"); 18672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18693856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp); 18702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18733856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_setParameter end"); 18742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 18752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_setParameter */ 18762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_getParameter() 18792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 18812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Virtualizer parameter 18822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 18842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 18852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 18862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 18872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 18882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 18902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 18912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 18922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 18952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter(EffectContext *pContext, 1899c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 19002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 19012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 19022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 1903c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1904c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 19052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 19062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 19072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter start"); 19092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 191123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 19127fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 19133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize); 19147fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 19157fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 19167fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 19177fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 19182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 19192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 19203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize); 19212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 19222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 19242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 19282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 19292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 193223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 19332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 19342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED Value is %d", 1936163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 19372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 19402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = VirtualizerGetStrength(pContext); 19412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d", 1943163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 19442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 19482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_getParameter end"); 19532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 19542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_getParameter */ 19552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_setParameter() 19582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 19602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Virtualizer parameter 19612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 19632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 19642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 19652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 19662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 19682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1971c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 19722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 19732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 1974c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1975c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 19762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter start"); 19782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1979c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 19802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 19812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 19823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength); 19833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength"); 19842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent VirtualizerSetStrength(pContext, (int32_t)strength); 19853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength"); 19862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param); 19892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_setParameter end"); 19932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 19942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_setParameter */ 19952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_getParameter() 19982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 20002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Equalizer parameter 20012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 20032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 20042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 20052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 20062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 20072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 20092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 20102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 20112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 20142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter(EffectContext *pContext, 2017c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 20182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 20192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 20202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 20212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 2022c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2023c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 20242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 20252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 20262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter start"); 20282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 20302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 20312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 20322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 20333be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_BAND_LEVEL: 20343be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_GET_BAND: 20352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int16_t)) { 20363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 20372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 20402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 20433be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (*pValueSize < 2 * sizeof(int16_t)) { 20443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize); 20453be9523784cc4038f601e510faee595117cdacb3Eric Laurent return -EINVAL; 20463be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 20473be9523784cc4038f601e510faee595117cdacb3Eric Laurent *pValueSize = 2 * sizeof(int16_t); 20483be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 20492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 20502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < 2 * sizeof(int32_t)) { 20513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 3 %d", *pValueSize); 20522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = 2 * sizeof(int32_t); 20552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20563be9523784cc4038f601e510faee595117cdacb3Eric Laurent 20572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 20582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)) { 20593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 5 %d", *pValueSize); 20602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 20632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 20662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 206823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: 206923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent if (*pValueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t)) { 20703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 207123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent return -EINVAL; 207223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 207323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent *pValueSize = (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t); 207423e1de74359f4bb1763aef0adfebe073122b032cEric Laurent break; 207523e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 20762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param); 20782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 20822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 20833be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)FIVEBAND_NUMBANDS; 20843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue); 20852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 20883be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = -1500; 20893be9523784cc4038f601e510faee595117cdacb3Eric Laurent *((int16_t *)pValue + 1) = 1500; 20903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", 2091d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue, *((int16_t *)pValue + 1)); 20922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2095c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 20972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21003be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2); 21013856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", 2102163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 21032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 2106c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 21072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 21082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2); 21123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", 2113163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 21142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 2117c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 21182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 21192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1)); 21233856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", 2124163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue, *((int32_t *)pValue + 1)); 21252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_BAND: 2128c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 21293be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2); 21303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", 2131d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // param2, *(uint16_t *)pValue); 21322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 21353be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext); 21363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue); 21372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 21403be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetNumPresets(); 21413856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue); 21422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 2145c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 21462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= EqualizerGetNumPresets()) { 21472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //if (param2 >= 20) { // AGO FIX 21482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name = (char *)pValue; 21522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1); 21532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name[*pValueSize - 1] = 0; 21542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = strlen(name) + 1; 21553856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", 2156163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, gEqualizerPresets[param2].name, *pValueSize); 21572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 215923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: { 21603be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 21613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES"); 21623be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[0] = (int16_t)EqualizerGetPreset(pContext); 21633be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[1] = (int16_t)FIVEBAND_NUMBANDS; 216423e1de74359f4bb1763aef0adfebe073122b032cEric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 21653be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[2 + i] = (int16_t)EqualizerGetBandLevel(pContext, i); 216623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 216723e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } break; 216823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 21692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 21703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param); 21712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2175d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //GV("\tEqualizer_getParameter end\n"); 21762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 21772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_getParameter */ 21782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_setParameter() 21812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 21832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Equalizer parameter 21842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 21862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 21872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 21882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 21892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 21912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 2193c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 21942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 21952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t preset; 21962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t band; 21972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t level; 2198c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2199c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 2200c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 22012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter start"); 22032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 22042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 22053be9523784cc4038f601e510faee595117cdacb3Eric Laurent preset = (int32_t)(*(uint16_t *)pValue); 22062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset); 22082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ((preset >= EqualizerGetNumPresets())||(preset < 0)) { 22092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 22102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetPreset(pContext, preset); 22132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2215c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent band = *pParamTemp; 22163be9523784cc4038f601e510faee595117cdacb3Eric Laurent level = (int32_t)(*(int16_t *)pValue); 22173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level); 22182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (band >= FIVEBAND_NUMBANDS) { 22192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 22202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetBandLevel(pContext, band, level); 22232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22243be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_PROPERTIES: { 22253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES"); 22263be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 22273be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[0] >= EqualizerGetNumPresets()) { 22283be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 22293be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 22303be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22313be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (p[0] >= 0) { 22323be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetPreset(pContext, (int)p[0]); 22333be9523784cc4038f601e510faee595117cdacb3Eric Laurent } else { 22343be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[1] != FIVEBAND_NUMBANDS) { 22353be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 22363be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 22373be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22383be9523784cc4038f601e510faee595117cdacb3Eric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 22393be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetBandLevel(pContext, i, (int)p[2 + i]); 22403be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22413be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 22423be9523784cc4038f601e510faee595117cdacb3Eric Laurent } break; 22432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 22443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_setParameter() invalid param %d", param); 22453be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 22462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22493856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_setParameter end"); 22502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 22512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_setParameter */ 22522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_getParameter() 22552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 22572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Volume parameter 22582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 22602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 22612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 22622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 22632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 22642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 22662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 22672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 22682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 22712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter(EffectContext *pContext, 2275c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 22762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 22772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 22782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 22792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 2280c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2281c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++;; 22822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 22832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter start"); 22852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 22872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 22882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 22892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2290163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (*pValueSize != sizeof(int16_t)){ 22913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1 %d", *pValueSize); 22922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 22952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 22982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 22992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)){ 23003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2 %d", *pValueSize); 23012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 23042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 23073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param); 23082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 23122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 23132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue)); 23143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d", 2315d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 23162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 23192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = 0; 23203856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d", 2321d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 23222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2325163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeGetStereoPosition(pContext, (int16_t *)pValue); 23263856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d", 2327d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 23282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeGetMute(pContext, (uint32_t *)pValue); 23323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d", 2333163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(uint32_t *)pValue); 23342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2337163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled; 23383856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d", 2339d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(uint32_t *)pValue); 23402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 23433856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param); 23442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 23452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_getParameter end"); 23492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 23502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_getParameter */ 23512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 23542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_setParameter() 23552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 23562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 23572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Volume parameter 23582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 23592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 23602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 23612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 23622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 23632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 23642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 23652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 23662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 23672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2368c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 23692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 23702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t level; 2371163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t position; 23722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent uint32_t mute; 2373163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t positionEnabled; 2374c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2375c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 23762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter start"); 23782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2379c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 23802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 23812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent level = *(int16_t *)pValue; 23823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level); 23833856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel"); 23842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeSetVolumeLevel(pContext, (int16_t)level); 23853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel"); 23862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2389163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent mute = *(uint32_t *)pValue; 23903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute); 23913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->setMute"); 2392163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetMute(pContext, mute); 23933856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->setMute"); 2394163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 23952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2397163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent positionEnabled = *(uint32_t *)pValue; 2398163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeEnableStereoPosition(pContext, positionEnabled); 2399163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved); 24003856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called"); 2401163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 24022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2404163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent position = *(int16_t *)pValue; 24053856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position); 24063856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition"); 2407163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, (int16_t)position); 24083856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition"); 2409163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 24102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 24123856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param); 24132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_setParameter end"); 24172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 24182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_setParameter */ 24192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2420163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent/**************************************************************************************** 2421163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Name : LVC_ToDB_s32Tos16() 2422163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Input : Signed 32-bit integer 2423163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Output : Signed 16-bit integer 2424163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * MSB (16) = sign bit 2425163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (15->05) = integer part 2426163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (04->01) = decimal part 2427163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Returns : Db value with respect to full scale 2428163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Description : 2429163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Remarks : 2430163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ****************************************************************************************/ 2431163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2432163fbcf84010b98e0374110454d85b804bc8d13bEric LaurentLVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) 2433163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent{ 2434163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 db_fix; 2435163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Shift; 2436163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 SmallRemainder; 2437163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_UINT32 Remainder = (LVM_UINT32)Lin_fix; 2438163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2439163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Count leading bits, 1 cycle in assembly*/ 2440163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (Shift = 0; Shift<32; Shift++) 2441163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2442163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((Remainder & 0x80000000U)!=0) 2443163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2444163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2445163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2446163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Remainder = Remainder << 1; 2447163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2449163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* 2450163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Based on the approximation equation (for Q11.4 format): 2451163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * 2452163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * dB = -96 * Shift + 16 * (8 * Remainder - 2 * Remainder^2) 2453163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent */ 2454163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(-96 * Shift); /* Six dB steps in Q11.4 format*/ 2455163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)((Remainder & 0x7fffffff) >> 24); 2456163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix + SmallRemainder ); 2457163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)(SmallRemainder * SmallRemainder); 2458163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - (LVM_INT16)((LVM_UINT16)SmallRemainder >> 9)); 24592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2460163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Correct for small offset */ 2461163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - 5); 24622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2463163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return db_fix; 2464163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 24652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 246629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 246729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Effect_setEnabled() 246829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 246929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Purpose: 247029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Enable or disable effect 247129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 247229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Inputs: 247329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// pContext - pointer to effect context 247429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// enabled - true if enabling the effect, false otherwise 247529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 247629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// Outputs: 247729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent// 247829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent//---------------------------------------------------------------------------- 247929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 248029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurentint Effect_setEnabled(EffectContext *pContext, bool enabled) 248129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent{ 24823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() type %d, enabled %d", pContext->EffectType, enabled); 248329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 248429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (enabled) { 2485b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent // Bass boost or Virtualizer can be temporarily disabled if playing over device speaker due 2486b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent // to their nature. 2487b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent bool tempDisabled = false; 248829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent switch (pContext->EffectType) { 248929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_BASS_BOOST: 249029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 24913856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already enabled"); 249229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 249329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2494dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb <= 0){ 2495dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2496dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 249729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 249829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 249929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bBassEnabled = LVM_TRUE; 2500b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent tempDisabled = pContext->pBundledContext->bBassTempDisabled; 250129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 250229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_EQUALIZER: 250329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) { 25043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already enabled"); 250529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 250629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2507dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq <= 0){ 2508dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2509dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 251029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 251129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 251229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE; 251329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 251429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VIRTUALIZER: 251529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { 25163856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already enabled"); 251729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 251829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2519dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt <= 0){ 2520dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2521dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 252229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 252329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1); 252429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE; 2525b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent tempDisabled = pContext->pBundledContext->bVirtualizerTempDisabled; 252629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 252729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VOLUME: 252829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE) { 25293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VOLUME is already enabled"); 253029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 253129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2532dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 253329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_TRUE; 253429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 253529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent default: 25363856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() invalid effect type"); 253729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 253829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 2539b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (!tempDisabled) { 2540b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent LvmEffect_enable(pContext); 2541b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent } 254229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } else { 254329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent switch (pContext->EffectType) { 254429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_BASS_BOOST: 254529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_FALSE) { 25463856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already disabled"); 254729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 254829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 254929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 255029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 255129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_EQUALIZER: 255229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE) { 25533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already disabled"); 255429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 255529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 255629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 255729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 255829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VIRTUALIZER: 255929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE) { 25603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already disabled"); 256129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 256229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 256329cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 256429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 256529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent case LVM_VOLUME: 256629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent if (pContext->pBundledContext->bVolumeEnabled == LVM_FALSE) { 25673856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() LVM_VOLUME is already disabled"); 256829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 256929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 257029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 257129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent break; 257229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent default: 25733856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_setEnabled() invalid effect type"); 257429cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return -EINVAL; 257529cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 257629cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent LvmEffect_disable(pContext); 257729cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent } 257829cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 257929cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent return 0; 258029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent} 258129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 2582dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//---------------------------------------------------------------------------- 2583dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// LVC_Convert_VolToDb() 2584dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//---------------------------------------------------------------------------- 2585dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Purpose: 2586dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Convery volume in Q24 to dB 2587dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// 2588dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// Inputs: 2589dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// vol: Q.24 volume dB 2590dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent// 2591dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//----------------------------------------------------------------------- 2592dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2593dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurentint16_t LVC_Convert_VolToDb(uint32_t vol){ 2594dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t dB; 2595dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2596dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = LVC_ToDB_s32Tos16(vol <<7); 2597dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = (dB +8)>>4; 2598dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent dB = (dB <-96) ? -96 : dB ; 2599dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2600dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return dB; 2601dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent} 2602dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 2604163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 26052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2606e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentextern "C" { 26072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Process */ 2608e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_process(effect_handle_t self, 2609163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *inBuffer, 2610163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *outBuffer){ 26112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 2612c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 26132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 2614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int lvmStatus = 0; 2615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *in = (LVM_INT16 *)inBuffer->raw; 2616163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw; 26172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26183856b090cd04ba5dd4a59a12430ed724d5995909Steve Block//ALOGV("\tEffect_process Start : Enabled = %d Called = %d (%8d %8d %8d)", 2619dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent//pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled, 2620c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountBb, 2621c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountVirt, 2622c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountEq); 2623c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 26242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 26253856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL"); 26262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2628dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 2629dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //if(pContext->EffectType == LVM_BASS_BOOST){ 26303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is BASS_BOOST"); 2631dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //}else if(pContext->EffectType == LVM_EQUALIZER){ 26323856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is LVM_EQUALIZER"); 2633dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //}else if(pContext->EffectType == LVM_VIRTUALIZER){ 26343856b090cd04ba5dd4a59a12430ed724d5995909Steve Block // ALOGV("\tEffect_process: Effect type is LVM_VIRTUALIZER"); 2635dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //} 2636dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 26372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (inBuffer == NULL || inBuffer->raw == NULL || 26382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer == NULL || outBuffer->raw == NULL || 26392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent inBuffer->frameCount != outBuffer->frameCount){ 26403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG"); 26412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2643163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&& 2644163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_BASS_BOOST)){ 26453856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled"); 2646c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb > 0){ 2647c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO 26483856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting to turn off BASS_BOOST, %d samples left", 2649c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountBb); 2650d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2651d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb <= 0) { 265229cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent status = -ENODATA; 2653dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 26543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_BASS_BOOST"); 2655c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 2656163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2657163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&& 2658163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VOLUME)){ 26593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_VOLUME Effect is not enabled"); 2660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2661dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 2662163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&& 2664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_EQUALIZER)){ 26653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled"); 2666c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq > 0){ 2667c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO 26683856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting to turn off EQUALIZER, %d samples left", 2669c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountEq); 2670d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2671d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq <= 0) { 2672c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2673dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 26743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_EQUALIZER"); 2675c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 26762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2677163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&& 2678163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VIRTUALIZER)){ 26793856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled"); 2680c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ 2681c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO 26823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process: Waiting for to turn off VIRTUALIZER, %d samples left", 2683c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountVirt); 2684d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent } 2685d71a0e1ac517cf312b9a96fe5ba9de04f2b9ffd4Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) { 2686c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2687dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 26883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() this is the last frame for LVM_VIRTUALIZER"); 2689c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 26902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2692dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(status != -ENODATA){ 2693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled++; 26942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2696163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->NumberEffectsCalled == 2697163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled){ 26983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d", 2699163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2700163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 27012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2702163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 27033856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_process() processing last frame"); 2704163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 2706163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process all the available frames, block processing is 2707163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent handled internalLY by the LVM bundle */ 2708163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent lvmStatus = android::LvmBundle_process( (LVM_INT16 *)inBuffer->raw, 27092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_INT16 *)outBuffer->raw, 27102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer->frameCount, 27112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext); 2712163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(lvmStatus != LVM_SUCCESS){ 27133856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus); 2714163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return lvmStatus; 2715163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27165dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent } else { 27173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d", 2718163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2719163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 2720163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // 2 is for stereo input 27215dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) { 27225dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent for (size_t i=0; i < outBuffer->frameCount*2; i++){ 27235dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent outBuffer->s16[i] = 27245dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent clamp16((LVM_INT32)outBuffer->s16[i] + (LVM_INT32)inBuffer->s16[i]); 27255dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent } 27265dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent } else { 27275dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2); 27285dc65e2ce92c7364da60bdff5f345daf145c2c0fEric Laurent } 27292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2730163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 27312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 27322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_process */ 27332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Command */ 2735e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_command(effect_handle_t self, 273625f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdCode, 273725f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdSize, 2738163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pCmdData, 273925f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t *replySize, 2740163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pReplyData){ 27412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 27422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int retsize; 27432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\t\nEffect_command start"); 27452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 27473856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_BASS_BOOST"); 27482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 27503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_VIRTUALIZER"); 2751163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 27533856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_EQUALIZER"); 2754163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 27563856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command setting command for LVM_VOLUME"); 2757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 27603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL"); 27612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize); 27652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2766163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Incase we disable an effect, next time process is 2767163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // called the number of effect called could be greater 2768163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled = 0; 27692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27703856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", 2771163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled, 2772163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 27732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (cmdCode){ 27752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_INIT: 2776010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 27773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d", 2778010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent pContext->EffectType); 2779010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent return -EINVAL; 2780010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent } 2781010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = 0; 27823856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start"); 27832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 27843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST"); 27852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::BassSetStrength(pContext, 0); 27862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 27883856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER"); 2789163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VirtualizerSetStrength(pContext, 0); 2790163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 27923856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER"); 2793163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::EqualizerSetPreset(pContext, 0); 2794163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 27963856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VOLUME"); 2797010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0); 2798163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2800163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28013d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent case EFFECT_CMD_SET_CONFIG: 28023d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_CONFIG start"); 28032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL|| 28042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize != sizeof(effect_config_t)|| 28052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 28062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int)){ 28073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 28083d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent "EFFECT_CMD_SET_CONFIG: ERROR"); 28093d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent return -EINVAL; 28103d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent } 28113d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent *(int *) pReplyData = android::Effect_setConfig(pContext, (effect_config_t *) pCmdData); 28123d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_CONFIG end"); 28133d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent break; 28143d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 28153d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent case EFFECT_CMD_GET_CONFIG: 28163d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent if (pReplyData == NULL || 28173d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent *replySize != sizeof(effect_config_t)) { 28183d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 28193d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent "EFFECT_CMD_GET_CONFIG: ERROR"); 28202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28223d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent 28233d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent android::Effect_getConfig(pContext, (effect_config_t *)pReplyData); 28242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 28252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_RESET: 28273856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start"); 28283d5188bd6abe55898f10a0edf3c05aff8aa2ef67Eric Laurent android::Effect_setConfig(pContext, &pContext->config); 28293856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end"); 28302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 28312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_GET_PARAM:{ 28333856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2834163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2836163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2837163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2838163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2839163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 28403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 28412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 28422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 28452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 28472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 28492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 28512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::BassBoost_getParameter(pContext, 2853c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 28542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 28552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 28562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 28582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28593856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM " 2860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2861163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2862163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2863163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 28642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2865163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2867163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2868163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2869163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2870163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 28713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 28722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 28732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 28762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 28782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 28802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 28822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Virtualizer_getParameter(pContext, 2884c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 28852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 28862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 28872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 28892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28903856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM " 2891163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2892163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2893163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2894163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 28952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 28973856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command cmdCode Case: " 2898163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 2899163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2900163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2901163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2902163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) { 29033856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 29042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM"); 29052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 2908163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 29092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 2910163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 29112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 2912163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 29132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 2914163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2915c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->status = android::Equalizer_getParameter(pContext, 2916c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 2917c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent &p->vsize, 2918c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data + voffset); 2919163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 29202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 2921163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 29223856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, " 2923163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pReplyData %08x %08x", 2924163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize, 2925163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset), 2926163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + 2927163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // sizeof(int32_t))); 29282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 29303856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2931163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2932163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2933163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2934163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 29353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 29362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 29372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 29402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 29422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 29442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 29462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Volume_getParameter(pContext, 2948c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 29492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 29502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 29512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 29532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command EFFECT_CMD_GET_PARAM " 2955163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2956163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2957163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2958163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 2959163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 29603856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end"); 29612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 29622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_PARAM:{ 29633856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 29642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 29653856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 2966dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2967dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *replySize, 2968dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2969163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2970163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2971163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2972163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2973163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 29743856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 29752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 29762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 29792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 29813856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 29822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 29832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29863856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tnBassBoost_command cmdSize is %d\n" 2987163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2988163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2989163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2990163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2991163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 29922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::BassBoost_setParameter(pContext, 2994c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 29952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + p->psize); 29962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 29983856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 2999d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3000d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 3001d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 3002163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3003163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 3004163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 3005163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 3006163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 30073856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 30082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 30092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 30122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 30143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 30152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 30162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30193856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tnVirtualizer_command cmdSize is %d\n" 3020163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 3021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 3022163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 3023163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 3024163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 30252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Virtualizer_setParameter(pContext, 3027c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3028163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 30292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 30313856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command cmdCode Case: " 3032d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // "EFFECT_CMD_SET_PARAM start"); 30333856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 3034d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3035d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 3036d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 30372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 30392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL || *replySize != sizeof(int32_t)) { 30403856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 30412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 30422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 30452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Equalizer_setParameter(pContext, 3047c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3048163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 30492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 30513856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 30523856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 3053163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 3054163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 3055d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) +sizeof(int32_t))); 30562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ( pCmdData == NULL|| 30582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))|| 30592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 30602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int32_t)){ 30613856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 30622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 30632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 30662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Volume_setParameter(pContext, 3068c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 3069163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 3070163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30713856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end"); 30722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 30732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_ENABLE: 30753856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start"); 30762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 30773856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR"); 30782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 3079163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 308029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent 308129cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_TRUE); 30822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3083163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 30842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_DISABLE: 30853856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start"); 30862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 30873856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR"); 30882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 3089163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 309029cc743e57f2a1701a0a0d3a0e5406ed0f2e8a89Eric Laurent *(int *)pReplyData = android::Effect_setEnabled(pContext, LVM_FALSE); 30912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 30922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_DEVICE: 3094163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 30953856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start"); 3096e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent uint32_t device = *(uint32_t *)pCmdData; 3097163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3098b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->EffectType == LVM_BASS_BOOST) { 3099b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if((device == AUDIO_DEVICE_OUT_SPEAKER) || 3100b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) || 3101b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){ 31023856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d", 3103163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 31043856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST"); 3105163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3106163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device doesnt support bassboost the effect must be temporarily disabled 3107163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 3108163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 3109163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3110b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 31113856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d", 3112163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3113163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 3114163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3115b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_TRUE; 3116b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent } else { 31173856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d", 3118163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3119163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3120163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports bassboost and the effect has been temporarily disabled 3121163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 3122163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3123b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { 31243856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d", 3125163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3126163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 3127163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3128b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 3129163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3130163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3131b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->EffectType == LVM_VIRTUALIZER) { 3132b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if((device == AUDIO_DEVICE_OUT_SPEAKER)|| 3133b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)|| 3134b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){ 31353856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d", 3136163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 31373856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER"); 3138163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3139163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //If a device doesnt support virtualizer the effect must be temporarily disabled 3140163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 3141163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 3142163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3143b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { 31443856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d", 3145163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3146163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 3147163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3148b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE; 3149b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent } else { 31503856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d", 3151163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3152163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3153163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports virtualizer and the effect has been temporarily disabled 3154163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 3155163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3156b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 31573856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d", 3158163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3159163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 3160163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3161b6431802fc6cff501a4311de288ba469839fbf86Eric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 3162163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3163163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 31643856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end"); 31652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3166163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3167163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_VOLUME: 3168163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 3169dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent uint32_t leftVolume, rightVolume; 3170dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t leftdB, rightdB; 3171dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int16_t maxdB, pandB; 3172dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume 3173dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent int status = 0; 3174dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 3175dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 3176163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3177163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // if pReplyData is NULL, VOL_CTRL is delegated to another effect 3178163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pReplyData == LVM_NULL){ 3179163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3180163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 31812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3182dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if (pCmdData == NULL || 3183dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent cmdSize != 2 * sizeof(uint32_t)) { 31843856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 3185dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent "EFFECT_CMD_SET_VOLUME: ERROR"); 3186dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent return -EINVAL; 3187163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3188163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3189dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftVolume = ((*(uint32_t *)pCmdData)); 3190dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightVolume = ((*((uint32_t *)pCmdData + 1))); 3191dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3192dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(leftVolume == 0x1000000){ 3193dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftVolume -= 1; 3194dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3195dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(rightVolume == 0x1000000){ 3196dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightVolume -= 1; 3197dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 3198dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3199dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Convert volume to dB 3200dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent leftdB = android::LVC_Convert_VolToDb(leftVolume); 3201dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent rightdB = android::LVC_Convert_VolToDb(rightVolume); 3202dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3203dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent pandB = rightdB - leftdB; 3204dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3205dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // Calculate max volume in dB 3206dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent maxdB = leftdB; 3207dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(rightdB > maxdB){ 3208dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent maxdB = rightdB; 3209dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent } 32103856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME Session: %d, SessionID: %d VOLUME is %d dB (%d), " 3211dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // "effect is %d", 3212dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //pContext->pBundledContext->SessionNo, pContext->pBundledContext->SessionId, 3213dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent //(int32_t)maxdB, maxVol<<7, pContext->EffectType); 32143856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left is %d, Right is %d", leftVolume, rightVolume); 32153856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEFFECT_CMD_SET_VOLUME: Left %ddB, Right %ddB, Position %ddB", 3216dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent // leftdB, rightdB, pandB); 3217d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 3218163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(pReplyData, vol_ret, sizeof(int32_t)*2); 3219dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent android::VolumeSetVolumeLevel(pContext, (int16_t)(maxdB*100)); 3220dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3221dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Get the current settings */ 3222dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LvmStatus =LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 3223dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 3224dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 3225dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3226dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Volume parameters */ 3227dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent ActiveParams.VC_Balance = pandB; 32283856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("\t\tVolumeSetStereoPosition() (-96dB -> +96dB)-> %d\n", ActiveParams.VC_Balance ); 3229dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent 3230dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent /* Activate the initial settings */ 3231dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LvmStatus =LVM_SetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 3232dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 3233dac69110ed1073bf0a9827a3f78698896dd05d97Eric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 3234163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3235163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3236163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_AUDIO_MODE: 3237163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 32382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 32392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 32402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 32412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 32423856b090cd04ba5dd4a59a12430ed724d5995909Steve Block //ALOGV("\tEffect_command end...\n\n"); 32432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 32442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_command */ 32452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3246e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent/* Effect Control Interface Implementation: get_descriptor */ 3247e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentint Effect_getDescriptor(effect_handle_t self, 3248e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent effect_descriptor_t *pDescriptor) 3249e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent{ 3250e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent EffectContext * pContext = (EffectContext *) self; 3251e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent const effect_descriptor_t *desc; 3252e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3253e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent if (pContext == NULL || pDescriptor == NULL) { 32543856b090cd04ba5dd4a59a12430ed724d5995909Steve Block ALOGV("Effect_getDescriptor() invalid param"); 3255e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 3256e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 3257e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3258e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent switch(pContext->EffectType) { 3259e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_BASS_BOOST: 3260e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gBassBoostDescriptor; 3261e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3262e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_VIRTUALIZER: 3263e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gVirtualizerDescriptor; 3264e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3265e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_EQUALIZER: 3266e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gEqualizerDescriptor; 3267e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3268e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent case LVM_VOLUME: 3269e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent desc = &android::gVolumeDescriptor; 3270e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent break; 3271e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent default: 3272e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return -EINVAL; 3273e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent } 3274e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3275a189a6883ee55cf62da1d7bf5bf5a8ab501938a4Glenn Kasten *pDescriptor = *desc; 3276e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3277e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent return 0; 3278e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} /* end Effect_getDescriptor */ 3279e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3280e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent// effect_handle_t interface implementation for effect 32812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst struct effect_interface_s gLvmEffectInterface = { 32822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_process, 3283e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent Effect_command, 3284ba7b8f881a9b6b21803752326d2932a3bd42d7cfEric Laurent Effect_getDescriptor, 3285ba7b8f881a9b6b21803752326d2932a3bd42d7cfEric Laurent NULL, 32862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; /* end gLvmEffectInterface */ 32872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3288e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurentaudio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = { 3289e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent tag : AUDIO_EFFECT_LIBRARY_TAG, 3290e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent version : EFFECT_LIBRARY_API_VERSION, 3291e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent name : "Effect Bundle Library", 3292e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent implementor : "NXP Software Ltd.", 3293e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent query_num_effects : android::EffectQueryNumberEffects, 3294e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent query_effect : android::EffectQueryEffect, 3295e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent create_effect : android::EffectCreate, 3296e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent release_effect : android::EffectRelease, 3297e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent get_descriptor : android::EffectGetDescriptor, 3298e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent}; 3299e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent 3300e1315cf0b63b4c14a77046519e6b01f6f60d74b0Eric Laurent} 3301