mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
audio: Implement OnSessionStarted for HAL 2.1
Patch implements OnSessionStarted for HAL 2.1. Bug: Tag: #feature Test: vts-tradefed run vts -m VtsHalBluetoothAudioV2_1TargetTest Sponsor: jpawlowski@ Change-Id: Ide76fe59c323726ae98e6311f7360eb733c1c7cc Change-Id: I84302cf653ffebcba3b4c875f6a156293d8dae75
This commit is contained in:
committed by
Jakub Pawlowski
parent
be9a813aec
commit
a80a851ada
@@ -79,6 +79,8 @@ struct PortStatusCallbacks {
|
||||
};
|
||||
|
||||
class BluetoothAudioSession {
|
||||
friend class BluetoothAudioSession_2_1;
|
||||
|
||||
private:
|
||||
// using recursive_mutex to allow hwbinder to re-enter agian.
|
||||
std::recursive_mutex mutex_;
|
||||
|
||||
@@ -29,6 +29,11 @@ using SessionType_2_1 =
|
||||
using SessionType_2_0 =
|
||||
::android::hardware::bluetooth::audio::V2_0::SessionType;
|
||||
|
||||
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration
|
||||
BluetoothAudioSession_2_1::invalidSoftwareAudioConfiguration = {};
|
||||
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration
|
||||
BluetoothAudioSession_2_1::invalidOffloadAudioConfiguration = {};
|
||||
|
||||
namespace {
|
||||
bool is_2_0_session_type(
|
||||
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
|
||||
@@ -60,6 +65,37 @@ BluetoothAudioSession_2_1::GetAudioSession() {
|
||||
return audio_session;
|
||||
}
|
||||
|
||||
bool BluetoothAudioSession_2_1::UpdateAudioConfig(
|
||||
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration&
|
||||
audio_config) {
|
||||
bool is_software_session =
|
||||
(session_type_2_1_ == SessionType_2_1::A2DP_SOFTWARE_ENCODING_DATAPATH ||
|
||||
session_type_2_1_ ==
|
||||
SessionType_2_1::HEARING_AID_SOFTWARE_ENCODING_DATAPATH ||
|
||||
session_type_2_1_ ==
|
||||
SessionType_2_1::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH ||
|
||||
session_type_2_1_ ==
|
||||
SessionType_2_1::LE_AUDIO_SOFTWARE_DECODED_DATAPATH);
|
||||
bool is_offload_session =
|
||||
(session_type_2_1_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH);
|
||||
auto audio_config_discriminator = audio_config.getDiscriminator();
|
||||
bool is_software_audio_config =
|
||||
(is_software_session &&
|
||||
audio_config_discriminator ==
|
||||
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration::
|
||||
hidl_discriminator::pcmConfig);
|
||||
bool is_offload_audio_config =
|
||||
(is_offload_session &&
|
||||
audio_config_discriminator ==
|
||||
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration::
|
||||
hidl_discriminator::codecConfig);
|
||||
if (!is_software_audio_config && !is_offload_audio_config) {
|
||||
return false;
|
||||
}
|
||||
audio_config_2_1_ = audio_config;
|
||||
return true;
|
||||
}
|
||||
|
||||
// The report function is used to report that the Bluetooth stack has started
|
||||
// this session without any failure, and will invoke session_changed_cb_ to
|
||||
// notify those registered bluetooth_audio outputs
|
||||
@@ -86,7 +122,27 @@ void BluetoothAudioSession_2_1::OnSessionStarted(
|
||||
|
||||
audio_session->OnSessionStarted(stack_iface, dataMQ, config);
|
||||
} else {
|
||||
LOG(FATAL) << " Not implemented yet!!";
|
||||
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
|
||||
if (stack_iface == nullptr) {
|
||||
LOG(ERROR) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||
<< ", IBluetoothAudioPort Invalid";
|
||||
} else if (!UpdateAudioConfig(audio_config)) {
|
||||
LOG(ERROR) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||
<< ", AudioConfiguration=" << toString(audio_config)
|
||||
<< " Invalid";
|
||||
} else if (!audio_session->UpdateDataPath(dataMQ)) {
|
||||
LOG(ERROR) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||
<< " DataMQ Invalid";
|
||||
audio_config_2_1_ =
|
||||
(session_type_2_1_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH
|
||||
? kInvalidOffloadAudioConfiguration
|
||||
: kInvalidSoftwareAudioConfiguration);
|
||||
} else {
|
||||
audio_session->stack_iface_ = stack_iface;
|
||||
LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||
<< ", AudioConfiguration=" << toString(audio_config);
|
||||
audio_session->ReportSessionStatus();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,11 @@ class BluetoothAudioSession_2_1 {
|
||||
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration&
|
||||
audio_config);
|
||||
|
||||
static ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration
|
||||
invalidSoftwareAudioConfiguration;
|
||||
static ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration
|
||||
invalidOffloadAudioConfiguration;
|
||||
|
||||
public:
|
||||
BluetoothAudioSession_2_1(
|
||||
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
|
||||
@@ -60,6 +65,13 @@ class BluetoothAudioSession_2_1 {
|
||||
// AudioConfiguration
|
||||
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration&
|
||||
GetAudioConfig();
|
||||
|
||||
static constexpr ::android::hardware::bluetooth::audio::V2_1::
|
||||
AudioConfiguration& kInvalidSoftwareAudioConfiguration =
|
||||
invalidSoftwareAudioConfiguration;
|
||||
static constexpr ::android::hardware::bluetooth::audio::V2_1::
|
||||
AudioConfiguration& kInvalidOffloadAudioConfiguration =
|
||||
invalidOffloadAudioConfiguration;
|
||||
};
|
||||
|
||||
class BluetoothAudioSessionInstance_2_1 {
|
||||
|
||||
Reference in New Issue
Block a user