From 1b92868010b5c1409692a86f6b27e4a265b64c1a Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 2 Oct 2014 19:41:47 -0700 Subject: audioflinger: fix pre processing transfer between record threads. Fix two problems remaining with pre processing effects transfer from one record thread to the next in case of tear down due to device connection: 1 - the enabled state of the effects was not communicated to the new HAL input stream. 2 - the effects saved in orphan chains list were not transfered to the new thread when a AudioRecord was created. Bug: 17757378. Change-Id: I0923c98470db3b51154dc89846157780a4c21e86 --- services/audioflinger/Effects.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'services/audioflinger/Effects.cpp') diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp index 4678880..bcaf8ae 100644 --- a/services/audioflinger/Effects.cpp +++ b/services/audioflinger/Effects.cpp @@ -440,6 +440,20 @@ status_t AudioFlinger::EffectModule::init() return status; } +void AudioFlinger::EffectModule::addEffectToHal_l() +{ + if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC || + (mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) { + sp thread = mThread.promote(); + if (thread != 0) { + audio_stream_t *stream = thread->stream(); + if (stream != NULL) { + stream->add_audio_effect(stream, mEffectInterface); + } + } + } +} + status_t AudioFlinger::EffectModule::start() { Mutex::Autolock _l(mLock); @@ -466,16 +480,7 @@ status_t AudioFlinger::EffectModule::start_l() status = cmdStatus; } if (status == 0) { - if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC || - (mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) { - sp thread = mThread.promote(); - if (thread != 0) { - audio_stream_t *stream = thread->stream(); - if (stream != NULL) { - stream->add_audio_effect(stream, mEffectInterface); - } - } - } + addEffectToHal_l(); sp chain = mChain.promote(); if (chain != 0) { chain->forceVolume(); @@ -1696,6 +1701,17 @@ bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right) return hasControl; } +void AudioFlinger::EffectChain::syncHalEffectsState() +{ + Mutex::Autolock _l(mLock); + for (size_t i = 0; i < mEffects.size(); i++) { + if (mEffects[i]->state() == EffectModule::ACTIVE || + mEffects[i]->state() == EffectModule::STOPPING) { + mEffects[i]->addEffectToHal_l(); + } + } +} + void AudioFlinger::EffectChain::dump(int fd, const Vector& args) { const size_t SIZE = 256; -- cgit v1.1