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

Commit cdcc9256 authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk
Browse files

le_audio: Don't update group configuration in non idle state

Group configuration should be not affected while in transtition or
streaming.

Tag: #bug
Test: atest bluetooth_le_audio_test
Sponsor: jpawlowski@
Bug: 220713692
Change-Id: I16d65f52d80d4db8f952cb2e694827eb86ac2f49
parent f1b682ba
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -1063,6 +1063,17 @@ class LeAudioClientImpl : public LeAudioClient {
         * Group would be assigned once service search is completed.
         */
        if (group) {
          /* Update of available context may happen during state transition
           * or while streaming. Don't bother current transition or streaming
           * process. Update configuration once group became idle.
           */
          if (group->IsInTransition() ||
              (group->GetState() ==
               AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING)) {
            group->SetPendingUpdateAvailableContexts(updated_avail_contexts);
            return;
          }

          std::optional<AudioContexts> updated_contexts =
              group->UpdateActiveContextsMap(updated_avail_contexts);
          if (updated_contexts) {
@@ -3071,6 +3082,30 @@ class LeAudioClientImpl : public LeAudioClient {
        if (!RestartStreamingAfterReconfiguration(group_id))
          CancelStreamingRequest();

        LeAudioDeviceGroup* group = aseGroups_.FindById(active_group_id_);
        if (!group) {
          LOG(ERROR) << __func__ << ", Failed to update pending available "
                     << "contexts for group: " << group_id;
          return;
        }

        /* Update group configuration with pending available context */
        std::optional<AudioContexts> pending_update_available_contexts =
            group->GetPendingUpdateAvailableContexts();
        if (pending_update_available_contexts) {
          std::optional<AudioContexts> updated_contexts =
              group->UpdateActiveContextsMap(*pending_update_available_contexts);

          if (updated_contexts) {
            callbacks_->OnAudioConf(group->audio_directions_, group->group_id_,
                                    group->snk_audio_locations_.to_ulong(),
                                    group->src_audio_locations_.to_ulong(),
                                    updated_contexts->to_ulong());
          }

          group->SetPendingUpdateAvailableContexts(std::nullopt);
        }

        break;
      }
      case GroupStreamStatus::RELEASING:
+10 −0
Original line number Diff line number Diff line
@@ -264,6 +264,15 @@ class LeAudioDeviceGroup {
    target_state_ = state;
  }

  inline std::optional<types::AudioContexts> GetPendingUpdateAvailableContexts()
      const {
    return pending_update_available_contexts_;
  }
  inline void SetPendingUpdateAvailableContexts(
      std::optional<types::AudioContexts> audio_contexts) {
    pending_update_available_contexts_ = audio_contexts;
  }

  bool IsInTransition(void);
  bool IsReleasing(void);
  void Dump(int fd);
@@ -285,6 +294,7 @@ class LeAudioDeviceGroup {
  /* Mask and table of currently supported contexts */
  types::LeAudioContextType active_context_type_;
  types::AudioContexts active_contexts_mask_;
  std::optional<types::AudioContexts> pending_update_available_contexts_;
  std::map<types::LeAudioContextType,
           const set_configurations::AudioSetConfiguration*>
      active_context_to_configuration_map;