Merge "Add support LE audio offload for HIDL 2.2" am: d2645ae70c am: 5513c4351b am: e22eea81ce

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

Change-Id: I682e3d05bf5fa8638a20d3c5bd242477df75e03c
This commit is contained in:
Treehugger Robot 2021-12-20 15:05:25 +00:00 committed by Automerger Merge Worker
commit 5bd86bb75c
12 changed files with 87 additions and 15 deletions

View file

@ -157,7 +157,11 @@ Return<void> BluetoothAudioProvidersFactory::getProviderCapabilities_2_1(
audio_capabilities[i].codecCapabilities(db_codec_capabilities[i]);
}
}
} else if (sessionType != SessionType::UNKNOWN) {
} else if (sessionType !=
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
sessionType !=
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH &&
sessionType != SessionType::UNKNOWN) {
std::vector<PcmParameters> db_pcm_capabilities =
android::bluetooth::audio::GetSoftwarePcmCapabilities_2_1();
if (db_pcm_capabilities.size() == 1) {

View file

@ -21,7 +21,7 @@
#include <android-base/logging.h>
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
namespace android {
namespace hardware {

View file

@ -22,7 +22,7 @@
#include "AudioPort_2_0_to_2_2_Wrapper.h"
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
namespace android {
namespace hardware {

View file

@ -20,7 +20,7 @@
#include <android-base/logging.h>
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
namespace android {
namespace hardware {

View file

@ -21,7 +21,7 @@
#include <android-base/logging.h>
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
namespace android {
namespace hardware {

View file

@ -22,7 +22,7 @@
#include "AudioPort_2_0_to_2_2_Wrapper.h"
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
namespace android {
namespace hardware {

View file

@ -22,7 +22,6 @@
#include "AudioPort_2_0_to_2_2_Wrapper.h"
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
namespace android {

View file

@ -87,7 +87,7 @@ class BluetoothAudioSessionControl_2_2 {
std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
if (session_ptr != nullptr) {
return session_ptr->GetAudioSession()->StartStream();
return session_ptr->StartStream();
}
return false;
}
@ -96,7 +96,7 @@ class BluetoothAudioSessionControl_2_2 {
std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
if (session_ptr != nullptr) {
return session_ptr->GetAudioSession()->SuspendStream();
return session_ptr->SuspendStream();
}
return false;
}
@ -105,7 +105,7 @@ class BluetoothAudioSessionControl_2_2 {
std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
if (session_ptr != nullptr) {
session_ptr->GetAudioSession()->StopStream();
session_ptr->StopStream();
}
}

View file

@ -46,6 +46,19 @@ bool is_2_0_session_type(
return false;
}
}
bool is_unsupported_2_1_session_type(
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
session_type) {
if (session_type ==
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
session_type ==
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
return true;
} else {
return false;
}
}
} // namespace
BluetoothAudioSession_2_1::BluetoothAudioSession_2_1(
@ -53,7 +66,8 @@ BluetoothAudioSession_2_1::BluetoothAudioSession_2_1(
session_type)
: audio_session(BluetoothAudioSessionInstance::GetSessionInstance(
static_cast<SessionType_2_0>(session_type))) {
if (is_2_0_session_type(session_type)) {
if (is_2_0_session_type(session_type) ||
is_unsupported_2_1_session_type(session_type)) {
session_type_2_1_ = (SessionType_2_1::UNKNOWN);
} else {
session_type_2_1_ = (session_type);
@ -80,7 +94,7 @@ BluetoothAudioSession_2_1::GetAudioConfig() {
// pcmConfig only differs between 2.0 and 2.1 in AudioConfiguration
if (fromConf.getDiscriminator() ==
AudioConfiguration::hidl_discriminator::codecConfig) {
toConf.codecConfig() = fromConf.codecConfig();
toConf.codecConfig(fromConf.codecConfig());
} else {
toConf.pcmConfig() = {
.sampleRate = static_cast<

View file

@ -76,7 +76,9 @@ BluetoothAudioSession_2_2::BluetoothAudioSession_2_2(
bool BluetoothAudioSession_2_2::IsSessionReady() {
if (session_type_2_1_ !=
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
session_type_2_1_ !=
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
return audio_session->IsSessionReady();
}
@ -157,7 +159,7 @@ BluetoothAudioSession_2_2::GetAudioConfig() {
GetAudioSession_2_1()->GetAudioConfig();
if (fromConf.getDiscriminator() ==
AudioConfiguration_2_1::hidl_discriminator::pcmConfig) {
toConf.pcmConfig() = fromConf.pcmConfig();
toConf.pcmConfig(fromConf.pcmConfig());
return toConf;
}
}
@ -167,7 +169,7 @@ BluetoothAudioSession_2_2::GetAudioConfig() {
// pcmConfig only differs between 2.0 and 2.1 in AudioConfiguration
if (fromConf.getDiscriminator() ==
AudioConfiguration::hidl_discriminator::codecConfig) {
toConf.codecConfig() = fromConf.codecConfig();
toConf.codecConfig(fromConf.codecConfig());
} else {
toConf.pcmConfig() = {
.sampleRate = static_cast<
@ -186,6 +188,52 @@ BluetoothAudioSession_2_2::GetAudioConfig() {
}
}
// Those control functions are for the bluetooth_audio module to start, suspend,
// stop stream, to check position, and to update metadata.
bool BluetoothAudioSession_2_2::StartStream() {
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (!IsSessionReady()) {
LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
<< " has NO session";
return false;
}
auto hal_retval = audio_session->stack_iface_->startStream();
if (!hal_retval.isOk()) {
LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
<< toString(session_type_2_1_) << " failed";
return false;
}
return true;
}
bool BluetoothAudioSession_2_2::SuspendStream() {
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (!IsSessionReady()) {
LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
<< " has NO session";
return false;
}
auto hal_retval = audio_session->stack_iface_->suspendStream();
if (!hal_retval.isOk()) {
LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
<< toString(session_type_2_1_) << " failed";
return false;
}
return true;
}
void BluetoothAudioSession_2_2::StopStream() {
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (!IsSessionReady()) {
return;
}
auto hal_retval = audio_session->stack_iface_->stopStream();
if (!hal_retval.isOk()) {
LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
<< toString(session_type_2_1_) << " failed";
}
}
bool BluetoothAudioSession_2_2::UpdateAudioConfig(
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration&
audio_config) {

View file

@ -69,6 +69,12 @@ class BluetoothAudioSession_2_2 {
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration&
audio_config);
// Those control functions are for the bluetooth_audio module to start,
// suspend, stop stream, to check position, and to update metadata.
bool StartStream();
bool SuspendStream();
void StopStream();
// The control function is for the bluetooth_audio module to get the current
// AudioConfiguration
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration

View file

@ -19,6 +19,7 @@
#include <android/hardware/bluetooth/audio/2.2/types.h>
#include "BluetoothAudioSupportedCodecsDB.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
namespace android {
namespace bluetooth {