[vlc-devel] [PATCH v2 16/24] snapshot: use the picture_chain API

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 18 16:45:22 CEST 2020


snap->picture represents the picture chain.

Unlike other picture chains, this one adds pictures at the front of the chain.
---
 src/video_output/snapshot.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/video_output/snapshot.c b/src/video_output/snapshot.c
index 2ee2d55432c..843b6a8aaad 100644
--- a/src/video_output/snapshot.c
+++ b/src/video_output/snapshot.c
@@ -70,11 +70,9 @@ void vout_snapshot_Destroy(vout_snapshot_t *snap)
     if (snap == NULL)
         return;
 
-    picture_t *picture = snap->picture;
-    while (picture) {
-        picture_t *next = picture->p_next;
+    while (snap->picture) {
+        picture_t *picture = picture_chain_pop_front( &snap->picture );
         picture_Release(picture);
-        picture = next;
     }
 
     free(snap);
@@ -107,14 +105,12 @@ picture_t *vout_snapshot_Get(vout_snapshot_t *snap, vlc_tick_t timeout)
     snap->request_count++;
 
     /* */
-    while (snap->is_available && !snap->picture &&
+    while (snap->is_available && !snap->picture) &&
         vlc_cond_timedwait(&snap->wait, &snap->lock, deadline) == 0);
 
     /* */
-    picture_t *picture = snap->picture;
-    if (picture)
-        snap->picture = picture->p_next;
-    else if (snap->request_count > 0)
+    picture_t *picture = picture_chain_pop_chain( &snap->picture );
+    if (!picture && snap->request_count > 0)
         snap->request_count--;
 
     vlc_mutex_unlock(&snap->lock);
@@ -153,8 +149,7 @@ void vout_snapshot_Set(vout_snapshot_t *snap,
 
         video_format_CopyCrop( &dup->format, fmt );
 
-        dup->p_next = snap->picture;
-        snap->picture = dup;
+        picture_chain_prepend( &snap->picture, dup );
         snap->request_count--;
     }
     vlc_cond_broadcast(&snap->wait);
-- 
2.26.2



More information about the vlc-devel mailing list