diff options
author | Eric Laurent <elaurent@google.com> | 2010-07-19 06:24:46 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2010-07-19 06:31:30 -0700 |
commit | 0d7e048cf2e38d32568261760aef82d1ee145126 (patch) | |
tree | 8cc4ce1bd601dae9c7f98d0235ff2be3a28275cf /services | |
parent | faf775e772e329e821d81ba735474df097b1e1e9 (diff) | |
download | frameworks_base-0d7e048cf2e38d32568261760aef82d1ee145126.zip frameworks_base-0d7e048cf2e38d32568261760aef82d1ee145126.tar.gz frameworks_base-0d7e048cf2e38d32568261760aef82d1ee145126.tar.bz2 |
Fixed problems in audio effect volume control.
Fixed the following problems in audio effect volume control in AudioFlinger:
- Make sure that the volumes returned by EffectChain::setVolume_l() are correct even is
no change is detected since last call
- Do not use isEnabled() to validate volume control but mState >= ACTIVE instead as the volume control
must be also active in STOPPING and STOPPED states.
Change-Id: Id62da3164fad500ee8a5efd6cd78c77e8fdcb541
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 31 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 3 |
2 files changed, 24 insertions, 10 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 7e528af..b38a5c8 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -2948,7 +2948,8 @@ bool AudioFlinger::PlaybackThread::Track::isReady() const { status_t AudioFlinger::PlaybackThread::Track::start() { status_t status = NO_ERROR; - LOGV("start(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid()); + LOGV("start(%d), calling thread %d session %d", + mName, IPCThreadState::self()->getCallingPid(), mSessionId); sp<ThreadBase> thread = mThread.promote(); if (thread != 0) { Mutex::Autolock _l(thread->mLock); @@ -5366,9 +5367,9 @@ status_t AudioFlinger::EffectModule::setVolume(uint32_t *left, uint32_t *right, // Send volume indication if EFFECT_FLAG_VOLUME_IND is set and read back altered volume // if controller flag is set (Note that controller == TRUE => EFFECT_FLAG_VOLUME_CTRL set) - if (isEnabled() && - (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_CTRL || - (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_IND) { + if ((mState >= ACTIVE) && + ((mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_CTRL || + (mDescriptor.flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_IND)) { status_t cmdStatus; uint32_t volume[2]; uint32_t *pVolume = NULL; @@ -5749,7 +5750,8 @@ void AudioFlinger::EffectHandle::dump(char* buffer, size_t size) AudioFlinger::EffectChain::EffectChain(const wp<ThreadBase>& wThread, int sessionId) : mThread(wThread), mSessionId(sessionId), mActiveTrackCnt(0), mOwnInBuffer(false), - mVolumeCtrlIdx(-1), mLeftVolume(0), mRightVolume(0) + mVolumeCtrlIdx(-1), mLeftVolume(0), mRightVolume(0), + mNewLeftVolume(0), mNewRightVolume(0) { } @@ -5980,25 +5982,34 @@ bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right) // first update volume controller for (size_t i = size; i > 0; i--) { - if (mEffects[i - 1]->isEnabled() && + if ((mEffects[i - 1]->state() >= EffectModule::ACTIVE) && (mEffects[i - 1]->desc().flags & EFFECT_FLAG_VOLUME_MASK) == EFFECT_FLAG_VOLUME_CTRL) { ctrlIdx = i - 1; + hasControl = true; break; } } if (ctrlIdx == mVolumeCtrlIdx && *left == mLeftVolume && *right == mRightVolume) { - return false; + if (hasControl) { + *left = mNewLeftVolume; + *right = mNewRightVolume; + } + return hasControl; } + if (mVolumeCtrlIdx != -1) { + hasControl = true; + } mVolumeCtrlIdx = ctrlIdx; - mLeftVolume = *left; - mRightVolume = *right; + mLeftVolume = newLeft; + mRightVolume = newRight; // second get volume update from volume controller if (ctrlIdx >= 0) { mEffects[ctrlIdx]->setVolume(&newLeft, &newRight, true); - hasControl = true; + mNewLeftVolume = newLeft; + mNewRightVolume = newRight; } // then indicate volume to all other effects in chain. // Pass altered volume to effects before volume controller diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 4507a48..99816f9 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -1110,6 +1110,9 @@ private: int mVolumeCtrlIdx; // index of insert effect having control over volume uint32_t mLeftVolume; // previous volume on left channel uint32_t mRightVolume; // previous volume on right channel + uint32_t mNewLeftVolume; // new volume on left channel + uint32_t mNewRightVolume; // new volume on right channel + }; friend class RecordThread; |