Fix AudioSystem::getAudioPort implementation
The implementation used to try to convert the complete provided
audio port into AIDL before passing to AP Service. The
corresponding AP Service method has been changed to only take
the port ID—the only piece of information which is actually
used by APM.
Bug: 221075345
Test: in preparation by a contractor
Change-Id: Id274ee14a8bfd2dcbfbb22b7a09b89dc6b7314ce
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 32c77c7..4c2284b 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -1497,13 +1497,12 @@
if (port == nullptr) {
return BAD_VALUE;
}
-
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- media::AudioPort portAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_v7_AudioPort(*port));
+ media::AudioPort portAidl;
RETURN_STATUS_IF_ERROR(
- statusTFromBinderStatus(aps->getAudioPort(portAidl, &portAidl)));
+ statusTFromBinderStatus(aps->getAudioPort(port->id, &portAidl)));
*port = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPort_audio_port_v7(portAidl));
return OK;
}
diff --git a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
index de0f75b..f10c5d0 100644
--- a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
@@ -216,8 +216,8 @@
inout Int count,
out AudioPort[] ports);
- /** Get attributes for a given audio port. */
- AudioPort getAudioPort(in AudioPort port);
+ /** Get attributes for the audio port with the given id (AudioPort.hal.id field). */
+ AudioPort getAudioPort(int /* audio_port_handle_t */ portId);
/**
* Create an audio patch between several source and sink ports.
diff --git a/media/libaudioclient/include/media/AudioSystem.h b/media/libaudioclient/include/media/AudioSystem.h
index baefee3..a1fb125 100644
--- a/media/libaudioclient/include/media/AudioSystem.h
+++ b/media/libaudioclient/include/media/AudioSystem.h
@@ -374,7 +374,8 @@
struct audio_port_v7 *ports,
unsigned int *generation);
- /* Get attributes for a given audio port */
+ /* Get attributes for a given audio port. On input, the port
+ * only needs the 'id' field to be filled in. */
static status_t getAudioPort(struct audio_port_v7 *port);
/* Create an audio patch between several source and sink ports */