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

Commit 0330727b authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Automerger Merge Worker
Browse files

Merge "leaudio: Fix the time of creating CIG" am: 3c600f95

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1997210

Change-Id: I8158b5f5f66ddf611f5b2339238a6172a582ce8d
parents 891c9c9e 3c600f95
Loading
Loading
Loading
Loading
+21 −21
Original line number Original line Diff line number Diff line
@@ -345,10 +345,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
    group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_QOS_CONFIGURED);
    group->SetState(AseState::BTA_LE_AUDIO_ASE_STATE_QOS_CONFIGURED);


    if (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) {
    if (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) {
      leAudioDevice = group->GetFirstActiveDevice();
      StartConfigQoSForTheGroup(group);
      LOG_ASSERT(leAudioDevice)
          << __func__ << " Shouldn't be called without an active device.";
      PrepareAndSendEnable(leAudioDevice);
    } else {
    } else {
      LOG(ERROR) << __func__
      LOG(ERROR) << __func__
                 << ", invalid state transition, from: " << group->GetState()
                 << ", invalid state transition, from: " << group->GetState()
@@ -1095,6 +1092,20 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
    ase = leAudioDevice->GetFirstActiveAse();
    ase = leAudioDevice->GetFirstActiveAse();
    LOG_ASSERT(ase) << __func__ << " shouldn't be called without an active ASE";
    LOG_ASSERT(ase) << __func__ << " shouldn't be called without an active ASE";
    do {
    do {
      /* Get completive (to be bi-directional CIS) CIS ID for ASE */
      uint8_t cis_id = leAudioDevice->GetMatchingBidirectionCisId(ase);
      if (cis_id == le_audio::kInvalidCisId) {
        /* Get next free CIS ID for group */
        cis_id = group->GetFirstFreeCisId();
        if (cis_id == le_audio::kInvalidCisId) {
          LOG(ERROR) << __func__ << ", failed to get free CIS ID";
          StopStream(group);
          return;
        }
      }

      ase->cis_id = cis_id;

      conf.ase_id = ase->id;
      conf.ase_id = ase->id;
      conf.target_latency = group->GetTargetLatency();
      conf.target_latency = group->GetTargetLatency();
      conf.target_phy = group->GetTargetPhy(ase->direction);
      conf.target_phy = group->GetTargetPhy(ase->direction);
@@ -1182,7 +1193,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {


          if (group->GetTargetState() ==
          if (group->GetTargetState() ==
              AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) {
              AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) {
            StartConfigQoSForTheGroup(group);
            CigCreate(group);
            return;
            return;
          } else {
          } else {
            LOG(ERROR) << __func__ << ", invalid state transition, from: "
            LOG(ERROR) << __func__ << ", invalid state transition, from: "
@@ -1246,7 +1257,7 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {


          if (group->GetTargetState() ==
          if (group->GetTargetState() ==
              AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) {
              AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) {
            StartConfigQoSForTheGroup(group);
            CigCreate(group);
            return;
            return;
          } else {
          } else {
            LOG(ERROR) << __func__
            LOG(ERROR) << __func__
@@ -1334,7 +1345,10 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
        if (leAudioDeviceNext) {
        if (leAudioDeviceNext) {
          PrepareAndSendConfigQos(group, leAudioDeviceNext);
          PrepareAndSendConfigQos(group, leAudioDeviceNext);
        } else {
        } else {
          CigCreate(group);
          leAudioDevice = group->GetFirstActiveDevice();
          LOG_ASSERT(leAudioDevice)
              << __func__ << " Shouldn't be called without an active device.";
          PrepareAndSendEnable(leAudioDevice);
        }
        }


        break;
        break;
@@ -1461,20 +1475,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {


    for (struct ase* ase = leAudioDevice->GetFirstActiveAse(); ase != nullptr;
    for (struct ase* ase = leAudioDevice->GetFirstActiveAse(); ase != nullptr;
         ase = leAudioDevice->GetNextActiveAse(ase)) {
         ase = leAudioDevice->GetNextActiveAse(ase)) {
      /* Get completive (to be bi-directional CIS) CIS ID for ASE */
      uint8_t cis_id = leAudioDevice->GetMatchingBidirectionCisId(ase);
      if (cis_id == le_audio::kInvalidCisId) {
        /* Get next free CIS ID for group */
        cis_id = group->GetFirstFreeCisId();
        if (cis_id == le_audio::kInvalidCisId) {
          LOG(ERROR) << __func__ << ", failed to get free CIS ID";
          StopStream(group);
          return;
        }
      }

      ase->cis_id = cis_id;

      /* TODO: Configure first ASE qos according to context type */
      /* TODO: Configure first ASE qos according to context type */
      struct le_audio::client_parser::ascs::ctp_qos_conf conf;
      struct le_audio::client_parser::ascs::ctp_qos_conf conf;
      conf.ase_id = ase->id;
      conf.ase_id = ase->id;
+13 −2
Original line number Original line Diff line number Diff line
@@ -1127,11 +1127,17 @@ TEST_F(StateMachineTest, testConfigureCodecSingle) {
  auto* leAudioDevice = group->GetFirstDevice();
  auto* leAudioDevice = group->GetFirstDevice();
  PrepareConfigureCodecHandler(group, 1);
  PrepareConfigureCodecHandler(group, 1);


  // Start the configuration and stream Media content
  /* Start the configuration and stream Media content.
   * Expect 1 time for the Codec Config call only. */
  EXPECT_CALL(gatt_queue,
  EXPECT_CALL(gatt_queue,
              WriteCharacteristic(1, leAudioDevice->ctp_hdls_.val_hdl, _,
              WriteCharacteristic(1, leAudioDevice->ctp_hdls_.val_hdl, _,
                                  GATT_WRITE_NO_RSP, _, _))
                                  GATT_WRITE_NO_RSP, _, _))
      .Times(2);
      .Times(1);

  /* Do nothing on the CigCreate, so the state machine stays in the configure
   * state */
  ON_CALL(*mock_iso_manager_, CreateCig).WillByDefault(Return());
  EXPECT_CALL(*mock_iso_manager_, CreateCig).Times(1);


  InjectInitialIdleNotification(group);
  InjectInitialIdleNotification(group);


@@ -1170,6 +1176,11 @@ TEST_F(StateMachineTest, testConfigureCodecMulti) {


  InjectInitialIdleNotification(group);
  InjectInitialIdleNotification(group);


  /* Do nothing on the CigCreate, so the state machine stays in the configure
   * state */
  ON_CALL(*mock_iso_manager_, CreateCig).WillByDefault(Return());
  EXPECT_CALL(*mock_iso_manager_, CreateCig).Times(1);

  // Start the configuration and stream the content
  // Start the configuration and stream the content
  ASSERT_TRUE(LeAudioGroupStateMachine::Get()->StartStream(
  ASSERT_TRUE(LeAudioGroupStateMachine::Get()->StartStream(
      group, static_cast<types::LeAudioContextType>(context_type)));
      group, static_cast<types::LeAudioContextType>(context_type)));