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

Commit 7f32a8e0 authored by Patty Huang's avatar Patty Huang
Browse files

Use new API `isStreamActive` to indicate the stream status.

BT stack will not change the audio location for disappear and later join
case, instead, BT stack will pass the target audio location and stream
to the audio HAL.

Bug: 249614160
Bug: 277857154
Test: LE audio offload disappear and later join with downmix enable
Change-Id: I4a651bcc59b91387e00b9982b7e9a015665e004e
parent 1f9c10f8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -632,10 +632,11 @@ AudioConfiguration offload_config_to_hal_audio_config(
      .peerDelayUs = static_cast<int32_t>(offload_config.peer_delay_ms * 1000),
      .leAudioCodecConfig = LeAudioCodecConfiguration(lc3_config)};

  for (auto& [handle, location] : offload_config.stream_map) {
  for (auto& [handle, location, state] : offload_config.stream_map) {
    ucast_config.streamMap.push_back({
        .streamHandle = handle,
        .audioChannelAllocation = static_cast<int32_t>(location),
        .isStreamActive = state,
    });
  }

+20 −12
Original line number Diff line number Diff line
@@ -3265,12 +3265,16 @@ class LeAudioClientImpl : public LeAudioClient {

    le_audio_source_hal_client_->UpdateRemoteDelay(remote_delay_ms);
    ConfirmLocalAudioSourceStreamingRequest();

    if (CodecManager::GetInstance()->GetAidlVersionInUsed() <
        AIDL_VERSION_SUPPORT_STREAM_ACTIVE) {
      /* We update the target audio allocation before streamStarted that the
       * offloder would know how to configure offloader encoder. We should check
       * if we need to update the current
       * allocation here as the target allocation and the current allocation is
       * different */
      updateOffloaderIfNeeded(group);
    }

    return true;
  }
@@ -3328,13 +3332,17 @@ class LeAudioClientImpl : public LeAudioClient {
    }
    le_audio_sink_hal_client_->UpdateRemoteDelay(remote_delay_ms);
    ConfirmLocalAudioSinkStreamingRequest();

    if (CodecManager::GetInstance()->GetAidlVersionInUsed() <
        AIDL_VERSION_SUPPORT_STREAM_ACTIVE) {
      /* We update the target audio allocation before streamStarted that the
     * offloder would know how to configure offloader decoder. We should check
       * offloder would know how to configure offloader encoder. We should check
       * if we need to update the current
       * allocation here as the target allocation and the current allocation is
       * different */
      updateOffloaderIfNeeded(group);
    }
  }

  void SuspendAudio(void) {
    CancelStreamingRequest();
+2 −2
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ struct codec_manager_impl {
          update_receiver) {
    if (stream_conf.sink_streams.empty()) return;

    if (stream_conf.sink_is_initial) {
    if (stream_conf.sink_is_initial || aidl_version_ >= 3) {
      sink_config.stream_map =
          stream_conf.sink_offloader_streams_target_allocation;
    } else {
@@ -139,7 +139,7 @@ struct codec_manager_impl {
          update_receiver) {
    if (stream_conf.source_streams.empty()) return;

    if (stream_conf.source_is_initial) {
    if (stream_conf.source_is_initial || aidl_version_ >= 3) {
      source_config.stream_map =
          stream_conf.source_offloader_streams_target_allocation;
    } else {
+2 −1
Original line number Diff line number Diff line
@@ -17,11 +17,12 @@
#pragma once

#include "le_audio_types.h"
#define AIDL_VERSION_SUPPORT_STREAM_ACTIVE 3

namespace le_audio {

struct offload_config {
  std::vector<std::pair<uint16_t, uint32_t>> stream_map;
  std::vector<stream_map_info> stream_map;
  uint8_t bits_per_sample;
  uint32_t sampling_rate;
  uint32_t frame_duration;
+16 −22
Original line number Diff line number Diff line
@@ -1834,10 +1834,8 @@ void LeAudioDeviceGroup::CreateStreamVectorForOffloader(uint8_t direction) {

  CisType cis_type;
  std::vector<std::pair<uint16_t, uint32_t>>* streams;
  std::vector<std::pair<uint16_t, uint32_t>>*
      offloader_streams_target_allocation;
  std::vector<std::pair<uint16_t, uint32_t>>*
      offloader_streams_current_allocation;
  std::vector<stream_map_info>* offloader_streams_target_allocation;
  std::vector<stream_map_info>* offloader_streams_current_allocation;
  std::string tag;
  uint32_t available_allocations = 0;
  bool* changed_flag;
@@ -1875,7 +1873,9 @@ void LeAudioDeviceGroup::CreateStreamVectorForOffloader(uint8_t direction) {

  if (offloader_streams_target_allocation->size() == 0) {
    *is_initial = true;
  } else if (*is_initial) {
  } else if (*is_initial ||
             CodecManager::GetInstance()->GetAidlVersionInUsed() >=
                 AIDL_VERSION_SUPPORT_STREAM_ACTIVE) {
    // As multiple CISes phone call case, the target_allocation already have the
    // previous data, but the is_initial flag not be cleared. We need to clear
    // here to avoid make duplicated target allocation stream map.
@@ -1895,24 +1895,16 @@ void LeAudioDeviceGroup::CreateStreamVectorForOffloader(uint8_t direction) {
  if (*is_initial && !not_all_cises_connected) {
    *changed_flag = false;
  }

  /* Note: For the offloader case we simplify allocation to only Left and Right.
   * If we need 2 CISes and only one is connected, the connected one will have
   * allocation set to stereo (left | right) and other one will have allocation
   * set to 0. Offloader in this case shall mix left and right and send it on
   * connected CIS. If there is only single CIS with stereo allocation, it means
   * that peer device support channel count 2 and offloader shall send two
   * channels in the single CIS.
   */

  for (auto& cis_entry : cises_) {
    if ((cis_entry.type == CisType::CIS_TYPE_BIDIRECTIONAL ||
         cis_entry.type == cis_type) &&
        cis_entry.conn_handle != 0) {
      uint32_t target_allocation = 0;
      uint32_t current_allocation = 0;
      bool is_active = false;
      for (const auto& s : *streams) {
        if (s.first == cis_entry.conn_handle) {
          is_active = true;
          target_allocation = AdjustAllocationForOffloader(s.second);
          current_allocation = target_allocation;
          if (not_all_cises_connected) {
@@ -1931,15 +1923,17 @@ void LeAudioDeviceGroup::CreateStreamVectorForOffloader(uint8_t direction) {

      LOG_INFO(
          "%s: Cis handle 0x%04x, target allocation  0x%08x, current "
          "allocation 0x%08x",
          "allocation 0x%08x, active: %d",
          tag.c_str(), cis_entry.conn_handle, target_allocation,
          current_allocation);
      if (*is_initial) {
        offloader_streams_target_allocation->emplace_back(
            std::make_pair(cis_entry.conn_handle, target_allocation));
          current_allocation, is_active);

      if (*is_initial || CodecManager::GetInstance()->GetAidlVersionInUsed() >=
                             AIDL_VERSION_SUPPORT_STREAM_ACTIVE) {
        offloader_streams_target_allocation->emplace_back(stream_map_info(
            cis_entry.conn_handle, target_allocation, is_active));
      }
      offloader_streams_current_allocation->emplace_back(
          std::make_pair(cis_entry.conn_handle, current_allocation));
      offloader_streams_current_allocation->emplace_back(stream_map_info(
          cis_entry.conn_handle, current_allocation, is_active));
    }
  }
}
Loading