Merge "audio: Improve testing of point-to-point connections" into main am: 049a82e5d9

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2753112

Change-Id: I2bd9cef92786b85abe73d6092ea6960ec8c27d91
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mikhail Naganov
2023-09-18 17:06:02 +00:00
committed by Automerger Merge Worker
2 changed files with 51 additions and 21 deletions

View File

@@ -145,28 +145,36 @@ AudioDeviceAddress::Tag suggestDeviceAddressTag(const AudioDeviceDescription& de
}
AudioPort GenerateUniqueDeviceAddress(const AudioPort& port) {
// Point-to-point connections do not use addresses.
static const std::set<std::string> kPointToPointConnections = {
AudioDeviceDescription::CONNECTION_ANALOG, AudioDeviceDescription::CONNECTION_HDMI,
AudioDeviceDescription::CONNECTION_HDMI_ARC,
AudioDeviceDescription::CONNECTION_HDMI_EARC, AudioDeviceDescription::CONNECTION_SPDIF};
static int nextId = 0;
using Tag = AudioDeviceAddress::Tag;
const auto& deviceDescription = port.ext.get<AudioPortExt::Tag::device>().device.type;
AudioDeviceAddress address;
switch (suggestDeviceAddressTag(port.ext.get<AudioPortExt::Tag::device>().device.type)) {
case Tag::id:
address = AudioDeviceAddress::make<Tag::id>(std::to_string(++nextId));
break;
case Tag::mac:
address = AudioDeviceAddress::make<Tag::mac>(
std::vector<uint8_t>{1, 2, 3, 4, 5, static_cast<uint8_t>(++nextId & 0xff)});
break;
case Tag::ipv4:
address = AudioDeviceAddress::make<Tag::ipv4>(
std::vector<uint8_t>{192, 168, 0, static_cast<uint8_t>(++nextId & 0xff)});
break;
case Tag::ipv6:
address = AudioDeviceAddress::make<Tag::ipv6>(std::vector<int32_t>{
0xfc00, 0x0123, 0x4567, 0x89ab, 0xcdef, 0, 0, ++nextId & 0xffff});
break;
case Tag::alsa:
address = AudioDeviceAddress::make<Tag::alsa>(std::vector<int32_t>{1, ++nextId});
break;
if (kPointToPointConnections.count(deviceDescription.connection) == 0) {
switch (suggestDeviceAddressTag(deviceDescription)) {
case Tag::id:
address = AudioDeviceAddress::make<Tag::id>(std::to_string(++nextId));
break;
case Tag::mac:
address = AudioDeviceAddress::make<Tag::mac>(
std::vector<uint8_t>{1, 2, 3, 4, 5, static_cast<uint8_t>(++nextId & 0xff)});
break;
case Tag::ipv4:
address = AudioDeviceAddress::make<Tag::ipv4>(
std::vector<uint8_t>{192, 168, 0, static_cast<uint8_t>(++nextId & 0xff)});
break;
case Tag::ipv6:
address = AudioDeviceAddress::make<Tag::ipv6>(std::vector<int32_t>{
0xfc00, 0x0123, 0x4567, 0x89ab, 0xcdef, 0, 0, ++nextId & 0xffff});
break;
case Tag::alsa:
address = AudioDeviceAddress::make<Tag::alsa>(std::vector<int32_t>{1, ++nextId});
break;
}
}
AudioPort result = port;
result.ext.get<AudioPortExt::Tag::device>().device.address = std::move(address);