vlc | branch: master | Steve Lhomme <[email protected]> | Thu Sep 17 16:50:38 
2020 +0200| [bd23210b5e0a0c1b0e662c2d7b5dab6bcf5aac78] | committer: Steve Lhomme

snapshot: use a FIFO to store the pending pictures to export

Since the snapshot keeps a reference to the picture to export, it's not made
available to the decoder until the export is done. It's better to release
pictures in the receiving order to match the decoder.

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

 src/video_output/snapshot.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/video_output/snapshot.c b/src/video_output/snapshot.c
index 2ee2d55432..7afe460217 100644
--- a/src/video_output/snapshot.c
+++ b/src/video_output/snapshot.c
@@ -47,6 +47,7 @@ struct vout_snapshot {
     bool        is_available;
     int         request_count;
     picture_t   *picture;
+    picture_t   *tail;
 
 };
 
@@ -62,6 +63,7 @@ vout_snapshot_t *vout_snapshot_New(void)
     snap->is_available = true;
     snap->request_count = 0;
     snap->picture = NULL;
+    snap->tail = NULL;
     return snap;
 }
 
@@ -70,11 +72,10 @@ 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 = snap->picture;
+        snap->picture = picture->p_next;
         picture_Release(picture);
-        picture = next;
     }
 
     free(snap);
@@ -153,8 +154,16 @@ void vout_snapshot_Set(vout_snapshot_t *snap,
 
         video_format_CopyCrop( &dup->format, fmt );
 
-        dup->p_next = snap->picture;
-        snap->picture = dup;
+        if (snap->picture == NULL)
+        {
+            snap->picture = dup;
+            snap->tail = dup;
+        }
+        else
+        {
+            snap->tail->p_next = dup;
+            snap->tail =  dup;
+        }
         snap->request_count--;
     }
     vlc_cond_broadcast(&snap->wait);

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to