IAudioFlinger: fix incorrect audio patch handle
While updating an exist audio patch, the handle should be pass into
patch panel. Otherwise, patch panel will treat it as a new patch,
then make audio routing incorrect.
Pass handle into patch panel if it exist.
Bug: 194367027
Test: Manual test
Change-Id: I15f0ecd47ec89140cd47f8aabbd9af5bd2b609e8
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index 0564cdf..0e2bdab 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -661,7 +661,11 @@
status_t AudioFlingerClientAdapter::createAudioPatch(const struct audio_patch* patch,
audio_patch_handle_t* handle) {
media::AudioPatch patchAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_AudioPatch(*patch));
- int32_t aidlRet;
+ int32_t aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t(
+ AUDIO_PATCH_HANDLE_NONE));
+ if (handle != nullptr) {
+ aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t(*handle));
+ }
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
mDelegate->createAudioPatch(patchAidl, &aidlRet)));
if (handle != nullptr) {
@@ -1136,7 +1140,8 @@
Status AudioFlingerServerAdapter::createAudioPatch(const media::AudioPatch& patch,
int32_t* _aidl_return) {
audio_patch patchLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPatch_audio_patch(patch));
- audio_patch_handle_t handleLegacy;
+ audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER(
+ aidl2legacy_int32_t_audio_patch_handle_t(*_aidl_return));
RETURN_BINDER_IF_ERROR(mDelegate->createAudioPatch(&patchLegacy, &handleLegacy));
*_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_patch_handle_t_int32_t(handleLegacy));
return Status::ok();