Additional context matching logic for LEA multi-codec
When we match with the remote capabilities, we don't filter by
preferred audio context, since they are suggestion.
Instead, we populate settings into 2 separated vector:
- Matched settings with matched preferred context,
- Matched settings,
We then filter by the first vector, then by the second vector.
Bug: 306225778
Test: atest VtsHalBluetoothAudioTargetTest
Change-Id: I03f322e8de509127d218a9de6b41dd39b2ebdcba
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp
index 5429a8f..780154a 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp
@@ -267,7 +267,7 @@
ase_configuration_settings_.clear();
configurations_.clear();
auto loaded = LoadContent(kLeAudioSetConfigs, kLeAudioSetScenarios,
- CodecLocation::HOST);
+ CodecLocation::ADSP);
if (!loaded)
LOG(ERROR) << ": Unable to load le audio set configuration files.";
} else
@@ -371,7 +371,6 @@
CodecSpecificConfigurationLtv::CodecFrameBlocksPerSDU();
frame_sdu_structure.value = codec_frames_blocks_per_sdu;
ase.codecConfiguration.push_back(frame_sdu_structure);
- // TODO: Channel count
}
void AudioSetConfigurationProviderJson::populateAseConfiguration(
@@ -415,8 +414,53 @@
}
void AudioSetConfigurationProviderJson::populateAseQosConfiguration(
- LeAudioAseQosConfiguration& qos,
- const le_audio::QosConfiguration* qos_cfg) {
+ LeAudioAseQosConfiguration& qos, const le_audio::QosConfiguration* qos_cfg,
+ LeAudioAseConfiguration& ase) {
+ std::optional<CodecSpecificConfigurationLtv::CodecFrameBlocksPerSDU>
+ frameBlock = std::nullopt;
+ std::optional<CodecSpecificConfigurationLtv::FrameDuration> frameDuration =
+ std::nullopt;
+ std::optional<CodecSpecificConfigurationLtv::AudioChannelAllocation>
+ allocation = std::nullopt;
+ std::optional<CodecSpecificConfigurationLtv::OctetsPerCodecFrame> octet =
+ std::nullopt;
+
+ for (auto& cfg_ltv : ase.codecConfiguration) {
+ auto tag = cfg_ltv.getTag();
+ if (tag == CodecSpecificConfigurationLtv::codecFrameBlocksPerSDU) {
+ frameBlock =
+ cfg_ltv.get<CodecSpecificConfigurationLtv::codecFrameBlocksPerSDU>();
+ } else if (tag == CodecSpecificConfigurationLtv::frameDuration) {
+ frameDuration =
+ cfg_ltv.get<CodecSpecificConfigurationLtv::frameDuration>();
+ } else if (tag == CodecSpecificConfigurationLtv::audioChannelAllocation) {
+ allocation =
+ cfg_ltv.get<CodecSpecificConfigurationLtv::audioChannelAllocation>();
+ } else if (tag == CodecSpecificConfigurationLtv::octetsPerCodecFrame) {
+ octet = cfg_ltv.get<CodecSpecificConfigurationLtv::octetsPerCodecFrame>();
+ }
+ }
+
+ int frameBlockValue = 1;
+ if (frameBlock.has_value()) frameBlockValue = frameBlock.value().value;
+
+ // Populate maxSdu
+ if (allocation.has_value() && octet.has_value()) {
+ auto channel_count = std::bitset<32>(allocation.value().bitmask).count();
+ qos.maxSdu = channel_count * octet.value().value * frameBlockValue;
+ }
+ // Populate sduIntervalUs
+ if (frameDuration.has_value()) {
+ switch (frameDuration.value()) {
+ case CodecSpecificConfigurationLtv::FrameDuration::US7500:
+ qos.sduIntervalUs = 7500;
+ break;
+ case CodecSpecificConfigurationLtv::FrameDuration::US10000:
+ qos.sduIntervalUs = 10000;
+ break;
+ }
+ qos.sduIntervalUs *= frameBlockValue;
+ }
qos.maxTransportLatencyMs = qos_cfg->max_transport_latency();
qos.retransmissionNum = qos_cfg->retransmission_number();
}
@@ -436,7 +480,7 @@
populateAseConfiguration(ase, flat_subconfig, qos_cfg);
// Translate into LeAudioAseQosConfiguration
- populateAseQosConfiguration(qos, qos_cfg);
+ populateAseQosConfiguration(qos, qos_cfg, ase);
// Translate location to data path id
switch (location) {
@@ -453,6 +497,8 @@
path.dataPathId = kIsoDataPathPlatformDefault;
break;
}
+ // Move codecId to iso data path
+ path.isoDataPathConfiguration.codecId = ase.codecId.value();
direction_conf.aseConfiguration = ase;
direction_conf.qosConfiguration = qos;
@@ -678,7 +724,8 @@
media_context.bitmask =
(AudioContext::ALERTS | AudioContext::INSTRUCTIONAL |
AudioContext::NOTIFICATIONS | AudioContext::EMERGENCY_ALARM |
- AudioContext::UNSPECIFIED | AudioContext::MEDIA);
+ AudioContext::UNSPECIFIED | AudioContext::MEDIA |
+ AudioContext::SOUND_EFFECTS);
AudioContext conversational_context = AudioContext();
conversational_context.bitmask =
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.h b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.h
index ce91fca..6639009 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.h
@@ -79,7 +79,7 @@
static void populateAseQosConfiguration(
LeAudioAseQosConfiguration& qos,
- const le_audio::QosConfiguration* qos_cfg);
+ const le_audio::QosConfiguration* qos_cfg, LeAudioAseConfiguration& ase);
static AseDirectionConfiguration SetConfigurationFromFlatSubconfig(
const le_audio::AudioSetSubConfiguration* flat_subconfig,