AudioFlinger: createEffect always look for same session effect chain.

Test: CTS AudioEffect tests
Bug: 128630419
Change-Id: Ieb08abfcb7a983e05fa8f25f6609468d9bd4620b
gugelfrei
Andy Hung 5 years ago
parent 0a2fc30b15
commit e778c4254d

@ -3278,31 +3278,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

@ -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:

Loading…
Cancel
Save