audio: Implement GetAudioConfig for HAL 2.1 am: 0b12cea833

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3c9b14bd71544f906e701088032c6df404d99597
This commit is contained in:
Grzegorz Kołodziejczyk 2021-03-01 19:29:35 +00:00 committed by Automerger Merge Worker
commit b7e7872798
3 changed files with 41 additions and 6 deletions

View file

@ -25,6 +25,8 @@ namespace audio {
class BluetoothAudioSessionControl_2_1 {
using SessionType_2_1 =
::android::hardware::bluetooth::audio::V2_1::SessionType;
using AudioConfiguration_2_1 =
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration;
public:
// The control API helps to check if session is ready or not
@ -65,18 +67,17 @@ class BluetoothAudioSessionControl_2_1 {
// The control API for the bluetooth_audio module to get current
// AudioConfiguration
static const AudioConfiguration& GetAudioConfig(
static const AudioConfiguration_2_1 GetAudioConfig(
const SessionType_2_1& session_type) {
std::shared_ptr<BluetoothAudioSession_2_1> session_ptr =
BluetoothAudioSessionInstance_2_1::GetSessionInstance(session_type);
if (session_ptr != nullptr) {
// TODO: map 2.1 to 2.0 audio config inside GetAudioConfig?
return session_ptr->GetAudioSession()->GetAudioConfig();
return session_ptr->GetAudioConfig();
} else if (session_type ==
SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH) {
return BluetoothAudioSession::kInvalidOffloadAudioConfiguration;
return BluetoothAudioSession_2_1::kInvalidOffloadAudioConfiguration;
} else {
return BluetoothAudioSession::kInvalidSoftwareAudioConfiguration;
return BluetoothAudioSession_2_1::kInvalidSoftwareAudioConfiguration;
}
}

View file

@ -65,6 +65,40 @@ BluetoothAudioSession_2_1::GetAudioSession() {
return audio_session;
}
// The control function is for the bluetooth_audio module to get the current
// AudioConfiguration
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration
BluetoothAudioSession_2_1::GetAudioConfig() {
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
if (audio_session->IsSessionReady()) {
// If session is unknown it means it should be 2.0 type
if (session_type_2_1_ != SessionType_2_1::UNKNOWN)
return audio_config_2_1_;
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration toConf;
const AudioConfiguration fromConf = GetAudioSession()->GetAudioConfig();
// pcmConfig only differs between 2.0 and 2.1 in AudioConfiguration
if (fromConf.getDiscriminator() ==
AudioConfiguration::hidl_discriminator::codecConfig) {
toConf.codecConfig() = fromConf.codecConfig();
} else {
toConf.pcmConfig() = {
.sampleRate = static_cast<
::android::hardware::bluetooth::audio::V2_1::SampleRate>(
fromConf.pcmConfig().sampleRate),
.channelMode = fromConf.pcmConfig().channelMode,
.bitsPerSample = fromConf.pcmConfig().bitsPerSample,
.dataIntervalUs = 0};
}
return toConf;
} else if (session_type_2_1_ ==
SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH) {
return kInvalidOffloadAudioConfiguration;
} else {
return kInvalidSoftwareAudioConfiguration;
}
}
bool BluetoothAudioSession_2_1::UpdateAudioConfig(
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration&
audio_config) {

View file

@ -63,7 +63,7 @@ class BluetoothAudioSession_2_1 {
// The control function is for the bluetooth_audio module to get the current
// AudioConfiguration
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration&
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration
GetAudioConfig();
static constexpr ::android::hardware::bluetooth::audio::V2_1::