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

Commit 7e193363 authored by Alice Kuo's avatar Alice Kuo
Browse files

LE audio hardware offload: audio configuration update for decode

Add audio configuration change for decode path

Bug: 197296692
Bug: 150670922
Test: Verify LE audio hardware offload decode update codec behavior
Change-Id: I8f59bc3463bc8d2883017342a7c22a1e88d81db1
parent 7decbf4f
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -318,10 +318,20 @@ void LeAudioClientInterface::Source::StopSession() {
}

void LeAudioClientInterface::Source::UpdateAudioConfigToHal(
    const ::le_audio::offload_config& config) {
  LOG(INFO) << __func__ << " source: not handle now";
    const ::le_audio::offload_config& offload_config) {
  if (HalVersionManager::GetHalTransport() ==
      BluetoothAudioHalTransport::HIDL) {
    if (hidl::le_audio::LeAudioSourceTransport::
            interface->GetTransportInstance()
                ->GetSessionType_2_1() !=
        hidl::SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
      return;
    }
    hidl::le_audio::LeAudioSourceTransport::interface->UpdateAudioConfig_2_2(
        hidl::le_audio::offload_config_to_hal_audio_config(offload_config));
    return;
  }
}

size_t LeAudioClientInterface::Source::Write(const uint8_t* p_buf,
                                             uint32_t len) {
+16 −8
Original line number Diff line number Diff line
@@ -2133,8 +2133,8 @@ class LeAudioClientImpl : public LeAudioClient {
          lc3_setup_encoder(dt_us, sr_hz, lc3_encoder_right_mem);
    } else if (CodecManager::GetInstance()->GetCodecLocation() ==
               le_audio::types::CodecLocation::ADSP) {
      CodecManager::GetInstance()->UpdateActiveAudioConfig(*stream_conf,
                                                           remote_delay_ms);
      CodecManager::GetInstance()->UpdateActiveSourceAudioConfig(
          *stream_conf, remote_delay_ms);
    }

    LeAudioClientAudioSource::UpdateRemoteDelay(remote_delay_ms);
@@ -2195,14 +2195,22 @@ class LeAudioClientImpl : public LeAudioClient {
      return;
    }

    uint16_t remote_delay_ms =
        group->GetRemoteDelay(le_audio::types::kLeAudioDirectionSource);

    if (CodecManager::GetInstance()->GetCodecLocation() ==
        le_audio::types::CodecLocation::HOST) {
      Lc3Config lc3Config(
          current_sink_codec_config.sample_rate,
        Lc3ConfigFrameDuration(current_sink_codec_config.data_interval_us), 1);
          Lc3ConfigFrameDuration(current_sink_codec_config.data_interval_us),
          1);

      lc3_decoder = new Lc3Decoder(lc3Config);

    uint16_t remote_delay_ms =
        group->GetRemoteDelay(le_audio::types::kLeAudioDirectionSource);
    } else if (CodecManager::GetInstance()->GetCodecLocation() ==
               le_audio::types::CodecLocation::ADSP) {
      CodecManager::GetInstance()->UpdateActiveSinkAudioConfig(*stream_conf,
                                                               remote_delay_ms);
    }

    LeAudioClientAudioSink::UpdateRemoteDelay(remote_delay_ms);
    LeAudioClientAudioSink::ConfirmStreamingRequest();
+44 −17
Original line number Diff line number Diff line
@@ -72,9 +72,10 @@ struct codec_manager_impl {
  }
  CodecLocation GetCodecLocation(void) const { return codec_location_; }

  void UpdateActiveAudioConfig(
  void UpdateActiveSourceAudioConfig(
      const le_audio::stream_configuration& stream_conf, uint16_t delay) {
    if (!stream_conf.sink_streams.empty()) {
    if (stream_conf.sink_streams.empty()) return;

    sink_config.stream_map = std::move(stream_conf.sink_streams);
    // TODO: set the default value 16 for now, would change it if we support
    // mode bits_per_sample
@@ -88,6 +89,23 @@ struct codec_manager_impl {
    sink_config.peer_delay = delay;
    LeAudioClientAudioSource::UpdateAudioConfigToHal(sink_config);
  }

  void UpdateActiveSinkAudioConfig(
      const le_audio::stream_configuration& stream_conf, uint16_t delay) {
    if (stream_conf.source_streams.empty()) return;

    source_config.stream_map = std::move(stream_conf.source_streams);
    // TODO: set the default value 16 for now, would change it if we support
    // mode bits_per_sample
    source_config.bits_per_sample = 16;
    source_config.sampling_rate = stream_conf.source_sample_frequency_hz;
    source_config.frame_duration = stream_conf.source_frame_duration_us;
    source_config.octets_per_frame = stream_conf.source_octets_per_codec_frame;
    // TODO: set the default value 1 for now, would change it if we need more
    // configuration
    source_config.blocks_per_sdu = 1;
    source_config.peer_delay = delay;
    LeAudioClientAudioSink::UpdateAudioConfigToHal(source_config);
  }

 private:
@@ -98,6 +116,7 @@ struct codec_manager_impl {
  CodecLocation codec_location_ = CodecLocation::HOST;
  bool offload_enable_ = false;
  le_audio::offload_config sink_config;
  le_audio::offload_config source_config;
};

struct CodecManager::impl {
@@ -137,10 +156,18 @@ types::CodecLocation CodecManager::GetCodecLocation(void) const {
  return pimpl_->codec_manager_impl_->GetCodecLocation();
}

void CodecManager::UpdateActiveAudioConfig(
void CodecManager::UpdateActiveSourceAudioConfig(
    const stream_configuration& stream_conf, uint16_t delay) {
  if (pimpl_->IsRunning())
    pimpl_->codec_manager_impl_->UpdateActiveSourceAudioConfig(stream_conf,
                                                               delay);
}

void CodecManager::UpdateActiveSinkAudioConfig(
    const stream_configuration& stream_conf, uint16_t delay) {
  if (pimpl_->IsRunning())
    pimpl_->codec_manager_impl_->UpdateActiveAudioConfig(stream_conf, delay);
    pimpl_->codec_manager_impl_->UpdateActiveSinkAudioConfig(stream_conf,
                                                             delay);
}

}  // namespace le_audio
+4 −2
Original line number Diff line number Diff line
@@ -41,8 +41,10 @@ class CodecManager {
  void Start(void);
  void Stop(void);
  virtual types::CodecLocation GetCodecLocation(void) const;
  virtual void UpdateActiveAudioConfig(const stream_configuration& stream_conf,
                                       uint16_t delay);
  virtual void UpdateActiveSourceAudioConfig(
      const stream_configuration& stream_conf, uint16_t delay);
  virtual void UpdateActiveSinkAudioConfig(
      const stream_configuration& stream_conf, uint16_t delay);

 private:
  struct impl;
+7 −2
Original line number Diff line number Diff line
@@ -37,9 +37,14 @@ types::CodecLocation CodecManager::GetCodecLocation() const {
  return pimpl_->GetCodecLocation();
}

void CodecManager::UpdateActiveAudioConfig(
void CodecManager::UpdateActiveSourceAudioConfig(
    const stream_configuration& stream_conf, uint16_t delay) {
  if (pimpl_) return pimpl_->UpdateActiveAudioConfig(stream_conf, delay);
  if (pimpl_) return pimpl_->UpdateActiveSourceAudioConfig(stream_conf, delay);
}

void CodecManager::UpdateActiveSinkAudioConfig(
    const stream_configuration& stream_conf, uint16_t delay) {
  if (pimpl_) return pimpl_->UpdateActiveSinkAudioConfig(stream_conf, delay);
}

void CodecManager::Start() {
Loading