Skip to content

Commit

Permalink
Merge "Add wrapper for LE Multi-codec's HAL functions" into main am: 7…
Browse files Browse the repository at this point in the history
…f2e59e

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2836297

Change-Id: I6300a2bc92cdf0ec6e8cc6efbecaf1a8b50f0d09
Signed-off-by: Automerger Merge Worker <[email protected]>
  • Loading branch information
Bao Do authored and android-build-merge-worker-robot committed Dec 14, 2023
2 parents c25e7af + 7f2e59e commit b85e7f3
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 0 deletions.
126 changes: 126 additions & 0 deletions system/audio_hal_interface/aidl/client_interface_aidl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,132 @@ size_t BluetoothAudioSourceClientInterface::WriteAudioData(const uint8_t* p_buf,
return total_written;
}

std::optional<IBluetoothAudioProviderFactory::ProviderInfo>
BluetoothAudioClientInterface::GetProviderInfo(SessionType session_type) {
if (provider_factory_ == nullptr) {
LOG(WARNING) << __func__ << ": No provider factory";
return std::nullopt;
}
std::optional<IBluetoothAudioProviderFactory::ProviderInfo> 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<IBluetoothAudioProvider::LeAudioAseConfigurationSetting>
BluetoothAudioClientInterface::GetLeAudioAseConfiguration(
std::optional<std::vector<
std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
remoteSinkAudioCapabilities,
std::optional<std::vector<
std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
remoteSourceAudioCapabilities,
std::vector<IBluetoothAudioProvider::LeAudioConfigurationRequirement>&
requirements) {
CHECK(provider_ != nullptr);

std::vector<IBluetoothAudioProvider::LeAudioAseConfigurationSetting>
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<std::vector<std::optional<MetadataLtv>>>& 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<std::vector<std::optional<MetadataLtv>>>& 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<std::vector<
std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
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
43 changes: 43 additions & 0 deletions system/audio_hal_interface/aidl/client_interface_aidl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,6 +95,43 @@ class BluetoothAudioClientInterface {

void FlushAudioData();

std::optional<IBluetoothAudioProviderFactory::ProviderInfo> GetProviderInfo(
SessionType session_type);

void SetCodecPriority(CodecId codec_id, int32_t priority);

std::vector<IBluetoothAudioProvider::LeAudioAseConfigurationSetting>
GetLeAudioAseConfiguration(
std::optional<std::vector<
std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
remoteSinkAudioCapabilities,
std::optional<std::vector<
std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
remoteSourceAudioCapabilities,
std::vector<IBluetoothAudioProvider::LeAudioConfigurationRequirement>&
requirements);

IBluetoothAudioProvider::LeAudioAseQosConfigurationPair
getLeAudioAseQosConfiguration(
IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement&
qosRequirement);

void onSinkAseMetadataChanged(
IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId,
std::optional<std::vector<std::optional<MetadataLtv>>>& metadata);

void onSourceAseMetadataChanged(
IBluetoothAudioProvider::AseState state, int32_t cigId, int32_t cisId,
std::optional<std::vector<std::optional<MetadataLtv>>>& metadata);

IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting
getLeAudioBroadcastConfiguration(
const std::optional<std::vector<
std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>&
remoteSinkAudioCapabilities,
const IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement&
requirement);

static constexpr PcmConfiguration kInvalidPcmConfiguration = {};

static bool is_aidl_available();
Expand Down

0 comments on commit b85e7f3

Please sign in to comment.