Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7e78727 authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk Committed by Automerger Merge Worker
Browse files

audio: Implement GetAudioConfig for HAL 2.1 am: 0b12cea8

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3c9b14bd71544f906e701088032c6df404d99597
parents 1832a8ce 0b12cea8
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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;
    }
  }

+34 −0
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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::