Loading system/bta/le_audio/codec_manager.cc +33 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <bluetooth/log.h> #include <bitset> #include <sstream> #include "audio_hal_client/audio_hal_client.h" #include "broadcaster/broadcast_configuration_provider.h" Loading Loading @@ -225,11 +226,34 @@ struct codec_manager_impl { requirements.audio_context_type); } void PrintDebugState() const { for (types::LeAudioContextType ctx_type : types::kLeAudioContextAllTypesArray) { std::stringstream os; os << ctx_type << ": "; if (context_type_offload_config_map_.count(ctx_type) == 0) { os << "{empty}"; } else { os << "{"; for (const auto& conf : context_type_offload_config_map_.at(ctx_type)) { os << conf->name << ", "; } os << "}"; } log::info("Offload configs for {}", os.str()); } } std::unique_ptr<AudioSetConfiguration> GetCodecConfig( const CodecManager::UnicastConfigurationRequirements& requirements, CodecManager::UnicastConfigurationVerifier verifier) { auto configs = GetSupportedCodecConfigurations(requirements); if (configs == nullptr) return nullptr; if (configs == nullptr) { log::error("No valid configuration matching the requirements: {}", requirements); PrintDebugState(); return nullptr; } // Note: For the only supported right now legacy software configuration // provider, we use the device group logic to match the proper // configuration with group capabilities. Note that this path only Loading Loading @@ -902,7 +926,14 @@ struct codec_manager_impl { std::vector<btle_audio_codec_config_t> codec_input_capa = {}; std::vector<btle_audio_codec_config_t> codec_output_capa = {}; int broadcast_target_config = -1; }; // namespace bluetooth::le_audio }; std::ostream& operator<<( std::ostream& os, const CodecManager::UnicastConfigurationRequirements& req) { os << "{audio context type: " << req.audio_context_type << "}"; return os; } struct CodecManager::impl { impl(const CodecManager& codec_manager) : codec_manager_(codec_manager) {} Loading system/bta/le_audio/codec_manager.h +19 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #pragma once #include <bluetooth/log.h> #include <vector> #include "broadcaster/broadcaster_types.h" Loading Loading @@ -62,6 +64,12 @@ class CodecManager { ::bluetooth::le_audio::types::LeAudioContextType audio_context_type; }; /* The verifier function checks each possible configuration (from the set of * all possible, supported configuration acquired from * AudioSetConfigurationProvider for the given scenario), to select a single * configuration, matching the current streaming audio group requirements. * Note: Used only with the legacy AudioSetConfigurationProvider. */ typedef std::function<const set_configurations::AudioSetConfiguration*( const UnicastConfigurationRequirements& requirements, const set_configurations::AudioSetConfigurations* confs)> Loading Loading @@ -119,4 +127,15 @@ class CodecManager { struct impl; std::unique_ptr<impl> pimpl_; }; std::ostream& operator<<( std::ostream& os, const CodecManager::UnicastConfigurationRequirements& req); } // namespace bluetooth::le_audio namespace fmt { template <> struct formatter< bluetooth::le_audio::CodecManager::UnicastConfigurationRequirements> : ostream_formatter {}; } // namespace fmt system/bta/le_audio/mock_codec_manager.cc +7 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,13 @@ void CodecManager::ClearCisConfiguration(uint8_t direction) { if (pimpl_) return pimpl_->ClearCisConfiguration(direction); } std::ostream& operator<<( std::ostream& os, const CodecManager::UnicastConfigurationRequirements& req) { os << "{audio context type: " << req.audio_context_type << "}"; return os; } // CodecManager::~CodecManager() = default; } // namespace bluetooth::le_audio Loading
system/bta/le_audio/codec_manager.cc +33 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <bluetooth/log.h> #include <bitset> #include <sstream> #include "audio_hal_client/audio_hal_client.h" #include "broadcaster/broadcast_configuration_provider.h" Loading Loading @@ -225,11 +226,34 @@ struct codec_manager_impl { requirements.audio_context_type); } void PrintDebugState() const { for (types::LeAudioContextType ctx_type : types::kLeAudioContextAllTypesArray) { std::stringstream os; os << ctx_type << ": "; if (context_type_offload_config_map_.count(ctx_type) == 0) { os << "{empty}"; } else { os << "{"; for (const auto& conf : context_type_offload_config_map_.at(ctx_type)) { os << conf->name << ", "; } os << "}"; } log::info("Offload configs for {}", os.str()); } } std::unique_ptr<AudioSetConfiguration> GetCodecConfig( const CodecManager::UnicastConfigurationRequirements& requirements, CodecManager::UnicastConfigurationVerifier verifier) { auto configs = GetSupportedCodecConfigurations(requirements); if (configs == nullptr) return nullptr; if (configs == nullptr) { log::error("No valid configuration matching the requirements: {}", requirements); PrintDebugState(); return nullptr; } // Note: For the only supported right now legacy software configuration // provider, we use the device group logic to match the proper // configuration with group capabilities. Note that this path only Loading Loading @@ -902,7 +926,14 @@ struct codec_manager_impl { std::vector<btle_audio_codec_config_t> codec_input_capa = {}; std::vector<btle_audio_codec_config_t> codec_output_capa = {}; int broadcast_target_config = -1; }; // namespace bluetooth::le_audio }; std::ostream& operator<<( std::ostream& os, const CodecManager::UnicastConfigurationRequirements& req) { os << "{audio context type: " << req.audio_context_type << "}"; return os; } struct CodecManager::impl { impl(const CodecManager& codec_manager) : codec_manager_(codec_manager) {} Loading
system/bta/le_audio/codec_manager.h +19 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #pragma once #include <bluetooth/log.h> #include <vector> #include "broadcaster/broadcaster_types.h" Loading Loading @@ -62,6 +64,12 @@ class CodecManager { ::bluetooth::le_audio::types::LeAudioContextType audio_context_type; }; /* The verifier function checks each possible configuration (from the set of * all possible, supported configuration acquired from * AudioSetConfigurationProvider for the given scenario), to select a single * configuration, matching the current streaming audio group requirements. * Note: Used only with the legacy AudioSetConfigurationProvider. */ typedef std::function<const set_configurations::AudioSetConfiguration*( const UnicastConfigurationRequirements& requirements, const set_configurations::AudioSetConfigurations* confs)> Loading Loading @@ -119,4 +127,15 @@ class CodecManager { struct impl; std::unique_ptr<impl> pimpl_; }; std::ostream& operator<<( std::ostream& os, const CodecManager::UnicastConfigurationRequirements& req); } // namespace bluetooth::le_audio namespace fmt { template <> struct formatter< bluetooth::le_audio::CodecManager::UnicastConfigurationRequirements> : ostream_formatter {}; } // namespace fmt
system/bta/le_audio/mock_codec_manager.cc +7 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,13 @@ void CodecManager::ClearCisConfiguration(uint8_t direction) { if (pimpl_) return pimpl_->ClearCisConfiguration(direction); } std::ostream& operator<<( std::ostream& os, const CodecManager::UnicastConfigurationRequirements& req) { os << "{audio context type: " << req.audio_context_type << "}"; return os; } // CodecManager::~CodecManager() = default; } // namespace bluetooth::le_audio