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

Commit 042d4f52 authored by shihchienc's avatar shihchienc
Browse files

[LE Audio] Handle later join case on offload

bluetooth.leaudio.dual_bidirection_swb.supported set to false is to
disable on both software and offload path in the system perspective.

When it turns to true, it means system supports this feature (and
software is default to be supported based on current design).

However offload path might not support due to limitation. Under this
condition, going through the offload path, for dual device it is not
swb but when one device is disconnected, it is swb, which makes user have
bad user experience. This patch fixed this.

Bug: 301358026
Test: manual
Test: atest -c --host bluetooth_le_audio_test bluetooth_le_audio_client_test bluetooth_le_audio_codec_manager_test  --no-bazel-mode
Change-Id: I4b46d504963e69190d02ce0e4201ecad4fce35a0
parent 155f88c9
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -127,6 +127,11 @@ struct codec_manager_impl {
  }
  CodecLocation GetCodecLocation(void) const { return codec_location_; }

  bool IsOffloadDualBiDirSwbSupported(void) const {
    return codec_location_ == le_audio::types::CodecLocation::ADSP &&
           offload_dual_bidirection_swb_supported_;
  }

  void UpdateActiveAudioConfig(
      const types::BidirectionalPair<stream_parameters>& stream_params,
      types::BidirectionalPair<uint16_t> delays_ms,
@@ -505,6 +510,11 @@ struct codec_manager_impl {
                                           adsp_capabilities)) {
          LOG(INFO) << "Offload supported conf, context type: " << (int)ctx_type
                    << ", settings -> " << software_audio_set_conf->name;
          if (AudioSetConfigurationProvider::Get()
                  ->CheckConfigurationIsDualBiDirSwb(
                      *software_audio_set_conf)) {
            offload_dual_bidirection_swb_supported_ = true;
          }
          context_type_offload_config_map_[ctx_type].push_back(
              software_audio_set_conf);
        }
@@ -516,6 +526,7 @@ struct codec_manager_impl {

  CodecLocation codec_location_ = CodecLocation::HOST;
  bool offload_enable_ = false;
  bool offload_dual_bidirection_swb_supported_ = false;
  types::BidirectionalPair<offloader_stream_maps_t> offloader_stream_maps;
  std::vector<le_audio::broadcast_offload_config> supported_broadcast_config;
  std::unordered_map<types::LeAudioContextType, AudioSetConfigurations>
@@ -566,6 +577,14 @@ types::CodecLocation CodecManager::GetCodecLocation(void) const {
  return pimpl_->codec_manager_impl_->GetCodecLocation();
}

bool CodecManager::IsOffloadDualBiDirSwbSupported(void) const {
  if (!pimpl_->IsRunning()) {
    return false;
  }

  return pimpl_->codec_manager_impl_->IsOffloadDualBiDirSwbSupported();
}

void CodecManager::UpdateActiveAudioConfig(
    const types::BidirectionalPair<stream_parameters>& stream_params,
    types::BidirectionalPair<uint16_t> delays_ms,
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ class CodecManager {
                 offloading_preference);
  void Stop(void);
  virtual types::CodecLocation GetCodecLocation(void) const;
  virtual bool IsOffloadDualBiDirSwbSupported(void) const;
  virtual void UpdateCisConfiguration(
      const std::vector<struct types::cis>& cises,
      const stream_parameters& stream_params, uint8_t direction);
+16 −8
Original line number Diff line number Diff line
@@ -1413,17 +1413,25 @@ bool LeAudioDeviceGroup::IsAudioSetConfigurationSupported(
    }
  }

  // when disabling 32k dual mic, for later join case, we need to
  // make sure the device is always choosing the config that its
  // sampling rate matches with the sampling rate which is used
  // when all devices in the group are connected.
  bool dual_bidirection_swb_supported_ = osi_property_get_bool(
      "bluetooth.leaudio.dual_bidirection_swb.supported", true);
  if (Size() > 1 && !dual_bidirection_swb_supported_ &&
  /* when disabling 32k dual mic, for later join case, we need to
   * make sure the device is always choosing the config that its
   * sampling rate matches with the sampling rate which is used
   * when all devices in the group are connected.
   */
  bool dual_bidirection_swb_supported_ =
      AudioSetConfigurationProvider::Get()->IsDualBiDirSwbSupported();
  if (Size() > 1 &&
      AudioSetConfigurationProvider::Get()->CheckConfigurationIsBiDirSwb(
          *audio_set_conf)) {
    if (!dual_bidirection_swb_supported_ ||
        !CodecManager::GetInstance()->IsOffloadDualBiDirSwbSupported()) {
      /* two conditions
       * 1) dual bidirection swb is not supported for both software/offload
       * 2) offload not supported
       */
      return false;
    }
  }

  LOG_DEBUG("Chosen ASE Configuration for group: %d, configuration: %s",
            this->group_id_, audio_set_conf->name.c_str());
+3 −0
Original line number Diff line number Diff line
@@ -32,8 +32,11 @@ class AudioSetConfigurationProvider {
  static void Cleanup();
  virtual const set_configurations::AudioSetConfigurations* GetConfigurations(
      ::le_audio::types::LeAudioContextType content_type) const;
  virtual bool IsDualBiDirSwbSupported(void) const;
  virtual bool CheckConfigurationIsBiDirSwb(
      const set_configurations::AudioSetConfiguration& set_configuration) const;
  virtual bool CheckConfigurationIsDualBiDirSwb(
      const set_configurations::AudioSetConfiguration& set_configuration) const;

 private:
  struct impl;
+36 −2
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ struct AudioSetConfigurationProviderJson {

  AudioSetConfigurationProviderJson(types::CodecLocation location) {
    dual_bidirection_swb_supported_ = osi_property_get_bool(
        "bluetooth.leaudio.dual_bidirection_swb.supported", true);
        "bluetooth.leaudio.dual_bidirection_swb.supported", false);
    ASSERT_LOG(LoadContent(kLeAudioSetConfigs, kLeAudioSetScenarios, location),
               ": Unable to load le audio set configuration files.");
  }
@@ -167,6 +167,10 @@ struct AudioSetConfigurationProviderJson {
    return nullptr;
  };

  bool IsDualBiDirSwbSupported(void) const {
    return dual_bidirection_swb_supported_;
  }

 private:
  /* Codec configurations */
  std::map<std::string, const AudioSetConfiguration> configurations_;
@@ -176,7 +180,8 @@ struct AudioSetConfigurationProviderJson {
      context_configurations_;

  /* property to check if bidirectional sampling frequency >= 32k dual mic is
   * supported or not */
   * supported or not
   */
  bool dual_bidirection_swb_supported_;

  static const bluetooth::le_audio::CodecSpecificConfiguration*
@@ -766,4 +771,33 @@ bool AudioSetConfigurationProvider::CheckConfigurationIsBiDirSwb(
  return dir == le_audio::types::kLeAudioDirectionBoth;
}

bool AudioSetConfigurationProvider::CheckConfigurationIsDualBiDirSwb(
    const set_configurations::AudioSetConfiguration& set_configuration) const {
  bool single_dev_dual_bidir_swb = false;
  bool dual_dev_dual_bidir_swb = false;

  for (const auto& conf : set_configuration.confs) {
    if (conf.codec.GetConfigSamplingFrequency() <
        le_audio::LeAudioCodecConfiguration::kSampleRate32000) {
      return false;
    }
    if (conf.device_cnt == 1 && conf.ase_cnt == 2) {
      single_dev_dual_bidir_swb |= conf.direction;
    } else if (conf.device_cnt == 2 && conf.ase_cnt == 2) {
      dual_dev_dual_bidir_swb |= conf.direction;
    }
  }

  return single_dev_dual_bidir_swb == le_audio::types::kLeAudioDirectionBoth ||
         dual_dev_dual_bidir_swb == le_audio::types::kLeAudioDirectionBoth;
}

bool AudioSetConfigurationProvider::IsDualBiDirSwbSupported(void) const {
  if (pimpl_->IsRunning()) {
    return pimpl_->config_provider_impl_->IsDualBiDirSwbSupported();
  }

  return false;
}

}  // namespace le_audio
Loading