EffectBundle.cpp revision d918324d44aa48b3b064ea9b87d0c520c38f15a9
12c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* 22c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2010-2010 NXP Software 32c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Copyright (C) 2009 The Android Open Source Project 42c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 52c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 62c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * you may not use this file except in compliance with the License. 72c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * You may obtain a copy of the License at 82c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 92c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * 112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * Unless required by applicable law or agreed to in writing, software 122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * See the License for the specific language governing permissions and 152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * limitations under the License. 162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define LOG_TAG "Bundle" 192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) 2097344f1d8e8e95fd07d5deee2ae2492a7e4c24b0Eric Laurent//#define LOG_NDEBUG 0 212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <cutils/log.h> 232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <assert.h> 242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <stdlib.h> 252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <string.h> 262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <new> 272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#include <EffectBundle.h> 282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// effect_interface_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){\ 352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\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){\ 392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\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){\ 432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\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){\ 472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Parameter error - "\ 482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "out of range returned by %s in %s\n", callingFunc, calledFunc);\ 492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Namespaces 532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace android { 542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace { 552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* local functions */ 572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define CHECK_ARG(cond) { \ 582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (!(cond)) { \ 592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Invalid argument: "#cond); \ 602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; \ 612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } \ 622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 64163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Flag to allow a one time init of global memory, only happens on first call ever 652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmInitFlag = LVM_FALSE; 66c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint LvmSessionsActive = 0; 67c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric LaurentSessionContext GlobalSessionMemory[LVM_MAX_SESSIONS]; 68c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint SessionIndex[LVM_MAX_SESSIONS]; 692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW BassBoost UUID 712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gBassBoostDescriptor = { 722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x8631f300, 0x72e2, 0x11df, 0xb57e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid 742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 75163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 76163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 77d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BASS_BOOST_CUP_LOAD_ARM9E, 78d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Dynamic Bass Boost", 802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Virtualizer UUID 842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVirtualizerDescriptor = { 85163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 86163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 88163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 89163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 90d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VIRTUALIZER_CUP_LOAD_ARM9E, 91d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Virtualizer", 932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Equalizer UUID 972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gEqualizerDescriptor = { 982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type 992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0xce772f20, 0x847d, 0x11df, 0xbb17, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid Eq NXP 1002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 101163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 102d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent EQUALIZER_CUP_LOAD_ARM9E, 103d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Equalizer", 1052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Volume UUID 1092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVolumeDescriptor = { 1102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 1112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x119341a0, 0x8469, 0x11df, 0x81f9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, //uuid VOL NXP 1122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 113163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 114d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent VOLUME_CUP_LOAD_ARM9E, 115d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent BUNDLE_MEM_USAGE, 1162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Volume", 1172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--- local function prototypes 1212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init (void); 1222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init (EffectContext *pContext); 1232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable (EffectContext *pContext); 1242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable (EffectContext *pContext); 1252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free (EffectContext *pContext); 126163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint Effect_configure (EffectContext *pContext, effect_config_t *pConfig); 127c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue); 128163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint BassBoost_getParameter (EffectContext *pContext, 129c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 132c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter (EffectContext *pContext, 134c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 136163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue); 137c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter (EffectContext *pContext, 139c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 142c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue); 1432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter (EffectContext *pContext, 144c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 1472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Library Interface Implementation */ 1492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){ 1502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\n\tEffectQueryNumberEffects start"); 1512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pNumEffects = 4; 152163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects); 153163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectQueryNumberEffects end\n"); 1542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryNumberEffects */ 1562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){ 1582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\n\tEffectQueryEffect start"); 1592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing index %d", index); 160163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pDescriptor == NULL){ 162163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer"); 1632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 1642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (index > 3){ 166163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index); 1672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -ENOENT; 1682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(index == LVM_BASS_BOOST){ 1702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_BASS_BOOST"); 1712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gBassBoostDescriptor, sizeof(effect_descriptor_t)); 1722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else if(index == LVM_VIRTUALIZER){ 1732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER"); 1742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gVirtualizerDescriptor, sizeof(effect_descriptor_t)); 1752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_EQUALIZER){ 1762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_EQUALIZER"); 1772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t)); 1782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_VOLUME){ 1792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_VOLUME"); 1802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gVolumeDescriptor, sizeof(effect_descriptor_t)); 181163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect end\n"); 1832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryEffect */ 1852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectCreate(effect_uuid_t *uuid, 1872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t sessionId, 1882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t ioId, 1892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_interface_t *pInterface){ 1902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int ret; 191c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int sessionNo; 1922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int i; 1932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext *pContext = new EffectContext; 1942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\n\tEffectCreate start session %d", sessionId); 1962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pInterface == NULL || uuid == NULL){ 198163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer"); 1992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 2002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 202c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(sessionId < 0){ 2032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : EffectCreate sessionId is less than 0"); 204163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 2052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmInitFlag == LVM_FALSE){ 2082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmInitFlag = LVM_TRUE; 2092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - Initializing all global memory"); 2102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmGlobalBundle_init(); 2112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 213c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffectCreate: There are %d LVM sessions acive\n", LvmSessionsActive); 214c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 215c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Find next available sessionNo 216c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(i=0; i<LVM_MAX_SESSIONS; i++){ 217c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if((SessionIndex[i] == -1)||(SessionIndex[i] == sessionId)){ 218c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo = i; 219c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent SessionIndex[i] = sessionId; 220c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId); 221c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 222c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 223c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 224c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 225c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(i==LVM_MAX_SESSIONS){ 226c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tLVM_ERROR : Cannot find memory to allocate for current session"); 227c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent return -EINVAL; 228c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 2292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // If this is the first create in this session 230c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(GlobalSessionMemory[sessionNo].bBundledEffectsEnabled == LVM_FALSE){ 231c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d", 232c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionId, sessionNo); 233c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 234c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LvmSessionsActive++; 235c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 236c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(LvmSessionsActive >= LVM_MAX_SESSIONS){ 237c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tLVM_ERROR : Number of active session is greater than LVM_MAX_SESSIONS (%d)", 238c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LVM_MAX_SESSIONS); 239c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent return -EINVAL; 240c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 241163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 242c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_TRUE; 243c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext = new BundledEffectContext; 2442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 245c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = GlobalSessionMemory[sessionNo].pBundledContext; 246c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionNo = sessionNo; 247c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SessionId = sessionId; 248163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = NULL; 249163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 250163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 251163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 252163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 253163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 254163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 255163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled = 0; 256163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 257163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->frameCount = 0; 258d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->firstVolume = LVM_TRUE; 259163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 260163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 261163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmInPtr = NULL; 262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmOutPtr = NULL; 263163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 264163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmInPtr = fopen("/data/tmp/bundle_pcm_in.pcm", "w"); 265163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmOutPtr = fopen("/data/tmp/bundle_pcm_out.pcm", "w"); 266163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((pContext->pBundledContext->PcmInPtr == NULL)|| 268163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->pBundledContext->PcmOutPtr == NULL)){ 269163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 270163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 271163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 272163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Saved strength is used to return the exact strength that was used in the set to the get 2742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * because we map the original strength range of 0:1000 to 1:15, and this will avoid 2752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * quantisation like effect when returning 2762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 277163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->BassStrengthSaved = 0; 278163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = 0; 279163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 280163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = 0; 281163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled = LVM_FALSE; 282163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = LVM_FALSE; 283163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = 0; 284163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - Calling LvmBundle_init"); 2862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ret = LvmBundle_init(pContext); 2872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (ret < 0){ 2892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : EffectCreate() Bundle init failed"); 2902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext->pBundledContext; 2912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext; 2922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return ret; 2932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 296c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d", 297c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent sessionNo); 298c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = 299c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[sessionNo].pBundledContext; 3002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext); 3022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create each Effect 3042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Bass Boost 3062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST"); 307c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated = LVM_TRUE; 308163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 309163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->itfe = &gLvmEffectInterface; 3102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_BASS_BOOST; 3112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Virtualizer 313163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER"); 314c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated=LVM_TRUE; 315163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VIRTUALIZER; 3182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Equalizer 320163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER"); 321c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated = LVM_TRUE; 322163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_EQUALIZER; 3252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 3262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Volume 327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_VOLUME"); 328c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated = LVM_TRUE; 329163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VOLUME; 332163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectCreate() invalid UUID"); 335163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 3362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pInterface = (effect_interface_t)pContext; 339163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate end..\n\n"); 3402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 3412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectCreate */ 3422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectRelease(effect_interface_t interface){ 3442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\n\tEffectRelease start %p", interface); 3452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *)interface; 3462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 347c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\n\tEffectRelease start interface: %p, context %p", interface, pContext->pBundledContext); 3482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 349163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer"); 3502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 351163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Clear the instantiated flag for the effect 3542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 3552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag"); 356163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated = LVM_FALSE; 3572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VIRTUALIZER) { 3582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag"); 359163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated 360163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent = LVM_FALSE; 3612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_EQUALIZER) { 3622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag"); 363163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated =LVM_FALSE; 3642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VOLUME) { 3652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag"); 366163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated = LVM_FALSE; 3672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 3682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n"); 3692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 370163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // if all effects are no longer instantiaed free the lvm memory and delete BundledEffectContext 3722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if((GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated == LVM_FALSE)&& 373163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated == LVM_FALSE)&& 374163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated ==LVM_FALSE)&& 375163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated==LVM_FALSE)) 3762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 377163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 378163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fclose(pContext->pBundledContext->PcmInPtr); 379163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fclose(pContext->pBundledContext->PcmOutPtr); 380163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 381c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 382c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LvmSessionsActive--; 383c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffectRelease: There are %d LVM sessions remaining\n", LvmSessionsActive); 384c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 385c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // Clear the SessionIndex 386c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 387c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(SessionIndex[i] == pContext->pBundledContext->SessionId){ 388c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent SessionIndex[i] = -1; 389c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n", 390c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent i, pContext->pBundledContext->SessionId); 391c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent break; 392c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 393c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 394c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 395163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectRelease: All effects are no longer instantiated\n"); 396163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBundledEffectsEnabled =LVM_FALSE; 397163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].pBundledContext = LVM_NULL; 398163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectRelease: Freeing LVM Bundle memory\n"); 399163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmEffect_free(pContext); 400c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext); 401163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent delete pContext->pBundledContext; 402c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext = LVM_NULL; 4032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // free the effect context for current effect 4052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext; 4062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease end\n"); 4082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 4092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectRelease */ 4112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init(){ 4132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmGlobalBundle_init start"); 4142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 4152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBundledEffectsEnabled = LVM_FALSE; 4162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVolumeInstantiated = LVM_FALSE; 4172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bEqualizerInstantiated = LVM_FALSE; 4182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBassInstantiated = LVM_FALSE; 4192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE; 4202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].pBundledContext = LVM_NULL; 421c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 422c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent SessionIndex[i] = -1; 4232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 4252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 4262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 4272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_init() 4282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 4292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Initialize engine with default configuration, creates instance 4302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// with all effects disabled. 4312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 4322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 4332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 4342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 4352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 4362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 4372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 4382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init(EffectContext *pContext){ 4402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status; 4412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init start"); 4432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 444163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; 445163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.channels = CHANNEL_STEREO; 446163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15; 447163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.samplingRate = 44100; 448163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.getBuffer = NULL; 449163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL; 450163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.cookie = NULL; 451163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL; 452163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; 453163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.channels = CHANNEL_STEREO; 454163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15; 455163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.samplingRate = 44100; 456163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.getBuffer = NULL; 457163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL; 458163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.cookie = NULL; 459163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL; 4602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 4622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext->pBundledContext->hInstance != NULL){ 4642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 4652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Calling pContext->pBassBoost->free()"); 4662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmEffect_free(pContext); 4682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 4702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Called pContext->pBassBoost->free()"); 4712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 4742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 4752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_InstParams_t InstParams; /* Instance parameters */ 4762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_EQNB_BandDef_t BandDefs[MAX_NUM_BANDS]; /* Equaliser band definitions */ 4772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ 4782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomBandDef_t HeadroomBandDef[LVM_HEADROOM_MAX_NBANDS]; 4792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; /* Memory allocation table */ 4802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bool bMallocFailure = LVM_FALSE; 4812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the capabilities */ 483163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent InstParams.BufferMode = LVM_UNMANAGED_BUFFERS; 4842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.MaxBlockSize = MAX_CALL_SIZE; 4852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.EQNB_NumBands = MAX_NUM_BANDS; 4862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.PSA_Included = LVM_PSA_ON; 4872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory, forcing alignment */ 4892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(LVM_NULL, 4902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 4912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 4922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmBundle_init") 4942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 4952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n"); 4972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory */ 4992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 5002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 5012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size); 5022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 504d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes " 505d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent "for region %u\n", MemTab.Region[i].Size, i ); 5062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bMallocFailure = LVM_TRUE; 5072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 508163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance allocated %ld bytes for region %u at %p\n", 5092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 5102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* If one or more of the memory regions failed to allocate, free the regions that were 5152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * succesfully allocated and return with an error 5162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 5172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(bMallocFailure == LVM_TRUE){ 5182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 5192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 520d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes " 521d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent "for region %u Not freeing\n", MemTab.Region[i].Size, i ); 5222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 523163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed: but allocated %ld bytes " 524163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent "for region %u at %p- free\n", 525163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 5262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 5272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 5302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 531163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully malloc'd memory\n"); 5322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Initialise */ 534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = LVM_NULL; 5352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 536163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Init sets the instance handle */ 537163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetInstanceHandle(&pContext->pBundledContext->hInstance, 5382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 5392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 5402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "LvmBundle_init") 5422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 5432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 544163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_GetInstanceHandle\n"); 5452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the initial process parameters */ 5472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* General parameters */ 5482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.OperatingMode = LVM_MODE_ON; 5492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SampleRate = LVM_FS_44100; 5502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SourceFormat = LVM_STEREO; 5512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SpeakerType = LVM_HEADPHONES; 5522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 553163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->SampleRate = LVM_FS_44100; 554c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 44100*2*2; // 2 secs Stereo 555c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 44100*2*2; // 2 secs Stereo 556c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 44100*2*2; // 2 secs Stereo 557163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 5582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Concert Sound parameters */ 5592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerOperatingMode = LVM_MODE_OFF; 5602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerType = LVM_CONCERTSOUND; 5612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerReverbLevel = 100; 562d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.CS_EffectLevel = LVM_CS_EFFECT_NONE; 5632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* N-Band Equaliser parameters */ 5652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_OperatingMode = LVM_EQNB_OFF; 5662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_NBands = FIVEBAND_NUMBANDS; 5672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.pEQNB_BandDefinition = &BandDefs[0]; 568163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 5692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 5702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 5712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 5722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].QFactor = EQNB_5BandPresetsQFactors[i]; 573163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDefs[i].Gain = EQNB_5BandSoftPresets[i]; 5742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume Control parameters */ 5772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_EffectLevel = 0; 5782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_Balance = 0; 5792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Treble Enhancement parameters */ 5812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_OperatingMode = LVM_TE_OFF; 5822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_EffectLevel = 0; 5832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 5852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 5862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = (LVM_PSA_DecaySpeed_en)0; 5872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 5892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_OperatingMode = LVM_BE_OFF; 5902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_EffectLevel = 0; 5912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 5922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_HPF = LVM_BE_HPF_ON; 5932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 5952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 5962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM; 5972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 598d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent /* TE Control parameters */ 599d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_OperatingMode = LVM_TE_OFF; 600d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent params.TE_EffectLevel = 0; 601d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 602163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, 6042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ¶ms); 6052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmBundle_init") 6072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 609163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetControlParameters\n"); 6102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the headroom parameters */ 6122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_Low = 20; 6132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_High = 4999; 6142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Headroom_Offset = 3; 6152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_Low = 5000; 6162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_High = 24000; 6172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Headroom_Offset = 4; 6182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.pHeadroomDefinition = &HeadroomBandDef[0]; 6192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON; 6202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.NHeadroomBands = 2; 6212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetHeadroomParams(pContext->pBundledContext->hInstance, 6232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &HeadroomParams); 6242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetHeadroomParams", "LvmBundle_init") 6262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 628163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetHeadroomParams\n"); 6292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init End"); 6302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 6312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_init */ 6322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_process() 6352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 6372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply LVM Bundle effects 6382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 6392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 6402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pIn: pointer to stereo 16 bit input data 6412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to stereo 16 bit output data 6422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// frameCount: Frames to process 6432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 6442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 6452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 6462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 6472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to updated stereo 16 bit output data 6482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 6492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_process(LVM_INT16 *pIn, 652163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOut, 653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int frameCount, 654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent EffectContext *pContext){ 6552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 6572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 6582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 659163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOutTmp; 660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){ 661163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOutTmp = pOut; 662163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOutTmp = (LVM_INT16 *)malloc(frameCount * sizeof(LVM_INT16) * 2); 664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pOutTmp == NULL){ 665163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : LvmBundle_process failed to allocate memory for " 666163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent "EFFECT_BUFFER_ACCESS_ACCUMULATE mode"); 667163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 668163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 669163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 670163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("LVM_ERROR : LvmBundle_process invalid access mode"); 671163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 672163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 6732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 674163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 675163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 6762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 6772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 678163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmBundle_process") 6792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 681163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->frameCount++; 682163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->frameCount == 100) 683163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 684163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBB: %d VIRT: %d EQ: %d, session (%d), context is %p\n", 685163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.BE_OperatingMode, 686163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.VirtualizerOperatingMode, ActiveParams.EQNB_OperatingMode, 687163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->SessionNo, pContext->pBundledContext); 688163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->frameCount = 0; 689163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 690163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 692163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pIn, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmInPtr); 693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmInPtr); 694163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 695163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 696d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("Calling LVM_Process"); 697d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 698163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process the samples */ 6992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */ 7002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pIn, /* Input buffer */ 7012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pOutTmp, /* Output buffer */ 7022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_UINT16)frameCount, /* Number of samples to read */ 7032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0); /* Audo Time */ 704163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_Process", "LvmBundle_process") 7062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 7072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 708163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 709163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pOutTmp, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmOutPtr); 710163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmOutPtr); 711163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 712163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 713163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 714163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (int i=0; i<frameCount*2; i++){ 715163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOut[i] += pOutTmp[i]; 716163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 717163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent free(pOutTmp); 718163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 7192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_process */ 7212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_enable() 7242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Enable the effect in the bundle 7262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 7312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable(EffectContext *pContext){ 735163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable start"); 736163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 7382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 7392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 740163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 741163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 7422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 7432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable") 7452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 746163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n"); 7472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 749163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST"); 7502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_ON; 7512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 753163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER"); 7542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_ON; 7552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER"); 7582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_ON; 7592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 761163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_VOLUME"); 762163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 7652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_enable") 7662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 767163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 768163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n"); 769163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable end"); 7702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 7722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_disable() 7752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Disable the effect in the bundle 7772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 7822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable(EffectContext *pContext){ 786163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable start"); 787163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 7892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 790163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 791163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 7922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 7932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_disable") 7952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 796163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n"); 7972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 799163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST"); 8002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_OFF; 8012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 803163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Enabling LVM_VIRTUALIZER"); 8042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_OFF; 8052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 807163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Enabling LVM_EQUALIZER"); 8082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_OFF; 8092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 811163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Enabling LVM_VOLUME"); 812163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 813163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 8142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 8152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_disable") 8162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 817163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 818163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n"); 819163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable end"); 8202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 8212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 8222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_free() 8252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Free all memory associated with the Bundle. 8272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 8292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 8302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 8322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free(EffectContext *pContext){ 8362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 8372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 8382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; 8392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Free the algorithm memory */ 8412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(pContext->pBundledContext->hInstance, 8422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 8432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_NULL); 8442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmEffect_free") 8462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 8482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 8492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress != NULL){ 850163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_free - START freeing %ld bytes for region %u at %p\n", 8512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 8522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 8542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 855163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_free - END freeing %ld bytes for region %u at %p\n", 8562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 8572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 858163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : LvmEffect_free - trying to free with NULL pointer %ld bytes " 8592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "for region %u at %p ERROR\n", 8602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 8612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmEffect_free */ 8652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Effect_configure() 8682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Set input and output audio configuration. 8702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 8722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 8732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pConfig: pointer to effect_config_t structure holding input and output 8742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// configuration parameters 8752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 8772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Effect_configure(EffectContext *pContext, effect_config_t *pConfig){ 881163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_Fs_en SampleRate; 882163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_configure start"); 8832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 8852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig != NULL); 8862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate); 8882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels); 8892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format); 8902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.channels == CHANNEL_STEREO); 8912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE 8922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE); 8932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15); 8942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(&pContext->config, pConfig, sizeof(effect_config_t)); 8962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 897163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent switch (pConfig->inputCfg.samplingRate) { 898163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 8000: 899163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_8000; 900c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 8000*2; // 2 secs Stereo 901163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 902163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 16000: 903163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_16000; 904c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 16000*2; // 2 secs Stereo 905163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 906163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 22050: 907163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_22050; 908c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 22050*2; // 2 secs Stereo 909163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 910163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 32000: 911163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_32000; 912c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 32000*2; // 2 secs Stereo 913163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 914163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 44100: 915163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_44100; 916c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 44100*2; // 2 secs Stereo 917163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 918163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 48000: 919163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_48000; 920c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo 921163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 922163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent default: 923163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate); 924163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 925163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 9262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 927163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->SampleRate != SampleRate){ 9282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 929163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; 930163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; 9312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 932163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_configure change sampling rate to %d", SampleRate); 9332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 934163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 935163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 936163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 9372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 938163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_configure") 939163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 9402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 941163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 9422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 943163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_configure") 944163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_configure Succesfully called LVM_SetControlParameters\n"); 945c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SampleRate = SampleRate; 9462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 947163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 948163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_configure keep sampling rate at %d", SampleRate); 949163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 9502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 951163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_configure End...."); 952163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 953163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end Effect_configure */ 9542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassGetStrength() 9572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 9592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 9602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 9612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// the bassboost uses 1-15, so to avoid a quantisation the original set value is used. However the 9622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 9632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t BassGetStrength(EffectContext *pContext){ 970163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved); 9712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 9732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 974163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 975163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 9762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 9772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassGetStrength") 9792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 9802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 981163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n"); 9822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Check that the strength returned matches the strength that was set earlier */ 984163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(ActiveParams.BE_EffectLevel != 985163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){ 9862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n", 9872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved); 9882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 9892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 991163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 992163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength() (saved) -> %d\n", pContext->pBundledContext->BassStrengthSaved ); 9932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return pContext->pBundledContext->BassStrengthSaved; 9942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassGetStrength */ 9952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassSetStrength() 9982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the BassBosst. Must first be converted from the range 0-1000 to 1-15 10012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 10052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid BassSetStrength(EffectContext *pContext, uint32_t strength){ 1009163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength(%d)", strength); 10102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->BassStrengthSaved = (int)strength; 10122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 10152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 10172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 10182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 10192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassSetStrength") 1021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength Succesfully returned from LVM_GetControlParameters\n"); 10222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 10242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel = (LVM_INT16)((15*strength)/1000); 10252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 10262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1027163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 10282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 10302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 10312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength") 1033163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n"); 10342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassSetStrength */ 10352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerGetStrength() 10382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 10412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 1042163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// the Virtualizer uses 1-100, so to avoid a quantisation the original set value is used.However the 10432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 10442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t VirtualizerGetStrength(EffectContext *pContext){ 1051163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved); 10522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 10552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 10572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerGetStrength") 10592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 10602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1061163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n"); 1062163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerGetStrength() (0-100) -> %d\n", ActiveParams.VirtualizerReverbLevel*10); 1063d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent return pContext->pBundledContext->VirtStrengthSaved; 10642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getStrength */ 10652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerSetStrength() 10682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the Virtualizer. Must first be converted from the range 0-1000 to 1-15 10712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 10752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){ 1079163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength(%d)", strength); 10802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 10822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1083163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = (int)strength; 1084163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 10852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 10862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 10872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerSetStrength") 1089163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n"); 10902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Virtualizer parameters */ 1092d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent ActiveParams.CS_EffectLevel = (int)((strength*32767)/1000); 10932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1094163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength ); 1095d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel ); 10962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 10982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 10992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength") 1100d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n"); 11012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setStrength */ 11022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandLevel() 11052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the gain currently being used for the band passed in 11072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 11102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 11132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){ 11162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1117163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Gain =0; 1118163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1119163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1120163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1121163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1122163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1123163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 11242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1125163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetBandLevel") 11262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1127163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1128163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Gain = (int32_t)BandDef[band].Gain*100; // Convert to millibels 11292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1130163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetBandLevel -> %d\n", Gain ); 1131163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 1132163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Gain; 11332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 11342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetBandLevel() 11372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets gain value for the given band. 11402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 11432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gain: Gain to be applied in millibels 11442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 11472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--------------------------------------------------------------------------- 1149d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurentvoid EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){ 1150163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int gainRounded; 1151163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(Gain > 0){ 1152163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain+50)/100); 1153163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1154163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain-50)/100); 1155163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1156163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded); 1157163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1158163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 11592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 11602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1161163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 11622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 11642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1165163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetBandLevel") 1166163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 1167d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEqualizerSetBandLevel just Got -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain); 11682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set local EQ parameters */ 1170163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1171163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[band].Gain = gainRounded; 11722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 11742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1175163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetBandLevel") 1176d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEqualizerSetBandLevel just Set -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain); 11772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 11792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 11802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 11812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetCentreFrequency() 11832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the frequency being used for the band passed in 11852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 11882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 11912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetCentreFrequency(EffectContext *pContext, int32_t band){ 1194163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Frequency =0; 11952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1196163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1197163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1198163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1199163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1200163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1201163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 12022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1203163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetCentreFrequency") 12042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1205163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1206163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Frequency = (int32_t)BandDef[band].Frequency*1000; // Convert to millibels 12072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1208163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetCentreFrequency -> %d\n", Frequency ); 1209163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetCentreFrequency Succesfully returned from LVM_GetControlParameters\n"); 1210163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Frequency; 12112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandFreqRange( 12152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets lower and upper boundaries of a band. 12192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the high shelf, the low bound is the band frequency and the high 12202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// bound is Nyquist. 12212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the peaking filters, they are the gain[dB]/2 points. 12222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 12252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 12292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 12302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1231163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t EqualizerGetBandFreqRange(EffectContext *pContext, int32_t band, uint32_t *pLow, 1232163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t *pHi){ 1233163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pLow = bandFreqRange[band][0]; 1234163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pHi = bandFreqRange[band][1]; 1235163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 12362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBand( 12402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Returns the band with the maximum influence on a given frequency. 12442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Result is unaffected by whether EQ is enabled or not, or by whether 12452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// changes have been committed or not. 12462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// targetFreq The target frequency, in millihertz. 12492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 12522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 12532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 12542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBand(EffectContext *pContext, uint32_t targetFreq){ 12562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int band = 0; 12572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1258163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(targetFreq < bandFreqRange[0][0]){ 1259163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1260163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if(targetFreq == bandFreqRange[0][0]){ 1261163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1263163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for(int i=0; i<FIVEBAND_NUMBANDS;i++){ 1264163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((targetFreq > bandFreqRange[i][0])&&(targetFreq <= bandFreqRange[i][1])){ 1265163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent band = i; 1266163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 12682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return band; 12692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPreset( 12732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets the currently set preset ID. 12772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Will return PRESET_CUSTOM in case the EQ parameters have been modified 12782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// manually since a preset was set. 12792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetPreset(EffectContext *pContext){ 1285163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return pContext->pBundledContext->CurPreset; 12862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetPreset( 12902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets the current preset by ID. 12942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// All the band parameters will be overridden. 12952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. 12992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid EqualizerSetPreset(EffectContext *pContext, int preset){ 13022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1303163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetPreset(%d)", preset); 13042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = preset; 13052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 13082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 13102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1311163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetPreset") 1312163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetPreset Succesfully returned from LVM_GetControlParameters\n"); 13132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //ActiveParams.pEQNB_BandDefinition = &BandDefs[0]; 13152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 13162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 1317163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 1318163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i]; 1319163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Gain 1320163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent = EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS]; 13212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 13222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the new settings */ 13232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1324163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetPreset") 13252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1326163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n"); 13272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 13282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 1329163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 13302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetNumPresets(){ 1331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return sizeof(gEqualizerPresets) / sizeof(PresetConfig); 13322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPresetName( 13362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets a human-readable name for a preset ID. Will return "Custom" if 13392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// PRESET_CUSTOM is passed. 13402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. Must be less than number of presets. 13432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//------------------------------------------------------------------------- 13452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst char * EqualizerGetPresetName(int32_t preset){ 1346163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetPresetName start(%d)", preset); 13472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (preset == PRESET_CUSTOM) { 13482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return "Custom"; 13492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 13502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return gEqualizerPresets[preset].name; 13512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1352163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetPresetName end(%d)", preset); 1353163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 13542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 13552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetVolumeLevel() 13582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// level level to be applied 13642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){ 13682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 13712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1372163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel Level to be set is %d %d\n", level, (LVM_INT16)(level/100)); 13732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 13742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 13752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 13762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1377163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters got: %d\n", 1378163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.VC_EffectLevel); 13792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume parameters */ 13812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VC_EffectLevel = (LVM_INT16)(level/100); 1382163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 13832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 13852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 13862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetVolumeLevel") 13872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 13882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1389163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n"); 1390163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1391163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1392163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1393163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 1394163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1395163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1396d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolumeSetVolumeLevel just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel ); 1397d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent if(pContext->pBundledContext->firstVolume == LVM_TRUE){ 1398d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); 1399d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process") 1400d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks"); 1401d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->firstVolume = LVM_FALSE; 1402d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent } 14032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 14042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setVolumeLevel */ 14052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeGetVolumeLevel() 14082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 14132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){ 14172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1418163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel start"); 1419163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 14202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 14212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 14222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetVolumeLevel") 14252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1427163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 1428163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n"); 14292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *level = ActiveParams.VC_EffectLevel*100; // Convert dB to millibels 1431163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel end"); 14322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 14332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end VolumeGetVolumeLevel */ 14342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetMute() 14372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 14422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 14432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){ 1447163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute start(%d)", mute); 14482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bMuteEnabled = mute; 14502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 14522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 14532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 14552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetMute") 14572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1459163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n"); 1460163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute to %d, level was %d\n", mute, ActiveParams.VC_EffectLevel ); 14612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set appropriate volume level */ 14632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){ 1464163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = ActiveParams.VC_EffectLevel; 1465163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = -96; 14662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 1467163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = pContext->pBundledContext->levelSaved; 14682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 14692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 14712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetMute") 14732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1475163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n"); 1476163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute end"); 14772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 14782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setMute */ 14792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1481163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetMute() 14822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 14872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Ourputs: 14892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 14902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){ 1493163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetMute start"); 1494163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)|| 1495163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){ 1496163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *mute = pContext->pBundledContext->bMuteEnabled; 1497163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 14982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 1499163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d", 1500163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled); 1501163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 15022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1503163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetMute end"); 15042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getMute */ 15052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1506163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint16_t VolumeConvertStereoPosition(int16_t position){ 1507163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t convertedPosition = 0; 1508163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1509163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent convertedPosition = (int16_t)(((float)position/1000)*96); 1510163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return convertedPosition; 1511163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1512163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 1513163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1514163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1515163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeSetStereoPosition() 1516163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1517163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1518163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1519163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1520163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1521163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1522163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1523163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1524163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1525163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1526163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint VolumeSetStereoPosition(EffectContext *pContext, int16_t position){ 1527163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1528163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1529163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1530163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Balance = 0; 1531163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1532c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 1533163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1535163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1536163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1537d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1538d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1539163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1540163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1541163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1542163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Position to be set is %d %d\n", position, Balance); 1543163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1544163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1545163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1546163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1547163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1548163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got:" 1549163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // " %d\n", ActiveParams.VC_Balance); 1550163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1551163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Volume parameters */ 1552163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = Balance; 1553163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition() (-96dB -> +96dB) -> %d\n", ActiveParams.VC_Balance ); 1554163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1555163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1556163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1557163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 1558163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1559163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1560163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Succesfully called LVM_SetControlParameters\n"); 15612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1562163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1563163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1564163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1565163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1566163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got: " 1567163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "%d\n", ActiveParams.VC_Balance); 1568163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1569163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent else{ 1570163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Position attempting to set, but not enabled %d %d\n", 1571163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //position, Balance); 1572163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1573d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n", 1574d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1575163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1576163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeSetStereoPosition */ 15772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1579163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1580163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetStereoPosition() 1581163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1582163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1583163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1584163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1585163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1586163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1587163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1588163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1589163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 15902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1591163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeGetStereoPosition(EffectContext *pContext, int16_t *position){ 1592163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition start"); 15932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1594163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1595163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1596163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 balance; 1597163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1598d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d", 1599d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1600163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1601163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1602163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition") 1603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1604163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1605163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition -> %d\n", ActiveParams.VC_Balance); 1606163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 1607163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1608163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1609163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1610163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1611163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(balance != ActiveParams.VC_Balance){ 1612163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1613163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *position = (LVM_INT16)pContext->pBundledContext->positionSaved; // Convert dB to millibels 1616d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved =%d\n", 1617d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //pContext->pBundledContext->positionSaved); 1618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeGetStereoPosition */ 16202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1621163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1622163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeEnableStereoPosition() 1623163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1624163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1625163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1626163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1627163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1628163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// mute: enable/disable flag 1629163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1630163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 16312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){ 1633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition start()"); 16342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = enabled; 16362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1637163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1638163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 16392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1640163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1641163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1642163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeEnableStereoPosition") 1643163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 16442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1645163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 1646163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition to %d, position was %d\n", 1647163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // enabled, ActiveParams.VC_Balance ); 16482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1649163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Set appropriate stereo position */ 1650163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_FALSE){ 1651163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 0; 1652163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 1654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1655163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 16562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1657163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1658163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1659163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeEnableStereoPosition") 1660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 16612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1662163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition Succesfully called LVM_SetControlParameters\n"); 1663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition end()\n"); 1664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1665163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeEnableStereoPosition */ 16662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_getParameter() 16692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 16712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a BassBoost parameter 16722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 16742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 16752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 16762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 16772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 16782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 16802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 16812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 16822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 16852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint BassBoost_getParameter(EffectContext *pContext, 1689c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 1690163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent size_t *pValueSize, 1691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue){ 16922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 1693c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1694c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 16952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 16962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 16972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1698163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_getParameter start"); 16992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 170123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 17027fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 1703d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize1 %d", *pValueSize); 17047fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 17057fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 17067fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 17077fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 17082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 17092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 1710d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize); 17112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 17122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 17142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 1717163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 17182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 17192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 172223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 17232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 17242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 172523e1de74359f4bb1763aef0adfebe073122b032cEric Laurent //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED Value is %d", 1726163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 17272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 17302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = BassGetStrength(pContext); 17312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1732163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d", 1733163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 17342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 17372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 17382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 17392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1742163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_getParameter end"); 17432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 17442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_getParameter */ 17452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_setParameter() 17482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a BassBoost parameter 17512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 17542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 17552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 17562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 17582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1761c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 17622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 17632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 1764c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 17652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1766163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter start"); 17672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1768c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (*pParamTemp){ 17692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 17702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 1771163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength); 1772163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength"); 17732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BassSetStrength(pContext, (int32_t)strength); 1774163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength"); 17752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 1777c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp); 17782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1781163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter end"); 17822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 17832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_setParameter */ 17842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_getParameter() 17872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Virtualizer parameter 17902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 17932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 17942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 17952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 17962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 17982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 17992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 18002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 18032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter(EffectContext *pContext, 1807c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 18082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 18092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 18102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 1811c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1812c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 18132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 18142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 18152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1816163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_getParameter start"); 18172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 181923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 18207fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent if (*pValueSize != sizeof(uint32_t)){ 18217fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize %d",*pValueSize); 18227fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent return -EINVAL; 18237fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent } 18247fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent *pValueSize = sizeof(uint32_t); 18257fa8a0ec14781a50695cf8c9dd2a85a5e8a3c3f0Eric Laurent break; 18262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 18272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 1828d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize); 18292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 18322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 18362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 184023e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 18412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 18422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 184323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED Value is %d", 1844163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 18452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 18482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = VirtualizerGetStrength(pContext); 18492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1850163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d", 1851163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 18522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 18562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 18572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_getParameter end"); 18612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 18622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_getParameter */ 18632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_setParameter() 18662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 18682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Virtualizer parameter 18692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 18712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 18722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 18732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 18742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 18762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1879c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 18802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 18812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 1882c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1883c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 18842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1885163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter start"); 18862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1887c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 18882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 18892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 1890163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength); 1891163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength"); 18922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent VirtualizerSetStrength(pContext, (int32_t)strength); 1893163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength"); 18942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 1896c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param); 18972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1900163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter end"); 19012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 19022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_setParameter */ 19032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_getParameter() 19062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 19082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Equalizer parameter 19092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 19112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 19122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 19132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 19142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 19152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 19172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 19182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 19192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 19222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter(EffectContext *pContext, 1925c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 19262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 19272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 19282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 19292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 1930c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 1931c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 19322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 19332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 19342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1935163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter start"); 19362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 19382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 19392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 19402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 19413be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_BAND_LEVEL: 19423be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_GET_BAND: 19432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int16_t)) { 1944163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 19452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 19462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 19482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 19513be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (*pValueSize < 2 * sizeof(int16_t)) { 19523be9523784cc4038f601e510faee595117cdacb3Eric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize); 19533be9523784cc4038f601e510faee595117cdacb3Eric Laurent return -EINVAL; 19543be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 19553be9523784cc4038f601e510faee595117cdacb3Eric Laurent *pValueSize = 2 * sizeof(int16_t); 19563be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 19572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 19582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < 2 * sizeof(int32_t)) { 1959d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 3 %d", *pValueSize); 19602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 19612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = 2 * sizeof(int32_t); 19632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19643be9523784cc4038f601e510faee595117cdacb3Eric Laurent 19652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 19662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)) { 1967d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 5 %d", *pValueSize); 19682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 19692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 19712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 19742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 197623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: 197723e1de74359f4bb1763aef0adfebe073122b032cEric Laurent if (*pValueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t)) { 197823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 197923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent return -EINVAL; 198023e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 198123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent *pValueSize = (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t); 198223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent break; 198323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 19842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 1985163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param); 19862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 19872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 19902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 19913be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)FIVEBAND_NUMBANDS; 1992163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue); 19932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 19963be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = -1500; 19973be9523784cc4038f601e510faee595117cdacb3Eric Laurent *((int16_t *)pValue + 1) = 1500; 1998163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", 1999d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue, *((int16_t *)pValue + 1)); 20002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2003c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 20052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20083be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2); 2009163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", 2010163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 20112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 2014c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 20162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2); 2020163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", 2021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 20222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 2025c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 20272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1)); 2031163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", 2032163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue, *((int32_t *)pValue + 1)); 20332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_BAND: 2036c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20373be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2); 2038163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", 2039d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // param2, *(uint16_t *)pValue); 20402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 20433be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext); 2044163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue); 20452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 20483be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetNumPresets(); 2049163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue); 20502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 2053c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent param2 = *pParamTemp; 20542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= EqualizerGetNumPresets()) { 20552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //if (param2 >= 20) { // AGO FIX 20562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name = (char *)pValue; 20602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1); 20612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name[*pValueSize - 1] = 0; 20622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = strlen(name) + 1; 2063163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", 2064163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, gEqualizerPresets[param2].name, *pValueSize); 20652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 206723e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: { 20683be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 206923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent LOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES"); 20703be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[0] = (int16_t)EqualizerGetPreset(pContext); 20713be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[1] = (int16_t)FIVEBAND_NUMBANDS; 207223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 20733be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[2 + i] = (int16_t)EqualizerGetBandLevel(pContext, i); 207423e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 207523e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } break; 207623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 20772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param); 20792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2083d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //GV("\tEqualizer_getParameter end\n"); 20842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 20852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_getParameter */ 20862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_setParameter() 20892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 20912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Equalizer parameter 20922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 20942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 20952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 20962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 20972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 20992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 2101c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 21022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 21032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t preset; 21042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t band; 21052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t level; 2106c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2107c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 2108c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 21092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2110163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter start"); 21112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 21122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 21133be9523784cc4038f601e510faee595117cdacb3Eric Laurent preset = (int32_t)(*(uint16_t *)pValue); 21142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2115163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset); 21162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ((preset >= EqualizerGetNumPresets())||(preset < 0)) { 21172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetPreset(pContext, preset); 21212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 2123c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent band = *pParamTemp; 21243be9523784cc4038f601e510faee595117cdacb3Eric Laurent level = (int32_t)(*(int16_t *)pValue); 2125163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level); 21262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (band >= FIVEBAND_NUMBANDS) { 21272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetBandLevel(pContext, band, level); 21312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21323be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_PROPERTIES: { 21333be9523784cc4038f601e510faee595117cdacb3Eric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES"); 21343be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 21353be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[0] >= EqualizerGetNumPresets()) { 21363be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 21373be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 21383be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 21393be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (p[0] >= 0) { 21403be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetPreset(pContext, (int)p[0]); 21413be9523784cc4038f601e510faee595117cdacb3Eric Laurent } else { 21423be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[1] != FIVEBAND_NUMBANDS) { 21433be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 21443be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 21453be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 21463be9523784cc4038f601e510faee595117cdacb3Eric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 21473be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetBandLevel(pContext, i, (int)p[2 + i]); 21483be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 21493be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 21503be9523784cc4038f601e510faee595117cdacb3Eric Laurent } break; 21512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 2152d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tLVM_ERROR : Equalizer_setParameter() invalid param %d", param); 21533be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 21542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2157163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter end"); 21582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 21592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_setParameter */ 21602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_getParameter() 21632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 21652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Volume parameter 21662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 21682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 21692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 21702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 21712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 21722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 21742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 21752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 21762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 21792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter(EffectContext *pContext, 2183c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent void *pParam, 21842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 21852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 21862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 21872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 2188c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2189c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++;; 21902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 21912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2192d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_getParameter start"); 21932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 21952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 21962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 21972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2198163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (*pValueSize != sizeof(int16_t)){ 21992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1 %d", *pValueSize); 22002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 22032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 22062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 22072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)){ 22082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2 %d", *pValueSize); 22092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 22122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 2215163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param); 22162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 22202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 22212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue)); 2222d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d", 2223d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 22242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 22272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = 0; 2228d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d", 2229d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 22302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2233163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeGetStereoPosition(pContext, (int16_t *)pValue); 2234d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d", 2235d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)pValue); 22362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2239163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeGetMute(pContext, (uint32_t *)pValue); 2240163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d", 2241163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(uint32_t *)pValue); 22422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2245163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled; 2246d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d", 2247d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(uint32_t *)pValue); 22482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 22512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param); 22522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 22532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2256163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_getParameter end"); 22572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 22582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_getParameter */ 22592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_setParameter() 22632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 22652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Volume parameter 22662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 22682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 22692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 22702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 22712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 22732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 22742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 22752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2276c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurentint Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue){ 22772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 22782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t level; 2279163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t position; 22802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent uint32_t mute; 2281163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t positionEnabled; 2282c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t *pParamTemp = (int32_t *)pParam; 2283c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int32_t param = *pParamTemp++; 22842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2285d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter start"); 22862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2287c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent switch (param){ 22882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 22892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent level = *(int16_t *)pValue; 2290d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level); 2291d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel"); 22922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeSetVolumeLevel(pContext, (int16_t)level); 2293d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel"); 22942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2297163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent mute = *(uint32_t *)pValue; 2298d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute); 2299d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() Calling pVolume->setMute"); 2300163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetMute(pContext, mute); 2301d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() Called pVolume->setMute"); 2302163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 23032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2305163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent positionEnabled = *(uint32_t *)pValue; 2306163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeEnableStereoPosition(pContext, positionEnabled); 2307163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved); 2308d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called"); 2309163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 23102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2312163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent position = *(int16_t *)pValue; 2313d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position); 2314d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition"); 2315163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, (int16_t)position); 2316d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition"); 2317163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 23182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 2320c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param); 23212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 23222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2324163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_setParameter end"); 23252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 23262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_setParameter */ 23272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2328163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent/**************************************************************************************** 2329163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Name : LVC_ToDB_s32Tos16() 2330163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Input : Signed 32-bit integer 2331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Output : Signed 16-bit integer 2332163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * MSB (16) = sign bit 2333163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (15->05) = integer part 2334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (04->01) = decimal part 2335163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Returns : Db value with respect to full scale 2336163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Description : 2337163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Remarks : 2338163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ****************************************************************************************/ 2339163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2340163fbcf84010b98e0374110454d85b804bc8d13bEric LaurentLVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) 2341163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent{ 2342163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 db_fix; 2343163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Shift; 2344163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 SmallRemainder; 2345163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_UINT32 Remainder = (LVM_UINT32)Lin_fix; 2346163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2347163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Count leading bits, 1 cycle in assembly*/ 2348163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (Shift = 0; Shift<32; Shift++) 2349163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2350163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((Remainder & 0x80000000U)!=0) 2351163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2352163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2353163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2354163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Remainder = Remainder << 1; 2355163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2357163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* 2358163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Based on the approximation equation (for Q11.4 format): 2359163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * 2360163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * dB = -96 * Shift + 16 * (8 * Remainder - 2 * Remainder^2) 2361163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent */ 2362163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(-96 * Shift); /* Six dB steps in Q11.4 format*/ 2363163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)((Remainder & 0x7fffffff) >> 24); 2364163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix + SmallRemainder ); 2365163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)(SmallRemainder * SmallRemainder); 2366163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - (LVM_INT16)((LVM_UINT16)SmallRemainder >> 9)); 23672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2368163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Correct for small offset */ 2369163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - 5); 23702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2371163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return db_fix; 2372163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 23732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2374163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 2375163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 23762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Process */ 23782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int Effect_process(effect_interface_t self, 2379163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *inBuffer, 2380163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *outBuffer){ 23812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 2382c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 2383c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 23842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 2385c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent int status2Sec = 0; 2386163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int lvmStatus = 0; 2387163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *in = (LVM_INT16 *)inBuffer->raw; 2388163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw; 23892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2390d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent//LOGV("\tEffect_process Start : Enabled = %d Called = %d", 2391d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent//pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled); 2392c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// LOGV("\tEffect_process Start : Samples left %d %d %d", 2393c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountBb, 2394c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountVirt, 2395c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// pContext->pBundledContext->SamplesToExitCountEq); 2396c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent 2397c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 2398c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition") 2399c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// if(LvmStatus != LVM_SUCCESS) return -EINVAL; 2400c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// LOGV("\tEffect_process Internal Operating Modes: BB %d VIRT %d EQ %d", 2401c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// ActiveParams.BE_OperatingMode, ActiveParams.VirtualizerOperatingMode, 2402c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent// ActiveParams.EQNB_OperatingMode); 24032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 24052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL"); 24062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (inBuffer == NULL || inBuffer->raw == NULL || 24092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer == NULL || outBuffer->raw == NULL || 24102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent inBuffer->frameCount != outBuffer->frameCount){ 24112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG"); 24122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2414163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&& 2415163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_BASS_BOOST)){ 2416c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent //LOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled"); 2417c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountBb > 0){ 2418c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status2Sec = -ENODATA; 2419c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO 2420c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent //LOGV("\tEffect_process: Waiting for 2 secs to turn off BASS_BOOST, %d samples left", 2421c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountBb); 2422c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } else { 2423163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2424c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 2425163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2426163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&& 2427163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VOLUME)){ 2428c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent //LOGV("\tEffect_process() LVM_VOLUME Effect is not enabled"); 2429163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2430163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2431163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&& 2432163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_EQUALIZER)){ 2433c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent //LOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled"); 2434c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountEq > 0){ 2435c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status2Sec = -ENODATA; 2436c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO 2437c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent //LOGV("\tEffect_process: Waiting for 2 secs to turn off EQUALIZER, %d samples left", 2438c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountEq); 2439c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } else { 2440c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2441c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 24422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2443163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&& 2444163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VIRTUALIZER)){ 2445c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent //LOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled"); 2446c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if(pContext->pBundledContext->SamplesToExitCountVirt > 0){ 2447c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status2Sec = -ENODATA; 2448c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO 2449c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent //LOGV("\tEffect_process: Waiting for 2 secs to turn off VIRTUALIZER, %d samples left", 2450c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent // pContext->pBundledContext->SamplesToExitCountVirt); 2451c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } else { 2452c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent status = -ENODATA; 2453c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent } 24542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2455163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2456163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If this is the last frame of an effect process its output with no effect 2457163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 2458163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 2459163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() accumulating last frame into output buffer"); 2460163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() trying copying last frame into output buffer"); 2461163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Enabled = %d Called = %d", 2462163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2463163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled); 2464163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2465163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2466163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() copying last frame into output buffer"); 2467163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2469163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2470c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent if((status2Sec != -ENODATA)&&(status != -ENODATA)){ 2471163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled++; 24722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2474163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->NumberEffectsCalled == 2475163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled){ 2476163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d", 2477163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2478163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 24792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2480163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 2481163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() actually processing last frame"); 2482163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 2484163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process all the available frames, block processing is 2485163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent handled internalLY by the LVM bundle */ 2486163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent lvmStatus = android::LvmBundle_process( (LVM_INT16 *)inBuffer->raw, 24872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_INT16 *)outBuffer->raw, 24882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer->frameCount, 24892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext); 2490163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(lvmStatus != LVM_SUCCESS){ 2491163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus); 2492163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return lvmStatus; 2493163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 2495163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d", 2496163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2497163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 2498163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // 2 is for stereo input 2499163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2); 25002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2501163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 25032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_process */ 25042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Command */ 25062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int Effect_command(effect_interface_t self, 250725f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdCode, 250825f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdSize, 2509163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pCmdData, 251025f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t *replySize, 2511163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pReplyData){ 25122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 25132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int retsize; 25142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2515163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\t\nEffect_command start"); 25162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2518163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_BASS_BOOST"); 25192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2521163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_VIRTUALIZER"); 2522163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 25232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2524163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_EQUALIZER"); 2525163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 25262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2527163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_VOLUME"); 2528163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 25292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 25312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL"); 25322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2535163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize); 25362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2537163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Incase we disable an effect, next time process is 2538163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // called the number of effect called could be greater 2539163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled = 0; 25402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2541163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", 2542163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled, 2543163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 25442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (cmdCode){ 25462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_INIT: 2547010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 2548010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent LOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d", 2549010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent pContext->EffectType); 2550010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent return -EINVAL; 2551010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent } 2552010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = 0; 2553163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start"); 25542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2555163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST"); 25562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::BassSetStrength(pContext, 0); 25572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2559163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER"); 2560163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VirtualizerSetStrength(pContext, 0); 2561163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 25622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2563163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER"); 2564163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::EqualizerSetPreset(pContext, 0); 2565163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 25662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2567d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VOLUME"); 2568010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0); 2569163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 25702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2571163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_CONFIGURE: 2573163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE start"); 25742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL|| 25752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize != sizeof(effect_config_t)|| 25762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 25772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int)){ 25782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 25792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_CONFIGURE: ERROR"); 25802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *) pReplyData = android::Effect_configure(pContext, (effect_config_t *) pCmdData); 2583163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE end"); 25842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_RESET: 2587163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start"); 25882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::Effect_configure(pContext, &pContext->config); 2589163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end"); 25902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 25912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_GET_PARAM:{ 2593163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2594163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2596163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2597163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2598163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2599163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 26002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 26012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 26022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 26052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 26072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 26092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 26112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::BassBoost_getParameter(pContext, 2613c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 26142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 26152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 26162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 26182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM " 2620163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2621163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2622163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2623163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 26242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2625163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 26262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2627163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2628163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2629163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2630163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 26312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 26322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 26332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 26362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 26382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 26402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 26422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Virtualizer_getParameter(pContext, 2644c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 26452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 26462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 26472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 26492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2650163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM " 2651163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2652163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 26552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2657163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command cmdCode Case: " 2658163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 2659163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2661163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2662163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) { 26632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 26642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM"); 26652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 2668163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 26692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 2670163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 26712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 2672163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 26732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 2674163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2675c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->status = android::Equalizer_getParameter(pContext, 2676c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data, 2677c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent &p->vsize, 2678c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent p->data + voffset); 2679163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 26802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 2681163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2682163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, " 2683163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pReplyData %08x %08x", 2684163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize, 2685163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset), 2686163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + 2687163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // sizeof(int32_t))); 26882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2690d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2692163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2693163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2694163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 26952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 26962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 26972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 27002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 27022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 27042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 27062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Volume_getParameter(pContext, 2708c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 27092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 27102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 27112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 27132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2714163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command EFFECT_CMD_GET_PARAM " 2715163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2716163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2717163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2718163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 2719163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2720163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end"); 27212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 27222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_PARAM:{ 2723163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 27242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2725163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2726163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2727163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2728163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2729163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2730163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2731163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2732163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2733163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 27342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 27352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 27362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 27392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 27412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 27422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 27432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2746163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tnBassBoost_command cmdSize is %d\n" 2747163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2748163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2749163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2750163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2751163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 27522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::BassBoost_setParameter(pContext, 2754c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 27552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + p->psize); 27562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2758d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 2759d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2760d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 2761d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2762163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2764163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2765163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2766163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 27672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 27682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 27692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 27722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 27742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 27752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 27762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2779163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tnVirtualizer_command cmdSize is %d\n" 2780163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2781163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2782163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2783163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2784163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 27852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Virtualizer_setParameter(pContext, 2787c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 2788163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 27892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2791d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEqualizer_command cmdCode Case: " 2792d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // "EFFECT_CMD_SET_PARAM start"); 2793d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2794d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2795d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *replySize, 2796d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 27972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 27992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL || *replySize != sizeof(int32_t)) { 28002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 28012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 28022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 28052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Equalizer_setParameter(pContext, 2807c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 2808163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 28092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2811d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tVolume_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 2812163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2813163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2814163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2815d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) +sizeof(int32_t))); 28162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ( pCmdData == NULL|| 28182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))|| 28192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 28202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int32_t)){ 28212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 28222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 28232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 28262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Volume_setParameter(pContext, 2828c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (void *)p->data, 2829163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 2830163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2831163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end"); 28322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 28332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_ENABLE: 2835c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start"); 28362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 28372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR"); 28382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 2839163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 28402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (pContext->EffectType){ 28412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_BASS_BOOST: 28422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){ 28432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 28442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 28452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bBassEnabled = LVM_TRUE; 2848d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEffect_command cmdCode Case:EFFECT_CMD_ENABLE LVM_BASS_BOOSTenabled"); 28492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 28502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_EQUALIZER: 28512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE){ 28522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 28532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 28542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE; 2857d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEffect_command cmdCode Case:EFFECT_CMD_ENABLE LVM_EQUALIZER enabled"); 2858163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 28592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VIRTUALIZER: 28602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 28612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 28622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 28632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE; 2866d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent //LOGV("\tEffect_command cmdCode :EFFECT_CMD_ENABLE LVM_VIRTUALIZER enabled"); 2867163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 28682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VOLUME: 28692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){ 28702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 28712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 28722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_TRUE; 2875d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_VOLUME enabled"); 28762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 28772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 28782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 28792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR, invalid Effect Type"); 2880163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 28812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = 0; 28832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2884163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2885c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountEq = 2886c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 0.1 secs Stereo 2887c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountBb = 2888c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*6); // 2 secs Stereo 2889c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountVirt = 2890c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 2 secs Stereo 2891c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE Samples to Exit = %d", 2892c59c6fd7f859b4010d788db89b8d4d76bbb70e57Eric Laurent pContext->pBundledContext->SamplesToExitCountBb); 2893163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE NumberEffectsEnabled = %d", 2894163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 2895163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE end"); 28962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2897163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 28982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_DISABLE: 2899163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start"); 29002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 29012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR"); 29022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 2903163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 29042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (pContext->EffectType){ 29052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_BASS_BOOST: 29062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_FALSE){ 29072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 29082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 29092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2911163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 2912163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2913163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_BASS_BOOST disabled"); 29142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 29152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_EQUALIZER: 29162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE){ 29172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 29182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 29192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 2922163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2923163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_EQUALIZER disabled"); 2924163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 29252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VIRTUALIZER: 29262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE){ 29272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 29282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 29292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 2932163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2933163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_VIRTUALIZER disabled"); 2934163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 29352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VOLUME: 29362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVolumeEnabled == LVM_FALSE){ 29372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 29382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 29392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 2942163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE LVM_VOLUME disabled"); 29432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 29442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 29452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 29462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR, invalid Effect Type"); 2947163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 2948163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 29492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = 0; 29502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 2951163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2952163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE NumberEffectsEnabled = %d", 2953163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 2954163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE end"); 29552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 29562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_DEVICE: 2958163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2959163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start"); 2960163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_device_e device = *(audio_device_e *)pCmdData; 2961163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2962163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2963163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)|| 2964163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){ 2965163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d", 2966163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2967163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST"); 2968163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2969163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device doesnt support bassboost the effect must be temporarily disabled 2970163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 2971163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 2972163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2973163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){ 2974163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d", 2975163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2976163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2977163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_TRUE; 2978163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2979163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2980163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d", 2981163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2982163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2983163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports bassboost and the effect has been temporarily disabled 2984163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 2985163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2986163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassTempDisabled == LVM_TRUE){ 2987163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d", 2988163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2989163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2990163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 2991163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2992163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2993163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2994163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2995163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)|| 2996163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){ 2997163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d", 2998163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2999163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER"); 3000163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3001163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //If a device doesnt support virtualizer the effect must be temporarily disabled 3002163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 3003163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 3004163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3005163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 3006163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d", 3007163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3008163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 3009163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE; 3010163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3011163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 3012163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d", 3013163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3014163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3015163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports virtualizer and the effect has been temporarily disabled 3016163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 3017163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3018163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerTempDisabled == LVM_TRUE){ 3019163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d", 3020163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 3021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 3022163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 3023163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3024163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3025163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3026163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end"); 30272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 3028163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3029163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_VOLUME: 3030163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 3031163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t vol = *(int32_t *)pCmdData; 3032163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t dB; 3033163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume 3034163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3035163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // if pReplyData is NULL, VOL_CTRL is delegated to another effect 3036163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pReplyData == LVM_NULL){ 3037163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3038163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 30392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3040163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(vol==0x1000000){ 3041163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent vol -= 1; 3042163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3043163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Convert volume linear (Q8.24) to volume dB (0->-96) 3044163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = android::LVC_ToDB_s32Tos16(vol <<7); 3045163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = (dB +8)>>4; 3046163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = (dB <-96) ? -96 : dB ; 3047163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3048d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent LOGV("\tEFFECT_CMD_SET_VOLUME Session: %d, SessionID: %d VOLUME is %d dB (%d), " 3049d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent "effect is %d", 3050d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent pContext->pBundledContext->SessionNo, pContext->pBundledContext->SessionId, 3051d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent (int32_t)dB, vol<<7, pContext->EffectType); 3052d918324d44aa48b3b064ea9b87d0c520c38f15a9Eric Laurent 3053163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(pReplyData, vol_ret, sizeof(int32_t)*2); 3054163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VolumeSetVolumeLevel(pContext, (int16_t)(dB*100)); 3055163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 3056163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3057163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_AUDIO_MODE: 3058163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 30592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 30602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 30612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 30622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3063163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command end...\n\n"); 30642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 30652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_command */ 30662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 30672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// effect_interface_t interface implementation for effect 30682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst struct effect_interface_s gLvmEffectInterface = { 30692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_process, 30702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_command 30712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; /* end gLvmEffectInterface */ 30722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3073