audio: Accept I/O handle for mix ports from the client
The client can pass the I/O handle to the HAL as part of
the requested audio port config. The HAL can store that handle
and use it as a cookie to match the port config with other HALs
(for example, SoundTrigger).
Updated behavior of IModule.setAudioPortConfig to copy
the handle for mix ports, and pass it back with the applied
config. Enforced this behavior in VTS.
Bug: 269551518
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ibc3f9eea4169610f1680937c764de42b4fe5194a
diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp
index 10aead2..5440b8d 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -895,6 +895,21 @@
out_suggested->gain = in_requested.gain.value();
}
+ if (in_requested.ext.getTag() != AudioPortExt::Tag::unspecified) {
+ if (in_requested.ext.getTag() == out_suggested->ext.getTag()) {
+ if (out_suggested->ext.getTag() == AudioPortExt::Tag::mix) {
+ // 'AudioMixPortExt.handle' is set by the client, copy from in_requested
+ out_suggested->ext.get<AudioPortExt::Tag::mix>().handle =
+ in_requested.ext.get<AudioPortExt::Tag::mix>().handle;
+ }
+ } else {
+ LOG(WARNING) << __func__ << ": requested ext tag "
+ << toString(in_requested.ext.getTag()) << " do not match port's tag "
+ << toString(out_suggested->ext.getTag());
+ requestedIsValid = false;
+ }
+ }
+
if (existing == configs.end() && requestedIsValid && requestedIsFullySpecified) {
out_suggested->id = getConfig().nextPortId++;
configs.push_back(*out_suggested);