Skip to content

Commit febd738

Browse files
W-Maixiaoxiang781216
authored andcommitted
nxaudio: fix audio stop logic to prevent buffer addition after STOP signal
- Ensure `AUDIO_STOP` via `ioctrl` is followed by `mq_send STOP` without race conditions. - Modify loop condition to correctly handle `running = false` upon receiving STOP signal. - Resolve potential issue where `AUDIO_MSG_DEQUEUE` could still accept buffers after STOP signal due to timing. Before: - `nxaudio_stop` would call `ioctrl AUDIO_STOP` followed by `mq_send STOP`, which might lead to `AUDIO_MSG_DEQUEUE` accepting buffers after STOP. After: - Synchronized the sequence of `ioctrl AUDIO_STOP` and `mq_send STOP` to prevent buffer addition after STOP. - Enhanced loop condition to accurately reflect the STOP state. Signed-off-by: xinbingnan <[email protected]>
1 parent 40a5e47 commit febd738

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

audioutils/nxaudio/nxaudio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ int nxaudio_stop(FAR struct nxaudio_s *nxaudio)
282282
{
283283
struct audio_msg_s term_msg;
284284

285-
ioctl(nxaudio->fd, AUDIOIOC_STOP, 0);
286-
287285
term_msg.msg_id = AUDIO_MSG_STOP;
288286
term_msg.u.data = 0;
289287
mq_send(nxaudio->mq, (FAR const char *)&term_msg, sizeof(term_msg), 0);
290288

289+
ioctl(nxaudio->fd, AUDIOIOC_STOP, 0);
290+
291291
return OK;
292292
}
293293

0 commit comments

Comments
 (0)