[vlc-devel] [PATCH 2/2] picture_fifo: replace picture_fifo_Peek with picture_fifo_IsEmpty

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 18 16:29:37 CEST 2020


The only use of picture_fifo_Peek() is to check whether the FIFO is empty.
No need to get a picture and release it just after for that.
---
 include/vlc_picture_fifo.h      | 8 ++------
 src/libvlccore.sym              | 2 +-
 src/misc/picture_fifo.c         | 8 +++-----
 src/video_output/video_output.c | 6 +-----
 4 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/include/vlc_picture_fifo.h b/include/vlc_picture_fifo.h
index a5b44e9d877..bb91095ae6d 100644
--- a/include/vlc_picture_fifo.h
+++ b/include/vlc_picture_fifo.h
@@ -57,13 +57,9 @@ VLC_API void picture_fifo_Delete( picture_fifo_t * );
 VLC_API picture_t * picture_fifo_Pop( picture_fifo_t * ) VLC_USED;
 
 /**
- * It returns the first picture_t pointer from the fifo but does not
- * remove it. The picture returned has been hold for you so you
- * must call picture_Release on it.
- *
- * If the fifo is empty, it return NULL without waiting.
+ * It returns whether the fifo is empty or not.
  */
-VLC_API picture_t * picture_fifo_Peek( picture_fifo_t * ) VLC_USED;
+VLC_API bool picture_fifo_IsEmpty( picture_fifo_t * );
 
 /**
  * It saves a picture_t into the fifo.
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index d82da661f5d..0aefc04500a 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -309,7 +309,7 @@ picture_Export
 picture_fifo_Delete
 picture_fifo_Flush
 picture_fifo_New
-picture_fifo_Peek
+picture_fifo_IsEmpty
 picture_fifo_Pop
 picture_fifo_Push
 picture_New
diff --git a/src/misc/picture_fifo.c b/src/misc/picture_fifo.c
index 3c0f6d3df9e..f75ae5b2637 100644
--- a/src/misc/picture_fifo.c
+++ b/src/misc/picture_fifo.c
@@ -91,15 +91,13 @@ picture_t *picture_fifo_Pop(picture_fifo_t *fifo)
 
     return picture;
 }
-picture_t *picture_fifo_Peek(picture_fifo_t *fifo)
+bool picture_fifo_IsEmpty(picture_fifo_t *fifo)
 {
     vlc_mutex_lock(&fifo->lock);
-    picture_t *picture = fifo->first;
-    if (picture)
-        picture_Hold(picture);
+    bool empty = fifo->first == NULL;
     vlc_mutex_unlock(&fifo->lock);
 
-    return picture;
+    return empty;
 }
 void picture_fifo_Flush(picture_fifo_t *fifo, vlc_tick_t date, bool flush_before)
 {
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index dc5e602002e..16c3b95dab4 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -364,11 +364,7 @@ bool vout_IsEmpty(vout_thread_t *vout)
     if (!sys->decoder_fifo)
         return true;
 
-    picture_t *picture = picture_fifo_Peek(sys->decoder_fifo);
-    if (picture)
-        picture_Release(picture);
-
-    return !picture;
+    return picture_fifo_IsEmpty(sys->decoder_fifo);
 }
 
 void vout_DisplayTitle(vout_thread_t *vout, const char *title)
-- 
2.26.2



More information about the vlc-devel mailing list