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

Steve Lhomme robux4 at ycbcr.xyz
Thu Aug 13 14:12:48 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.
---
 src/video_output/control.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/video_output/control.c b/src/video_output/control.c
index a4f92771eda..be70abea9c8 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,16 @@ int vout_control_Pop(vout_control_t *ctrl, vout_control_cmd_t *cmd,
     vlc_mutex_lock(&ctrl->lock);
 
     if (deadline != INVALID_DEADLINE) {
-        while (ctrl->cmd.i_size <= 0 && ctrl->can_sleep) {
+        while (ctrl->cmd.i_size <= 0 && ctrl->can_sleep && !ctrl->is_dead) {
             if (vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline))
                 break;
         }
     }
 
     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