Skip to content

Commit 4321fef

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: Audio: Ensure that stream is in streaming state for ISO recv
Adds check to verify that the audio stream is actually in the streaming state before handling the audio data. As per the BAP spec, a stream that is not in the streaming state shall not send any data, and this check is to handle any remote devices that are not working correctly. Signed-off-by: Emil Gydesen <[email protected]>
1 parent fb43a48 commit 4321fef

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

subsys/bluetooth/audio/ascs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,19 @@ static void ascs_iso_recv(struct bt_iso_chan *chan,
458458
return;
459459
}
460460

461+
/* Since 2 streams can share the same CIS, the CIS may be connected and
462+
* capable of transferring data, without the bt_audio_stream being in
463+
* the streaming state. In that case we simply ignore the data.
464+
*/
465+
if (stream->ep->status.state != BT_AUDIO_EP_STATE_STREAMING) {
466+
if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) {
467+
BT_DBG("Stream %p is not in the streaming state: %u",
468+
stream, stream->ep->status.state);
469+
}
470+
471+
return;
472+
}
473+
461474
ops = stream->ops;
462475

463476
if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) {

subsys/bluetooth/audio/unicast_client.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ static void unicast_client_ep_iso_recv(struct bt_iso_chan *chan,
9595
return;
9696
}
9797

98+
/* Since 2 streams can share the same CIS, the CIS may be connected and
99+
* capable of transferring data, without the bt_audio_stream being in
100+
* the streaming state. In that case we simply ignore the data.
101+
*/
102+
if (stream->ep->status.state != BT_AUDIO_EP_STATE_STREAMING) {
103+
if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) {
104+
BT_DBG("Stream %p is not in the streaming state: %u",
105+
stream, stream->ep->status.state);
106+
}
107+
108+
return;
109+
}
110+
98111
ops = stream->ops;
99112

100113
if (IS_ENABLED(CONFIG_BT_AUDIO_DEBUG_STREAM_DATA)) {

0 commit comments

Comments
 (0)