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

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

leaudio: Notify Offloader about disconnected CIS

Offloader might be not notified about disconnected CIS when ACL was
still there. This patch fixes this.

Bug: 331775328
Test: atest bluetooth_le_audio_test
Flag: Exempt, regression checked with unit tests.

Change-Id: Id7e08594e3c4b53d8222cc83bf35bd09017a1275
parent bbf3802a
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -716,6 +716,26 @@ public:
    group->ClearAllCises();
  }

  void SendStreamingStatusCbIfNeeded(LeAudioDeviceGroup* group) {
    /* This function should be called when some of the set members got disconnected but there are
     * still other CISes connected. When state machine is in STREAMING state, status will be sent up
     * to the user, so it can update encoder or offloader.
     */
    log::info("group_id: {}", group->group_id_);
    if (group->HaveAllCisesDisconnected()) {
      log::info("All cises disconnected;");
      return;
    }

    if ((group->GetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) &&
        (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING)) {
      state_machine_callbacks_->StatusReportCb(group->group_id_, GroupStreamStatus::STREAMING);
    } else {
      log::warn("group_id {} not in streaming, CISes are still there", group->group_id_);
      group->PrintDebugState();
    }
  }

  void RemoveCigForGroup(LeAudioDeviceGroup* group) {
    log::debug("Group: {}, id: {} cig state: {}", fmt::ptr(group), group->group_id_,
               ToString(group->cig.GetState()));
@@ -792,18 +812,7 @@ public:
       */
      if (!group->HaveAllCisesDisconnected()) {
        /* some CISes are connected */

        if ((group->GetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) &&
            (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING)) {
          /* We keep streaming but want others to let know user that it might
           * be need to update CodecManager with new CIS configuration
           */
          state_machine_callbacks_->StatusReportCb(group->group_id_, GroupStreamStatus::STREAMING);
        } else {
          log::warn("group_id {} not in streaming, CISes are still there", group->group_id_);
          group->PrintDebugState();
        }

        SendStreamingStatusCbIfNeeded(group);
        return;
      }
    }
@@ -1101,6 +1110,7 @@ public:
         */
        if (!group->HaveAllCisesDisconnected()) {
          /* There is ASE streaming for some device. Continue streaming. */
          SendStreamingStatusCbIfNeeded(group);
          log::warn("Group member disconnected during streaming. Cis handle 0x{:04x}",
                    event->cis_conn_hdl);
          return;
+19 −3
Original line number Diff line number Diff line
@@ -4022,7 +4022,8 @@ TEST_F(StateMachineTest, testAseAutonomousRelease) {

  // Validate initial GroupStreamStatus
  EXPECT_CALL(mock_callbacks_,
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::STREAMING));
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::STREAMING))
          .Times(1);

  // Start the configuration and stream Media content
  ASSERT_TRUE(LeAudioGroupStateMachine::Get()->StartStream(
@@ -4030,7 +4031,12 @@ TEST_F(StateMachineTest, testAseAutonomousRelease) {
          {.sink = types::AudioContexts(context_type),
           .source = types::AudioContexts(context_type)}));

  testing::Mock::VerifyAndClearExpectations(&mock_callbacks_);

  // Validate new GroupStreamStatus
  EXPECT_CALL(mock_callbacks_,
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::STREAMING))
          .Times(1);
  EXPECT_CALL(mock_callbacks_,
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::IDLE))
          .Times(AtLeast(1));
@@ -4090,7 +4096,8 @@ TEST_F(StateMachineTest, testAseAutonomousRelease2Devices) {

  // Validate initial GroupStreamStatus
  EXPECT_CALL(mock_callbacks_,
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::STREAMING));
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::STREAMING))
          .Times(1);

  // Start the configuration and stream Media content
  ASSERT_TRUE(LeAudioGroupStateMachine::Get()->StartStream(
@@ -4098,7 +4105,15 @@ TEST_F(StateMachineTest, testAseAutonomousRelease2Devices) {
          {.sink = types::AudioContexts(context_type),
           .source = types::AudioContexts(context_type)}));

  // Check streaming will continue
  testing::Mock::VerifyAndClearExpectations(&mock_callbacks_);

  /* Check streaming will continue. Streaming status should be send up so the user
   * can update e.g. CIS count
   */
  EXPECT_CALL(mock_callbacks_,
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::STREAMING))
          .Times(1);

  EXPECT_CALL(mock_callbacks_,
              StatusReportCb(leaudio_group_id, bluetooth::le_audio::GroupStreamStatus::IDLE))
          .Times(0);
@@ -4117,6 +4132,7 @@ TEST_F(StateMachineTest, testAseAutonomousRelease2Devices) {
                               &codec_configured_state_params);
    InjectAseStateNotification(&ase, device, group, ascs::kAseStateIdle,
                               &codec_configured_state_params);
    testing::Mock::VerifyAndClearExpectations(&mock_callbacks_);
  }
}