Loading system/bta/le_audio/state_machine.cc +21 −21 Original line number Original line Diff line number Diff line Loading @@ -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() Loading Loading @@ -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); Loading Loading @@ -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: " Loading Loading @@ -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__ Loading Loading @@ -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; Loading Loading @@ -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; Loading system/bta/le_audio/state_machine_test.cc +13 −2 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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))); Loading Loading
system/bta/le_audio/state_machine.cc +21 −21 Original line number Original line Diff line number Diff line Loading @@ -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() Loading Loading @@ -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); Loading Loading @@ -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: " Loading Loading @@ -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__ Loading Loading @@ -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; Loading Loading @@ -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; Loading
system/bta/le_audio/state_machine_test.cc +13 −2 Original line number Original line Diff line number Diff line Loading @@ -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); Loading Loading @@ -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))); Loading