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

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

leaudio: Notify connected when subscribed for CCC

Make sure to not notify connected until all the CCC are registered and
MTU is changed on the reconnection.

Otherwise, when reconnected during streaming, stream will not be able to
setup because GATT is busy with the descritors registration and MTU
change.

This is regression after:
4b1536c90b5  leaudio: Fix the MTU exchange request

Bug: 228351333
Test: atest BluetoothInstrumentationTests
Test: manual: Connect earbuds while streaming
Tag: #feature
Merged-In: I5b023907764e6c4552f199a8a17f02e5bddbd0de
Change-Id: I5b023907764e6c4552f199a8a17f02e5bddbd0de
(cherry picked from commit 50805bd5)
parent be07b0aa
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -1566,6 +1566,14 @@ class LeAudioClientImpl : public LeAudioClient {
  void RegisterKnownNotifications(LeAudioDevice* leAudioDevice) {
    LOG(INFO) << __func__ << " device: " << leAudioDevice->address_;

    if (leAudioDevice->ctp_hdls_.val_hdl == 0) {
      LOG_ERROR(
          "Control point characteristic is mandatory - disconnecting device %s",
          leAudioDevice->address_.ToString().c_str());
      DisconnectDevice(leAudioDevice);
      return;
    }

    /* GATTC will ommit not registered previously handles */
    for (auto pac_tuple : leAudioDevice->snk_pacs_) {
      subscribe_for_notification(leAudioDevice->conn_id_,
@@ -1597,14 +1605,12 @@ class LeAudioClientImpl : public LeAudioClient {
                                 leAudioDevice->address_,
                                 leAudioDevice->audio_supp_cont_hdls_);

    if (leAudioDevice->ctp_hdls_.val_hdl != 0)
      subscribe_for_notification(leAudioDevice->conn_id_,
                                 leAudioDevice->address_,
                                 leAudioDevice->ctp_hdls_);

    for (struct ase& ase : leAudioDevice->ases_)
      subscribe_for_notification(leAudioDevice->conn_id_,
                                 leAudioDevice->address_, ase.hdls);

    subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_,
                               leAudioDevice->ctp_hdls_);
  }

  void changeMtuIfPossible(LeAudioDevice* leAudioDevice) {
@@ -1653,7 +1659,7 @@ class LeAudioClientImpl : public LeAudioClient {
     * just notify connected  */
    if (leAudioDevice->known_service_handles_ &&
        !leAudioDevice->notify_connected_after_read_) {
      connectionReady(leAudioDevice);
      LOG_INFO("Wait for CCC registration and MTU change request");
      return;
    }

@@ -2155,6 +2161,15 @@ class LeAudioClientImpl : public LeAudioClient {
    if (status == GATT_SUCCESS) {
      LOG(INFO) << __func__
                << ", successfully registered on ccc: " << loghex(hdl);

      if (leAudioDevice->ctp_hdls_.ccc_hdl == hdl &&
          leAudioDevice->known_service_handles_ &&
          !leAudioDevice->notify_connected_after_read_) {
        /* Reconnection case. Control point is the last CCC LeAudio is
         * registering for on reconnection */
        connectionReady(leAudioDevice);
      }

      return;
    }