[vlc-devel] [PATCH v2 12/13] video_output: replace control deadline wait for a picture with internal lock

Steve Lhomme robux4 at ycbcr.xyz
Mon Aug 17 15:15:31 CEST 2020


The picture push replaces the vout_control_Wake with a conditional signal.

vout_control_Dead() is not needed anymore since we never push commands anymore.
---
 src/video_output/video_output.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 8d1c3cab9fb..27034cb3eca 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -503,7 +503,6 @@ void vout_PutPicture(vout_thread_t *vout, picture_t *picture)
     vlc_mutex_lock(&sys->control_lock);
     picture_fifo_Push(sys->decoder_fifo, picture);
     vlc_cond_signal(&sys->has_pictures);
-    vout_control_Wake(&sys->control);
     vlc_mutex_unlock(&sys->control_lock);
 }
 
@@ -1889,8 +1888,6 @@ static void *Thread(void *object)
     bool wait = false;
 
     for (;;) {
-        vout_control_cmd_t cmd;
-
         if (wait)
         {
             if (deadline != INVALID_DEADLINE)
@@ -1902,16 +1899,17 @@ static void *Thread(void *object)
         }
 
         vlc_mutex_lock(&sys->control_lock);
-        while (!vout_control_Pop(&sys->control, &cmd, deadline,
-                                 &sys->has_pictures, &sys->control_lock)) {
-            if (atomic_load(&sys->terminate))
-            {
-                vlc_mutex_unlock(&sys->control_lock);
-                return NULL;
-            }
-        }
+        picture_t *peek = picture_fifo_Peek(sys->decoder_fifo);
+        if (peek)
+            picture_Release(peek);
+        else
+            // wait until a new picture comes in or until the deadline
+            vlc_cond_timedwait(&sys->has_pictures, &sys->control_lock, deadline);
         vlc_mutex_unlock(&sys->control_lock);
 
+        if (atomic_load(&sys->terminate))
+            return NULL;
+
         wait = ThreadDisplayPicture(vout, &deadline) != VLC_SUCCESS;
 
         if (atomic_load(&sys->terminate))
-- 
2.26.2



More information about the vlc-devel mailing list