[vlc-commits] video_output:control: rename can_sleep to forced_awake

Steve Lhomme git at videolan.org
Tue Jan 19 08:56:46 UTC 2021


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Dec 18 08:15:15 2020 +0100| [6ec7b9635c22854b59ff6227f02f287bb38715a9] | committer: Steve Lhomme

video_output:control: rename can_sleep to forced_awake

Invert the values as it means the opposite.
Explain why we keep forced_awake true while there are pending mouse events in
the FIFO.

This might also be handled out of control.c. The wake could just cause the
cond_timedwait to exit but the state to ignore the deadline and keep popping
mouse states from the control FIFO could be handled in video_output.c.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ec7b9635c22854b59ff6227f02f287bb38715a9
---

 src/video_output/control.c | 11 +++++++----
 src/video_output/control.h |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/video_output/control.c b/src/video_output/control.c
index c5b14887ec..5d72caf60e 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -38,7 +38,7 @@ void vout_control_Init(vout_control_t *ctrl)
 
     ctrl->is_held = false;
     ctrl->is_waiting = false;
-    ctrl->can_sleep = true;
+    ctrl->forced_awake = false;
     ARRAY_INIT(ctrl->cmd);
 }
 
@@ -59,7 +59,7 @@ void vout_control_PushMouse(vout_control_t *ctrl, const vlc_mouse_t *video_mouse
 void vout_control_Wake(vout_control_t *ctrl)
 {
     vlc_mutex_lock(&ctrl->lock);
-    ctrl->can_sleep = false;
+    ctrl->forced_awake = true;
     vlc_cond_signal(&ctrl->wait_request);
     vlc_mutex_unlock(&ctrl->lock);
 }
@@ -89,7 +89,7 @@ int vout_control_Pop(vout_control_t *ctrl, vlc_mouse_t *mouse, vlc_tick_t deadli
 
     if (ctrl->cmd.i_size <= 0) {
         /* Spurious wakeups are perfectly fine */
-        if (deadline != VLC_TICK_INVALID && ctrl->can_sleep) {
+        if (deadline != VLC_TICK_INVALID && !ctrl->forced_awake) {
             ctrl->is_waiting = true;
             vlc_cond_signal(&ctrl->wait_available);
             vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline);
@@ -104,8 +104,11 @@ int vout_control_Pop(vout_control_t *ctrl, vlc_mouse_t *mouse, vlc_tick_t deadli
         has_cmd = true;
         *mouse = ARRAY_VAL(ctrl->cmd, 0);
         ARRAY_REMOVE(ctrl->cmd, 0);
+        // keep forced_awake set, if it is, so we report all mouse states we have
+        // after we were awaken when a new picture has been pushed by the decoder
+        // see vout_control_Wake
     } else {
-        ctrl->can_sleep = true;
+        ctrl->forced_awake = false;
     }
     vlc_mutex_unlock(&ctrl->lock);
 
diff --git a/src/video_output/control.h b/src/video_output/control.h
index 35e8aad652..e85af59236 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -32,7 +32,7 @@ typedef struct {
     vlc_cond_t  wait_available;
 
     /* */
-    bool can_sleep;
+    bool forced_awake;
     bool is_waiting;
     bool is_held;
     DECL_ARRAY(vlc_mouse_t) cmd;



More information about the vlc-commits mailing list