[vlc-commits] vout: remove unnecessary lock around the picture FIFO

Rémi Denis-Courmont git at videolan.org
Sat Nov 1 10:31:46 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct 30 22:55:27 2014 +0200| [98f3a7b37d290c3b003eda65b56d619fa30aba9d] | committer: Rémi Denis-Courmont

vout: remove unnecessary lock around the picture FIFO

The picture FIFO has a lock internally to protect its internal state
while picture references protect the pictures.

There is no need to protect the FIFO usage with the picture lock.
At this point, the picture lock is only protected the decoder pool.

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

 src/video_output/video_output.c |   41 ++++++++++++++-------------------------
 1 file changed, 15 insertions(+), 26 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 83df593..32d0915 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -330,43 +330,36 @@ void vout_Reset(vout_thread_t *vout)
 
 bool vout_IsEmpty(vout_thread_t *vout)
 {
-    vlc_mutex_lock(&vout->p->picture_lock);
-
     picture_t *picture = picture_fifo_Peek(vout->p->decoder_fifo);
     if (picture)
         picture_Release(picture);
 
-    vlc_mutex_unlock(&vout->p->picture_lock);
-
     return !picture;
 }
 
 void vout_FixLeaks( vout_thread_t *vout )
 {
-    vlc_mutex_lock(&vout->p->picture_lock);
-
     picture_t *picture = picture_fifo_Peek(vout->p->decoder_fifo);
-    if (!picture) {
-        picture = picture_pool_Get(vout->p->decoder_pool);
-    }
-
-    if (picture) {
+    if (picture != NULL) {
         picture_Release(picture);
-        /* Not all pictures has been displayed yet or some are
-         * free */
-        vlc_mutex_unlock(&vout->p->picture_lock);
-        return;
-    }
-
-    /* There is no reason that no pictures are available, force one
-     * from the pool, becarefull with it though */
-    msg_Err(vout, "pictures leaked, trying to workaround");
+        return; /* Not all pictures has been displayed yet */
 
-    /* */
-    picture_pool_NonEmpty(vout->p->decoder_pool);
+    }
 
+    vlc_mutex_lock(&vout->p->picture_lock);
+    picture = picture_pool_Get(vout->p->decoder_pool);
+
+    if (picture != NULL)
+        picture_Release(picture); /* Not all pictures are referenced */
+    else {
+        /* There are no reasons that no pictures are available, force one
+         * from the pool, be careful with it though */
+        msg_Err(vout, "pictures leaked, trying to workaround");
+        picture_pool_NonEmpty(vout->p->decoder_pool);
+    }
     vlc_mutex_unlock(&vout->p->picture_lock);
 }
+
 void vout_NextPicture(vout_thread_t *vout, mtime_t *duration)
 {
     vout_control_cmd_t cmd;
@@ -441,13 +434,9 @@ picture_t *vout_GetPicture(vout_thread_t *vout)
  */
 void vout_PutPicture(vout_thread_t *vout, picture_t *picture)
 {
-    vlc_mutex_lock(&vout->p->picture_lock);
-
     picture->p_next = NULL;
     picture_fifo_Push(vout->p->decoder_fifo, picture);
 
-    vlc_mutex_unlock(&vout->p->picture_lock);
-
     vout_control_Wake(&vout->p->control);
 }
 



More information about the vlc-commits mailing list