[vlc-devel] [PATCH 09/22] picture_fifo: use the picture_chain API

Steve Lhomme robux4 at ycbcr.xyz
Thu Sep 17 17:33:31 CEST 2020


fifo->first represents the picture chain and fifo->tail the tail that is used
to append pictures.
---
 src/misc/picture_fifo.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/misc/picture_fifo.c b/src/misc/picture_fifo.c
index a63ab88623d..f67202c31b7 100644
--- a/src/misc/picture_fifo.c
+++ b/src/misc/picture_fifo.c
@@ -49,7 +49,7 @@ static void PictureFifoReset(picture_fifo_t *fifo)
 }
 static void PictureFifoPush(picture_fifo_t *fifo, picture_t *picture)
 {
-    assert(!picture->p_next);
+    assert(picture_chain_empty(picture));
     if (fifo->first == NULL)
     {
         fifo->first = picture;
@@ -57,20 +57,12 @@ static void PictureFifoPush(picture_fifo_t *fifo, picture_t *picture)
     }
     else
     {
-        fifo->tail->p_next = picture;
-        fifo->tail =  picture;
-        picture->p_next = NULL; // we're appending a picture, not a chain
+        fifo->tail = picture_chain_append( fifo->tail, picture );
     }
 }
 static picture_t *PictureFifoPop(picture_fifo_t *fifo)
 {
-    if (fifo->first == NULL)
-        return NULL;
-
-    picture_t *picture = fifo->first;
-    fifo->first = picture->p_next;
-    picture->p_next = NULL;
-    return picture;
+    return picture_chain_pop_front( &fifo->first );
 }
 
 picture_fifo_t *picture_fifo_New(void)
@@ -114,17 +106,15 @@ void picture_fifo_Flush(picture_fifo_t *fifo, vlc_tick_t date, bool flush_before
 
     vlc_mutex_lock(&fifo->lock);
 
-    picture_t *old_fifo = fifo->first;
+    picture_t *old_chain = fifo->first;
     PictureFifoReset(fifo);
 
     picture_fifo_t tmp;
     PictureFifoReset(&tmp);
 
-    while (old_fifo) {
-        picture = old_fifo;
-        old_fifo = old_fifo->p_next;
+    while (old_chain) {
+        picture_t *picture = picture_chain_pop_front( &old_chain );
 
-        picture->p_next = NULL;
         if ((date == VLC_TICK_INVALID) ||
             ( flush_before && picture->date <= date) ||
             (!flush_before && picture->date >= date))
-- 
2.26.2



More information about the vlc-devel mailing list