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

Commit 7f93f0cc authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Fix ASE clear on ACL disconnection

If CIS was disconnected first, the ASE got inactive but keep the
conn_handle and the state.
When ACL got disconnected, the ASE state shall be removed but since ASE
was not active, state was no removed.

This patch also adds some useful logs

Bug: 263359541
Test: atest BluetoothInstrumentationTests
Test: manual bud disconnection/reconnection while streaming
Tag: #feature
Change-Id: I12c6d62daf87fa6d513372c7d91b9f10806e5850
parent 434e3b29
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4416,7 +4416,8 @@ class LeAudioClientImpl : public LeAudioClient {
void le_audio_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data) {
  if (!p_data || !instance) return;

  DLOG(INFO) << __func__ << " event = " << +event;
  LOG_DEBUG("%s event = %d", p_data->remote_bda.ToString().c_str(),
            static_cast<int>(event));

  switch (event) {
    case BTA_GATTC_DEREG_EVT:
+14 −7
Original line number Diff line number Diff line
@@ -2469,7 +2469,8 @@ void LeAudioDevice::Dump(int fd) {
             << ",\tactive: " << ase.active << ", dir: "
             << (ase.direction == types::kLeAudioDirectionSink ? "sink"
                                                               : "source")
             << ",\tcis_id: " << static_cast<int>(ase.cis_id) << ",\tstate: "
             << ",\tcis_id: " << static_cast<int>(ase.cis_id)
             << ",\tcis_handle: " << ase.cis_conn_hdl << ",\tstate: "
             << bluetooth::common::ToString(ase.data_path_state);
    }
  }
@@ -2547,7 +2548,14 @@ bool LeAudioDevice::ActivateConfiguredAses(LeAudioContextType context_type) {

void LeAudioDevice::DeactivateAllAses(void) {
  for (auto& ase : ases_) {
    if (ase.active) {
    if (ase.active == false &&
        ase.data_path_state != AudioStreamDataPathState::IDLE) {
      LOG_WARN(
          " %s, ase_id: %d, ase.cis_id: %d, cis_handle: 0x%02x, "
          "ase.data_path=%s",
          address_.ToString().c_str(), ase.id, ase.cis_id, ase.cis_conn_hdl,
          bluetooth::common::ToString(ase.data_path_state).c_str());
    }
    ase.state = AseState::BTA_LE_AUDIO_ASE_STATE_IDLE;
    ase.data_path_state = AudioStreamDataPathState::IDLE;
    ase.active = false;
@@ -2555,7 +2563,6 @@ void LeAudioDevice::DeactivateAllAses(void) {
    ase.cis_conn_hdl = 0;
  }
}
}

std::vector<uint8_t> LeAudioDevice::GetMetadata(
    AudioContexts context_type, const std::vector<uint8_t>& ccid_list) {
+2 −3
Original line number Diff line number Diff line
@@ -614,6 +614,8 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
                                      LeAudioDevice* leAudioDevice) {
    FreeLinkQualityReports(leAudioDevice);
    leAudioDevice->conn_id_ = GATT_INVALID_CONN_ID;
    /* mark ASEs as not used. */
    leAudioDevice->DeactivateAllAses();

    if (!group) {
      LOG(ERROR) << __func__
@@ -622,9 +624,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
      return;
    }

    /* mark ASEs as not used. */
    leAudioDevice->DeactivateAllAses();

    /* If group is in Idle and not transitioning, just update the current group
     * audio context availability which could change due to disconnected group
     * member.