audio: Implement OnSessionStarted for HAL 2.1 am: a80a851ada
am: 81624c5ef7
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1608075 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ie36b0d63792fec5cb3e1d113e546b2e8217cc765
This commit is contained in:
commit
2f667a0384
3 changed files with 71 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue