3232#include <zephyr/toolchain.h>
3333
3434#include "bap_common.h"
35+ #include "bap_stream_rx.h"
3536#include "bstests.h"
3637#include "common.h"
3738
@@ -44,7 +45,6 @@ CREATE_FLAG(flag_base_metadata_updated);
4445CREATE_FLAG (flag_pa_synced );
4546CREATE_FLAG (flag_syncable );
4647CREATE_FLAG (flag_pa_sync_lost );
47- CREATE_FLAG (flag_received );
4848CREATE_FLAG (flag_pa_request );
4949CREATE_FLAG (flag_bis_sync_requested );
5050CREATE_FLAG (flag_big_sync_mic_failure );
@@ -528,9 +528,13 @@ static void validate_stream_codec_cfg(const struct bt_bap_stream *stream)
528528
529529static void started_cb (struct bt_bap_stream * stream )
530530{
531+ struct audio_test_stream * test_stream = audio_test_stream_from_bap_stream (stream );
531532 struct bt_bap_ep_info info ;
532533 int err ;
533534
535+ memset (& test_stream -> last_info , 0 , sizeof (test_stream -> last_info ));
536+ test_stream -> rx_cnt = 0U ;
537+
534538 err = bt_bap_ep_get_info (stream -> ep , & info );
535539 if (err != 0 ) {
536540 FAIL ("Failed to get EP info: %d\n" , err );
@@ -578,57 +582,10 @@ static void stopped_cb(struct bt_bap_stream *stream, uint8_t reason)
578582 }
579583}
580584
581- static void recv_cb (struct bt_bap_stream * stream ,
582- const struct bt_iso_recv_info * info ,
583- struct net_buf * buf )
584- {
585- struct audio_test_stream * test_stream = audio_test_stream_from_bap_stream (stream );
586-
587- if ((test_stream -> rx_cnt % 100U ) == 0U ) {
588- printk ("[%zu]: Incoming audio on stream %p len %u and ts %u\n" , test_stream -> rx_cnt ,
589- stream , buf -> len , info -> ts );
590- }
591-
592- if (test_stream -> rx_cnt > 0U && info -> ts == test_stream -> last_info .ts ) {
593- FAIL ("Duplicated timestamp received: %u\n" , test_stream -> last_info .ts );
594- return ;
595- }
596-
597- if (test_stream -> rx_cnt > 0U && info -> seq_num == test_stream -> last_info .seq_num ) {
598- FAIL ("Duplicated PSN received: %u\n" , test_stream -> last_info .seq_num );
599- return ;
600- }
601-
602- if (info -> flags & BT_ISO_FLAGS_ERROR ) {
603- /* Fail the test if we have not received what we expected */
604- if (!TEST_FLAG (flag_received )) {
605- FAIL ("ISO receive error\n" );
606- }
607-
608- return ;
609- }
610-
611- if (info -> flags & BT_ISO_FLAGS_LOST ) {
612- FAIL ("ISO receive lost\n" );
613- return ;
614- }
615-
616- if (memcmp (buf -> data , mock_iso_data , buf -> len ) == 0 ) {
617- test_stream -> rx_cnt ++ ;
618-
619- if (test_stream -> rx_cnt >= MIN_SEND_COUNT ) {
620- /* We set the flag is just one stream has received the expected */
621- SET_FLAG (flag_received );
622- }
623- } else {
624- FAIL ("Unexpected data received\n" );
625- }
626- }
627-
628585static struct bt_bap_stream_ops stream_ops = {
629586 .started = started_cb ,
630587 .stopped = stopped_cb ,
631- .recv = recv_cb
588+ .recv = bap_stream_rx_recv_cb ,
632589};
633590
634591static int init (void )
@@ -964,7 +921,7 @@ static void test_common(void)
964921 }
965922
966923 printk ("Waiting for data\n" );
967- WAIT_FOR_FLAG (flag_received );
924+ WAIT_FOR_FLAG (flag_audio_received );
968925 backchannel_sync_send_all (); /* let other devices know we have received what we wanted */
969926
970927 /* Ensure that we also see the metadata update */
@@ -1051,7 +1008,7 @@ static void test_sink_encrypted(void)
10511008 }
10521009
10531010 printk ("Waiting for data\n" );
1054- WAIT_FOR_FLAG (flag_received );
1011+ WAIT_FOR_FLAG (flag_audio_received );
10551012
10561013 backchannel_sync_send_all (); /* let other devices know we have received data */
10571014
@@ -1140,7 +1097,7 @@ static void broadcast_sink_with_assistant(void)
11401097 }
11411098
11421099 printk ("Waiting for data\n" );
1143- WAIT_FOR_FLAG (flag_received );
1100+ WAIT_FOR_FLAG (flag_audio_received );
11441101 backchannel_sync_send_all (); /* let other devices know we have received what we wanted */
11451102
11461103 /* Ensure that we also see the metadata update */
0 commit comments