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

Commit c1a2722a authored by shihchienc's avatar shihchienc Committed by Patrick Chang
Browse files

[LE Audio] Handle later join case for 32k bidirectional dual mic

In conversational mode, when we disable 32k bidirectional dual mic,
we select other configs like 16k bidirectional dual mic.

However, when users connect to only one bud while they put one earbud
back into cases, we select single device on 32k, which is not suitable.

This is because CIG is already configured for 16k but when there is
only one device connected, we choose 32k for single device, and this
will make us removing CIG and create CIG again.

The user experience is not good as the audio will stop for some time.
This patch handles this case.

Also, not insert config to the mpa when it is empty.

Bug: 298946279
Test: check early exit and later join on conversational streaming
Test: atest -c bluetooth_le_audio_test bluetooth_le_audio_client_test
Change-Id: I50a0ccc0906a2c3edefcfa553224498e87a54267
parent 7f7d8d59
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -1413,6 +1413,18 @@ 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_ &&
      AudioSetConfigurationProvider::Get()->CheckConfigurationIsBiDirSwb(
          *audio_set_conf)) {
    return false;
  }

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


 private:
 private:
  struct impl;
  struct impl;
+22 −9
Original line number Original line Diff line number Diff line
@@ -71,10 +71,8 @@ struct AudioSetConfigurationProviderJson {
  static constexpr auto kDefaultScenario = "Media";
  static constexpr auto kDefaultScenario = "Media";


  AudioSetConfigurationProviderJson(types::CodecLocation location) {
  AudioSetConfigurationProviderJson(types::CodecLocation location) {
    dual_swb_bidirection_supported_ = osi_property_get_bool(
    dual_bidirection_swb_supported_ = osi_property_get_bool(
        "persist.bluetooth.leaudio_dual_bidirection_swb."
        "bluetooth.leaudio.dual_bidirection_swb.supported", true);
        "supported",
        true);
    ASSERT_LOG(LoadContent(kLeAudioSetConfigs, kLeAudioSetScenarios, location),
    ASSERT_LOG(LoadContent(kLeAudioSetConfigs, kLeAudioSetScenarios, location),
               ": Unable to load le audio set configuration files.");
               ": Unable to load le audio set configuration files.");
  }
  }
@@ -166,7 +164,7 @@ struct AudioSetConfigurationProviderJson {


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


  static const bluetooth::le_audio::CodecSpecificConfiguration*
  static const bluetooth::le_audio::CodecSpecificConfiguration*
  LookupCodecSpecificParam(
  LookupCodecSpecificParam(
@@ -435,7 +433,7 @@ struct AudioSetConfigurationProviderJson {
      }
      }
    }
    }


    if (!dual_swb_bidirection_supported_) {
    if (!dual_bidirection_swb_supported_) {
      if ((dual_dev_one_chan_stereo_sink_swb &&
      if ((dual_dev_one_chan_stereo_sink_swb &&
           dual_dev_one_chan_stereo_source_swb) ||
           dual_dev_one_chan_stereo_source_swb) ||
          (single_dev_one_chan_stereo_sink_swb &&
          (single_dev_one_chan_stereo_sink_swb &&
@@ -525,9 +523,11 @@ struct AudioSetConfigurationProviderJson {


    LOG_DEBUG(": Updating %d config entries.", flat_configs->size());
    LOG_DEBUG(": Updating %d config entries.", flat_configs->size());
    for (auto const& flat_cfg : *flat_configs) {
    for (auto const& flat_cfg : *flat_configs) {
      configurations_.insert({flat_cfg->name()->str(),
      auto configuration = AudioSetConfigurationFromFlat(flat_cfg, &codec_cfgs,
                              AudioSetConfigurationFromFlat(
                                                         &qos_cfgs, location);
                                  flat_cfg, &codec_cfgs, &qos_cfgs, location)});
      if (!configuration.confs.empty()) {
        configurations_.insert({flat_cfg->name()->str(), configuration});
      }
    }
    }


    return true;
    return true;
@@ -740,4 +740,17 @@ AudioSetConfigurationProvider::GetConfigurations(
  return nullptr;
  return nullptr;
}
}


bool AudioSetConfigurationProvider::CheckConfigurationIsBiDirSwb(
    const set_configurations::AudioSetConfiguration& set_configuration) const {
  uint8_t dir = 0;

  for (const auto& conf : set_configuration.confs) {
    if (conf.codec.GetConfigSamplingFrequency() >=
        le_audio::LeAudioCodecConfiguration::kSampleRate32000) {
      dir |= conf.direction;
    }
  }
  return dir == le_audio::types::kLeAudioDirectionBoth;
}

}  // namespace le_audio
}  // namespace le_audio