diff --git a/bluetooth/audio/2.1/default/BluetoothAudioProvidersFactory.cpp b/bluetooth/audio/2.1/default/BluetoothAudioProvidersFactory.cpp index b0d171a7ba..d7d5476fbf 100644 --- a/bluetooth/audio/2.1/default/BluetoothAudioProvidersFactory.cpp +++ b/bluetooth/audio/2.1/default/BluetoothAudioProvidersFactory.cpp @@ -157,7 +157,11 @@ Return 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 db_pcm_capabilities = android::bluetooth::audio::GetSoftwarePcmCapabilities_2_1(); if (db_pcm_capabilities.size() == 1) { diff --git a/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp b/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp index ba31d39f2c..eb87178c38 100644 --- a/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp +++ b/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp @@ -21,7 +21,7 @@ #include #include "BluetoothAudioSessionReport_2_2.h" -#include "BluetoothAudioSupportedCodecsDB_2_1.h" +#include "BluetoothAudioSupportedCodecsDB_2_2.h" namespace android { namespace hardware { diff --git a/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp b/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp index 3c0ff4214d..18ac2925ad 100644 --- a/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp +++ b/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp @@ -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 { diff --git a/bluetooth/audio/2.2/default/BluetoothAudioProvidersFactory.cpp b/bluetooth/audio/2.2/default/BluetoothAudioProvidersFactory.cpp index 510833de9f..51ee422845 100644 --- a/bluetooth/audio/2.2/default/BluetoothAudioProvidersFactory.cpp +++ b/bluetooth/audio/2.2/default/BluetoothAudioProvidersFactory.cpp @@ -20,7 +20,7 @@ #include -#include "BluetoothAudioSupportedCodecsDB_2_1.h" +#include "BluetoothAudioSupportedCodecsDB_2_2.h" namespace android { namespace hardware { diff --git a/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp b/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp index 9b3294fe8b..25e49a19d4 100644 --- a/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp +++ b/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp @@ -21,7 +21,7 @@ #include #include "BluetoothAudioSessionReport_2_2.h" -#include "BluetoothAudioSupportedCodecsDB_2_1.h" +#include "BluetoothAudioSupportedCodecsDB_2_2.h" namespace android { namespace hardware { diff --git a/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp b/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp index 9ec17766f5..a7a00233c2 100644 --- a/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp +++ b/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp @@ -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 { diff --git a/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp b/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp index e3da26757d..2b0c02f09d 100644 --- a/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp +++ b/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp @@ -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 { diff --git a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h index b4ba8cfc4a..dbdf24765d 100644 --- a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h +++ b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h @@ -87,7 +87,7 @@ class BluetoothAudioSessionControl_2_2 { std::shared_ptr 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 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 session_ptr = BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type); if (session_ptr != nullptr) { - session_ptr->GetAudioSession()->StopStream(); + session_ptr->StopStream(); } } diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp b/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp index 646e22532f..bf1f9b5b2a 100644 --- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp +++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp @@ -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(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< diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp index 80df5d9eb5..ee2096b179 100644 --- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp +++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp @@ -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 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 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 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) { diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h index d6ae3d73c4..3f1f0e009b 100644 --- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h +++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h @@ -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 diff --git a/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.h b/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.h index 59d22b7a0a..832161673c 100644 --- a/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.h +++ b/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.h @@ -19,6 +19,7 @@ #include #include "BluetoothAudioSupportedCodecsDB.h" +#include "BluetoothAudioSupportedCodecsDB_2_1.h" namespace android { namespace bluetooth {