1717
1818LOG_MODULE_REGISTER (bap_stream_rx , LOG_LEVEL_INF );
1919
20+ #define LOG_INTERVAL 100
21+
2022static void log_stream_rx (struct bt_bap_stream * stream , const struct bt_iso_recv_info * info ,
2123 struct net_buf * buf )
2224{
@@ -27,54 +29,77 @@ static void log_stream_rx(struct bt_bap_stream *stream, const struct bt_iso_recv
2729 info -> seq_num , info -> ts );
2830}
2931
32+ static void log_stream_err (struct audio_test_stream * test_stream ,
33+ const struct bt_iso_recv_info * info , struct net_buf * buf )
34+ {
35+ if (!test_stream -> last_rx_failed || (test_stream -> rx_cnt % LOG_INTERVAL ) == 0U ) {
36+ log_stream_rx (& test_stream -> stream .bap_stream , info , buf );
37+ }
38+
39+ test_stream -> last_rx_failed = true;
40+ }
41+
3042void bap_stream_rx_recv_cb (struct bt_bap_stream * stream , const struct bt_iso_recv_info * info ,
3143 struct net_buf * buf )
3244{
3345 struct audio_test_stream * test_stream = audio_test_stream_from_bap_stream (stream );
46+ static bool last_failed ;
3447
3548 test_stream -> rx_cnt ++ ;
3649 if ((info -> flags & BT_ISO_FLAGS_VALID ) != 0 ) {
3750 if (memcmp (buf -> data , mock_iso_data , buf -> len ) == 0 ) {
3851 test_stream -> valid_rx_cnt ++ ;
52+ last_failed = false;
3953
4054 if (test_stream -> valid_rx_cnt >= MIN_SEND_COUNT ) {
41- /* We set the flag is just one stream has received the expected */
42- SET_FLAG (flag_audio_received );
55+ SET_FLAG (test_stream -> flag_audio_received );
4356 }
4457 } else {
45- log_stream_rx ( stream , info , buf );
58+ log_stream_err ( test_stream , info , buf );
4659 FAIL ("Unexpected data received\n" );
4760 }
4861 }
4962
50- if ((test_stream -> rx_cnt % 50U ) == 0U ) {
63+ if ((test_stream -> rx_cnt % LOG_INTERVAL ) == 0U ) {
5164 log_stream_rx (stream , info , buf );
5265 }
5366
67+ if (test_stream -> rx_cnt >= LOG_INTERVAL && test_stream -> valid_rx_cnt == 0U ) {
68+ log_stream_err (test_stream , info , buf );
69+
70+ FAIL ("No valid RX received: %zu/%zu\n" , test_stream -> valid_rx_cnt ,
71+ test_stream -> rx_cnt );
72+ }
73+
5474 if (info -> ts == test_stream -> last_info .ts ) {
55- log_stream_rx (stream , info , buf );
75+ log_stream_err (test_stream , info , buf );
76+
5677 if (test_stream -> valid_rx_cnt > 1U ) {
5778 FAIL ("Duplicated timestamp received: %u\n" , test_stream -> last_info .ts );
5879 }
5980 }
6081
6182 if (info -> seq_num == test_stream -> last_info .seq_num ) {
62- log_stream_rx (stream , info , buf );
83+ log_stream_err (test_stream , info , buf );
84+
6385 if (test_stream -> valid_rx_cnt > 1U ) {
6486 FAIL ("Duplicated PSN received: %u\n" , test_stream -> last_info .seq_num );
6587 }
6688 }
6789
6890 if (info -> flags & BT_ISO_FLAGS_ERROR ) {
6991 /* Fail the test if we have not received what we expected */
70- log_stream_rx (stream , info , buf );
71- if (test_stream -> valid_rx_cnt > 1U && !TEST_FLAG (flag_audio_received )) {
92+ log_stream_err (test_stream , info , buf );
93+
94+ if (test_stream -> valid_rx_cnt > 1U &&
95+ !TEST_FLAG (test_stream -> flag_audio_received )) {
7296 FAIL ("ISO receive error\n" );
7397 }
7498 }
7599
76100 if (info -> flags & BT_ISO_FLAGS_LOST ) {
77- log_stream_rx (stream , info , buf );
101+ log_stream_err (test_stream , info , buf );
102+
78103 if (test_stream -> valid_rx_cnt > 1U ) {
79104 FAIL ("ISO receive lost\n" );
80105 }
0 commit comments