summaryrefslogtreecommitdiffstats
path: root/services/audioflinger
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2019-03-15 19:47:37 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-03-15 19:47:37 +0000
commit88a6078ced774995aa8326468f36cf7fa2924aae (patch)
tree91252acb979a248ff47aa654200705a552264b9f /services/audioflinger
parentef9d3a6952cf538d9b8ac58a74aa1952c1fd9529 (diff)
parente778c4254d3018553ff245448aa9d750c5628699 (diff)
downloadframeworks_av-88a6078ced774995aa8326468f36cf7fa2924aae.tar.gz
frameworks_av-88a6078ced774995aa8326468f36cf7fa2924aae.tar.bz2
frameworks_av-88a6078ced774995aa8326468f36cf7fa2924aae.zip
Merge "AudioFlinger: createEffect always look for same session effect chain."
Diffstat (limited to 'services/audioflinger')
-rw-r--r--services/audioflinger/AudioFlinger.cpp25
-rw-r--r--services/audioflinger/AudioFlinger.h20
2 files changed, 23 insertions, 22 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index e13e7aa06f..735885cc3c 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3286,31 +3286,12 @@ sp<IEffect> AudioFlinger::createEffect(
goto Exit;
}
// look for the thread where the specified audio session is present
- for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- uint32_t sessionType = mPlaybackThreads.valueAt(i)->hasAudioSession(sessionId);
- if (sessionType != 0) {
- io = mPlaybackThreads.keyAt(i);
- // thread with same effect session is preferable
- if ((sessionType & ThreadBase::EFFECT_SESSION) != 0) {
- break;
- }
- }
- }
+ io = findIoHandleBySessionId_l(sessionId, mPlaybackThreads);
if (io == AUDIO_IO_HANDLE_NONE) {
- for (size_t i = 0; i < mRecordThreads.size(); i++) {
- if (mRecordThreads.valueAt(i)->hasAudioSession(sessionId) != 0) {
- io = mRecordThreads.keyAt(i);
- break;
- }
- }
+ io = findIoHandleBySessionId_l(sessionId, mRecordThreads);
}
if (io == AUDIO_IO_HANDLE_NONE) {
- for (size_t i = 0; i < mMmapThreads.size(); i++) {
- if (mMmapThreads.valueAt(i)->hasAudioSession(sessionId) != 0) {
- io = mMmapThreads.keyAt(i);
- break;
- }
- }
+ io = findIoHandleBySessionId_l(sessionId, mMmapThreads);
}
// If no output thread contains the requested session ID, default to
// first output. The effect chain will be moved to the correct output
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 1441e15f19..ec5dfb177d 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -558,6 +558,26 @@ using effect_buffer_t = int16_t;
#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: