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

Commit d9aad819 authored by Roopa Sattiraju's avatar Roopa Sattiraju Committed by Automerger Merge Worker
Browse files

Merge "leaudio: Fix for invalid offloader behavior on localSink" into main am: e5f3f2d8

parents ff4a11b0 e5f3f2d8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4225,7 +4225,8 @@ class LeAudioClientImpl : public LeAudioClient {
        break;
      case AudioState::READY_TO_START:
        LOG_ERROR(
            " called in wrong state. \n audio_receiver_state: %s \n"
            " Double resume request, just ignore it.. \n audio_receiver_state: "
            "%s \n"
            "audio_sender_state: %s \n isPendingConfiguration: %s \n "
            "Reconfiguring to %s",
            ToString(audio_receiver_state_).c_str(),
@@ -4233,7 +4234,6 @@ class LeAudioClientImpl : public LeAudioClient {
            (group->IsPendingConfiguration() ? "true" : "false"),
            ToString(configuration_context_type_).c_str());
        group->PrintDebugState();
        CancelStreamingRequest();
        break;
      case AudioState::READY_TO_RELEASE:
        switch (audio_sender_state_) {
+66 −0
Original line number Diff line number Diff line
@@ -3793,6 +3793,72 @@ TEST_F(UnicastTest, DoubleResumeFromAF) {
  TestAudioDataTransfer(group_id, cis_count_out, cis_count_in, 1920);
}

TEST_F(UnicastTest, DoubleResumeFromAFOnLocalSink) {
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

  default_channel_cnt = 1;

  SetSampleDatabaseEarbudsValid(
      1, test_address0, codec_spec_conf::kLeAudioLocationStereo,
      codec_spec_conf::kLeAudioLocationStereo, default_channel_cnt,
      default_channel_cnt, 0x0004,
      /* source sample freq 16khz */ false /*add_csis*/, true /*add_cas*/,
      true /*add_pacs*/, default_ase_cnt /*add_ascs_cnt*/, 1 /*set_size*/,
      0 /*rank*/);
  EXPECT_CALL(mock_audio_hal_client_callbacks_,
              OnConnectionState(ConnectionState::CONNECTED, test_address0))
      .Times(1);
  EXPECT_CALL(mock_audio_hal_client_callbacks_,
              OnGroupNodeStatus(test_address0, _, GroupNodeStatus::ADDED))
      .WillOnce(DoAll(SaveArg<1>(&group_id)));

  ConnectLeAudio(test_address0);
  ASSERT_NE(group_id, bluetooth::groups::kGroupUnknown);

  // Audio sessions are started only when device gets active
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start(_, _)).Times(1);
  EXPECT_CALL(*mock_le_audio_sink_hal_client_, Start(_, _)).Times(1);
  LeAudioClient::Get()->GroupSetActive(group_id);
  SyncOnMainLoop();

  EXPECT_CALL(mock_state_machine_, StartStream(_, _, _, _)).Times(1);

  block_streaming_state_callback = true;

  UpdateLocalSinkMetadata(AUDIO_SOURCE_MIC);
  LocalAudioSinkResume();

  SyncOnMainLoop();
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);

  EXPECT_CALL(*mock_le_audio_sink_hal_client_, CancelStreamingRequest())
      .Times(0);

  // Actuall test here: send additional resume which shall be ignored.
  LocalAudioSinkResume();

  EXPECT_CALL(mock_state_machine_, StopStream(_)).Times(0);

  do_in_main_thread(
      FROM_HERE,
      base::BindOnce(
          [](int group_id, le_audio::LeAudioGroupStateMachine::Callbacks*
                               state_machine_callbacks) {
            state_machine_callbacks->StatusReportCb(
                group_id, GroupStreamStatus::STREAMING);
          },
          group_id, base::Unretained(state_machine_callbacks_)));
  SyncOnMainLoop();
  Mock::VerifyAndClearExpectations(&mock_state_machine_);

  // Verify Data transfer on local audio sink which is started
  constexpr uint8_t cis_count_out = 0;
  constexpr uint8_t cis_count_in = 1;
  TestAudioDataTransfer(group_id, cis_count_out, cis_count_in, 0, 40);
}

TEST_F(UnicastTest, RemoveNodeWhileStreaming) {
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;