From 47f8c7303c9e2054f1492b02b6c7472385c52dc9 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Mon, 7 Mar 2016 03:43:14 -0800 Subject: 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 --- services/audiopolicy/service/AudioPolicyService.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'services/audiopolicy/service/AudioPolicyService.h') diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h index 27a62f4..9b17a26 100644 --- a/services/audiopolicy/service/AudioPolicyService.h +++ b/services/audiopolicy/service/AudioPolicyService.h @@ -235,6 +235,10 @@ public: audio_unique_id_t sessionId, bool added); void doOnOutputSessionEffectsUpdate(audio_stream_type_t stream, audio_unique_id_t sessionId, bool added); + void releaseOutputSessionEffectsDelayed(audio_io_handle_t output, + audio_stream_type_t stream, + audio_unique_id_t sessionId, + int delayMs); private: AudioPolicyService() ANDROID_API; @@ -268,7 +272,8 @@ private: UPDATE_AUDIOPATCH_LIST, SET_AUDIOPORT_CONFIG, DYN_POLICY_MIX_STATE_UPDATE, - EFFECT_SESSION_UPDATE + EFFECT_SESSION_UPDATE, + RELEASE_OUTPUT_SESSION_EFFECTS, }; AudioCommandThread (String8 name, const wp& service); @@ -313,6 +318,10 @@ private: void insertCommand_l(AudioCommand *command, int delayMs = 0); void effectSessionUpdateCommand(audio_stream_type_t stream, audio_unique_id_t sessionId, bool added); + void releaseOutputSessionEffectsCommand(audio_io_handle_t output, + audio_stream_type_t stream, + audio_unique_id_t sessionId, + int delayMs = 0); private: class AudioCommandData; @@ -416,6 +425,13 @@ private: bool mAdded; }; + class ReleaseOutputSessionEffectsData : public AudioCommandData { + public: + audio_io_handle_t mOutput; + audio_stream_type_t mStream; + audio_unique_id_t mSessionId; + }; + Mutex mLock; Condition mWaitWorkCV; Vector < sp > mAudioCommands; // list of pending commands -- cgit v1.1