EffectBundle.cpp revision 163fbcf84010b98e0374110454d85b804bc8d13b
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]) 20163fbcf84010b98e0374110454d85b804bc8d13bEric 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#define LVM_MAX_SESSIONS 32 302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define MAX_NUM_BANDS 5 312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define MAX_CALL_SIZE 256 322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// effect_interface_t interface implementation for bass boost 342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" const struct effect_interface_s gLvmEffectInterface; 352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\ 372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_NULLADDRESS){\ 382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Parameter error - "\ 392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_ALIGNMENTERROR){\ 422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Parameter error - "\ 432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad alignment returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_INVALIDNUMSAMPLES){\ 462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Parameter error - "\ 472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\ 482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (LvmStatus == LVM_OUTOFRANGE){\ 502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Parameter error - "\ 512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "out of range returned by %s in %s\n", callingFunc, calledFunc);\ 522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }\ 532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Namespaces 562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace android { 572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentnamespace { 582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* local functions */ 602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent#define CHECK_ARG(cond) { \ 612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (!(cond)) { \ 622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Invalid argument: "#cond); \ 632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; \ 642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } \ 652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 67163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Flag to allow a one time init of global memory, only happens on first call ever 682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmInitFlag = LVM_FALSE; 692c8e5cab3faa6d360e222b7a6c40a80083d021acEric LaurentSessionContext GlobalSessionMemory[32]; 702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW BassBoost UUID 722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gBassBoostDescriptor = { 732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x8631f300, 0x72e2, 0x11df, 0xb57e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid 752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 76163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 77163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0, // TODO 792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1, 802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Dynamic Bass Boost", 812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Virtualizer UUID 852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVirtualizerDescriptor = { 86163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 87163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent {0x1d4033c0, 0x8557, 0x11df, 0x9f2d, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, 882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 89163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_DEVICE_IND 90163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent | EFFECT_FLAG_VOLUME_CTRL), 912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0, // TODO 922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1, 932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Virtualizer", 942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Equalizer UUID 982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gEqualizerDescriptor = { 992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type 1002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0xce772f20, 0x847d, 0x11df, 0xbb17, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid Eq NXP 1012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 102163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 1032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0, // TODO 1042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1, 1052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Equalizer", 1062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// NXP SW Volume UUID 1102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst effect_descriptor_t gVolumeDescriptor = { 1112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x09e8ede0, 0xddde, 0x11db, 0xb4f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, 1122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent {0x119341a0, 0x8469, 0x11df, 0x81f9, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, //uuid VOL NXP 1132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EFFECT_API_VERSION, 114163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_VOLUME_CTRL), 1152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0, // TODO 1162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1, 1172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "Volume", 1182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "NXP Software Ltd.", 1192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; 1202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--- local function prototypes 1222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init (void); 1232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init (EffectContext *pContext); 1242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable (EffectContext *pContext); 1252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable (EffectContext *pContext); 1262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free (EffectContext *pContext); 127163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint Effect_configure (EffectContext *pContext, effect_config_t *pConfig); 1282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue); 129163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint BassBoost_getParameter (EffectContext *pContext, 1302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 1312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 1332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue); 1342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter (EffectContext *pContext, 1352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 1362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 137163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue); 1382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue); 1392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter (EffectContext *pContext, 1402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 1412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 1432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue); 1442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter (EffectContext *pContext, 1452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 1462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 1472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue); 1482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Library Interface Implementation */ 1502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){ 1512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\n\tEffectQueryNumberEffects start"); 1522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pNumEffects = 4; 153163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects); 154163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectQueryNumberEffects end\n"); 1552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryNumberEffects */ 1572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){ 1592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\n\tEffectQueryEffect start"); 1602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing index %d", index); 161163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pDescriptor == NULL){ 163163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer"); 1642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 1652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (index > 3){ 167163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index); 1682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -ENOENT; 1692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(index == LVM_BASS_BOOST){ 1712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_BASS_BOOST"); 1722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gBassBoostDescriptor, sizeof(effect_descriptor_t)); 1732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else if(index == LVM_VIRTUALIZER){ 1742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER"); 1752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gVirtualizerDescriptor, sizeof(effect_descriptor_t)); 1762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_EQUALIZER){ 1772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_EQUALIZER"); 1782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t)); 1792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(index == LVM_VOLUME){ 1802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect processing LVM_VOLUME"); 1812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pDescriptor, &gVolumeDescriptor, sizeof(effect_descriptor_t)); 182163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectQueryEffect end\n"); 1842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 1852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectQueryEffect */ 1862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectCreate(effect_uuid_t *uuid, 1882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t sessionId, 1892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t ioId, 1902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_interface_t *pInterface){ 1912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int ret; 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 2022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if((sessionId < 0)||(sessionId >= LVM_MAX_SESSIONS)){ 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 2132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // If this is the first create in this session 2142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(GlobalSessionMemory[sessionId].bBundledEffectsEnabled == LVM_FALSE){ 2152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - This is the first effect in current session %d", sessionId); 2162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - Setting up Bundled Effects Instance for session %d", sessionId); 217163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[sessionId].bBundledEffectsEnabled = LVM_TRUE; 2192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[sessionId].pBundledContext = new BundledEffectContext; 2202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext; 222163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->SessionNo = sessionId; 223163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = NULL; 224163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 225163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 226163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 227163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 228163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 229163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 230163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled = 0; 231163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 232163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->frameCount = 0; 233163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 234163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 235163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmInPtr = NULL; 236163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmOutPtr = NULL; 237163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 238163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmInPtr = fopen("/data/tmp/bundle_pcm_in.pcm", "w"); 239163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->PcmOutPtr = fopen("/data/tmp/bundle_pcm_out.pcm", "w"); 240163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 241163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((pContext->pBundledContext->PcmInPtr == NULL)|| 242163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->pBundledContext->PcmOutPtr == NULL)){ 243163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 244163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 245163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 246163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Saved strength is used to return the exact strength that was used in the set to the get 2482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * because we map the original strength range of 0:1000 to 1:15, and this will avoid 2492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * quantisation like effect when returning 2502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 251163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->BassStrengthSaved = 0; 252163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = 0; 253163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 254163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = 0; 255163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled = LVM_FALSE; 256163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = LVM_FALSE; 257163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = 0; 258163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - Calling LvmBundle_init"); 2602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ret = LvmBundle_init(pContext); 2612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (ret < 0){ 2632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : EffectCreate() Bundle init failed"); 2642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext->pBundledContext; 2652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext; 2662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return ret; 2672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 2702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext; 2712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 272163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext); 2742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create each Effect 2762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 2772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Bass Boost 2782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST"); 2792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[sessionId].bBassInstantiated = LVM_TRUE; 280163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 281163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->itfe = &gLvmEffectInterface; 2822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_BASS_BOOST; 2832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 2842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Virtualizer 285163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER"); 2862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[sessionId].bVirtualizerInstantiated = LVM_TRUE; 287163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 2892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VIRTUALIZER; 2902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 2912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Equalizer 292163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER"); 2932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[sessionId].bEqualizerInstantiated = LVM_TRUE; 294163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 2962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_EQUALIZER; 2972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){ 2982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Create Volume 299163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate - Effect to be created is LVM_VOLUME"); 3002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[sessionId].bVolumeInstantiated = LVM_TRUE; 301163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->itfe = &gLvmEffectInterface; 3032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->EffectType = LVM_VOLUME; 304163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent else{ 306163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectCreate() invalid UUID"); 307163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 3082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pInterface = (effect_interface_t)pContext; 311163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectCreate end..\n\n"); 3122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 3132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectCreate */ 3142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int EffectRelease(effect_interface_t interface){ 3162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\n\tEffectRelease start %p", interface); 3172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *)interface; 3182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 320163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer"); 3212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 322163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 3232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // Clear the instantiated flag for the effect 3252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 3262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag"); 327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated = LVM_FALSE; 3282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VIRTUALIZER) { 3292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag"); 330163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated 331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent = LVM_FALSE; 3322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_EQUALIZER) { 3332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag"); 334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated =LVM_FALSE; 3352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else if(pContext->EffectType == LVM_VOLUME) { 3362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag"); 337163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated = LVM_FALSE; 3382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 3392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n"); 3402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 341163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 3422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // if all effects are no longer instantiaed free the lvm memory and delete BundledEffectContext 3432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if((GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated == LVM_FALSE)&& 344163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated == LVM_FALSE)&& 345163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated ==LVM_FALSE)&& 346163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated==LVM_FALSE)) 3472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 348163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 349163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fclose(pContext->pBundledContext->PcmInPtr); 350163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fclose(pContext->pBundledContext->PcmOutPtr); 351163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 352163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectRelease: All effects are no longer instantiated\n"); 353163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBundledEffectsEnabled =LVM_FALSE; 354163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent GlobalSessionMemory[pContext->pBundledContext->SessionNo].pBundledContext = LVM_NULL; 355163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectRelease: Freeing LVM Bundle memory\n"); 356163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmEffect_free(pContext); 357163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffectRelease: Deleting LVM Bundle context\n"); 358163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent delete pContext->pBundledContext; 3592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent // free the effect context for current effect 3612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent delete pContext; 3622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tEffectRelease end\n"); 3642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 3652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end EffectRelease */ 3672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmGlobalBundle_init(){ 3692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmGlobalBundle_init start"); 3702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for(int i=0; i<LVM_MAX_SESSIONS; i++){ 3712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBundledEffectsEnabled = LVM_FALSE; 3722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVolumeInstantiated = LVM_FALSE; 3732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bEqualizerInstantiated = LVM_FALSE; 3742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bBassInstantiated = LVM_FALSE; 3752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE; 3762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent GlobalSessionMemory[i].pBundledContext = LVM_NULL; 3772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 3782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 3792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 3802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 3812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_init() 3822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 3832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Initialize engine with default configuration, creates instance 3842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// with all effects disabled. 3852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 3862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 3872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 3882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 3892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 3902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 3912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 3922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_init(EffectContext *pContext){ 3942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status; 3952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 3962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init start"); 3972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 398163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; 399163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.channels = CHANNEL_STEREO; 400163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15; 401163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.samplingRate = 44100; 402163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.getBuffer = NULL; 403163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL; 404163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.bufferProvider.cookie = NULL; 405163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL; 406163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; 407163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.channels = CHANNEL_STEREO; 408163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15; 409163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.samplingRate = 44100; 410163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.getBuffer = NULL; 411163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL; 412163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.bufferProvider.cookie = NULL; 413163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL; 4142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 4162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext->pBundledContext->hInstance != NULL){ 4182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 4192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Calling pContext->pBassBoost->free()"); 4202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmEffect_free(pContext); 4222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init pContext->pBassBoost != NULL " 4242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "-> Called pContext->pBassBoost->free()"); 4252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 4282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 4292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_InstParams_t InstParams; /* Instance parameters */ 4302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_EQNB_BandDef_t BandDefs[MAX_NUM_BANDS]; /* Equaliser band definitions */ 4312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomParams_t HeadroomParams; /* Headroom parameters */ 4322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_HeadroomBandDef_t HeadroomBandDef[LVM_HEADROOM_MAX_NBANDS]; 4332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; /* Memory allocation table */ 4342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bool bMallocFailure = LVM_FALSE; 4352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the capabilities */ 437163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent InstParams.BufferMode = LVM_UNMANAGED_BUFFERS; 4382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.MaxBlockSize = MAX_CALL_SIZE; 4392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.EQNB_NumBands = MAX_NUM_BANDS; 4402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent InstParams.PSA_Included = LVM_PSA_ON; 4412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory, forcing alignment */ 4432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(LVM_NULL, 4442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 4452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 4462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmBundle_init") 4482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 4492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n"); 4512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Allocate memory */ 4532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 4542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 4552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size); 4562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 458163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes for region %u\n", 4592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i ); 4602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent bMallocFailure = LVM_TRUE; 4612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 462163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance allocated %ld bytes for region %u at %p\n", 4632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 4642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* If one or more of the memory regions failed to allocate, free the regions that were 4692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent * succesfully allocated and return with an error 4702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent */ 4712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(bMallocFailure == LVM_TRUE){ 4722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 4732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress == LVM_NULL){ 474163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed to allocate %ld bytes for region %u - +" 475163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent "Not freeing\n", MemTab.Region[i].Size, i ); 4762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 477163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR :LvmBundle_init CreateInstance Failed: but allocated %ld bytes " 478163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent "for region %u at %p- free\n", 479163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 4802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 4812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 4832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 4842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 485163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully malloc'd memory\n"); 4862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Initialise */ 488163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->hInstance = LVM_NULL; 4892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 490163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Init sets the instance handle */ 491163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetInstanceHandle(&pContext->pBundledContext->hInstance, 4922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 4932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &InstParams); 4942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 4952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "LvmBundle_init") 4962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 4972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 498163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_GetInstanceHandle\n"); 4992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the initial process parameters */ 5012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* General parameters */ 5022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.OperatingMode = LVM_MODE_ON; 5032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SampleRate = LVM_FS_44100; 5042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SourceFormat = LVM_STEREO; 5052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.SpeakerType = LVM_HEADPHONES; 5062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 507163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->SampleRate = LVM_FS_44100; 508163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 5092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Concert Sound parameters */ 5102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerOperatingMode = LVM_MODE_OFF; 5112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerType = LVM_CONCERTSOUND; 5122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VirtualizerReverbLevel = 100; 5132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.CS_EffectLevel = LVM_CS_EFFECT_HIGH; 5142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* N-Band Equaliser parameters */ 5162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_OperatingMode = LVM_EQNB_OFF; 5172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.EQNB_NBands = FIVEBAND_NUMBANDS; 5182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.pEQNB_BandDefinition = &BandDefs[0]; 519163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 5202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 5212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 5222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 5232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BandDefs[i].QFactor = EQNB_5BandPresetsQFactors[i]; 524163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDefs[i].Gain = EQNB_5BandSoftPresets[i]; 5252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 5262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume Control parameters */ 5282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_EffectLevel = 0; 5292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.VC_Balance = 0; 5302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Treble Enhancement parameters */ 5322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_OperatingMode = LVM_TE_OFF; 5332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.TE_EffectLevel = 0; 5342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 5362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 5372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = (LVM_PSA_DecaySpeed_en)0; 5382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 5402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_OperatingMode = LVM_BE_OFF; 5412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_EffectLevel = 0; 5422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 5432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.BE_HPF = LVM_BE_HPF_ON; 5442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* PSA Control parameters */ 5462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_Enable = LVM_PSA_OFF; 5472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent params.PSA_PeakDecayRate = LVM_PSA_SPEED_MEDIUM; 5482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 549163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 550163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, 5512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ¶ms); 5522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmBundle_init") 5542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 5552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 556163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetControlParameters\n"); 5572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set the headroom parameters */ 5592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_Low = 20; 5602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Limit_High = 4999; 5612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[0].Headroom_Offset = 3; 5622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_Low = 5000; 5632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Limit_High = 24000; 5642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomBandDef[1].Headroom_Offset = 4; 5652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.pHeadroomDefinition = &HeadroomBandDef[0]; 5662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON; 5672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent HeadroomParams.NHeadroomBands = 2; 5682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetHeadroomParams(pContext->pBundledContext->hInstance, 5702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &HeadroomParams); 5712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetHeadroomParams", "LvmBundle_init") 5732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 5742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 575163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmBundle_init CreateInstance Succesfully called LVM_SetHeadroomParams\n"); 5762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLvmBundle_init End"); 5772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 5782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_init */ 5792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmBundle_process() 5822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 5842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply LVM Bundle effects 5852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 5872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pIn: pointer to stereo 16 bit input data 5882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to stereo 16 bit output data 5892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// frameCount: Frames to process 5902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 5912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 5922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 5942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pOut: pointer to updated stereo 16 bit output data 5952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 5962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 5972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 5982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmBundle_process(LVM_INT16 *pIn, 599163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOut, 600163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int frameCount, 601163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent EffectContext *pContext){ 6022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 6042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 6052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 606163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *pOutTmp; 607163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE){ 608163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOutTmp = pOut; 609163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 610163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOutTmp = (LVM_INT16 *)malloc(frameCount * sizeof(LVM_INT16) * 2); 611163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pOutTmp == NULL){ 612163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : LvmBundle_process failed to allocate memory for " 613163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent "EFFECT_BUFFER_ACCESS_ACCUMULATE mode"); 614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 616163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 617163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("LVM_ERROR : LvmBundle_process invalid access mode"); 618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 6202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 621163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 622163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 6232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 6242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 625163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmBundle_process") 6262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 628163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->frameCount++; 629163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->frameCount == 100) 630163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 631163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBB: %d VIRT: %d EQ: %d, session (%d), context is %p\n", 632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.BE_OperatingMode, 633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.VirtualizerOperatingMode, ActiveParams.EQNB_OperatingMode, 634163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->SessionNo, pContext->pBundledContext); 635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->frameCount = 0; 636163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 637163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 638163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 639163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pIn, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmInPtr); 640163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmInPtr); 641163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 642163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 643163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process the samples */ 6442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_Process(pContext->pBundledContext->hInstance, /* Instance handle */ 6452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pIn, /* Input buffer */ 6462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pOutTmp, /* Output buffer */ 6472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_UINT16)frameCount, /* Number of samples to read */ 6482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 0); /* Audo Time */ 649163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_Process", "LvmBundle_process") 6512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 6522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #ifdef LVM_PCM 654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fwrite(pOutTmp, frameCount*sizeof(LVM_INT16)*2, 1, pContext->pBundledContext->PcmOutPtr); 655163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent fflush(pContext->pBundledContext->PcmOutPtr); 656163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent #endif 657163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 658163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 659163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (int i=0; i<frameCount*2; i++){ 660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pOut[i] += pOutTmp[i]; 661163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 662163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent free(pOutTmp); 663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 6642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 6652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmBundle_process */ 6662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_enable() 6692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Enable the effect in the bundle 6712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 6722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 6732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 6742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 6752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 6762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 6772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 6782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_enable(EffectContext *pContext){ 680163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable start"); 681163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 6822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 6832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 6842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 685163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 686163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 6872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 6882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_enable") 6902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable Succesfully called LVM_GetControlParameters\n"); 6922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 6932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 694163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_BASS_BOOST"); 6952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_ON; 6962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 6972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 698163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_VIRTUALIZER"); 6992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_ON; 7002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 702163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_EQUALIZER"); 7032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_ON; 7042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 706163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_enable : Enabling LVM_VOLUME"); 707163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 708163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 7102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_enable") 7112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 712163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 713163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n"); 714163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_enable end"); 7152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 7172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_disable() 7202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Disable the effect in the bundle 7222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 7272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint LvmEffect_disable(EffectContext *pContext){ 731163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable start"); 732163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 7342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 735163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 736163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 7372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 7382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_disable") 7402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 741163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable Succesfully called LVM_GetControlParameters\n"); 7422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST) { 744163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Disabling LVM_BASS_BOOST"); 7452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_OperatingMode = LVM_BE_OFF; 7462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER) { 748163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Enabling LVM_VIRTUALIZER"); 7492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerOperatingMode = LVM_MODE_OFF; 7502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER) { 752163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Enabling LVM_EQUALIZER"); 7532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.EQNB_OperatingMode = LVM_EQNB_OFF; 7542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 7552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME) { 756163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_disable : Enabling LVM_VOLUME"); 757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 758163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 7592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 7602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_disable") 7612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 762163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n"); 764163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLvmEffect_disable end"); 7652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 7662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 7672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// LvmEffect_free() 7702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Free all memory associated with the Bundle. 7722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 7742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 7752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 7772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 7782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 7792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid LvmEffect_free(EffectContext *pContext){ 7812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 7822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t params; /* Control Parameters */ 7832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_MemTab_t MemTab; 7842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Free the algorithm memory */ 7862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetMemoryTable(pContext->pBundledContext->hInstance, 7872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &MemTab, 7882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_NULL); 7892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "LvmEffect_free") 7912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){ 7932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].Size != 0){ 7942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (MemTab.Region[i].pBaseAddress != NULL){ 795163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_free - START freeing %ld bytes for region %u at %p\n", 7962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 7972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 7982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent free(MemTab.Region[i].pBaseAddress); 7992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 800163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLvmEffect_free - END freeing %ld bytes for region %u at %p\n", 8012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 8022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 803163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : LvmEffect_free - trying to free with NULL pointer %ld bytes " 8042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "for region %u at %p ERROR\n", 8052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress); 8062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 8092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end LvmEffect_free */ 8102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Effect_configure() 8132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Set input and output audio configuration. 8152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 8172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 8182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pConfig: pointer to effect_config_t structure holding input and output 8192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// configuration parameters 8202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 8222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 8232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Effect_configure(EffectContext *pContext, effect_config_t *pConfig){ 826163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_Fs_en SampleRate; 827163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_configure start"); 8282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pContext != NULL); 8302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig != NULL); 8312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate); 8332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels); 8342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format); 8352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.channels == CHANNEL_STEREO); 8362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE 8372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE); 8382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15); 8392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(&pContext->config, pConfig, sizeof(effect_config_t)); 8412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 842163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent switch (pConfig->inputCfg.samplingRate) { 843163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 8000: 844163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_8000; 845163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 846163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 16000: 847163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_16000; 848163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 849163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 22050: 850163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_22050; 851163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 852163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 32000: 853163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_32000; 854163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 855163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 44100: 856163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_44100; 857163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 858163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case 48000: 859163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SampleRate = LVM_FS_48000; 860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 861163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent default: 862163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate); 863163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 864163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 8652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 866163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->SampleRate != SampleRate){ 8672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 868163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; 869163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; 8702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 871163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_configure change sampling rate to %d", SampleRate); 8722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 873163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 874163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 875163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 8762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 877163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_configure") 878163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 8792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 880163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 8812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 882163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_configure") 883163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_configure Succesfully called LVM_SetControlParameters\n"); 8842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 885163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 886163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_configure keep sampling rate at %d", SampleRate); 887163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 8882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 889163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_configure End...."); 890163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 891163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end Effect_configure */ 8922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 8932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassGetStrength() 8952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 8962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 8972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 8982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 8992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// the bassboost uses 1-15, so to avoid a quantisation the original set value is used. However the 9002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 9012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t BassGetStrength(EffectContext *pContext){ 908163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength() (0-1000) -> %d\n", pContext->pBundledContext->BassStrengthSaved); 9092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 9112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 912163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 913163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 9142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 9152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassGetStrength") 9172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 9182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 919163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength Succesfully returned from LVM_GetControlParameters\n"); 9202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Check that the strength returned matches the strength that was set earlier */ 922163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(ActiveParams.BE_EffectLevel != 923163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (LVM_INT16)((15*pContext->pBundledContext->BassStrengthSaved)/1000)){ 9242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassGetStrength module strength does not match savedStrength %d %d\n", 9252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel, pContext->pBundledContext->BassStrengthSaved); 9262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 9272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 9282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 929163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 930163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassGetStrength() (saved) -> %d\n", pContext->pBundledContext->BassStrengthSaved ); 9312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return pContext->pBundledContext->BassStrengthSaved; 9322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassGetStrength */ 9332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassSetStrength() 9362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 9382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the BassBosst. Must first be converted from the range 0-1000 to 1-15 9392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 9432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid BassSetStrength(EffectContext *pContext, uint32_t strength){ 947163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength(%d)", strength); 9482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->BassStrengthSaved = (int)strength; 9502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 9522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 9532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 9552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 9562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent &ActiveParams); 9572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "BassSetStrength") 959163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength Succesfully returned from LVM_GetControlParameters\n"); 9602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Bass Enhancement parameters */ 9622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_EffectLevel = (LVM_INT16)((15*strength)/1000); 9632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.BE_CentreFreq = LVM_BE_CENTRE_90Hz; 9642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 965163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength() (0-15) -> %d\n", ActiveParams.BE_EffectLevel ); 9662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 9682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 9692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength") 971163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n"); 9722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassSetStrength */ 9732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerGetStrength() 9762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 9782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// get the effect strength currently being used, what is actually returned is the strengh that was 9792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// previously used in the set, this is because the app uses a strength in the range 0-1000 while 980163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// the Virtualizer uses 1-100, so to avoid a quantisation the original set value is used.However the 9812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// actual used value is checked to make sure it corresponds to the one being returned 9822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 9842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 9852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 9862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 9872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentuint32_t VirtualizerGetStrength(EffectContext *pContext){ 989163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerGetStrength (0-1000) -> %d\n",pContext->pBundledContext->VirtStrengthSaved); 9902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 9922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 9932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 9952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 9962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerGetStrength") 9972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 9982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 999163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerGetStrength Succesfully returned from LVM_GetControlParameters\n"); 1000163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerGetStrength() (0-100) -> %d\n", ActiveParams.VirtualizerReverbLevel*10); 10012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return ActiveParams.VirtualizerReverbLevel*10; 10022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getStrength */ 10032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VirtualizerSetStrength() 10062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Apply the strength to the Virtualizer. Must first be converted from the range 0-1000 to 1-15 10092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// strength strength to be applied 10132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){ 1017163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength(%d)", strength); 10182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 10202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1021163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->VirtStrengthSaved = (int)strength; 1022163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 10232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 10242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,&ActiveParams); 10252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VirtualizerSetStrength") 1027163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength Succesfully returned from LVM_GetControlParameters\n"); 10282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Virtualizer parameters */ 10302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VirtualizerReverbLevel = (LVM_INT16)(strength/10); 10312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1032163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength ); 1033163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.VirtualizerReverbLevel ); 10342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 10362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 10372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength") 1038163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n"); 10392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setStrength */ 10402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandLevel() 10432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the gain currently being used for the band passed in 10452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 10482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 10512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){ 10542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1055163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Gain =0; 1056163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1057163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1058163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1059163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1060163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1061163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 10622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1063163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetBandLevel") 10642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1065163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1066163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Gain = (int32_t)BandDef[band].Gain*100; // Convert to millibels 10672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1068163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetBandLevel -> %d\n", Gain ); 1069163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 1070163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Gain; 10712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 10722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 10732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetBandLevel() 10752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 10762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 10772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets gain value for the given band. 10782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 10802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 10812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gain: Gain to be applied in millibels 10822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 10832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 10852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 10862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//--------------------------------------------------------------------------- 10872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid EqualizerSetBandLevel(EffectContext *pContext, int band, int Gain){ 1088163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int gainRounded; 1089163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(Gain > 0){ 1090163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain+50)/100); 1091163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1092163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent gainRounded = (int)((Gain-50)/100); 1093163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1094163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded); 1095163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1096163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 10972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 10982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1099163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 11002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 11022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1103163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetBandLevel") 1104163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetBandLevel Succesfully returned from LVM_GetControlParameters\n"); 1105163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetBandLevel just Got -> %d\n", ActiveParams.pEQNB_BandDefinition[band].Gain); 11062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set local EQ parameters */ 1108163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1109163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[band].Gain = gainRounded; 11102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 11122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1113163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetBandLevel") 1114163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetBandLevel just Set -> %d\n", ActiveParams.pEQNB_BandDefinition[band].Gain); 11152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = PRESET_CUSTOM; 11172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 11182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 11192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetCentreFrequency() 11212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: Retrieve the frequency being used for the band passed in 11232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 11262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 11292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetCentreFrequency(EffectContext *pContext, int32_t band){ 1132163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t Frequency =0; 11332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1134163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1135163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1136163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_EQNB_BandDef_t *BandDef; 1137163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1138163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, 1139163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent &ActiveParams); 11402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1141163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetCentreFrequency") 11422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1143163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent BandDef = ActiveParams.pEQNB_BandDefinition; 1144163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Frequency = (int32_t)BandDef[band].Frequency*1000; // Convert to millibels 11452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1146163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetCentreFrequency -> %d\n", Frequency ); 1147163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetCentreFrequency Succesfully returned from LVM_GetControlParameters\n"); 1148163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return Frequency; 11492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 11502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBandFreqRange( 11532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets lower and upper boundaries of a band. 11572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the high shelf, the low bound is the band frequency and the high 11582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// bound is Nyquist. 11592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// For the peaking filters, they are the gain[dB]/2 points. 11602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// band: band number 11632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 11662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 11672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 11682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1169163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t EqualizerGetBandFreqRange(EffectContext *pContext, int32_t band, uint32_t *pLow, 1170163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t *pHi){ 1171163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pLow = bandFreqRange[band][0]; 1172163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *pHi = bandFreqRange[band][1]; 1173163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 11742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 11752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 11762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetBand( 11782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 11802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Returns the band with the maximum influence on a given frequency. 11822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Result is unaffected by whether EQ is enabled or not, or by whether 11832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// changes have been committed or not. 11842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 11862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// targetFreq The target frequency, in millihertz. 11872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 11882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 11892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 11902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: lower band range 11912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pLow: upper band range 11922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 11932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetBand(EffectContext *pContext, uint32_t targetFreq){ 11942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int band = 0; 11952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1196163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(targetFreq < bandFreqRange[0][0]){ 1197163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1198163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else if(targetFreq == bandFreqRange[0][0]){ 1199163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1200163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1201163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for(int i=0; i<FIVEBAND_NUMBANDS;i++){ 1202163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((targetFreq > bandFreqRange[i][0])&&(targetFreq <= bandFreqRange[i][1])){ 1203163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent band = i; 1204163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1205163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 12062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return band; 12072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPreset( 12112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets the currently set preset ID. 12152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Will return PRESET_CUSTOM in case the EQ parameters have been modified 12162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// manually since a preset was set. 12172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetPreset(EffectContext *pContext){ 1223163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return pContext->pBundledContext->CurPreset; 12242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerSetPreset( 12282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Sets the current preset by ID. 12322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// All the band parameters will be overridden. 12332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 12362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. 12372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentvoid EqualizerSetPreset(EffectContext *pContext, int preset){ 12402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1241163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetPreset(%d)", preset); 12422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->CurPreset = preset; 12432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 12452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 12462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 12482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1249163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetPreset") 1250163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetPreset Succesfully returned from LVM_GetControlParameters\n"); 12512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //ActiveParams.pEQNB_BandDefinition = &BandDefs[0]; 12532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent for (int i=0; i<FIVEBAND_NUMBANDS; i++) 12542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent { 1255163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i]; 1256163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i]; 1257163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.pEQNB_BandDefinition[i].Gain 1258163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent = EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS]; 12592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 12602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the new settings */ 12612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetPreset") 12632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1264163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n"); 12652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return; 12662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 1267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 12682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t EqualizerGetNumPresets(){ 1269163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return sizeof(gEqualizerPresets) / sizeof(PresetConfig); 12702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// EqualizerGetPresetName( 12742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Gets a human-readable name for a preset ID. Will return "Custom" if 12772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// PRESET_CUSTOM is passed. 12782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 12802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// preset The preset ID. Must be less than number of presets. 12812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//------------------------------------------------------------------------- 12832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst char * EqualizerGetPresetName(int32_t preset){ 1284163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetPresetName start(%d)", preset); 12852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (preset == PRESET_CUSTOM) { 12862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return "Custom"; 12872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } else { 12882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return gEqualizerPresets[preset].name; 12892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1290163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizerGetPresetName end(%d)", preset); 1291163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 12922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} 12932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 12942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetVolumeLevel() 12962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 12972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 12982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 12992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// level level to be applied 13022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){ 13062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 13092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1310163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel Level to be set is %d %d\n", level, (LVM_INT16)(level/100)); 13112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 13122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 13132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 13142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1315163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters got: %d\n", 1316163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //ActiveParams.VC_EffectLevel); 13172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Volume parameters */ 13192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent ActiveParams.VC_EffectLevel = (LVM_INT16)(level/100); 1320163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 13212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 13232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 13242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetVolumeLevel") 13252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 13262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n"); 1328163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1329163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1330163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel") 1332163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1333163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetVolumeLevel just set (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 13352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 13362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setVolumeLevel */ 13372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeGetVolumeLevel() 13402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){ 13492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1350163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel start"); 1351163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 13522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 13542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 13562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetVolumeLevel") 13572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 13582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1359163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel ); 1360163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n"); 13612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *level = ActiveParams.VC_EffectLevel*100; // Convert dB to millibels 1363163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetVolumeLevel end"); 13642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 13652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end VolumeGetVolumeLevel */ 13662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// VolumeSetMute() 13692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 13712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 13732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 13742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 13752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 13762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 13772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){ 1379163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute start(%d)", mute); 13802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bMuteEnabled = mute; 13822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 13842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 13852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Get the current settings */ 13872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 13882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetMute") 13892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 13902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1391163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n"); 1392163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute to %d, level was %d\n", mute, ActiveParams.VC_EffectLevel ); 13932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 13942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Set appropriate volume level */ 13952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){ 1396163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->levelSaved = ActiveParams.VC_EffectLevel; 1397163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = -96; 13982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 1399163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_EffectLevel = pContext->pBundledContext->levelSaved; 14002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 14012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent /* Activate the initial settings */ 14032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 14042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetMute") 14052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 14062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1407163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n"); 1408163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetMute end"); 14092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 14102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end setMute */ 14112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 1413163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetMute() 14142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 14162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 14182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pContext: effect engine context 14192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 14202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Ourputs: 14212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// mute: enable/disable flag 14222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 14232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 14242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint32_t VolumeGetMute(EffectContext *pContext, uint32_t *mute){ 1425163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetMute start"); 1426163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((pContext->pBundledContext->bMuteEnabled == LVM_FALSE)|| 1427163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->pBundledContext->bMuteEnabled == LVM_TRUE)){ 1428163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *mute = pContext->pBundledContext->bMuteEnabled; 1429163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 14302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 1431163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : VolumeGetMute read an invalid value from context %d", 1432163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bMuteEnabled); 1433163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 14342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 1435163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetMute end"); 14362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end getMute */ 14372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1438163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint16_t VolumeConvertStereoPosition(int16_t position){ 1439163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t convertedPosition = 0; 1440163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1441163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent convertedPosition = (int16_t)(((float)position/1000)*96); 1442163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return convertedPosition; 1443163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1444163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 1445163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1446163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1447163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeSetStereoPosition() 1448163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1449163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1450163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1451163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1452163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1453163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1454163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1455163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1456163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1457163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1458163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint VolumeSetStereoPosition(EffectContext *pContext, int16_t position){ 1459163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1460163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1461163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 1462163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Balance = 0; 1463163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1464163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1465163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1466163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1467163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1468163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1469163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition start pContext->pBundledContext->positionSaved = %d", pContext->pBundledContext->positionSaved); 1470163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1471163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1472163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1473163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Position to be set is %d %d\n", position, Balance); 1474163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->positionSaved = position; 1475163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1476163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1477163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1478163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1479163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got:" 1480163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // " %d\n", ActiveParams.VC_Balance); 1481163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1482163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Volume parameters */ 1483163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = Balance; 1484163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition() (-96dB -> +96dB) -> %d\n", ActiveParams.VC_Balance ); 1485163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1486163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1487163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1488163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetStereoPosition") 1489163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1490163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1491163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Succesfully called LVM_SetControlParameters\n"); 14922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1493163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1494163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1495163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetStereoPosition") 1496163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1497163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Succesfully returned from LVM_GetControlParameters got: " 1498163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "%d\n", ActiveParams.VC_Balance); 1499163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1500163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent else{ 1501163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition Position attempting to set, but not enabled %d %d\n", 1502163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //position, Balance); 1503163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1504163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeSetStereoPosition end pContext->pBundledContext->positionSaved = %d\n", pContext->pBundledContext->positionSaved); 1505163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1506163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeSetStereoPosition */ 15072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1509163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1510163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeGetStereoPosition() 1511163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1512163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1513163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1514163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1515163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1516163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1517163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Outputs: 1518163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// position: stereo position 1519163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 15202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1521163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeGetStereoPosition(EffectContext *pContext, int16_t *position){ 1522163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition start"); 15232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1524163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1525163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */ 1526163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 balance; 1527163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1528163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition start pContext->pBundledContext->positionSaved = %d", pContext->pBundledContext->positionSaved); 1529163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1530163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1531163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition") 1532163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 1533163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition -> %d\n", ActiveParams.VC_Balance); 1535163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 1536163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1537163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1538163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 1539163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_TRUE){ 1540163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(balance != ActiveParams.VC_Balance){ 1541163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 1542163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1543163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 1544163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *position = (LVM_INT16)pContext->pBundledContext->positionSaved; // Convert dB to millibels 1545163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeGetStereoPosition end returning pContext->pBundledContext->positionSaved = %d\n", pContext->pBundledContext->positionSaved); 1546163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1547163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeGetStereoPosition */ 15482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1549163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1550163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// VolumeEnableStereoPosition() 1551163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 1552163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Purpose: 1553163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1554163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// Inputs: 1555163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// pContext: effect engine context 1556163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// mute: enable/disable flag 1557163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent// 1558163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent//---------------------------------------------------------------------------- 15592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1560163fbcf84010b98e0374110454d85b804bc8d13bEric Laurentint32_t VolumeEnableStereoPosition(EffectContext *pContext, uint32_t enabled){ 1561163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition start()"); 15622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1563163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bStereoPositionEnabled = enabled; 15642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1565163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ControlParams_t ActiveParams; /* Current control Parameters */ 1566163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ 15672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1568163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Get the current settings */ 1569163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1570163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeEnableStereoPosition") 1571163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 15722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1573163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition Succesfully returned from LVM_GetControlParameters\n"); 1574163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition to %d, position was %d\n", 1575163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // enabled, ActiveParams.VC_Balance ); 15762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1577163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Set appropriate stereo position */ 1578163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bStereoPositionEnabled == LVM_FALSE){ 1579163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 0; 1580163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 1581163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ActiveParams.VC_Balance = 1582163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved); 1583163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 15842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1585163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Activate the initial settings */ 1586163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); 1587163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeEnableStereoPosition") 1588163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(LvmStatus != LVM_SUCCESS) return -EINVAL; 15892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1590163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition Succesfully called LVM_SetControlParameters\n"); 1591163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolumeEnableStereoPosition end()\n"); 1592163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return 0; 1593163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} /* end VolumeEnableStereoPosition */ 15942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 15952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_getParameter() 15972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 15982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 15992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a BassBoost parameter 16002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 16022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pBassBoost - handle to instance data 16032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 16042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 16052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 16062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 16082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 16092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 16102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 16132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint BassBoost_getParameter(EffectContext *pContext, 1617163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t *pParam, 1618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent size_t *pValueSize, 1619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pValue){ 16202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 16212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param = *pParam++; 16222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 16232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 16242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1625163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_getParameter start"); 16262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 16282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH_SUP: 16292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 16302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 16312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid pValueSize2 %d", *pValueSize); 16322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 16332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 16342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 16352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 16362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 1638163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 16392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 16402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 16412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 16432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH_SUP: 16442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 16452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1646163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUP Value is %d", 1647163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 16482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 16492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 16512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = BassGetStrength(pContext); 16522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH Value is %d", 1654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 16552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 16562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 16582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_getParameter() invalid param %d", param); 16592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 16602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 16612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 16622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_getParameter end"); 16642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 16652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_getParameter */ 16662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// BassBoost_setParameter() 16692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 16712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set 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 value 16772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 16792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 16802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 16812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){ 16832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 16842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 16852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1686163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter start"); 16872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 16882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (*pParam){ 16892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case BASSBOOST_PARAM_STRENGTH: 16902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 1691163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength); 1692163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter() Calling pBassBoost->BassSetStrength"); 16932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent BassSetStrength(pContext, (int32_t)strength); 1694163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength"); 16952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 16962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 16972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParam); 16982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 16992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1701163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_setParameter end"); 17022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 17032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end BassBoost_setParameter */ 17042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_getParameter() 17072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Virtualizer parameter 17102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 17132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 17142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 17152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 17162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 17182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 17192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 17202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 17232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_getParameter(EffectContext *pContext, 17272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 17282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 17292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 17302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 17312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param = *pParam++; 17322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 17332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 17342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1735163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_getParameter start"); 17362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 17382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUP: 17392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 17402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize != sizeof(int16_t)){ 1741163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid pValueSize2 %d",*pValueSize); 17422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 17432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 17452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 17482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 17492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 17502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 17532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUP: 17542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 17552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1756163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUP Value is %d", 1757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(uint32_t *)pValue); 17582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 17612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = VirtualizerGetStrength(pContext); 17622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1763163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH Value is %d", 1764163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)pValue); 17652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 17682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_getParameter() invalid param %d", param); 17692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 17702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 17712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 17722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1773163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_getParameter end"); 17742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 17752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_getParameter */ 17762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Virtualizer_setParameter() 17792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 17812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Virtualizer parameter 17822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 17842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVirtualizer - handle to instance data 17852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 17862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 17872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 17892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 17902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 17912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){ 17932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 17942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t strength; 17952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1796163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter start"); 17972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 17982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (*pParam){ 17992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VIRTUALIZER_PARAM_STRENGTH: 18002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strength = *(int16_t *)pValue; 1801163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength); 1802163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter() Calling pVirtualizer->setStrength"); 18032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent VirtualizerSetStrength(pContext, (int32_t)strength); 1804163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength"); 18052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 18072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", *pParam); 18082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1811163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_setParameter end"); 18122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 18132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Virtualizer_setParameter */ 18142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_getParameter() 18172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 18192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Equalizer parameter 18202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 18222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 18232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 18242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 18252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 18262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 18282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 18292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 18302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 18332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 18342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 18352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_getParameter(EffectContext *pContext, 18362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 18372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 18382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 18392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 18402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 18412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param = *pParam++; 18422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 18432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 18442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1845163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter start"); 18462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 18482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 18492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 18502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 18512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int16_t)) { 1852163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 18532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 18562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 18592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 18602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < 2 * sizeof(int32_t)) { 1861163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize); 18622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = 2 * sizeof(int32_t); 18652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 18672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_BAND: 18682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 18692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)) { 1870163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 18712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 18742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 18772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 1880163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param); 18812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 18852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 18862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = FIVEBAND_NUMBANDS; 1887163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue); 18882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 18912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = -1500; 18922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *((int32_t *)pValue + 1) = 1500; 1893163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", 1894163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)pValue, *((int32_t *)pValue + 1)); 18952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 18982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 18992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 19002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetBandLevel(pContext, param2); 1904163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", 1905163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 19062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 19092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 19112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2); 1915163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", 1916163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 19172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 19202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 19222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1)); 1926163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", 1927163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue, *((int32_t *)pValue + 1)); 19282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_BAND: 19312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetBand(pContext, param2); 1933163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", 1934163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 19352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 19382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = EqualizerGetPreset(pContext); 1939163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue); 19402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 19432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = EqualizerGetNumPresets(); 1944163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue); 19452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 19482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= EqualizerGetNumPresets()) { 19502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //if (param2 >= 20) { // AGO FIX 19512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name = (char *)pValue; 19552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1); 19562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name[*pValueSize - 1] = 0; 19572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = strlen(name) + 1; 1958163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", 1959163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, gEqualizerPresets[param2].name, *pValueSize); 19602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param); 19642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1968163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter end"); 19692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 19702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_getParameter */ 19712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_setParameter() 19742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 19762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Equalizer parameter 19772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 19792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 19802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 19812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 19822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 19842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 19852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){ 19872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 19882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t preset; 19892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t band; 19902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t level; 19912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param = *pParam++; 19922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1993163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter start"); 19942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 19952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 19962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent preset = *(int16_t *)pValue; 19972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1998163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset); 19992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ((preset >= EqualizerGetNumPresets())||(preset < 0)) { 20002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetPreset(pContext, preset); 20042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 20062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent band = *pParam; 20072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent level = *(int32_t *)pValue; 2008163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level); 20092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (band >= FIVEBAND_NUMBANDS) { 20102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetBandLevel(pContext, band, level); 20142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : setParameter() invalid param %d", param); 20172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2020163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter end"); 20212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 20222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_setParameter */ 20232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_getParameter() 20262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 20282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Volume parameter 20292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 20312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 20322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 20332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 20342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 20352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 20372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 20382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 20392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 20422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter(EffectContext *pContext, 20462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 20472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 20482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 20492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 20502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 20512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param = *pParam++; 20522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 20532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 20542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter start"); 20562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 20582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 20592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 20602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2061163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (*pValueSize != sizeof(int16_t)){ 20622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1 %d", *pValueSize); 20632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 20662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 20692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 20702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)){ 20712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2 %d", *pValueSize); 20722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 20752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 2078163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param); 20792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 20802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 20832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 20842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue)); 2085163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d", 2086163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int16_t *)pValue); 20872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 20902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = 0; 20912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d", 20922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue); 20932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2096163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeGetStereoPosition(pContext, (int16_t *)pValue); 20972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d", 20982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue); 20992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2102163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeGetMute(pContext, (uint32_t *)pValue); 2103163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d", 2104163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(uint32_t *)pValue); 21052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2108163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled; 21092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d", 21102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue); 21112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 21142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param); 21152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2119163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_getParameter end"); 21202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 21212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_getParameter */ 21222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_setParameter() 21262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 21282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Volume parameter 21292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 21312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 21322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 21332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 21342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 21362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){ 21402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 21412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t level; 2142163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t position; 21432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent uint32_t mute; 2144163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t positionEnabled; 21452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter start"); 21472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (*pParam){ 21492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 21502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent level = *(int16_t *)pValue; 21512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level); 21522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel"); 21532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeSetVolumeLevel(pContext, (int16_t)level); 21542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel"); 21552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2158163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent mute = *(uint32_t *)pValue; 2159163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute); 2160163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->setMute"); 2161163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetMute(pContext, mute); 2162163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Called pVolume->setMute"); 2163163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 21642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2166163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent positionEnabled = *(uint32_t *)pValue; 2167163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeEnableStereoPosition(pContext, positionEnabled); 2168163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved); 2169163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called"); 2170163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 21712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2173163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent position = *(int16_t *)pValue; 2174163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position); 2175163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition"); 2176163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, (int16_t)position); 2177163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition"); 2178163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 21792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 21812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", *pParam); 21822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2185163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_setParameter end"); 21862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 21872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_setParameter */ 21882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2189163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent/**************************************************************************************** 2190163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Name : LVC_ToDB_s32Tos16() 2191163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Input : Signed 32-bit integer 2192163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Output : Signed 16-bit integer 2193163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * MSB (16) = sign bit 2194163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (15->05) = integer part 2195163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (04->01) = decimal part 2196163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Returns : Db value with respect to full scale 2197163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Description : 2198163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Remarks : 2199163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ****************************************************************************************/ 2200163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2201163fbcf84010b98e0374110454d85b804bc8d13bEric LaurentLVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) 2202163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent{ 2203163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 db_fix; 2204163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Shift; 2205163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 SmallRemainder; 2206163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_UINT32 Remainder = (LVM_UINT32)Lin_fix; 2207163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2208163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Count leading bits, 1 cycle in assembly*/ 2209163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (Shift = 0; Shift<32; Shift++) 2210163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2211163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((Remainder & 0x80000000U)!=0) 2212163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2213163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2214163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2215163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Remainder = Remainder << 1; 2216163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 22172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2218163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* 2219163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Based on the approximation equation (for Q11.4 format): 2220163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * 2221163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * dB = -96 * Shift + 16 * (8 * Remainder - 2 * Remainder^2) 2222163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent */ 2223163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(-96 * Shift); /* Six dB steps in Q11.4 format*/ 2224163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)((Remainder & 0x7fffffff) >> 24); 2225163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix + SmallRemainder ); 2226163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)(SmallRemainder * SmallRemainder); 2227163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - (LVM_INT16)((LVM_UINT16)SmallRemainder >> 9)); 22282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2229163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Correct for small offset */ 2230163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - 5); 22312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2232163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return db_fix; 2233163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 22342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2235163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 2236163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 22372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Process */ 22392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int Effect_process(effect_interface_t self, 2240163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *inBuffer, 2241163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *outBuffer){ 22422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 22432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 2244163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int lvmStatus = 0; 2245163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *in = (LVM_INT16 *)inBuffer->raw; 2246163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw; 22472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2248163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Start : Enabled = %d Called = %d", 2249163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled); 22502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 22522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL"); 22532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (inBuffer == NULL || inBuffer->raw == NULL || 22562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer == NULL || outBuffer->raw == NULL || 22572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent inBuffer->frameCount != outBuffer->frameCount){ 22582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG"); 22592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 22602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2261163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&& 2262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_BASS_BOOST)){ 2263163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_BASS_BOOST Effect is not enabled"); 2264163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2265163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2266163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&& 2267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VOLUME)){ 2268163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_VOLUME Effect is not enabled"); 2269163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2270163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2271163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&& 2272163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_EQUALIZER)){ 2273163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_EQUALIZER Effect is not enabled"); 2274163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 22752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2276163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&& 2277163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VIRTUALIZER)){ 2278163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_VIRTUALIZER Effect is not enabled"); 2279163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 22802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2281163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2282163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If this is the last frame of an effect process its output with no effect 2283163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 2284163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 2285163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() accumulating last frame into output buffer"); 2286163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() trying copying last frame into output buffer"); 2287163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Enabled = %d Called = %d", 2288163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2289163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled); 2290163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2291163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2292163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() copying last frame into output buffer"); 2293163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 22942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2295163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2296163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status != -ENODATA){ 2297163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled++; 22982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2300163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->NumberEffectsCalled == 2301163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled){ 2302163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d", 2303163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2304163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 23052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2306163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 2307163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() actually processing last frame"); 2308163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 2310163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process all the available frames, block processing is 2311163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent handled internalLY by the LVM bundle */ 2312163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent lvmStatus = android::LvmBundle_process( (LVM_INT16 *)inBuffer->raw, 23132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_INT16 *)outBuffer->raw, 23142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer->frameCount, 23152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext); 2316163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(lvmStatus != LVM_SUCCESS){ 2317163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus); 2318163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return lvmStatus; 2319163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 2321163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d", 2322163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2323163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 2324163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // 2 is for stereo input 2325163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2); 23262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 23282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 23292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_process */ 23302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Command */ 23322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int Effect_command(effect_interface_t self, 2333163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int cmdCode, 2334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int cmdSize, 2335163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pCmdData, 2336163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int *replySize, 2337163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pReplyData){ 23382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 23392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int retsize; 23402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 23412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2342163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\t\nEffect_command start"); 23432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2345163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_BASS_BOOST"); 23462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2348163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_VIRTUALIZER"); 2349163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2351163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_EQUALIZER"); 2352163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2354163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_VOLUME"); 2355163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 23582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL"); 23592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2362163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize); 23632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2364163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Incase we disable an effect, next time process is 2365163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // called the number of effect called could be greater 2366163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled = 0; 23672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2368163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", 2369163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled, 2370163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 23712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (cmdCode){ 23732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_INIT: 2374163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start"); 23752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2376163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST"); 23772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 23792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 23802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_INIT: ERROR"); 23812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::BassSetStrength(pContext, 0); 23852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2387163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER"); 23882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 23902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 23912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_INIT: ERROR"); 23922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2395163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VirtualizerSetStrength(pContext, 0); 2396163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2398163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER"); 23992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 24012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 24022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_INIT: ERROR"); 24032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2406163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::EqualizerSetPreset(pContext, 0); 2407163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2409163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2410163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_INIT start"); 24112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 24132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 24142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_INIT: ERROR"); 24152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = android::VolumeSetVolumeLevel(pContext, 0); 24192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(status == -EINVAL){ 2420163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 24212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2422163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2424163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 24252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_CONFIGURE: 2426163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE start"); 24272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL|| 24282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize != sizeof(effect_config_t)|| 24292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 24302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int)){ 24312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 24322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_CONFIGURE: ERROR"); 24332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *) pReplyData = android::Effect_configure(pContext, (effect_config_t *) pCmdData); 2436163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE end"); 24372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_RESET: 2440163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start"); 24412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::Effect_configure(pContext, &pContext->config); 2442163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end"); 24432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_GET_PARAM:{ 2446163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2447163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 24482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2449163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2450163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2451163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2452163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 24532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 24542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 24552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 24582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 24602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 24622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 24642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::BassBoost_getParameter(pContext, 24662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 24672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 24682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 24692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 24712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2472163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM " 2473163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2474163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2475163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2476163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 24772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2478163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 24792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2480163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2481163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2482163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2483163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 24842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 24852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 24862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 24892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 24912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 24932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 24952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Virtualizer_getParameter(pContext, 24972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 24982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 24992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 25002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 25022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2503163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM " 2504163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2505163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2506163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2507163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 25082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2510163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command cmdCode Case: " 2511163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 2512163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2513163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2514163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2515163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) { 25162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 25172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM"); 25182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 2521163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 2523163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 2525163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 2527163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Equalizer_getParameter(pContext, (int32_t *)p->data, &p->vsize, 25292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 2530163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 2532163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2533163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, " 2534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pReplyData %08x %08x", 2535163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize, 2536163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset), 2537163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + 2538163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // sizeof(int32_t))); 25392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2541163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command cmdCode Case: " 2542163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 2543163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2544163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2545163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2546163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 25472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 25482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 25492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 25522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 25542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 25562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 25582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Volume_getParameter(pContext, 25602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 25612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 25622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 25632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 25652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2566163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command EFFECT_CMD_GET_PARAM " 2567163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2568163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2569163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2570163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 2571163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2572163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end"); 25732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 25742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_PARAM:{ 2575163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 25762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2577163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2578163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2579163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2580163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2581163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2582163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2583163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2584163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2585163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 25862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 25872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 25882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 25912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 25932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 25942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 25952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2598163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tnBassBoost_command cmdSize is %d\n" 2599163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2600163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2601163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2602163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 26042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::BassBoost_setParameter(pContext, 26062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 26072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + p->psize); 26082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2610163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 2611163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2612163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2613163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2614163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2615163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2616163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2617163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 26192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 26202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 26212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 26242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 26262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 26272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 26282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2631163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tnVirtualizer_command cmdSize is %d\n" 2632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2634163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2636163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 26372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Virtualizer_setParameter(pContext, 26392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 2640163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 26412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2643163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command cmdCode Case: " 2644163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_SET_PARAM start"); 2645163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2646163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2647163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2648163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 26492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 26512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL || *replySize != sizeof(int32_t)) { 26522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 26532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 26542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 26572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Equalizer_setParameter(pContext, 26592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 2660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 26612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command cmdCode Case: " 2664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_SET_PARAM start"); 2665163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2666163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2667163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2668163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 26692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ( pCmdData == NULL|| 26712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))|| 26722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 26732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int32_t)){ 26742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 26752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 26762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 26792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Volume_setParameter(pContext, 26812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 2682163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 2683163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2684163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end"); 26852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 26862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_ENABLE: 2688163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start"); 26892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 26902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR"); 26912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 2692163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 26932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (pContext->EffectType){ 26942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_BASS_BOOST: 26952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){ 26962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 26972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 26982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bBassEnabled = LVM_TRUE; 2701163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_BASS_BOOST enabled"); 27022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_EQUALIZER: 27042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE){ 27052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 27062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 27072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE; 2710163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_EQUALIZER enabled"); 2711163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 27122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VIRTUALIZER: 27132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 27142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 27152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 27162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE; 2719163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case:EFFECT_CMD_ENABLE LVM_VIRTUALIZER enabled"); 2720163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 27212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VOLUME: 27222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){ 27232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 27242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 27252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_TRUE; 2728163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_VOLUME enabled"); 27292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 27312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 27322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR, invalid Effect Type"); 2733163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 27342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = 0; 27362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2737163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2738163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE NumberEffectsEnabled = %d", 2739163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 2740163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE end"); 27412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2742163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 27432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_DISABLE: 2744163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start"); 27452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 27462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR"); 27472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 2748163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (pContext->EffectType){ 27502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_BASS_BOOST: 27512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_FALSE){ 27522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 27532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 27542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2756163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 2757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2758163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_BASS_BOOST disabled"); 27592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_EQUALIZER: 27612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE){ 27622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 27632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 27642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 2767163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2768163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_EQUALIZER disabled"); 2769163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 27702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VIRTUALIZER: 27712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE){ 27722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 27732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 27742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 2777163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2778163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_VIRTUALIZER disabled"); 2779163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 27802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VOLUME: 27812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVolumeEnabled == LVM_FALSE){ 27822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 27832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 27842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 2787163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE LVM_VOLUME disabled"); 27882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 27902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 27912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR, invalid Effect Type"); 2792163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 2793163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = 0; 27952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 2796163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2797163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE NumberEffectsEnabled = %d", 2798163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 2799163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE end"); 28002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 28012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_DEVICE: 2803163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2804163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start"); 2805163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_device_e device = *(audio_device_e *)pCmdData; 2806163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2807163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2808163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)|| 2809163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){ 2810163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d", 2811163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2812163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST"); 2813163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2814163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device doesnt support bassboost the effect must be temporarily disabled 2815163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 2816163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 2817163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2818163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){ 2819163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d", 2820163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2821163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2822163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_TRUE; 2823163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2824163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2825163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d", 2826163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2827163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2828163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports bassboost and the effect has been temporarily disabled 2829163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 2830163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2831163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassTempDisabled == LVM_TRUE){ 2832163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d", 2833163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2834163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2835163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 2836163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2837163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2838163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2839163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2840163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)|| 2841163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){ 2842163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d", 2843163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2844163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER"); 2845163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2846163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //If a device doesnt support virtualizer the effect must be temporarily disabled 2847163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 2848163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 2849163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2850163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 2851163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d", 2852163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2853163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2854163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE; 2855163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2856163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2857163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d", 2858163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2859163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports virtualizer and the effect has been temporarily disabled 2861163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 2862163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2863163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerTempDisabled == LVM_TRUE){ 2864163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d", 2865163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2866163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2867163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 2868163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2869163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2870163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2871163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end"); 28722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2873163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2874163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_VOLUME: 2875163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2876163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t channels = cmdSize/sizeof(int32_t); 2877163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t vol = *(int32_t *)pCmdData; 2878163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t vol_db; 2879163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t dB; 2880163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t vol_db_rnd; 2881163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume 2882163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2883163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // if pReplyData is NULL, VOL_CTRL is delegated to another effect 2884163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pReplyData == LVM_NULL){ 2885163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2886163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 28872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2888163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(vol==0x1000000){ 2889163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent vol -= 1; 2890163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2891163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Convert volume linear (Q8.24) to volume dB (0->-96) 2892163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = android::LVC_ToDB_s32Tos16(vol <<7); 2893163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = (dB +8)>>4; 2894163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = (dB <-96) ? -96 : dB ; 2895163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2896163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tSession: %d, VOLUME is %d dB (%d), effect is %d", 2897163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->SessionNo, (int32_t)dB, vol<<7, pContext->EffectType); 2898163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(pReplyData, vol_ret, sizeof(int32_t)*2); 2899163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VolumeSetVolumeLevel(pContext, (int16_t)(dB*100)); 2900163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2901163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2902163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_AUDIO_MODE: 2903163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 29042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 29052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2908163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command end...\n\n"); 29092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 29102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_command */ 29112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// effect_interface_t interface implementation for effect 29132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst struct effect_interface_s gLvmEffectInterface = { 29142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_process, 29152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_command 29162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; /* end gLvmEffectInterface */ 29172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2918