AudioFlinger: createEffect always look for same session effect chain.
Test: CTS AudioEffect tests
Bug: 128630419
Change-Id: Ieb08abfcb7a983e05fa8f25f6609468d9bd4620b
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 1441e15..ec5dfb1 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -558,6 +558,26 @@
#include "PatchPanel.h"
+ // Find io handle by session id.
+ // Preference is given to an io handle with a matching effect chain to session id.
+ // If none found, AUDIO_IO_HANDLE_NONE is returned.
+ template <typename T>
+ static audio_io_handle_t findIoHandleBySessionId_l(
+ audio_session_t sessionId, const T& threads) {
+ audio_io_handle_t io = AUDIO_IO_HANDLE_NONE;
+
+ for (size_t i = 0; i < threads.size(); i++) {
+ const uint32_t sessionType = threads.valueAt(i)->hasAudioSession(sessionId);
+ if (sessionType != 0) {
+ io = threads.keyAt(i);
+ if ((sessionType & AudioFlinger::ThreadBase::EFFECT_SESSION) != 0) {
+ break; // effect chain here.
+ }
+ }
+ }
+ return io;
+ }
+
// server side of the client's IAudioTrack
class TrackHandle : public android::BnAudioTrack {
public: