Skip to content

Commit 78f8c43

Browse files
alexsvenkoffes
authored andcommitted
applications: nrf5340_audio: Only check PD of configured streams
- Only compare presentation delay with other streams if they are in: - Configured state - QoS configured state - Enabling state - Streaming state - Added test to cover the changes - OCT-3516 Signed-off-by: Alexander Svensen <[email protected]>
1 parent b814764 commit 78f8c43

File tree

2 files changed

+61
-0
lines changed
  • applications/nrf5340_audio/src/bluetooth/bt_stream/unicast
  • tests/nrf5340_audio/server_store

2 files changed

+61
-0
lines changed

applications/nrf5340_audio/src/bluetooth/bt_stream/unicast/server_store.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,18 @@ static bool pres_dly_stream_ignore(struct bt_bap_stream const *const existing_st
407407
return true;
408408
}
409409

410+
/* Check if the existing stream has gotten into a codec configured, QoS configured,
411+
* enabling or streaming state.
412+
*/
413+
if (!le_audio_ep_state_check(existing_stream->ep, BT_BAP_EP_STATE_CODEC_CONFIGURED) &&
414+
!le_audio_ep_state_check(existing_stream->ep, BT_BAP_EP_STATE_QOS_CONFIGURED) &&
415+
!le_audio_ep_state_check(existing_stream->ep, BT_BAP_EP_STATE_ENABLING) &&
416+
!le_audio_ep_state_check(existing_stream->ep, BT_BAP_EP_STATE_STREAMING)) {
417+
LOG_DBG("Existing stream not in codec configured, QoS configured, enabling or "
418+
"streaming state");
419+
return true;
420+
}
421+
410422
stream_print(&existing_stream->ep->qos_pref, true, "Existing");
411423
return false;
412424
}

tests/nrf5340_audio/server_store/main.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ ZTEST(suite_server_store, test_pres_dly_not_found)
370370
TEST_UNICAST_GROUP(unicast_group);
371371

372372
TEST_CAP_STREAM(TCS_1_existing, BT_AUDIO_DIR_SINK, 1100, 0xAAAA);
373+
TCS_1_existing.bap_stream.ep->state = BT_BAP_EP_STATE_STREAMING;
373374
TCS_1_existing.bap_stream.ep->qos_pref.pd_min = 1000;
374375
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_min = 2000;
375376
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_max = 3000;
@@ -407,6 +408,48 @@ ZTEST(suite_server_store, test_pres_dly_not_found)
407408
srv_store_unlock();
408409
}
409410

411+
ZTEST(suite_server_store, test_pres_dly_ignored)
412+
{
413+
414+
int ret;
415+
416+
ret = srv_store_lock(K_NO_WAIT);
417+
zassert_equal(ret, 0);
418+
419+
TEST_UNICAST_GROUP(unicast_group);
420+
421+
TEST_CAP_STREAM(TCS_1_existing, BT_AUDIO_DIR_SINK, 4000, 0xAAAA);
422+
TCS_1_existing.bap_stream.ep->state = BT_BAP_EP_STATE_IDLE;
423+
TCS_1_existing.bap_stream.ep->qos_pref.pd_min = 4000;
424+
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_min = 5000;
425+
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_max = 6000;
426+
TCS_1_existing.bap_stream.ep->qos_pref.pd_max = 7000;
427+
428+
mock_add_stream_to_group(&TCS_1_existing.bap_stream, &unicast_group);
429+
430+
uint32_t computed_pres_dly_us = 0;
431+
uint32_t existing_pres_dly_us = 0;
432+
bool group_reconfig_needed = false;
433+
434+
TEST_CAP_STREAM(TCS_1_new, BT_AUDIO_DIR_SINK, 0, 0xAAAA);
435+
struct bt_bap_qos_cfg_pref server_qos_pref;
436+
437+
server_qos_pref.pd_min = 1000;
438+
server_qos_pref.pref_pd_min = 2000;
439+
server_qos_pref.pref_pd_max = 3000;
440+
server_qos_pref.pd_max = 4000;
441+
442+
ret = srv_store_pres_dly_find(&TCS_1_new.bap_stream, &computed_pres_dly_us,
443+
&existing_pres_dly_us, &server_qos_pref,
444+
&group_reconfig_needed, &unicast_group);
445+
446+
zassert_equal(ret, 0);
447+
zassert_equal(computed_pres_dly_us, 2000,
448+
"Computed presentation delay should be equal to preferred min");
449+
450+
srv_store_unlock();
451+
}
452+
410453
ZTEST(suite_server_store, test_pres_delay_advanced)
411454
{
412455
int ret;
@@ -417,6 +460,7 @@ ZTEST(suite_server_store, test_pres_delay_advanced)
417460
zassert_equal(ret, 0);
418461

419462
TEST_CAP_STREAM(TCS_1_existing, BT_AUDIO_DIR_SINK, 2500, 0xAAAA);
463+
TCS_1_existing.bap_stream.ep->state = BT_BAP_EP_STATE_STREAMING;
420464
TCS_1_existing.bap_stream.ep->qos_pref.pd_min = 1001;
421465
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_min = 2000;
422466
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_max = 3000;
@@ -480,6 +524,7 @@ ZTEST(suite_server_store, test_pres_delay_multiple_streams)
480524
zassert_equal(ret, 0);
481525

482526
TEST_CAP_STREAM(TCS_1_existing, BT_AUDIO_DIR_SINK, 1800, 0xAAAA);
527+
TCS_1_existing.bap_stream.ep->state = BT_BAP_EP_STATE_STREAMING;
483528
TCS_1_existing.bap_stream.ep->qos_pref.pd_min = 1000;
484529
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_min = 2300;
485530
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_max = 3000;
@@ -488,6 +533,7 @@ ZTEST(suite_server_store, test_pres_delay_multiple_streams)
488533
mock_add_stream_to_group(&TCS_1_existing.bap_stream, &unicast_group);
489534

490535
TEST_CAP_STREAM(TCS_2_existing, BT_AUDIO_DIR_SINK, 1800, 0xAAAA);
536+
TCS_2_existing.bap_stream.ep->state = BT_BAP_EP_STATE_STREAMING;
491537
TCS_2_existing.bap_stream.ep->qos_pref.pd_min = 1500;
492538
TCS_2_existing.bap_stream.ep->qos_pref.pref_pd_min = 2500;
493539
TCS_2_existing.bap_stream.ep->qos_pref.pref_pd_max = 3000;
@@ -496,6 +542,7 @@ ZTEST(suite_server_store, test_pres_delay_multiple_streams)
496542
mock_add_stream_to_group(&TCS_2_existing.bap_stream, &unicast_group);
497543

498544
TEST_CAP_STREAM(TCS_3_existing, BT_AUDIO_DIR_SINK, 1800, 0xAAAA);
545+
TCS_3_existing.bap_stream.ep->state = BT_BAP_EP_STATE_STREAMING;
499546
TCS_3_existing.bap_stream.ep->qos_pref.pd_min = 1800;
500547
TCS_3_existing.bap_stream.ep->qos_pref.pref_pd_min = 2500;
501548
TCS_3_existing.bap_stream.ep->qos_pref.pref_pd_max = 3000;
@@ -589,6 +636,7 @@ ZTEST(suite_server_store, test_pres_delay_multi_group)
589636
zassert_equal(ret, 0);
590637

591638
TEST_CAP_STREAM(TCS_1_existing, BT_AUDIO_DIR_SINK, 2000, 0xAAAA);
639+
TCS_1_existing.bap_stream.ep->state = BT_BAP_EP_STATE_STREAMING;
592640
TCS_1_existing.bap_stream.ep->qos_pref.pd_min = 1000;
593641
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_min = 2000;
594642
TCS_1_existing.bap_stream.ep->qos_pref.pref_pd_max = 3000;
@@ -598,6 +646,7 @@ ZTEST(suite_server_store, test_pres_delay_multi_group)
598646

599647
/* Add stream in another group */
600648
TEST_CAP_STREAM(TCS_2_existing, BT_AUDIO_DIR_SINK, 500, 0xBBBB);
649+
TCS_2_existing.bap_stream.ep->state = BT_BAP_EP_STATE_STREAMING;
601650
TCS_2_existing.bap_stream.ep->qos_pref.pd_min = 500;
602651
TCS_2_existing.bap_stream.ep->qos_pref.pref_pd_min = 500;
603652
TCS_2_existing.bap_stream.ep->qos_pref.pref_pd_max = 500;

0 commit comments

Comments
 (0)