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

Commit e08a02ac authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Clear CIS ID allocation when group goes to IDLE

If CIS ID are cleared on CIG Remove, but ASE are cached and stay in
configured state, state machine cannot go directly to QoS Confing
because CIS ID might change.
With this patch, CIS ID are also cached in case group stays in
Configured state

Bug: 222674521
Bug: 150670922
Test: atest --bluetooth_le_audio_test bluetoot_le_audio_client_test

Change-Id: Ia785af19404bd90c28abf1fb4d22c4b40a2e3135
parent 05c4d206
Loading
Loading
Loading
Loading
+20 −2
Original line number Original line Diff line number Diff line
@@ -386,7 +386,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {


      for (auto& ase : leAudioDevice->ases_) {
      for (auto& ase : leAudioDevice->ases_) {
        ase.data_path_state = AudioStreamDataPathState::IDLE;
        ase.data_path_state = AudioStreamDataPathState::IDLE;
        ase.cis_id = le_audio::kInvalidCisId;
      }
      }
    } while ((leAudioDevice = group->GetNextDevice(leAudioDevice)));
    } while ((leAudioDevice = group->GetNextDevice(leAudioDevice)));
  }
  }
@@ -490,6 +489,22 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
              << ", duplicatePackets: " << loghex(duplicatePackets);
              << ", duplicatePackets: " << loghex(duplicatePackets);
  }
  }


  void ReleaseCisIds(LeAudioDeviceGroup* group) {
    if (group == nullptr) {
      LOG_DEBUG(" Group is null.");
      return;
    }
    LOG_DEBUG(" Releasing CIS is for group %d", group->group_id_);

    LeAudioDevice* leAudioDevice = group->GetFirstDevice();
    while (leAudioDevice != nullptr) {
      for (auto& ase : leAudioDevice->ases_) {
        ase.cis_id = le_audio::kInvalidCisId;
      }
      leAudioDevice = group->GetNextDevice(leAudioDevice);
    }
  }

  void ProcessHciNotifAclDisconnected(LeAudioDeviceGroup* group,
  void ProcessHciNotifAclDisconnected(LeAudioDeviceGroup* group,
                                      LeAudioDevice* leAudioDevice) {
                                      LeAudioDevice* leAudioDevice) {
    FreeLinkQualityReports(leAudioDevice);
    FreeLinkQualityReports(leAudioDevice);
@@ -559,6 +574,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
    group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE);
    group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE);
    group->SetTargetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE);
    group->SetTargetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE);
    if (alarm_is_scheduled(watchdog_)) alarm_cancel(watchdog_);
    if (alarm_is_scheduled(watchdog_)) alarm_cancel(watchdog_);
    ReleaseCisIds(group);
    state_machine_callbacks_->StatusReportCb(group->group_id_,
    state_machine_callbacks_->StatusReportCb(group->group_id_,
                                             GroupStreamStatus::IDLE);
                                             GroupStreamStatus::IDLE);


@@ -857,6 +873,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
                      << " shouldn't be called without an active ASE";
                      << " shouldn't be called without an active ASE";
      do {
      do {
        auto& cis = ase->cis_id;
        auto& cis = ase->cis_id;
        ASSERT_LOG(ase->cis_id != le_audio::kInvalidCisId,
                   " ase id %d has invalid cis id %d", ase->id, ase->cis_id);
        auto iter =
        auto iter =
            find_if(cis_cfgs.begin(), cis_cfgs.end(),
            find_if(cis_cfgs.begin(), cis_cfgs.end(),
                    [&cis](auto const& cfg) { return cis == cfg.cis_id; });
                    [&cis](auto const& cfg) { return cis == cfg.cis_id; });
@@ -1061,7 +1079,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
          if (alarm_is_scheduled(watchdog_)) alarm_cancel(watchdog_);
          if (alarm_is_scheduled(watchdog_)) alarm_cancel(watchdog_);


          group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE);
          group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_IDLE);

          ReleaseCisIds(group);
          state_machine_callbacks_->StatusReportCb(group->group_id_,
          state_machine_callbacks_->StatusReportCb(group->group_id_,
                                                   GroupStreamStatus::IDLE);
                                                   GroupStreamStatus::IDLE);
        }
        }