[vlc-devel] [PATCH v2 09/24] picture_fifo: use the picture_chain API
Steve Lhomme
robux4 at ycbcr.xyz
Fri Sep 18 16:45:15 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 f9e67a67663..966a4d5c30a 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_has_chained_pics(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)
@@ -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 = 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