[vlc-devel] [PATCH v2 7/7] vout/control: don't return new commands if the queue is dead

Steve Lhomme robux4 at ycbcr.xyz
Fri Aug 14 11:57:32 CEST 2020


Also forbid waiting in the next calls if the queue is dead.

And signal the control pop to stop waiting so we can exit quickly.

There are no more spurious calls possible. At least one value of the if is
modified when signaling wait_request.
---
 src/video_output/control.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/video_output/control.c b/src/video_output/control.c
index 6f038255738..5a7a370d7cf 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -71,6 +71,8 @@ void vout_control_Dead(vout_control_t *ctrl)
 {
     vlc_mutex_lock(&ctrl->lock);
     ctrl->is_dead = true;
+    ctrl->can_sleep = false;
+    vlc_cond_signal(&ctrl->wait_request);
     vlc_mutex_unlock(&ctrl->lock);
 }
 
@@ -135,13 +137,15 @@ int vout_control_Pop(vout_control_t *ctrl, vout_control_cmd_t *cmd,
     vlc_mutex_lock(&ctrl->lock);
 
     if (deadline != INVALID_DEADLINE) {
-        /* Spurious wakeups are perfectly fine */
-        if (ctrl->cmd.i_size <= 0 && ctrl->can_sleep) {
+        if (ctrl->cmd.i_size <= 0 && ctrl->can_sleep && !ctrl->is_dead) {
             vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline);
         }
     }
 
     int ret;
+    if (ctrl->is_dead)
+        ret = VLC_EGENERIC;
+    else
     if (ctrl->cmd.i_size > 0) {
         ret = VLC_SUCCESS;
         *cmd = ARRAY_VAL(ctrl->cmd, 0);
-- 
2.26.2



More information about the vlc-devel mailing list