audiopolicy: fixup! audiopolicy: HW Bridge Sink matching rule
Bug: 172833835
Test: atest testRecordFromRemoteSubmix twice
Test: adb shell ./data/AudioPolicyEmulatorTests/AudioPolicyEmulatorTests --gtest_filter=*VoiceCallBridgingTest*
adb shell /data/nativetest64/AudioPolicyEmulatorTests/AudioPolicyEmulatorTests --gtest_filter=PlaybackReroutingUsageMatch/LegacyPlaybackReRoutingTest.playbackReRouting/*
Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: I9eb9de9682624cc18644e0239bda72c2bb5b502c
Merged-In: I9eb9de9682624cc18644e0239bda72c2bb5b502c
diff --git a/services/audiopolicy/common/managerdefinitions/include/HwModule.h b/services/audiopolicy/common/managerdefinitions/include/HwModule.h
index b5b10f3..9ba745a 100644
--- a/services/audiopolicy/common/managerdefinitions/include/HwModule.h
+++ b/services/audiopolicy/common/managerdefinitions/include/HwModule.h
@@ -52,8 +52,12 @@
devices.merge(mDynamicDevices);
return devices;
}
+ std::string getTagForDevice(audio_devices_t device,
+ const String8 &address = String8(),
+ audio_format_t codec = AUDIO_FORMAT_DEFAULT);
void addDynamicDevice(const sp<DeviceDescriptor> &device)
{
+ device->setDynamic();
mDynamicDevices.add(device);
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
index 8545f8e..f6859c7 100644
--- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
@@ -49,11 +49,13 @@
{
}
+// Let DeviceDescriptorBase initialize the address since it handles specific cases like
+// legacy remote submix where "0" is added as default address.
DeviceDescriptor::DeviceDescriptor(const AudioDeviceTypeAddr &deviceTypeAddr,
const std::string &tagName,
const FormatVector &encodedFormats) :
DeviceDescriptorBase(deviceTypeAddr), mTagName(tagName), mEncodedFormats(encodedFormats),
- mDeclaredAddress(deviceTypeAddr.getAddress())
+ mDeclaredAddress(DeviceDescriptorBase::address())
{
mCurrentEncodedFormat = AUDIO_FORMAT_DEFAULT;
/* If framework runs against a pre 5.0 Audio HAL, encoded formats are absent from the config.
diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
index 2967014..3a143b0 100644
--- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
@@ -41,6 +41,14 @@
}
}
+std::string HwModule::getTagForDevice(audio_devices_t device, const String8 &address,
+ audio_format_t codec)
+{
+ DeviceVector declaredDevices = getDeclaredDevices();
+ sp<DeviceDescriptor> deviceDesc = declaredDevices.getDevice(device, address, codec);
+ return deviceDesc ? deviceDesc->getTagName() : std::string{};
+}
+
status_t HwModule::addOutputProfile(const std::string& name, const audio_config_t *config,
audio_devices_t device, const String8& address)
{
@@ -49,7 +57,8 @@
profile->addAudioProfile(new AudioProfile(config->format, config->channel_mask,
config->sample_rate));
- sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device, "" /*tagName*/, address.string());
+ sp<DeviceDescriptor> devDesc =
+ new DeviceDescriptor(device, getTagForDevice(device), address.string());
addDynamicDevice(devDesc);
// Reciprocally attach the device to the module
devDesc->attach(this);
@@ -116,7 +125,8 @@
profile->addAudioProfile(new AudioProfile(config->format, config->channel_mask,
config->sample_rate));
- sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device, "" /*tagName*/, address.string());
+ sp<DeviceDescriptor> devDesc =
+ new DeviceDescriptor(device, getTagForDevice(device), address.string());
addDynamicDevice(devDesc);
// Reciprocally attach the device to the module
devDesc->attach(this);