summaryrefslogtreecommitdiff
path: root/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
diff options
context:
space:
mode:
authorHaamed Gheibi <haamed@google.com>2022-02-04 13:47:26 -0800
committerHaamed Gheibi <haamed@google.com>2022-02-04 13:55:47 -0800
commitf99b35c293439db0b7436b47b939eb8c7bf21b51 (patch)
tree6cd9b0719554809447c845616317cca5409b93ae /bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
parenta028272dee9220e6810cbdcfb2328c34f8afe4c2 (diff)
parent332dead340bb196c6ba3f6978e8fb53966c74bf7 (diff)
Merge TP1A.220120.003
Change-Id: Ie5eba313ee102e452f5f96942ed2f3a7bb4e8f01
Diffstat (limited to 'bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp')
-rw-r--r--bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
index 60ac4ece6f..4613ddc05a 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
@@ -22,10 +22,15 @@
#include <android-base/stringprintf.h>
#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioPort.h>
+#include "../aidl_session/HidlToAidlMiddleware_2_0.h"
+#include "../aidl_session/HidlToAidlMiddleware_2_2.h"
+
namespace android {
namespace bluetooth {
namespace audio {
+using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_0;
+using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_2;
using ::android::hardware::audio::common::V5_0::AudioSource;
using ::android::hardware::audio::common::V5_0::RecordTrackMetadata;
using ::android::hardware::audio::common::V5_0::SinkMetadata;
@@ -93,6 +98,7 @@ BluetoothAudioSession_2_2::BluetoothAudioSession_2_2(
} else {
session_type_2_1_ = (session_type);
}
+ raw_session_type_ = session_type;
invalidSoftwareAudioConfiguration.pcmConfig(kInvalidPcmParameters);
invalidOffloadAudioConfiguration.codecConfig(
audio_session->kInvalidCodecConfiguration);
@@ -100,6 +106,8 @@ BluetoothAudioSession_2_2::BluetoothAudioSession_2_2(
}
bool BluetoothAudioSession_2_2::IsSessionReady() {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::IsSessionReady(raw_session_type_);
if (session_type_2_1_ !=
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
session_type_2_1_ !=
@@ -122,6 +130,9 @@ BluetoothAudioSession_2_2::GetAudioSession_2_1() {
void BluetoothAudioSession_2_2::UpdateSinkMetadata(
const struct sink_metadata* sink_metadata) {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::UpdateSinkMetadata(raw_session_type_,
+ sink_metadata);
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (!IsSessionReady()) {
LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
@@ -172,6 +183,8 @@ void BluetoothAudioSession_2_2::UpdateSinkMetadata(
// AudioConfiguration
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
BluetoothAudioSession_2_2::GetAudioConfig() {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::GetAudioConfig(raw_session_type_);
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (IsSessionReady()) {
auto audio_config_discriminator = audio_config_2_2_.getDiscriminator();
@@ -226,6 +239,8 @@ 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() {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::StartStream(raw_session_type_);
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (!IsSessionReady()) {
LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
@@ -242,6 +257,8 @@ bool BluetoothAudioSession_2_2::StartStream() {
}
bool BluetoothAudioSession_2_2::SuspendStream() {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::SuspendStream(raw_session_type_);
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (!IsSessionReady()) {
LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
@@ -258,6 +275,8 @@ bool BluetoothAudioSession_2_2::SuspendStream() {
}
void BluetoothAudioSession_2_2::StopStream() {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::StopStream(raw_session_type_);
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (!IsSessionReady()) {
return;
@@ -395,6 +414,9 @@ void BluetoothAudioSession_2_2::OnSessionEnded() {
// @return: cookie - the assigned number to this bluetooth_audio output
uint16_t BluetoothAudioSession_2_2::RegisterStatusCback(
const PortStatusCallbacks_2_2& cbacks) {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::RegisterControlResultCback(
+ raw_session_type_, cbacks);
if (session_type_2_1_ !=
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
session_type_2_1_ !=
@@ -432,6 +454,9 @@ uint16_t BluetoothAudioSession_2_2::RegisterStatusCback(
// PortStatusCallbacks_2_2
// @param: cookie - indicates which bluetooth_audio output is
void BluetoothAudioSession_2_2::UnregisterStatusCback(uint16_t cookie) {
+ if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
+ return HidlToAidlMiddleware_2_2::UnregisterControlResultCback(
+ raw_session_type_, cookie);
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (session_type_2_1_ !=
SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&