diff options
author | Steve Kondik <steve@cyngn.com> | 2016-03-07 03:43:14 -0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2016-03-08 17:34:54 -0800 |
commit | 47f8c7303c9e2054f1492b02b6c7472385c52dc9 (patch) | |
tree | 99179985590f64d6c01051365deaa59552d1d582 /services/audiopolicy/service/AudioPolicyEffects.cpp | |
parent | 0479d7c79a7fd6f112e8dc7e45c009cf6602dbaa (diff) | |
download | frameworks_av-47f8c7303c9e2054f1492b02b6c7472385c52dc9.zip frameworks_av-47f8c7303c9e2054f1492b02b6c7472385c52dc9.tar.gz frameworks_av-47f8c7303c9e2054f1492b02b6c7472385c52dc9.tar.bz2 |
audiopolicy: Defer release of output session effects
* Some effects modules are racy and don't tolerate being destroyed
and immediately resurrected on the same session. This is
the common case when switching tracks, and the use of default
output effects makes the problem even worse. Certain apps
which handle gapless in a sloppy way are also to blame.
* Instead of immediately nuking the entire descriptor with the
stream, just decrease the refcount and defer it for 10 seconds.
If it needs resurrected, the refcount will be increased and
the delayed release command will not shoot it in the face.
Change-Id: I068dd72c4180023a74eb9ccbe8a180f6f0683dbf
Diffstat (limited to 'services/audiopolicy/service/AudioPolicyEffects.cpp')
-rw-r--r-- | services/audiopolicy/service/AudioPolicyEffects.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/services/audiopolicy/service/AudioPolicyEffects.cpp b/services/audiopolicy/service/AudioPolicyEffects.cpp index d72e255..f2d7f6f 100644 --- a/services/audiopolicy/service/AudioPolicyEffects.cpp +++ b/services/audiopolicy/service/AudioPolicyEffects.cpp @@ -295,16 +295,49 @@ status_t AudioPolicyEffects::releaseOutputSessionEffects(audio_io_handle_t outpu } EffectVector *procDesc = mOutputSessions.valueAt(index); + + // just in case it already has a death wish + if (procDesc->mRefCount == 0) { + return NO_ERROR; + } + procDesc->mRefCount--; ALOGV("releaseOutputSessionEffects(): session: %d, refCount: %d", audioSession, procDesc->mRefCount); + + if (procDesc->mRefCount == 0) { + mAudioPolicyService->releaseOutputSessionEffectsDelayed( + output, stream, audioSession, 10000); + } + + return status; +} + +status_t AudioPolicyEffects::doReleaseOutputSessionEffects(audio_io_handle_t output, + audio_stream_type_t stream, + int audioSession) +{ + status_t status = NO_ERROR; + (void) output; // argument not used for now + + Mutex::Autolock _l(mLock); + ssize_t index = mOutputSessions.indexOfKey(audioSession); + if (index < 0) { + ALOGV("doReleaseOutputSessionEffects: no output processing was attached to this stream"); + return NO_ERROR; + } + + EffectVector *procDesc = mOutputSessions.valueAt(index); + ALOGV("doReleaseOutputSessionEffects(): session: %d, refCount: %d", + audioSession, procDesc->mRefCount); + if (procDesc->mRefCount == 0) { procDesc->setProcessorEnabled(false); procDesc->mEffects.clear(); delete procDesc; mOutputSessions.removeItemsAt(index); mAudioPolicyService->onOutputSessionEffectsUpdate(stream, audioSession, false); - ALOGV("releaseOutputSessionEffects(): output processing released from session: %d", + ALOGV("doReleaseOutputSessionEffects(): output processing released from session: %d", audioSession); } return status; |