EffectBundle.cpp revision 3be9523784cc4038f601e510faee595117cdacb3
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){ 162823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 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){ 164323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case BASSBOOST_PARAM_STRENGTH_SUPPORTED: 16442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 16452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 164623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent //LOGV("\tBassBoost_getParameter() BASSBOOST_PARAM_STRENGTH_SUPPORTED 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){ 173823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 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){ 175323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case VIRTUALIZER_PARAM_STRENGTH_SUPPORTED: 17542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue = 1; 17552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 175623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent //LOGV("\tVirtualizer_getParameter() VIRTUALIZER_PARAM_STRENGTH_SUPPORTED 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: 18513be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_BAND_LEVEL: 18523be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_GET_BAND: 18532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int16_t)) { 1854163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 18552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 18582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 18613be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (*pValueSize < 2 * sizeof(int16_t)) { 18623be9523784cc4038f601e510faee595117cdacb3Eric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize); 18633be9523784cc4038f601e510faee595117cdacb3Eric Laurent return -EINVAL; 18643be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 18653be9523784cc4038f601e510faee595117cdacb3Eric Laurent *pValueSize = 2 * sizeof(int16_t); 18663be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 18673be9523784cc4038f601e510faee595117cdacb3Eric Laurent 18682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 18692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < 2 * sizeof(int32_t)) { 1870163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize); 18712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = 2 * sizeof(int32_t); 18742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18753be9523784cc4038f601e510faee595117cdacb3Eric Laurent 18762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 18772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)) { 1878163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 18792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 18822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 18842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 18852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 18862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 188723e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: 188823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent if (*pValueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t)) { 188923e1de74359f4bb1763aef0adfebe073122b032cEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize); 189023e1de74359f4bb1763aef0adfebe073122b032cEric Laurent return -EINVAL; 189123e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 189223e1de74359f4bb1763aef0adfebe073122b032cEric Laurent *pValueSize = (2 + FIVEBAND_NUMBANDS) * sizeof(uint16_t); 189323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent break; 189423e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 18952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 1896163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter unknown param %d", param); 18972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 18982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 18992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 19012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_NUM_BANDS: 19023be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)FIVEBAND_NUMBANDS; 1903163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue); 19042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_LEVEL_RANGE: 19073be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = -1500; 19083be9523784cc4038f601e510faee595117cdacb3Eric Laurent *((int16_t *)pValue + 1) = 1500; 1909163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", 1910163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)pValue, *((int32_t *)pValue + 1)); 19112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 19142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 19162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19193be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2); 1920163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", 1921163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 19222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CENTER_FREQ: 19252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 19272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int32_t *)pValue = EqualizerGetCentreFrequency(pContext, param2); 1931163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", 1932163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 19332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_FREQ_RANGE: 19362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= FIVEBAND_NUMBANDS) { 19382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerGetBandFreqRange(pContext, param2, (uint32_t *)pValue, ((uint32_t *)pValue + 1)); 1942163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", 1943163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue, *((int32_t *)pValue + 1)); 19442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_BAND: 19472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19483be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2); 1949163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", 1950163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, *(int32_t *)pValue); 19512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 19543be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext); 1955163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue); 19562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_NUM_OF_PRESETS: 19593be9523784cc4038f601e510faee595117cdacb3Eric Laurent *(uint16_t *)pValue = (uint16_t)EqualizerGetNumPresets(); 1960163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue); 19612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_GET_PRESET_NAME: 19642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent param2 = *pParam; 19652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (param2 >= EqualizerGetNumPresets()) { 19662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent //if (param2 >= 20) { // AGO FIX 19672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name = (char *)pValue; 19712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent strncpy(name, EqualizerGetPresetName(param2), *pValueSize - 1); 19722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent name[*pValueSize - 1] = 0; 19732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = strlen(name) + 1; 1974163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", 1975163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // param2, gEqualizerPresets[param2].name, *pValueSize); 19762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 197823e1de74359f4bb1763aef0adfebe073122b032cEric Laurent case EQ_PARAM_PROPERTIES: { 19793be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 198023e1de74359f4bb1763aef0adfebe073122b032cEric Laurent LOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES"); 19813be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[0] = (int16_t)EqualizerGetPreset(pContext); 19823be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[1] = (int16_t)FIVEBAND_NUMBANDS; 198323e1de74359f4bb1763aef0adfebe073122b032cEric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 19843be9523784cc4038f601e510faee595117cdacb3Eric Laurent p[2 + i] = (int16_t)EqualizerGetBandLevel(pContext, i); 198523e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } 198623e1de74359f4bb1763aef0adfebe073122b032cEric Laurent } break; 198723e1de74359f4bb1763aef0adfebe073122b032cEric Laurent 19882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 19892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid param %d", param); 19902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 19912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 19922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 19932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 1994163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_getParameter end"); 19952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 19962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_getParameter */ 19972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 19982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 19992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Equalizer_setParameter() 20002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 20022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Equalizer parameter 20032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 20052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pEqualizer - handle to instance data 20062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 20072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 20082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 20102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){ 20132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 20142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t preset; 20152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t band; 20162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t level; 20172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param = *pParam++; 20182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2019163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter start"); 20202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param) { 20212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_CUR_PRESET: 20223be9523784cc4038f601e510faee595117cdacb3Eric Laurent preset = (int32_t)(*(uint16_t *)pValue); 20232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2024163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset); 20252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ((preset >= EqualizerGetNumPresets())||(preset < 0)) { 20262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetPreset(pContext, preset); 20302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EQ_PARAM_BAND_LEVEL: 20322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent band = *pParam; 20333be9523784cc4038f601e510faee595117cdacb3Eric Laurent level = (int32_t)(*(int16_t *)pValue); 2034163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level); 20352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (band >= FIVEBAND_NUMBANDS) { 20362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 20372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EqualizerSetBandLevel(pContext, band, level); 20402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20413be9523784cc4038f601e510faee595117cdacb3Eric Laurent case EQ_PARAM_PROPERTIES: { 20423be9523784cc4038f601e510faee595117cdacb3Eric Laurent //LOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES"); 20433be9523784cc4038f601e510faee595117cdacb3Eric Laurent int16_t *p = (int16_t *)pValue; 20443be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[0] >= EqualizerGetNumPresets()) { 20453be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 20463be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 20473be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 20483be9523784cc4038f601e510faee595117cdacb3Eric Laurent if (p[0] >= 0) { 20493be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetPreset(pContext, (int)p[0]); 20503be9523784cc4038f601e510faee595117cdacb3Eric Laurent } else { 20513be9523784cc4038f601e510faee595117cdacb3Eric Laurent if ((int)p[1] != FIVEBAND_NUMBANDS) { 20523be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 20533be9523784cc4038f601e510faee595117cdacb3Eric Laurent break; 20543be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 20553be9523784cc4038f601e510faee595117cdacb3Eric Laurent for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { 20563be9523784cc4038f601e510faee595117cdacb3Eric Laurent EqualizerSetBandLevel(pContext, i, (int)p[2 + i]); 20573be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 20583be9523784cc4038f601e510faee595117cdacb3Eric Laurent } 20593be9523784cc4038f601e510faee595117cdacb3Eric Laurent } break; 20602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 20612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : setParameter() invalid param %d", param); 20623be9523784cc4038f601e510faee595117cdacb3Eric Laurent status = -EINVAL; 20632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 20642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 20652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2066163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_setParameter end"); 20672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 20682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Equalizer_setParameter */ 20692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_getParameter() 20722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 20742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Get a Volume parameter 20752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 20772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 20782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 20792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to variable to hold retrieved value 20802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValueSize - pointer to value size: maximum size as input 20812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 20832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValue updated with parameter value 20842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// *pValueSize updated with actual value size 20852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Side Effects: 20882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 20892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 20902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 20912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_getParameter(EffectContext *pContext, 20922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t *pParam, 20932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent size_t *pValueSize, 20942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent void *pValue){ 20952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 20962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int bMute = 0; 20972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param = *pParam++; 20982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int32_t param2; 20992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent char *name; 21002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter start"); 21022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 21042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 21052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 21062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2107163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (*pValueSize != sizeof(int16_t)){ 21082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 1 %d", *pValueSize); 21092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 21102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int16_t); 21122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 21152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 21162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (*pValueSize < sizeof(int32_t)){ 21172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid pValueSize 2 %d", *pValueSize); 21182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 21192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *pValueSize = sizeof(int32_t); 21212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 2124163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter unknown param %d", param); 21252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 21262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (param){ 21292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 21302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeGetVolumeLevel(pContext, (int16_t *)(pValue)); 2131163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_LEVEL Value is %d", 2132163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int16_t *)pValue); 21332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MAXLEVEL: 21362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue = 0; 21372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_MAXLEVEL Value is %d", 21382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue); 21392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2142163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent VolumeGetStereoPosition(pContext, (int16_t *)pValue); 21432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_STEREOPOSITION Value is %d", 21442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int16_t *)pValue); 21452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2148163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeGetMute(pContext, (uint32_t *)pValue); 2149163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_MUTE Value is %d", 2150163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(uint32_t *)pValue); 21512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2154163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pValue = pContext->pBundledContext->bStereoPositionEnabled; 21552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_getParameter() VOLUME_PARAM_ENABLESTEREOPOSITION Value is %d", 21562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(uint32_t *)pValue); 21572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 21602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_getParameter() invalid param %d", param); 21612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = -EINVAL; 21622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 21632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 21642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2165163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_getParameter end"); 21662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 21672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_getParameter */ 21682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Volume_setParameter() 21722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Purpose: 21742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Set a Volume parameter 21752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Inputs: 21772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pVolume - handle to instance data 21782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pParam - pointer to parameter 21792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// pValue - pointer to value 21802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// Outputs: 21822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// 21832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent//---------------------------------------------------------------------------- 21842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentint Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){ 21862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 21872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int16_t level; 2188163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t position; 21892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent uint32_t mute; 2190163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent uint32_t positionEnabled; 21912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter start"); 21932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 21942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (*pParam){ 21952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_LEVEL: 21962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent level = *(int16_t *)pValue; 21972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level); 21982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->setVolumeLevel"); 21992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent status = VolumeSetVolumeLevel(pContext, (int16_t)level); 22002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tVolume_setParameter() Called pVolume->setVolumeLevel"); 22012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_MUTE: 2204163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent mute = *(uint32_t *)pValue; 2205163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->setMute, mute is %d", mute); 2206163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->setMute"); 2207163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetMute(pContext, mute); 2208163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Called pVolume->setMute"); 2209163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 22102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_ENABLESTEREOPOSITION: 2212163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent positionEnabled = *(uint32_t *)pValue; 2213163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeEnableStereoPosition(pContext, positionEnabled); 2214163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, pContext->pBundledContext->positionSaved); 2215163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() VOLUME_PARAM_ENABLESTEREOPOSITION called"); 2216163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 22172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case VOLUME_PARAM_STEREOPOSITION: 2219163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent position = *(int16_t *)pValue; 2220163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() VOLUME_PARAM_STEREOPOSITION value is %d", position); 2221163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Calling pVolume->VolumeSetStereoPosition"); 2222163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = VolumeSetStereoPosition(pContext, (int16_t)position); 2223163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tVolume_setParameter() Called pVolume->VolumeSetStereoPosition"); 2224163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 22252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 22272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", *pParam); 22282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 22292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 22302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2231163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_setParameter end"); 22322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 22332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Volume_setParameter */ 22342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2235163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent/**************************************************************************************** 2236163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Name : LVC_ToDB_s32Tos16() 2237163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Input : Signed 32-bit integer 2238163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Output : Signed 16-bit integer 2239163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * MSB (16) = sign bit 2240163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (15->05) = integer part 2241163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * (04->01) = decimal part 2242163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Returns : Db value with respect to full scale 2243163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Description : 2244163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Remarks : 2245163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent ****************************************************************************************/ 2246163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2247163fbcf84010b98e0374110454d85b804bc8d13bEric LaurentLVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) 2248163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent{ 2249163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 db_fix; 2250163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 Shift; 2251163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 SmallRemainder; 2252163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_UINT32 Remainder = (LVM_UINT32)Lin_fix; 2253163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2254163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Count leading bits, 1 cycle in assembly*/ 2255163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent for (Shift = 0; Shift<32; Shift++) 2256163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2257163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((Remainder & 0x80000000U)!=0) 2258163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2259163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2260163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2261163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent Remainder = Remainder << 1; 2262163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 22632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2264163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* 2265163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * Based on the approximation equation (for Q11.4 format): 2266163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * 2267163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent * dB = -96 * Shift + 16 * (8 * Remainder - 2 * Remainder^2) 2268163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent */ 2269163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(-96 * Shift); /* Six dB steps in Q11.4 format*/ 2270163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)((Remainder & 0x7fffffff) >> 24); 2271163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix + SmallRemainder ); 2272163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent SmallRemainder = (LVM_INT16)(SmallRemainder * SmallRemainder); 2273163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - (LVM_INT16)((LVM_UINT16)SmallRemainder >> 9)); 22742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2275163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Correct for small offset */ 2276163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent db_fix = (LVM_INT16)(db_fix - 5); 22772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2278163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return db_fix; 2279163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} 22802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2281163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 2282163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent} // namespace 22832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Process */ 22852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int Effect_process(effect_interface_t self, 2286163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *inBuffer, 2287163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_buffer_t *outBuffer){ 22882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 22892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int status = 0; 2290163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int lvmStatus = 0; 2291163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *in = (LVM_INT16 *)inBuffer->raw; 2292163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw; 22932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2294163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Start : Enabled = %d Called = %d", 2295163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled); 22962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 22972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 22982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL"); 22992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (inBuffer == NULL || inBuffer->raw == NULL || 23022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer == NULL || outBuffer->raw == NULL || 23032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent inBuffer->frameCount != outBuffer->frameCount){ 23042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG"); 23052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 23062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2307163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&& 2308163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_BASS_BOOST)){ 2309163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_BASS_BOOST Effect is not enabled"); 2310163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2311163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2312163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&& 2313163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VOLUME)){ 2314163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_VOLUME Effect is not enabled"); 2315163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 2316163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2317163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&& 2318163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_EQUALIZER)){ 2319163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_EQUALIZER Effect is not enabled"); 2320163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 23212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2322163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&& 2323163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (pContext->EffectType == LVM_VIRTUALIZER)){ 2324163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_process() ERROR LVM_VIRTUALIZER Effect is not enabled"); 2325163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent status = -ENODATA; 23262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2327163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2328163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If this is the last frame of an effect process its output with no effect 2329163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 2330163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){ 2331163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() accumulating last frame into output buffer"); 2332163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() trying copying last frame into output buffer"); 2333163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Enabled = %d Called = %d", 2334163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2335163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled); 2336163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2337163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2338163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() copying last frame into output buffer"); 2339163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2341163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2342163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status != -ENODATA){ 2343163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsCalled++; 23442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2346163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->NumberEffectsCalled == 2347163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->NumberEffectsEnabled){ 2348163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d", 2349163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2350163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 23512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2352163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(status == -ENODATA){ 2353163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tLVM_ERROR : Effect_process() actually processing last frame"); 2354163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsCalled = 0; 2356163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent /* Process all the available frames, block processing is 2357163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent handled internalLY by the LVM bundle */ 2358163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent lvmStatus = android::LvmBundle_process( (LVM_INT16 *)inBuffer->raw, 23592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (LVM_INT16 *)outBuffer->raw, 23602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent outBuffer->frameCount, 23612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext); 2362163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(lvmStatus != LVM_SUCCESS){ 2363163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus); 2364163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return lvmStatus; 2365163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent }else{ 2367163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d", 2368163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsEnabled, 2369163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType); 2370163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // 2 is for stereo input 2371163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2); 23722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2373163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 23742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return status; 23752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_process */ 23762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent/* Effect Control Interface Implementation: Command */ 23782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentextern "C" int Effect_command(effect_interface_t self, 237925f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdCode, 238025f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t cmdSize, 2381163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pCmdData, 238225f4395b932fa9859a6e91ba77c5d20d009da64aEric Laurent uint32_t *replySize, 2383163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent void *pReplyData){ 23842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent EffectContext * pContext = (EffectContext *) self; 23852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int retsize; 23862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2387163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\t\nEffect_command start"); 23882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 23892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2390163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_BASS_BOOST"); 23912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 23922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2393163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_VIRTUALIZER"); 2394163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2396163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_EQUALIZER"); 2397163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 23982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2399163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command setting command for LVM_VOLUME"); 2400163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pContext == NULL){ 24032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command ERROR pContext == NULL"); 24042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2407163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize); 24082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2409163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Incase we disable an effect, next time process is 2410163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // called the number of effect called could be greater 2411163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled = 0; 24122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2413163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d", 2414163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsCalled, 2415163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 24162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (cmdCode){ 24182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_INIT: 2419010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 2420010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent LOGV("\tLVM_ERROR, EFFECT_CMD_INIT: ERROR for effect type %d", 2421010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent pContext->EffectType); 2422010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent return -EINVAL; 2423010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent } 2424010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = 0; 2425163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT start"); 24262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2427163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_BASS_BOOST"); 24282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::BassSetStrength(pContext, 0); 24292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2431163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_VIRTUALIZER"); 2432163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VirtualizerSetStrength(pContext, 0); 2433163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2435163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_INIT for LVM_EQUALIZER"); 2436163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::EqualizerSetPreset(pContext, 0); 2437163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2439163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2440163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_INIT start"); 2441010ae0dd9eab40a49a840388230d8bb2f97c530eEric Laurent *(int *) pReplyData = android::VolumeSetVolumeLevel(pContext, 0); 2442163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 24432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2444163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 24452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_CONFIGURE: 2446163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE start"); 24472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pCmdData == NULL|| 24482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize != sizeof(effect_config_t)|| 24492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 24502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int)){ 24512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 24522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_CONFIGURE: ERROR"); 24532c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *) pReplyData = android::Effect_configure(pContext, (effect_config_t *) pCmdData); 2456163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_CONFIGURE end"); 24572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_RESET: 2460163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET start"); 24612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent android::Effect_configure(pContext, &pContext->config); 2462163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_RESET end"); 24632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 24642c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_GET_PARAM:{ 2466163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM start"); 2467163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 24682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2469163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2470163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2471163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2472163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 24732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 24742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 24752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 24762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 24772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 24782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 24802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 24822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 24842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::BassBoost_getParameter(pContext, 24862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 24872c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 24882c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 24892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 24902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 24912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2492163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_command EFFECT_CMD_GET_PARAM " 2493163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2494163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2495163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2496163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 24972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2498163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 24992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2500163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2501163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2502163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2503163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 25042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 25052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 25062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 25092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 25112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 25132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 25152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Virtualizer_getParameter(pContext, 25172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 25182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 25192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 25202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 25222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2523163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_command EFFECT_CMD_GET_PARAM " 2524163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2525163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2526163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2527163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 25282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2530163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command cmdCode Case: " 2531163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 2532163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2533163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2534163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2535163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) { 25362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 25372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM"); 25382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 2541163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 2543163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 2545163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 2547163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Equalizer_getParameter(pContext, (int32_t *)p->data, &p->vsize, 25492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 2550163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 25512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 2552163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2553163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, " 2554163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pReplyData %08x %08x", 2555163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize, 2556163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset), 2557163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + 2558163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // sizeof(int32_t))); 25592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25602c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2561163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command cmdCode Case: " 2562163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_GET_PARAM start"); 2563163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL || 2564163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 2565163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL || 2566163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){ 25672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 25682c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_GET_PARAM: ERROR"); 25692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 25702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 25712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *)pCmdData; 25722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize); 25742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p = (effect_param_t *)pReplyData; 25762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); 25782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->status = android::Volume_getParameter(pContext, 25802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 25812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (size_t *)&p->vsize, 25822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + voffset); 25832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 25842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize = sizeof(effect_param_t) + voffset + p->vsize; 25852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2586163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command EFFECT_CMD_GET_PARAM " 2587163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "*pCmdData %d, *replySize %d, *pReplyData %d ", 2588163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2589163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2590163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset)); 2591163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2592163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_GET_PARAM end"); 25932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 25942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_PARAM:{ 2595163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM start"); 25962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2597163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tBassBoost_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2598163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2599163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2600163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2601163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2602163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2603163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2604163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2605163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 26062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 26072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 26082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 26112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26122c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 26132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 26142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 26152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2618163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tnBassBoost_command cmdSize is %d\n" 2619163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2620163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2621163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2622163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2623163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 26242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::BassBoost_setParameter(pContext, 26262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 26272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent p->data + p->psize); 26282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2630163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVirtualizer_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d", 2631163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2632163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2633163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 2634163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2635163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if (pCmdData == NULL|| 2636163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent cmdSize != (int)(sizeof(effect_param_t) + sizeof(int32_t) +sizeof(int16_t))|| 2637163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pReplyData == NULL|| 2638163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *replySize != sizeof(int32_t)){ 26392c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 26402c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 26412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 26442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (p->psize != sizeof(int32_t)){ 26462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 26472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)"); 26482c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2651163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tnVirtualizer_command cmdSize is %d\n" 2652163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tsizeof(effect_param_t) is %d\n" 2653163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->psize is %d\n" 2654163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\tp->vsize is %d" 2655163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "\n", 2656163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // cmdSize, sizeof(effect_param_t), p->psize, p->vsize ); 26572c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26582c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Virtualizer_setParameter(pContext, 26592c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 2660163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 26612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26622c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_EQUALIZER){ 2663163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_command cmdCode Case: " 2664163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_SET_PARAM start"); 2665163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEqualizer_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 || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) || 26712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL || *replySize != sizeof(int32_t)) { 26722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 26732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 26742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26762c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 26772c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26782c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Equalizer_setParameter(pContext, 26792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 2680163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 26812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->EffectType == LVM_VOLUME){ 2683163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command cmdCode Case: " 2684163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_SET_PARAM start"); 2685163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tVolume_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ", 2686163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), 2687163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *replySize, 2688163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t))); 26892c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 26902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if ( pCmdData == NULL|| 26912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t))|| 26922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pReplyData == NULL|| 26932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *replySize != sizeof(int32_t)){ 26942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 26952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_SET_PARAM: ERROR"); 26962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 26972c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 26982c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent effect_param_t *p = (effect_param_t *) pCmdData; 26992c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = android::Volume_setParameter(pContext, 27012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent (int32_t *)p->data, 2702163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent p->data + p->psize); 2703163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2704163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end"); 27052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } break; 27062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 27072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_ENABLE: 2708163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start"); 27092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 27102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR"); 27112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 2712163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27132c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (pContext->EffectType){ 27142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_BASS_BOOST: 27152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){ 27162c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 27172c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 27182c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27192c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bBassEnabled = LVM_TRUE; 2721163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_BASS_BOOST enabled"); 27222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27232c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_EQUALIZER: 27242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE){ 27252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 27262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 27272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27282c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_TRUE; 2730163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_EQUALIZER enabled"); 2731163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 27322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VIRTUALIZER: 27332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 27342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 27352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 27362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27382c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE; 2739163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case:EFFECT_CMD_ENABLE LVM_VIRTUALIZER enabled"); 2740163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 27412c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VOLUME: 27422c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){ 27432c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 27442c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled"); 27452c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27462c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27472c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_TRUE; 2748163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE LVM_VOLUME enabled"); 27492c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27502c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 27512c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 27522c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_ENABLE: ERROR, invalid Effect Type"); 2753163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 27542c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27552c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = 0; 27562c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsEnabled++; 2757163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2758163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE NumberEffectsEnabled = %d", 2759163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 2760163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE end"); 27612c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2762163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 27632c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_DISABLE: 2764163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE start"); 27652c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if (pReplyData == NULL || *replySize != sizeof(int)){ 27662c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_DISABLE: ERROR"); 27672c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 2768163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 27692c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent switch (pContext->EffectType){ 27702c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_BASS_BOOST: 27712c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_FALSE){ 27722c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : BassBoost_command cmdCode Case: " 27732c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 27742c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27752c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 2776163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassEnabled = LVM_FALSE; 2777163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2778163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_BASS_BOOST disabled"); 27792c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 27802c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_EQUALIZER: 27812c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE){ 27822c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Equalizer_command cmdCode Case: " 27832c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 27842c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27852c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27862c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE; 2787163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2788163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_EQUALIZER disabled"); 2789163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 27902c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VIRTUALIZER: 27912c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE){ 27922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Virtualizer_command cmdCode Case: " 27932c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 27942c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 27952c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 27962c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE; 2797163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: " 2798163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // "EFFECT_CMD_DISABLE LVM_VIRTUALIZER disabled"); 2799163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 28002c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case LVM_VOLUME: 28012c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent if(pContext->pBundledContext->bVolumeEnabled == LVM_FALSE){ 28022c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Volume_command cmdCode Case: " 28032c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled"); 28042c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 28052c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 28062c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->bVolumeEnabled = LVM_FALSE; 2807163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE LVM_VOLUME disabled"); 28082c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 28092c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 28102c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent LOGV("\tLVM_ERROR : Effect_command cmdCode Case: " 28112c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent "EFFECT_CMD_DISABLE: ERROR, invalid Effect Type"); 2812163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent return -EINVAL; 2813163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 28142c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent *(int *)pReplyData = 0; 28152c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent pContext->pBundledContext->NumberEffectsEnabled--; 2816163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2817163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE NumberEffectsEnabled = %d", 2818163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // pContext->pBundledContext->NumberEffectsEnabled); 2819163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_DISABLE end"); 28202c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 28212c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 28222c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent case EFFECT_CMD_SET_DEVICE: 2823163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2824163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start"); 2825163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent audio_device_e device = *(audio_device_e *)pCmdData; 2826163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2827163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_BASS_BOOST){ 2828163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)|| 2829163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){ 2830163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d", 2831163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2832163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST"); 2833163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2834163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device doesnt support bassboost the effect must be temporarily disabled 2835163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 2836163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 2837163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2838163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){ 2839163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d", 2840163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2841163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2842163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_TRUE; 2843163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2844163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2845163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d", 2846163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2847163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2848163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports bassboost and the effect has been temporarily disabled 2849163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 2850163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2851163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bBassTempDisabled == LVM_TRUE){ 2852163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d", 2853163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2854163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2855163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bBassTempDisabled = LVM_FALSE; 2856163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2857163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2858163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2859163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->EffectType == LVM_VIRTUALIZER){ 2860163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if((device == DEVICE_SPEAKER)||(device == DEVICE_BLUETOOTH_SCO_CARKIT)|| 2861163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent (device == DEVICE_BLUETOOTH_A2DP_SPEAKER)){ 2862163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d", 2863163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2864163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER"); 2865163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2866163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //If a device doesnt support virtualizer the effect must be temporarily disabled 2867163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // the effect must still report its original state as this can only be changed 2868163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // by the ENABLE/DISABLE command 2869163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2870163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){ 2871163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d", 2872163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2873163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_disable(pContext); 2874163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE; 2875163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2876163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent }else{ 2877163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d", 2878163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2879163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2880163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // If a device supports virtualizer and the effect has been temporarily disabled 2881163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // previously then re-enable it 2882163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2883163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pContext->pBundledContext->bVirtualizerTempDisabled == LVM_TRUE){ 2884163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d", 2885163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent *(int32_t *)pCmdData); 2886163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::LvmEffect_enable(pContext); 2887163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE; 2888163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2889163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2890163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2891163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end"); 28922c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent break; 2893163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2894163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_VOLUME: 2895163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent { 2896163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t channels = cmdSize/sizeof(int32_t); 2897163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t vol = *(int32_t *)pCmdData; 2898163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t vol_db; 2899163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t dB; 2900163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int16_t vol_db_rnd; 2901163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume 2902163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2903163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // if pReplyData is NULL, VOL_CTRL is delegated to another effect 2904163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(pReplyData == LVM_NULL){ 2905163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2906163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 29072c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2908163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent if(vol==0x1000000){ 2909163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent vol -= 1; 2910163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2911163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent // Convert volume linear (Q8.24) to volume dB (0->-96) 2912163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = android::LVC_ToDB_s32Tos16(vol <<7); 2913163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = (dB +8)>>4; 2914163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent dB = (dB <-96) ? -96 : dB ; 2915163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent 2916163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tSession: %d, VOLUME is %d dB (%d), effect is %d", 2917163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //pContext->pBundledContext->SessionNo, (int32_t)dB, vol<<7, pContext->EffectType); 2918163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent memcpy(pReplyData, vol_ret, sizeof(int32_t)*2); 2919163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent android::VolumeSetVolumeLevel(pContext, (int16_t)(dB*100)); 2920163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 2921163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent } 2922163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent case EFFECT_CMD_SET_AUDIO_MODE: 2923163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent break; 29242c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent default: 29252c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return -EINVAL; 29262c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent } 29272c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2928163fbcf84010b98e0374110454d85b804bc8d13bEric Laurent //LOGV("\tEffect_command end...\n\n"); 29292c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent return 0; 29302c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent} /* end Effect_command */ 29312c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 29322c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent// effect_interface_t interface implementation for effect 29332c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurentconst struct effect_interface_s gLvmEffectInterface = { 29342c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_process, 29352c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent Effect_command 29362c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent}; /* end gLvmEffectInterface */ 29372c8e5cab3faa6d360e222b7a6c40a80083d021acEric Laurent 2938