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

Commit 4275a27e authored by Łukasz Rymanowski (xWF)'s avatar Łukasz Rymanowski (xWF) Committed by Gerrit Code Review
Browse files

Merge changes Idd5f9fdd,I3bda2a1b,I840e5c1f into main

* changes:
  leaudio: Allow unidirectional GAME context.
  leaudio: Refactor unidirectional handling for VOICE ASSISTANT
  leaudio: Change return type for FindFirstSupportedConfiguration
parents 65f71541 846a56a0
Loading
Loading
Loading
Loading
+8304 −7487

File changed.

Preview size limit exceeded, changes collapsed.

+293 −257
Original line number Diff line number Diff line
@@ -207,7 +207,43 @@
        "One-TwoChan-SnkAse-Lc3_48_4-One-OneChan-SrcAse-Lc3_32_2_Balanced_Reliability",
        "One-OneChan-SnkAse-Lc3_48_4-One-OneChan-SrcAse-Lc3_16_2_Balanced_Reliability",
        "One-OneChan-SnkAse-Lc3_48_4-One-OneChan-SrcAse-Lc3_24_2_Balanced_Reliability",
                "One-OneChan-SnkAse-Lc3_48_4-One-OneChan-SrcAse-Lc3_32_2_Balanced_Reliability"
        "One-OneChan-SnkAse-Lc3_48_4-One-OneChan-SrcAse-Lc3_32_2_Balanced_Reliability",
        "Two-OneChan-SnkAse-Lc3_48_2_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_48_3_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_48_1_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_32_2_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_32_1_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_24_2_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_24_1_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_16_2_Low_Latency",
        "Two-OneChan-SnkAse-Lc3_16_1_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_48_2_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_48_3_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_48_1_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_32_2_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_32_1_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_24_2_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_24_1_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_16_2_Low_Latency",
        "One-TwoChan-SnkAse-Lc3_16_1_Low_Latency",
        "Two-OneChan-SrcAse-Lc3_32_2_Low_Latency",
        "Two-OneChan-SrcAse-Lc3_32_1_Low_Latency",
        "Two-OneChan-SrcAse-Lc3_24_2_Low_Latency",
        "Two-OneChan-SrcAse-Lc3_24_1_Low_Latency",
        "Two-OneChan-SrcAse-Lc3_16_2_Low_Latency",
        "Two-OneChan-SrcAse-Lc3_16_1_Low_Latency",
        "One-TwoChan-SrcAse-Lc3_32_2_Low_Latency",
        "One-TwoChan-SrcAse-Lc3_32_1_Low_Latency",
        "One-TwoChan-SrcAse-Lc3_24_2_Low_Latency",
        "One-TwoChan-SrcAse-Lc3_24_1_Low_Latency",
        "One-TwoChan-SrcAse-Lc3_16_2_Low_Latency",
        "One-TwoChan-SrcAse-Lc3_16_1_Low_Latency",
        "One-OneChan-SrcAse-Lc3_32_2_Low_Latency",
        "One-OneChan-SrcAse-Lc3_32_1_Low_Latency",
        "One-OneChan-SrcAse-Lc3_24_2_Low_Latency",
        "One-OneChan-SrcAse-Lc3_24_1_Low_Latency",
        "One-OneChan-SrcAse-Lc3_16_2_Low_Latency",
        "One-OneChan-SrcAse-Lc3_16_1_Low_Latency"
      ]
    },
    {
+4 −49
Original line number Diff line number Diff line
@@ -317,8 +317,8 @@ public:
    }

    /* Choose the right configuration context */
    auto new_configuration_context = AdjustForVoiceAssistant(
            group, ChooseConfigurationContextType(local_metadata_context_types_.source));
    auto new_configuration_context =
            ChooseConfigurationContextType(local_metadata_context_types_.source);

    log::debug("new_configuration_context= {}", ToString(new_configuration_context));
    ReconfigureOrUpdateMetadata(group, new_configuration_context,
@@ -4374,9 +4374,6 @@ public:
      LeAudioContextType context_priority_list[] = {
              /* Highest priority first */
              LeAudioContextType::CONVERSATIONAL,
              /* Handling RINGTONE will cause the ringtone volume slider to trigger
               * reconfiguration. This will be fixed in b/283349711.
               */
              LeAudioContextType::RINGTONE,
              LeAudioContextType::LIVE,
              LeAudioContextType::VOICEASSISTANTS,
@@ -4755,46 +4752,6 @@ public:
    return remote_metadata;
  }

  LeAudioContextType AdjustForVoiceAssistant(LeAudioDeviceGroup* group,
                                             LeAudioContextType new_configuration_context) {
    if (!com::android::bluetooth::flags::le_audio_support_unidirectional_voice_assistant()) {
      log::debug("Flag le_audio_support_unidirectional_voice_assistant NOT enabled");
      return new_configuration_context;
    }

    /* Some remote devices expect VOICE ASSISTANT to be unidirectional Phone is
     * Source and Earbuds are Sink */
    if (new_configuration_context != LeAudioContextType::VOICEASSISTANTS) {
      return new_configuration_context;
    }

    auto sink_supported_contexts =
            group->GetSupportedContexts(bluetooth::le_audio::types::kLeAudioDirectionSink);
    auto source_supported_contexts =
            group->GetSupportedContexts(bluetooth::le_audio::types::kLeAudioDirectionSource);

    log::debug("group_id: {}, sink_supported: {}, source_supported {}", group->group_id_,
               ToString(sink_supported_contexts), ToString(source_supported_contexts));
    if (sink_supported_contexts.test(LeAudioContextType::VOICEASSISTANTS) &&
        source_supported_contexts.test(LeAudioContextType::VOICEASSISTANTS)) {
      return new_configuration_context;
    }

    if (sink_supported_contexts.test(LeAudioContextType::VOICEASSISTANTS)) {
      log::info(
              "group_id {} supports only Sink direction for Voice Assistant. "
              "Selecting configurarion context type {}",
              group->group_id_, ToString(LeAudioContextType::INSTRUCTIONAL));

      return LeAudioContextType::INSTRUCTIONAL;
    }

    log::warn("group_id: {},  unexpected configuration, sink_supported: {}, source_supported {}",
              group->group_id_, ToString(sink_supported_contexts),
              ToString(source_supported_contexts));
    return new_configuration_context;
  }

  /* Return true if stream is started */
  bool ReconfigureOrUpdateRemote(LeAudioDeviceGroup* group, int remote_direction) {
    if (stack_config_get_interface()->get_pts_force_le_audio_multiple_contexts_metadata()) {
@@ -4811,8 +4768,7 @@ public:
                local_metadata_context_types_.source.to_string(), override_contexts.to_string());

      /* Choose the right configuration context */
      auto new_configuration_context =
              AdjustForVoiceAssistant(group, ChooseConfigurationContextType(override_contexts));
      auto new_configuration_context = ChooseConfigurationContextType(override_contexts);

      log::debug("new_configuration_context= {}.", ToString(new_configuration_context));
      BidirectionalPair<AudioContexts> remote_contexts = {.sink = override_contexts,
@@ -4829,8 +4785,7 @@ public:

    /* Choose the right configuration context */
    auto config_context_candids = get_bidirectional(remote_metadata);
    auto new_config_context =
            AdjustForVoiceAssistant(group, ChooseConfigurationContextType(config_context_candids));
    auto new_config_context = ChooseConfigurationContextType(config_context_candids);
    log::debug("config_context_candids= {}, new_config_context= {}",
               ToString(config_context_candids), ToString(new_config_context));

+4 −5
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ public:

  std::unique_ptr<AudioSetConfiguration> GetCodecConfig(
          const CodecManager::UnicastConfigurationRequirements& requirements,
          CodecManager::UnicastConfigurationVerifier verifier) {
          CodecManager::UnicastConfigurationProvider provider) {
    if (IsUsingCodecExtensibility()) {
      auto hal_config = unicast_local_source_hal_client->GetUnicastConfig(requirements);
      if (hal_config) {
@@ -361,8 +361,7 @@ public:
    //       configuration with group capabilities. Note that this path only
    //       supports the LC3 codec format. For the multicodec support we should
    //       rely on the configuration matcher behind the AIDL interface.
    auto conf = verifier(requirements, &configs);
    return conf ? std::make_unique<AudioSetConfiguration>(*conf) : nullptr;
    return provider(requirements, &configs);
  }

  bool CheckCodecConfigIsBiDirSwb(const AudioSetConfiguration& config) {
@@ -1192,9 +1191,9 @@ bool CodecManager::UpdateActiveBroadcastAudioHalClient(

std::unique_ptr<AudioSetConfiguration> CodecManager::GetCodecConfig(
        const CodecManager::UnicastConfigurationRequirements& requirements,
        CodecManager::UnicastConfigurationVerifier verifier) {
        CodecManager::UnicastConfigurationProvider provider) {
  if (pimpl_->IsRunning()) {
    return pimpl_->codec_manager_impl_->GetCodecConfig(requirements, verifier);
    return pimpl_->codec_manager_impl_->GetCodecConfig(requirements, provider);
  }

  return nullptr;
+4 −4
Original line number Diff line number Diff line
@@ -77,16 +77,16 @@ public:
    std::optional<std::vector<DeviceDirectionRequirements>> source_requirements;
  };

  /* The verifier function checks each possible configuration (from the set of
  /* The provider function checks each possible configuration (from the set of
   * all possible, supported configuration acquired from
   * AudioSetConfigurationProvider for the given scenario), to select a single
   * configuration, matching the current streaming audio group requirements.
   * Note: Used only with the legacy AudioSetConfigurationProvider.
   */
  typedef std::function<const set_configurations::AudioSetConfiguration*(
  typedef std::function<std::unique_ptr<set_configurations::AudioSetConfiguration>(
          const UnicastConfigurationRequirements& requirements,
          const set_configurations::AudioSetConfigurations* confs)>
          UnicastConfigurationVerifier;
          UnicastConfigurationProvider;

  struct BroadcastConfigurationRequirements {
    std::vector<std::pair<bluetooth::le_audio::types::LeAudioContextType, uint8_t>>
@@ -119,7 +119,7 @@ public:
          std::function<void(const offload_config& config, uint8_t direction)> update_receiver);
  virtual std::unique_ptr<::bluetooth::le_audio::set_configurations::AudioSetConfiguration>
  GetCodecConfig(const UnicastConfigurationRequirements& requirements,
                 UnicastConfigurationVerifier verifier);
                 UnicastConfigurationProvider provider);
  virtual bool CheckCodecConfigIsBiDirSwb(
          const ::bluetooth::le_audio::set_configurations::AudioSetConfiguration& config) const;
  virtual bool CheckCodecConfigIsDualBiDirSwb(
Loading