[vlc-devel] [PATCH] vout: set the thread in sleep state when a deadline is provided

Felix Abecassis felix.abecassis at gmail.com
Tue Feb 18 19:04:53 CET 2014


Previously, the is_sleeping flag was not set to true if a deadline was
passed to vout_control_Pop. Consequently, the condition variable would
not be signalled by function vout_control_Wake, called by
vout_PutPicture to give a vout a picture to display. Thus, the vout
would not wake up even when receiving several pictures, instead the
vout waits until the end of the deadline. If the deadline was computed
as the "refresh" deadline from ThreadDisplayPicture, the sleep time
can be as high as 60-70 ms.
---
 src/video_output/control.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/video_output/control.c b/src/video_output/control.c
index 930e09b..c880775 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -189,14 +189,14 @@ int vout_control_Pop(vout_control_t *ctrl, vout_control_cmd_t *cmd,
         const mtime_t max_deadline = mdate() + timeout;
 
         /* Supurious wake up are perfectly fine */
-        if (deadline <= VLC_TS_INVALID) {
-            ctrl->is_sleeping = true;
-            if (ctrl->can_sleep)
+        ctrl->is_sleeping = true;
+        if (ctrl->can_sleep) {
+            if (deadline <= VLC_TS_INVALID)
                 vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, max_deadline);
-            ctrl->is_sleeping = false;
-        } else {
-            vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, __MIN(deadline, max_deadline));
+            else
+                vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, __MIN(deadline, max_deadline));
         }
+        ctrl->is_sleeping = false;
     }
 
     bool has_cmd;
-- 
1.8.3.2




More information about the vlc-devel mailing list