[vlc-devel] [PATCH v3 8/8] RFC video_output:control: move the is_held wait in control_Pop

Steve Lhomme robux4 at ycbcr.xyz
Fri Dec 18 06:42:14 UTC 2020


The only way is_held can become true is when control_Hold passed. And for
control_Hold to pass, is_waiting has to become true. This only way this can
happen is during the wait with a deadline. So we can narrow the is_held wait
to that part of the code.

As correct as it may be, this shows that when there is no deadline (frame by
frame mode, no displayed.current yet on start/after a flush, render delayed)
the control_Pop is non blocking and can cause the vout thread to loop a lot.
---
 src/video_output/control.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/video_output/control.c b/src/video_output/control.c
index c5b14887ecb..422e3f6f101 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -94,12 +94,12 @@ int vout_control_Pop(vout_control_t *ctrl, vlc_mouse_t *mouse, vlc_tick_t deadli
             vlc_cond_signal(&ctrl->wait_available);
             vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline);
             ctrl->is_waiting = false;
+
+            while (ctrl->is_held)
+                vlc_cond_wait(&ctrl->wait_available, &ctrl->lock);
         }
     }
 
-    while (ctrl->is_held)
-        vlc_cond_wait(&ctrl->wait_available, &ctrl->lock);
-
     if (ctrl->cmd.i_size > 0) {
         has_cmd = true;
         *mouse = ARRAY_VAL(ctrl->cmd, 0);
-- 
2.29.2



More information about the vlc-devel mailing list