Request minimum buffer even if need_pool is FALSE
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 5 Sep 2017 20:20:44 +0000 (16:20 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 6 Sep 2017 18:19:37 +0000 (14:19 -0400)
When tee is used, it will not request a pool, but still it wants to
know how many buffers are required.

https://bugzilla.gnome.org/show_bug.cgi?id=730758

12 files changed:
ext/directfb/dfbvideosink.c
ext/gl/caopengllayersink.m
ext/gl/gstglimagesink.c
ext/gl/gstglmixer.c
ext/gtk/gstgtkglsink.c
ext/qt/gstqtsink.cc
ext/vulkan/vkupload.c
ext/wayland/gstwaylandsink.c
gst-libs/gst/gl/gstglfilter.c
sys/applemedia/avsamplevideosink.m
sys/d3dvideosink/d3dvideosink.c
sys/kms/gstkmssink.c

index 2a7cfee..ae21b1b 100644 (file)
@@ -2273,6 +2273,12 @@ gst_dfbvideosink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
 
   gst_query_parse_allocation (query, &caps, &need_pool);
 
+  if (!caps) {
+    GST_WARNING_OBJECT (dfbvideosink, "Missing caps in allocation query.");
+    return FALSE;
+  }
+
+  /* FIXME re-using buffer pool breaks renegotiation */
   if ((pool = dfbvideosink->pool))
     gst_object_ref (pool);
 
@@ -2293,6 +2299,16 @@ gst_dfbvideosink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
       return FALSE;
     }
     gst_structure_free (config);
+  } else {
+    GstVideoInfo info;
+
+    if (!gst_video_info_from_caps (caps)) {
+      GST_WARNING_OBJECT (dfbvideosink,
+          "Invalid video caps in allocation query");
+      return FALSE;
+    }
+
+    size = info.size;
   }
 
   gst_query_add_allocation_pool (query, pool, size, 1, 0);
index fc96258..eccc872 100644 (file)
@@ -730,6 +730,7 @@ gst_ca_opengl_layer_sink_propose_allocation (GstBaseSink * bsink, GstQuery * que
   GstBufferPool *pool = NULL;
   GstStructure *config;
   GstCaps *caps;
+  GstVideoInfo info;
   guint size;
   gboolean need_pool;
 
@@ -741,15 +742,13 @@ gst_ca_opengl_layer_sink_propose_allocation (GstBaseSink * bsink, GstQuery * que
   if (caps == NULL)
     goto no_caps;
 
-  if (need_pool) {
-    GstVideoInfo info;
-
-    if (!gst_video_info_from_caps (&info, caps))
-      goto invalid_caps;
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
 
-    /* the normal size of a frame */
-    size = info.size;
+  /* the normal size of a frame */
+  size = info.size;
 
+  if (need_pool) {
     GST_DEBUG_OBJECT (ca_sink, "create new pool");
 
     pool = gst_gl_buffer_pool_new (ca_sink->context);
@@ -758,11 +757,12 @@ gst_ca_opengl_layer_sink_propose_allocation (GstBaseSink * bsink, GstQuery * que
 
     if (!gst_buffer_pool_set_config (pool, config))
         goto config_failed;
+  }
 
-    /* we need at least 2 buffer because we hold on to the last one */
-    gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  /* we need at least 2 buffer because we hold on to the last one */
+  gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  if (pool)
     gst_object_unref (pool);
-  }
 
   if (ca_sink->context->gl_vtable->FenceSync)
     gst_query_add_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, 0);
index 71668f6..01fb181 100644 (file)
@@ -1844,6 +1844,8 @@ gst_glimage_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
   GstGLImageSink *glimage_sink = GST_GLIMAGE_SINK (bsink);
   GstStructure *config;
   GstCaps *caps;
+  GstBufferPool *pool = NULL;
+  GstVideoInfo info;
   guint size;
   gboolean need_pool;
   GstStructure *allocation_meta = NULL;
@@ -1856,16 +1858,13 @@ gst_glimage_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
   if (caps == NULL)
     goto no_caps;
 
-  if (need_pool) {
-    GstBufferPool *pool;
-    GstVideoInfo info;
-
-    if (!gst_video_info_from_caps (&info, caps))
-      goto invalid_caps;
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
 
-    /* the normal size of a frame */
-    size = info.size;
+  /* the normal size of a frame */
+  size = info.size;
 
+  if (need_pool) {
     GST_DEBUG_OBJECT (glimage_sink, "create new pool");
 
     pool = gst_gl_buffer_pool_new (glimage_sink->context);
@@ -1878,11 +1877,12 @@ gst_glimage_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
       g_object_unref (pool);
       goto config_failed;
     }
+  }
 
-    /* we need at least 2 buffer because we hold on to the last one */
-    gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  /* we need at least 2 buffer because we hold on to the last one */
+  gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  if (pool)
     g_object_unref (pool);
-  }
 
   if (glimage_sink->context->gl_vtable->FenceSync)
     gst_query_add_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, 0);
index c048661..af9de45 100644 (file)
@@ -140,10 +140,10 @@ gst_gl_mixer_propose_allocation (GstAggregator * agg,
   GstBufferPool *pool = NULL;
   GstStructure *config;
   GstCaps *caps;
+  GstVideoInfo info;
   guint size = 0;
   gboolean need_pool;
 
-
   if (!GST_AGGREGATOR_CLASS (gst_gl_mixer_parent_class)->propose_allocation
       (agg, agg_pad, decide_query, query))
     return FALSE;
@@ -155,18 +155,16 @@ gst_gl_mixer_propose_allocation (GstAggregator * agg,
   if (caps == NULL)
     goto no_caps;
 
-  if (need_pool) {
-    GstVideoInfo info;
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
 
-    if (!gst_video_info_from_caps (&info, caps))
-      goto invalid_caps;
+  /* the normal size of a frame */
+  size = info.size;
 
+  if (need_pool) {
     GST_DEBUG_OBJECT (mix, "create new pool");
     pool = gst_gl_buffer_pool_new (context);
 
-    /* the normal size of a frame */
-    size = info.size;
-
     config = gst_buffer_pool_get_config (pool);
     gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
 
@@ -174,10 +172,11 @@ gst_gl_mixer_propose_allocation (GstAggregator * agg,
       g_object_unref (pool);
       goto config_failed;
     }
+  }
 
-    gst_query_add_allocation_pool (query, pool, size, 1, 0);
+  gst_query_add_allocation_pool (query, pool, size, 1, 0);
+  if (pool)
     g_object_unref (pool);
-  }
 
   /* we also support various metadata */
   if (context->gl_vtable->FenceSync)
index d9d389b..4439e85 100644 (file)
@@ -202,6 +202,7 @@ gst_gtk_gl_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
   GstBufferPool *pool = NULL;
   GstStructure *config;
   GstCaps *caps;
+  GstVideoInfo info;
   guint size;
   gboolean need_pool;
   GstStructure *allocation_meta = NULL;
@@ -215,18 +216,16 @@ gst_gtk_gl_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
   if (caps == NULL)
     goto no_caps;
 
-  if (need_pool) {
-    GstVideoInfo info;
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
 
-    if (!gst_video_info_from_caps (&info, caps))
-      goto invalid_caps;
+  /* the normal size of a frame */
+  size = info.size;
 
+  if (need_pool) {
     GST_DEBUG_OBJECT (gtk_sink, "create new pool");
     pool = gst_gl_buffer_pool_new (gtk_sink->context);
 
-    /* the normal size of a frame */
-    size = info.size;
-
     config = gst_buffer_pool_get_config (pool);
     gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
     gst_buffer_pool_config_add_option (config,
@@ -234,11 +233,12 @@ gst_gtk_gl_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
 
     if (!gst_buffer_pool_set_config (pool, config))
       goto config_failed;
+  }
 
-    /* we need at least 2 buffer because we hold on to the last one */
-    gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  /* we need at least 2 buffer because we hold on to the last one */
+  gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  if (pool)
     gst_object_unref (pool);
-  }
 
   GST_OBJECT_LOCK (gtk_sink);
   display_width = gtk_sink->display_width;
index 31495fe..2a4ad7c 100644 (file)
@@ -421,6 +421,7 @@ gst_qt_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
   if (caps == NULL)
     goto no_caps;
 
+  /* FIXME re-using buffer pool breaks renegotiation */
   if ((pool = qt_sink->pool))
     gst_object_ref (pool);
 
@@ -439,30 +440,31 @@ gst_qt_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
       pool = NULL;
     }
     gst_structure_free (config);
-  }
-
-  if (pool == NULL && need_pool) {
+  } else {
     GstVideoInfo info;
 
     if (!gst_video_info_from_caps (&info, caps))
       goto invalid_caps;
 
-    GST_DEBUG_OBJECT (qt_sink, "create new pool");
-    pool = gst_gl_buffer_pool_new (qt_sink->context);
-
     /* the normal size of a frame */
     size = info.size;
+  }
+
+  if (pool == NULL && need_pool) {
+  
+    GST_DEBUG_OBJECT (qt_sink, "create new pool");
+    pool = gst_gl_buffer_pool_new (qt_sink->context);
 
     config = gst_buffer_pool_get_config (pool);
     gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
     if (!gst_buffer_pool_set_config (pool, config))
       goto config_failed;
   }
+
   /* we need at least 2 buffer because we hold on to the last one */
-  if (pool) {
-    gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  if (pool)
     gst_object_unref (pool);
-  }
 
   /* we also support various metadata */
   gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, 0);
index 8839630..f42010f 100644 (file)
@@ -109,23 +109,23 @@ _buffer_propose_allocation (gpointer impl, GstQuery * decide_query,
   struct BufferUpload *raw = impl;
   gboolean need_pool;
   GstCaps *caps;
+  GstVideoInfo info;
   guint size;
+  GstBufferPool *pool = NULL;
 
   gst_query_parse_allocation (query, &caps, &need_pool);
 
   if (caps == NULL)
     return;
 
-  if (need_pool) {
-    GstBufferPool *pool;
-    GstStructure *config;
-    GstVideoInfo info;
+  if (!gst_video_info_from_caps (&info, caps))
+    return;
 
-    if (!gst_video_info_from_caps (&info, caps))
-      return;
+  /* the normal size of a frame */
+  size = info.size;
 
-    /* the normal size of a frame */
-    size = info.size;
+  if (need_pool) {
+    GstStructure *config;
 
     pool = gst_vulkan_buffer_pool_new (raw->upload->device);
 
@@ -136,10 +136,11 @@ _buffer_propose_allocation (gpointer impl, GstQuery * decide_query,
       g_object_unref (pool);
       return;
     }
+  }
 
-    gst_query_add_allocation_pool (query, pool, size, 1, 0);
+  gst_query_add_allocation_pool (query, pool, size, 1, 0);
+  if (pool)
     g_object_unref (pool);
-  }
 
   return;
 }
index 46a710f..6f9c976 100644 (file)
@@ -536,10 +536,9 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
   if (need_pool)
     pool = gst_wayland_create_pool (sink, caps);
 
-  if (pool) {
-    gst_query_add_allocation_pool (query, pool, sink->video_info.size, 2, 0);
+  gst_query_add_allocation_pool (query, pool, sink->video_info.size, 2, 0);
+  if (pool)
     g_object_unref (pool);
-  }
 
   gst_query_add_allocation_param (query, gst_wl_shm_allocator_get (), NULL);
   gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
index 9f03b50..15f7b61 100644 (file)
@@ -774,7 +774,9 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
   GstGLFilter *filter = GST_GL_FILTER (trans);
   GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
   GstCaps *caps;
+  GstVideoInfo info;
   guint size;
+  GstBufferPool *pool = NULL;
   gboolean need_pool;
 
   gst_query_parse_allocation (query, &caps, &need_pool);
@@ -782,16 +784,14 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
   if (caps == NULL)
     goto no_caps;
 
-  if (need_pool) {
-    GstBufferPool *pool;
-    GstStructure *config;
-    GstVideoInfo info;
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
 
-    if (!gst_video_info_from_caps (&info, caps))
-      goto invalid_caps;
+  /* the normal size of a frame */
+  size = info.size;
 
-    /* the normal size of a frame */
-    size = info.size;
+  if (need_pool) {
+    GstStructure *config;
 
     GST_DEBUG_OBJECT (filter, "create new pool");
     pool = gst_gl_buffer_pool_new (context);
@@ -803,10 +803,11 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
       g_object_unref (pool);
       goto config_failed;
     }
+  }
 
-    gst_query_add_allocation_pool (query, pool, size, 1, 0);
+  gst_query_add_allocation_pool (query, pool, size, 1, 0);
+  if (pool)
     g_object_unref (pool);
-  }
 
   if (context->gl_vtable->FenceSync)
     gst_query_add_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, 0);
index 8e2d79b..aa27cf7 100644 (file)
@@ -782,6 +782,7 @@ gst_av_sample_video_sink_propose_allocation (GstBaseSink * bsink, GstQuery * que
   if (caps == NULL)
     goto no_caps;
 
+  /* FIXME re-using buffer pool breaks renegotiation */
   if ((pool = av_sink->pool))
     gst_object_ref (pool);
 
@@ -800,19 +801,19 @@ gst_av_sample_video_sink_propose_allocation (GstBaseSink * bsink, GstQuery * que
       pool = NULL;
     }
     gst_structure_free (config);
-  }
-
-  if (pool == NULL && need_pool) {
+  } else {
     GstVideoInfo info;
 
     if (!gst_video_info_from_caps (&info, caps))
       goto invalid_caps;
 
-    GST_DEBUG_OBJECT (av_sink, "create new pool");
-    pool = gst_video_buffer_pool_new ();
-
     /* the normal size of a frame */
     size = info.size;
+  }
+
+  if (pool == NULL && need_pool) {
+    GST_DEBUG_OBJECT (av_sink, "create new pool");
+    pool = gst_video_buffer_pool_new ();
 
     config = gst_buffer_pool_get_config (pool);
     gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
@@ -820,10 +821,9 @@ gst_av_sample_video_sink_propose_allocation (GstBaseSink * bsink, GstQuery * que
       goto config_failed;
   }
   /* we need at least 2 buffer because we hold on to the last one */
-  if (pool) {
-    gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  if (pool)
     gst_object_unref (pool);
-  }
 
   /* we also support various metadata */
   gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, 0);
index 073b774..43e4322 100644 (file)
@@ -470,6 +470,7 @@ gst_d3dvideosink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
   return TRUE;
 #endif
 
+  /* FIXME re-using buffer pool breaks renegotiation */
   GST_OBJECT_LOCK (sink);
   pool = sink->pool ? gst_object_ref (sink->pool) : NULL;
   GST_OBJECT_UNLOCK (sink);
@@ -489,9 +490,7 @@ gst_d3dvideosink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
       pool = NULL;
     }
     gst_structure_free (config);
-  }
-
-  if (pool == NULL && need_pool) {
+  } else {
     GstVideoInfo info;
 
     if (!gst_video_info_from_caps (&info, caps)) {
@@ -500,11 +499,13 @@ gst_d3dvideosink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
       return FALSE;
     }
 
-    GST_DEBUG_OBJECT (sink, "create new pool");
-    pool = gst_d3dsurface_buffer_pool_new (sink);
-
     /* the normal size of a frame */
     size = info.size;
+  }
+
+  if (pool == NULL && need_pool) {
+    GST_DEBUG_OBJECT (sink, "create new pool");
+    pool = gst_d3dsurface_buffer_pool_new (sink);
 
     config = gst_buffer_pool_get_config (pool);
     /* we need at least 2 buffer because we hold on to the last one */
@@ -516,11 +517,10 @@ gst_d3dvideosink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
     }
   }
 
-  if (pool) {
-    /* we need at least 2 buffer because we hold on to the last one */
-    gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  /* we need at least 2 buffer because we hold on to the last one */
+  gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  if (pool)
     gst_object_unref (pool);
-  }
 
   return TRUE;
 }
index d37762a..2c6cc7f 100644 (file)
@@ -982,11 +982,10 @@ gst_kms_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
       goto no_pool;
   }
 
-  if (pool) {
-    /* we need at least 2 buffer because we hold on to the last one */
-    gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  /* we need at least 2 buffer because we hold on to the last one */
+  gst_query_add_allocation_pool (query, pool, size, 2, 0);
+  if (pool)
     gst_object_unref (pool);
-  }
 
   gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
   gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, NULL);