casaroli commented on code in PR #21910:
URL: https://github.com/apache/nuttx/pull/21910#discussion_r4659121864


##########
audio/audio.c:
##########
@@ -89,6 +89,7 @@ struct audio_upperhalf_s
 {
   struct audio_info_s          info;     /* Record the last playing audio 
format */
   mutex_t                      lock;     /* Supports mutual exclusion */
+  mutex_t                      mqlock;   /* Keeps the opens for a thread that 
sends */

Review Comment:
   `AUDIOIOC_STOP` calls the lower half with `upper->lock` held (audio.c:1032 
to 1404), and `wm8904_stop()` joins its worker thread (wm8904.c:1649). On its 
way out the worker sends `AUDIO_CALLBACK_DEQUEUE` and `AUDIO_CALLBACK_COMPLETE` 
(wm8904.c:2160-2182) from that other thread, so with a recursive `upper->lock` 
the worker waits for the lock and the stop waits for the worker. `mqlock` is 
not held across the lower half, so it does not deadlock.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to