diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.cc b/system/audio_hal_interface/aidl/client_interface_aidl.cc index a41ead521f8..9faa7250226 100644 --- a/system/audio_hal_interface/aidl/client_interface_aidl.cc +++ b/system/audio_hal_interface/aidl/client_interface_aidl.cc @@ -560,6 +560,132 @@ size_t BluetoothAudioSourceClientInterface::WriteAudioData(const uint8_t* p_buf, return total_written; } +std::optional +BluetoothAudioClientInterface::GetProviderInfo(SessionType session_type) { + if (provider_factory_ == nullptr) { + LOG(WARNING) << __func__ << ": No provider factory"; + return std::nullopt; + } + std::optional provider_info; + auto aidl_retval = + provider_factory_->getProviderInfo(session_type, &provider_info); + if (!aidl_retval.isOk()) { + LOG(FATAL) << __func__ << ": BluetoothAudioHal::getProviderInfo failure: " + << aidl_retval.getDescription(); + } + return provider_info; +} + +void BluetoothAudioClientInterface::SetCodecPriority(CodecId codec_id, + int32_t priority) { + CHECK(provider_ != nullptr); + auto aidl_retval = provider_->setCodecPriority(codec_id, priority); + if (!aidl_retval.isOk()) { + LOG(FATAL) << __func__ << ": BluetoothAudioHal::setCodecPriority failure: " + << aidl_retval.getDescription(); + } +} + +std::vector +BluetoothAudioClientInterface::GetLeAudioAseConfiguration( + std::optional>>& + remoteSinkAudioCapabilities, + std::optional>>& + remoteSourceAudioCapabilities, + std::vector& + requirements) { + CHECK(provider_ != nullptr); + + std::vector + configurations; + auto aidl_retval = provider_->getLeAudioAseConfiguration( + remoteSinkAudioCapabilities, remoteSourceAudioCapabilities, requirements, + &configurations); + + if (!aidl_retval.isOk()) { + LOG(FATAL) << __func__ + << ": BluetoothAudioHal::getLeAudioAseConfiguration failure: " + << aidl_retval.getDescription(); + } + + LOG(INFO) << __func__ + << ": BluetoothAudioHal::getLeAudioAseConfiguration returned " + << configurations.size() << " configurations."; + return configurations; +} + +IBluetoothAudioProvider::LeAudioAseQosConfigurationPair +BluetoothAudioClientInterface::getLeAudioAseQosConfiguration( + IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement& + qosRequirement) { + CHECK(provider_ != nullptr); + + IBluetoothAudioProvider::LeAudioAseQosConfigurationPair qos_configuration; + auto aidl_retval = provider_->getLeAudioAseQosConfiguration( + qosRequirement, &qos_configuration); + + if (!aidl_retval.isOk()) { + LOG(FATAL) << __func__ + << ": BluetoothAudioHal::getLeAudioAseQosConfiguration failure: " + << aidl_retval.getDescription(); + } + return qos_configuration; +} + +void BluetoothAudioClientInterface::onSinkAseMetadataChanged( + IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId, + std::optional>>& metadata) { + CHECK(provider_ != nullptr); + + auto aidl_retval = + provider_->onSinkAseMetadataChanged(state, cigId, cisId, metadata); + + if (!aidl_retval.isOk()) { + LOG(FATAL) << __func__ + << ": BluetoothAudioHal::onSinkAseMetadataChanged failure: " + << aidl_retval.getDescription(); + } +} + +void BluetoothAudioClientInterface::onSourceAseMetadataChanged( + IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId, + std::optional>>& metadata) { + CHECK(provider_ != nullptr); + + auto aidl_retval = + provider_->onSourceAseMetadataChanged(state, cigId, cisId, metadata); + + if (!aidl_retval.isOk()) { + LOG(FATAL) << __func__ + << ": BluetoothAudioHal::onSinkAseMetadataChanged failure: " + << aidl_retval.getDescription(); + } +} + +IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting +BluetoothAudioClientInterface::getLeAudioBroadcastConfiguration( + const std::optional>>& + remoteSinkAudioCapabilities, + const IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement& + requirement) { + CHECK(provider_ != nullptr); + + IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting setting; + auto aidl_retval = provider_->getLeAudioBroadcastConfiguration( + remoteSinkAudioCapabilities, requirement, &setting); + + if (!aidl_retval.isOk()) { + LOG(FATAL) << __func__ + << ": BluetoothAudioHal::onSinkAseMetadataChanged failure: " + << aidl_retval.getDescription(); + } + + return setting; +} + } // namespace aidl } // namespace audio } // namespace bluetooth diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.h b/system/audio_hal_interface/aidl/client_interface_aidl.h index a0863ffde2e..0dd9575acba 100644 --- a/system/audio_hal_interface/aidl/client_interface_aidl.h +++ b/system/audio_hal_interface/aidl/client_interface_aidl.h @@ -39,11 +39,17 @@ namespace aidl { using ::aidl::android::hardware::bluetooth::audio::AudioCapabilities; using ::aidl::android::hardware::bluetooth::audio::AudioConfiguration; using ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus; +using ::aidl::android::hardware::bluetooth::audio::CodecId; +using ::aidl::android::hardware::bluetooth::audio::CodecInfo; +using ::aidl::android::hardware::bluetooth::audio::CodecSpecificCapabilitiesLtv; +using ::aidl::android::hardware::bluetooth::audio:: + CodecSpecificConfigurationLtv; using ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioPort; using ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider; using ::aidl::android::hardware::bluetooth::audio:: IBluetoothAudioProviderFactory; using ::aidl::android::hardware::bluetooth::audio::LatencyMode; +using ::aidl::android::hardware::bluetooth::audio::MetadataLtv; using ::aidl::android::hardware::bluetooth::audio::PcmConfiguration; using ::aidl::android::hardware::common::fmq::MQDescriptor; @@ -89,6 +95,43 @@ class BluetoothAudioClientInterface { void FlushAudioData(); + std::optional GetProviderInfo( + SessionType session_type); + + void SetCodecPriority(CodecId codec_id, int32_t priority); + + std::vector + GetLeAudioAseConfiguration( + std::optional>>& + remoteSinkAudioCapabilities, + std::optional>>& + remoteSourceAudioCapabilities, + std::vector& + requirements); + + IBluetoothAudioProvider::LeAudioAseQosConfigurationPair + getLeAudioAseQosConfiguration( + IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement& + qosRequirement); + + void onSinkAseMetadataChanged( + IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId, + std::optional>>& metadata); + + void onSourceAseMetadataChanged( + IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId, + std::optional>>& metadata); + + IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting + getLeAudioBroadcastConfiguration( + const std::optional>>& + remoteSinkAudioCapabilities, + const IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement& + requirement); + static constexpr PcmConfiguration kInvalidPcmConfiguration = {}; static bool is_aidl_available();