audio: effect: prevents spurious call to remove/add device effects
Bug: 268441977
Test: make
When multiple clients are using a same input, each time a client is
added/removed, the audio path will be recreated, thus leading to
removing/adding the device effect on audio hal if a device effect is
used.
This CL prevents from removing/adding a device effect when a patch handle
is reused, by checking if it involves same sink device/source mix or sink mix
/source device.
Change-Id: I9545f701835a4269a870b66e4f68351aca384683
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
diff --git a/services/audioflinger/PatchCommandThread.cpp b/services/audioflinger/PatchCommandThread.cpp
index f4aab1f..858784d 100644
--- a/services/audioflinger/PatchCommandThread.cpp
+++ b/services/audioflinger/PatchCommandThread.cpp
@@ -56,6 +56,16 @@
releaseAudioPatchCommand(handle);
}
+void AudioFlinger::PatchCommandThread::updateAudioPatch(audio_patch_handle_t oldHandle,
+ audio_patch_handle_t newHandle, const PatchPanel::Patch& patch) {
+ ALOGV("%s handle %d mHalHandle %d num sinks %d device sink %08x",
+ __func__, oldHandle, patch.mHalHandle,
+ patch.mAudioPatch.num_sinks,
+ patch.mAudioPatch.num_sinks > 0 ? patch.mAudioPatch.sinks[0].ext.device.type : 0);
+
+ updateAudioPatchCommand(oldHandle, newHandle, patch);
+}
+
bool AudioFlinger::PatchCommandThread::threadLoop()
NO_THREAD_SAFETY_ANALYSIS // bug in clang compiler.
{
@@ -102,6 +112,21 @@
}
}
break;
+ case UPDATE_AUDIO_PATCH: {
+ const auto data = (UpdateAudioPatchData*) command->mData.get();
+ ALOGV("%s processing update audio patch old handle %d new handle %d",
+ __func__,
+ data->mOldHandle, data->mNewHandle);
+
+ for (const auto& listener : listenersCopy) {
+ auto spListener = listener.promote();
+ if (spListener) {
+ spListener->onUpdateAudioPatch(data->mOldHandle,
+ data->mNewHandle, data->mPatch);
+ }
+ }
+ }
+ break;
default:
ALOGW("%s unknown command %d", __func__, command->mCommand);
break;
@@ -143,6 +168,16 @@
sendCommand(command);
}
+void AudioFlinger::PatchCommandThread::updateAudioPatchCommand(
+ audio_patch_handle_t oldHandle, audio_patch_handle_t newHandle,
+ const PatchPanel::Patch& patch) {
+ sp<Command> command = sp<Command>::make(UPDATE_AUDIO_PATCH,
+ new UpdateAudioPatchData(oldHandle, newHandle, patch));
+ ALOGV("%s adding update patch old handle %d new handle %d mHalHandle %d.",
+ __func__, oldHandle, newHandle, patch.mHalHandle);
+ sendCommand(command);
+}
+
void AudioFlinger::PatchCommandThread::exit() {
ALOGV("%s", __func__);
{