From 9b2e28d91d00638e76a39ec219e99aa33241b242 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 5 Sep 2017 16:20:44 -0400 Subject: [PATCH] Request minimum buffer even if need_pool is FALSE 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 --- ext/directfb/dfbvideosink.c | 16 ++++++++++++++++ ext/gl/caopengllayersink.m | 24 ++++++++++++------------ ext/gl/gstglimagesink.c | 26 +++++++++++++------------- ext/gl/gstglmixer.c | 23 +++++++++++------------ ext/gtk/gstgtkglsink.c | 24 ++++++++++++------------ ext/qt/gstqtsink.cc | 20 +++++++++++--------- ext/vulkan/vkupload.c | 23 ++++++++++++----------- ext/wayland/gstwaylandsink.c | 5 ++--- gst-libs/gst/gl/gstglfilter.c | 23 ++++++++++++----------- sys/applemedia/avsamplevideosink.m | 18 +++++++++--------- sys/d3dvideosink/d3dvideosink.c | 20 ++++++++++---------- sys/kms/gstkmssink.c | 7 +++---- 12 files changed, 123 insertions(+), 106 deletions(-) diff --git a/ext/directfb/dfbvideosink.c b/ext/directfb/dfbvideosink.c index 2a7cfee544..ae21b1b400 100644 --- a/ext/directfb/dfbvideosink.c +++ b/ext/directfb/dfbvideosink.c @@ -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); diff --git a/ext/gl/caopengllayersink.m b/ext/gl/caopengllayersink.m index fc96258b97..eccc8724e4 100644 --- a/ext/gl/caopengllayersink.m +++ b/ext/gl/caopengllayersink.m @@ -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 (!gst_video_info_from_caps (&info, caps)) + goto invalid_caps; + + /* the normal size of a frame */ + size = info.size; + if (need_pool) { - GstVideoInfo info; - - if (!gst_video_info_from_caps (&info, caps)) - goto invalid_caps; - - /* the normal size of a frame */ - size = info.size; - GST_DEBUG_OBJECT (ca_sink, "create new pool"); pool = gst_gl_buffer_pool_new (ca_sink->context); @@ -758,12 +757,13 @@ 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); - gst_object_unref (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); + 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); diff --git a/ext/gl/gstglimagesink.c b/ext/gl/gstglimagesink.c index 71668f6e43..01fb181f97 100644 --- a/ext/gl/gstglimagesink.c +++ b/ext/gl/gstglimagesink.c @@ -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 (!gst_video_info_from_caps (&info, caps)) + goto invalid_caps; + + /* the normal size of a frame */ + size = info.size; + if (need_pool) { - GstBufferPool *pool; - GstVideoInfo info; - - if (!gst_video_info_from_caps (&info, caps)) - goto invalid_caps; - - /* the normal size of a frame */ - size = info.size; - GST_DEBUG_OBJECT (glimage_sink, "create new pool"); pool = gst_gl_buffer_pool_new (glimage_sink->context); @@ -1878,12 +1877,13 @@ 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); - g_object_unref (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); + 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); diff --git a/ext/gl/gstglmixer.c b/ext/gl/gstglmixer.c index c0486616b2..af9de452b7 100644 --- a/ext/gl/gstglmixer.c +++ b/ext/gl/gstglmixer.c @@ -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 (!gst_video_info_from_caps (&info, caps)) + goto invalid_caps; + + /* the normal size of a frame */ + size = info.size; + if (need_pool) { - GstVideoInfo info; - - if (!gst_video_info_from_caps (&info, caps)) - goto invalid_caps; - 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,11 +172,12 @@ gst_gl_mixer_propose_allocation (GstAggregator * agg, g_object_unref (pool); goto config_failed; } - - gst_query_add_allocation_pool (query, pool, size, 1, 0); - g_object_unref (pool); } + 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) gst_query_add_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, 0); diff --git a/ext/gtk/gstgtkglsink.c b/ext/gtk/gstgtkglsink.c index d9d389b36d..4439e85fbf 100644 --- a/ext/gtk/gstgtkglsink.c +++ b/ext/gtk/gstgtkglsink.c @@ -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 (!gst_video_info_from_caps (&info, caps)) + goto invalid_caps; + + /* the normal size of a frame */ + size = info.size; + if (need_pool) { - GstVideoInfo info; - - if (!gst_video_info_from_caps (&info, caps)) - goto invalid_caps; - 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,12 +233,13 @@ 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); - gst_object_unref (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); + if (pool) + gst_object_unref (pool); + GST_OBJECT_LOCK (gtk_sink); display_width = gtk_sink->display_width; display_height = gtk_sink->display_height; diff --git a/ext/qt/gstqtsink.cc b/ext/qt/gstqtsink.cc index 31495feca5..2a4ad7ccc6 100644 --- a/ext/qt/gstqtsink.cc +++ b/ext/qt/gstqtsink.cc @@ -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); diff --git a/ext/vulkan/vkupload.c b/ext/vulkan/vkupload.c index 8839630e99..f42010f184 100644 --- a/ext/vulkan/vkupload.c +++ b/ext/vulkan/vkupload.c @@ -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 (!gst_video_info_from_caps (&info, caps)) + return; + + /* the normal size of a frame */ + size = info.size; + if (need_pool) { - GstBufferPool *pool; GstStructure *config; - GstVideoInfo info; - - if (!gst_video_info_from_caps (&info, caps)) - return; - - /* the normal size of a frame */ - size = info.size; pool = gst_vulkan_buffer_pool_new (raw->upload->device); @@ -136,11 +136,12 @@ _buffer_propose_allocation (gpointer impl, GstQuery * decide_query, g_object_unref (pool); return; } - - gst_query_add_allocation_pool (query, pool, size, 1, 0); - g_object_unref (pool); } + gst_query_add_allocation_pool (query, pool, size, 1, 0); + if (pool) + g_object_unref (pool); + return; } diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 46a710fd0b..6f9c976b6a 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -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); diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index 9f03b50447..15f7b614e3 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -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 (!gst_video_info_from_caps (&info, caps)) + goto invalid_caps; + + /* the normal size of a frame */ + size = info.size; + if (need_pool) { - GstBufferPool *pool; GstStructure *config; - GstVideoInfo info; - - if (!gst_video_info_from_caps (&info, caps)) - goto invalid_caps; - - /* the normal size of a frame */ - size = info.size; GST_DEBUG_OBJECT (filter, "create new pool"); pool = gst_gl_buffer_pool_new (context); @@ -803,11 +803,12 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans, g_object_unref (pool); goto config_failed; } - - gst_query_add_allocation_pool (query, pool, size, 1, 0); - g_object_unref (pool); } + 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); diff --git a/sys/applemedia/avsamplevideosink.m b/sys/applemedia/avsamplevideosink.m index 8e2d79ba15..aa27cf746d 100644 --- a/sys/applemedia/avsamplevideosink.m +++ b/sys/applemedia/avsamplevideosink.m @@ -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); diff --git a/sys/d3dvideosink/d3dvideosink.c b/sys/d3dvideosink/d3dvideosink.c index 073b7743dd..43e4322e1e 100644 --- a/sys/d3dvideosink/d3dvideosink.c +++ b/sys/d3dvideosink/d3dvideosink.c @@ -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; } diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c index d37762a0dd..2c6cc7f6a8 100644 --- a/sys/kms/gstkmssink.c +++ b/sys/kms/gstkmssink.c @@ -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);