Skip to content

Commit 7fa1cee

Browse files
author
Eric Laurent
committed
Fix issue 381905: BassBoostTest CTS tests fail...
When AudioEffectTest is executed, an Equalizer is created and enabled on a MediaPlayer session. Effects on the output mix are therefore suspended. Then the MediaPlayer is released with the effect still enabled. In this case, Audioflinger::purgeStaleEffects_l() fails to restore the suspended effects when the effect attached to the released audio session is removed. When subsequent tests are executed on output mix effects, these effects cannot be enabled as they are still suspended. Fixed purgeStaleEffects_l() to restore suspended effects if the effect removed is enabled. Also fixed EffectHandle::disconnect() to only restore suspended effects if the disconnected handle actually has control over the effect. Change-Id: I67232e7c34680b0cc01abfd57d5d510a524e5d4f
1 parent 70ac412 commit 7fa1cee

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,13 @@ void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled(const sp<EffectModule
13321332
int sessionId)
13331333
{
13341334
Mutex::Autolock _l(mLock);
1335+
checkSuspendOnEffectEnabled_l(effect, enabled, sessionId);
1336+
}
13351337

1338+
void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled_l(const sp<EffectModule>& effect,
1339+
bool enabled,
1340+
int sessionId)
1341+
{
13361342
if (mType != RECORD) {
13371343
// suspend all effects in AUDIO_SESSION_OUTPUT_MIX when enabling any effect on
13381344
// another session. This gives the priority to well behaved effect control panels
@@ -5224,6 +5230,9 @@ void AudioFlinger::purgeStaleEffects_l() {
52245230
sp<EffectHandle> handle = effect->mHandles[j].promote();
52255231
if (handle != 0) {
52265232
handle->mEffect.clear();
5233+
if (handle->mHasControl && handle->mEnabled) {
5234+
t->checkSuspendOnEffectEnabled_l(effect, false, effect->sessionId());
5235+
}
52275236
}
52285237
}
52295238
AudioSystem::unregisterEffect(effect->id());
@@ -6844,7 +6853,7 @@ void AudioFlinger::EffectHandle::disconnect(bool unpiniflast)
68446853
}
68456854
mEffect->disconnect(this, unpiniflast);
68466855

6847-
if (mEnabled) {
6856+
if (mHasControl && mEnabled) {
68486857
sp<ThreadBase> thread = mEffect->thread().promote();
68496858
if (thread != 0) {
68506859
thread->checkSuspendOnEffectEnabled(mEffect, false, mEffect->sessionId());

services/audioflinger/AudioFlinger.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,12 @@ class AudioFlinger :
492492
int sessionId = AUDIO_SESSION_OUTPUT_MIX);
493493
// check if some effects must be suspended/restored when an effect is enabled
494494
// or disabled
495-
virtual void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
495+
void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
496496
bool enabled,
497497
int sessionId = AUDIO_SESSION_OUTPUT_MIX);
498-
498+
void checkSuspendOnEffectEnabled_l(const sp<EffectModule>& effect,
499+
bool enabled,
500+
int sessionId = AUDIO_SESSION_OUTPUT_MIX);
499501
mutable Mutex mLock;
500502

501503
protected:
@@ -1299,7 +1301,7 @@ class AudioFlinger :
12991301
// suspend all eligible effects
13001302
void setEffectSuspendedAll_l(bool suspend);
13011303
// check if effects should be suspend or restored when a given effect is enable or disabled
1302-
virtual void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
1304+
void checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
13031305
bool enabled);
13041306

13051307
status_t dump(int fd, const Vector<String16>& args);

0 commit comments

Comments
 (0)