Lines Matching defs:pContext
90 void LE_reset(LoudnessEnhancerContext *pContext)
92 ALOGV(" > LE_reset(%p)", pContext);
94 if (pContext->mCompressor != NULL) {
95 float targetAmp = pow(10, pContext->mTargetGainmB/2000.0f); // mB to linear amplification
96 ALOGV("LE_reset(): Target gain=%dmB <=> factor=%.2fX", pContext->mTargetGainmB, targetAmp);
97 pContext->mCompressor->Initialize(targetAmp, pContext->mConfig.inputCfg.samplingRate);
99 ALOGE("LE_reset(%p): null compressors, can't apply target gain", pContext);
109 // pContext: effect engine context
117 int LE_setConfig(LoudnessEnhancerContext *pContext, effect_config_t *pConfig)
119 ALOGV("LE_setConfig(%p)", pContext);
129 pContext->mConfig = *pConfig;
131 LE_reset(pContext);
143 // pContext: effect engine context
151 void LE_getConfig(LoudnessEnhancerContext *pContext, effect_config_t *pConfig)
153 *pConfig = pContext->mConfig;
163 // pContext: effect engine context
169 int LE_init(LoudnessEnhancerContext *pContext)
171 ALOGV("LE_init(%p)", pContext);
173 pContext->mConfig.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
174 pContext->mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
175 pContext->mConfig.inputCfg.format = kProcessFormat;
176 pContext->mConfig.inputCfg.samplingRate = 44100;
177 pContext->mConfig.inputCfg.bufferProvider.getBuffer = NULL;
178 pContext->mConfig.inputCfg.bufferProvider.releaseBuffer = NULL;
179 pContext->mConfig.inputCfg.bufferProvider.cookie = NULL;
180 pContext->mConfig.inputCfg.mask = EFFECT_CONFIG_ALL;
181 pContext->mConfig.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
182 pContext->mConfig.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO;
183 pContext->mConfig.outputCfg.format = kProcessFormat;
184 pContext->mConfig.outputCfg.samplingRate = 44100;
185 pContext->mConfig.outputCfg.bufferProvider.getBuffer = NULL;
186 pContext->mConfig.outputCfg.bufferProvider.releaseBuffer = NULL;
187 pContext->mConfig.outputCfg.bufferProvider.cookie = NULL;
188 pContext->mConfig.outputCfg.mask = EFFECT_CONFIG_ALL;
190 pContext->mTargetGainmB = LOUDNESS_ENHANCER_DEFAULT_TARGET_GAIN_MB;
191 float targetAmp = pow(10, pContext->mTargetGainmB/2000.0f); // mB to linear amplification
192 ALOGV("LE_init(): Target gain=%dmB <=> factor=%.2fX", pContext->mTargetGainmB, targetAmp);
194 if (pContext->mCompressor == NULL) {
195 pContext->mCompressor = new le_fx::AdaptiveDynamicRangeCompression();
196 pContext->mCompressor->Initialize(targetAmp, pContext->mConfig.inputCfg.samplingRate);
199 LE_setConfig(pContext, &pContext->mConfig);
223 LoudnessEnhancerContext *pContext = new LoudnessEnhancerContext;
225 pContext->mItfe = &gLEInterface;
226 pContext->mState = LOUDNESS_ENHANCER_STATE_UNINITIALIZED;
228 pContext->mCompressor = NULL;
229 ret = LE_init(pContext);
232 delete pContext;
236 *pHandle = (effect_handle_t)pContext;
238 pContext->mState = LOUDNESS_ENHANCER_STATE_INITIALIZED;
240 ALOGV(" LELib_Create context is %p", pContext);
247 LoudnessEnhancerContext * pContext = (LoudnessEnhancerContext *)handle;
250 if (pContext == NULL) {
253 pContext->mState = LOUDNESS_ENHANCER_STATE_UNINITIALIZED;
254 if (pContext->mCompressor != NULL) {
255 delete pContext->mCompressor;
256 pContext->mCompressor = NULL;
258 delete pContext;
285 LoudnessEnhancerContext * pContext = (LoudnessEnhancerContext *)self;
287 if (pContext == NULL) {
303 const float inputAmp = pow(10, pContext->mTargetGainmB/2000.0f) * scale;
305 float inputAmp = pow(10, pContext->mTargetGainmB/2000.0f);
313 pContext->mCompressor->Compress(&leftSample, &rightSample);
319 pContext->mCompressor->Compress(&leftSample, &rightSample);
327 if (pContext->mConfig.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) {
335 if (pContext->mConfig.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) {
344 if (pContext->mState != LOUDNESS_ENHANCER_STATE_ACTIVE) {
353 LoudnessEnhancerContext * pContext = (LoudnessEnhancerContext *)self;
355 if (pContext == NULL || pContext->mState == LOUDNESS_ENHANCER_STATE_UNINITIALIZED) {
365 *(int *) pReplyData = LE_init(pContext);
372 *(int *) pReplyData = LE_setConfig(pContext,
380 LE_getConfig(pContext, (effect_config_t *)pReplyData);
383 LE_reset(pContext);
389 if (pContext->mState != LOUDNESS_ENHANCER_STATE_INITIALIZED) {
392 pContext->mState = LOUDNESS_ENHANCER_STATE_ACTIVE;
400 if (pContext->mState != LOUDNESS_ENHANCER_STATE_ACTIVE) {
403 pContext->mState = LOUDNESS_ENHANCER_STATE_INITIALIZED;
424 ALOGV("get target gain(mB) = %d", pContext->mTargetGainmB);
425 *((int32_t *)p->data + 1) = pContext->mTargetGainmB;
447 pContext->mTargetGainmB = *((int32_t *)p->data + 1);
448 ALOGV("set target gain(mB) = %d", pContext->mTargetGainmB);
449 LE_reset(pContext); // apply parameter update
472 LoudnessEnhancerContext * pContext = (LoudnessEnhancerContext *) self;
474 if (pContext == NULL || pDescriptor == NULL) {