[vlc-devel] [PATCH 1/4] vout: drop pictures owned by old vouts

Thomas Guillem thomas at gllm.fr
Sun Sep 24 11:34:56 CEST 2017


See FIXME comment.
---
 include/vlc_picture_pool.h      |  7 +++++++
 src/misc/picture_pool.c         |  8 ++++++++
 src/video_output/video_output.c | 14 ++++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/include/vlc_picture_pool.h b/include/vlc_picture_pool.h
index 679e98682c..8b04370bfb 100644
--- a/include/vlc_picture_pool.h
+++ b/include/vlc_picture_pool.h
@@ -155,6 +155,13 @@ VLC_API void picture_pool_Enum( picture_pool_t *,
 void picture_pool_Cancel( picture_pool_t *, bool canceled );
 
 /**
+ * Test if a picture belongs to the picture pool
+ *
+ * FIXME: remove this function when the vout_PutPicture() hack is fixed.
+ */
+bool picture_pool_OwnsPic( picture_pool_t *, picture_t *);
+
+/**
  * Reserves pictures from a pool and creates a new pool with those.
  *
  * When the new pool is released, pictures are returned to the master pool.
diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
index 17bf3b7b82..bb957c4af5 100644
--- a/src/misc/picture_pool.c
+++ b/src/misc/picture_pool.c
@@ -296,6 +296,14 @@ void picture_pool_Cancel(picture_pool_t *pool, bool canceled)
     vlc_mutex_unlock(&pool->lock);
 }
 
+bool picture_pool_OwnsPic(picture_pool_t *pool, picture_t *pic)
+{
+    picture_priv_t *priv = (picture_priv_t *)pic;
+    uintptr_t sys = (uintptr_t)priv->gc.opaque;
+    picture_pool_t *picpool = (void *)(sys & ~(POOL_MAX - 1));
+    return pool == picpool;
+}
+
 unsigned picture_pool_GetSize(const picture_pool_t *pool)
 {
     return pool->picture_count;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index c432c70aa0..efb342de9f 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -425,9 +425,19 @@ picture_t *vout_GetPicture(vout_thread_t *vout)
 void vout_PutPicture(vout_thread_t *vout, picture_t *picture)
 {
     picture->p_next = NULL;
-    picture_fifo_Push(vout->p->decoder_fifo, picture);
+    if (picture_pool_OwnsPic(vout->p->decoder_pool, picture))
+    {
+        picture_fifo_Push(vout->p->decoder_fifo, picture);
 
-    vout_control_Wake(&vout->p->control);
+        vout_control_Wake(&vout->p->control);
+    }
+    else
+    {
+        /* FIXME: HACK: Drop this picture because the vout changed. The old
+         * picture pool need to be kept by the new vout. This requires a major
+         * "vout display" API change. */
+        picture_Release(picture);
+    }
 }
 
 /* */
-- 
2.11.0



More information about the vlc-devel mailing list