[vlc-commits] picture_fifo: use the picture_chain API

Steve Lhomme git at videolan.org
Wed Sep 23 16:17:54 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Sep 17 16:30:13 2020 +0200| [f2a87539c333b9027ec2deb1ec449719c4dbdfe2] | committer: Steve Lhomme

picture_fifo: use the picture_chain API

fifo->first represents the picture chain and fifo->tail the tail that is used
to append pictures.

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

 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 46838669e2..2e6c227e79 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_HasChainedPics(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 = vlc_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 vlc_picture_chain_PopFront( &fifo->first );
 }
 
 picture_fifo_t *picture_fifo_New(void)
@@ -112,17 +104,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 = vlc_picture_chain_PopFront( &old_chain );
 
-        picture->p_next = NULL;
         if ((date == VLC_TICK_INVALID) ||
             ( flush_before && picture->date <= date) ||
             (!flush_before && picture->date >= date))



More information about the vlc-commits mailing list