fakevideosink: request an extra buffer if enable-last-sample is enabled

If the 'enable-last-sample' property is enabled, fakevideosink will keep
a reference on last rendered buffer which may lead to buffer starvation
in the pipeline.
Request one extra buffer in this case so we always have a buffer flying
in the pipeline.

https://bugzilla.gnome.org/show_bug.cgi?id=795109
This commit is contained in:
Guillaume Desmottes 2018-04-09 17:54:05 +02:00
parent c427860a20
commit 9cd77b1644

View file

@ -52,8 +52,10 @@ G_DEFINE_TYPE (GstFakeVideoSink, gst_fake_video_sink, GST_TYPE_BIN);
static gboolean
gst_fake_video_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
GstFakeVideoSink *self = GST_FAKE_VIDEO_SINK (parent);
GstCaps *caps;
GstVideoInfo info;
guint min_buffers = 1;
if (GST_QUERY_TYPE (query) != GST_QUERY_ALLOCATION)
return gst_pad_query_default (pad, parent, query);
@ -62,7 +64,11 @@ gst_fake_video_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
if (!gst_video_info_from_caps (&info, caps))
return FALSE;
gst_query_add_allocation_pool (query, NULL, info.size, 1, 0);
/* Request an extra buffer if we are keeping a ref on the last rendered buffer */
if (gst_base_sink_is_last_sample_enabled (GST_BASE_SINK (self->child)))
min_buffers++;
gst_query_add_allocation_pool (query, NULL, info.size, min_buffers, 0);
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);
gst_query_add_allocation_meta (query,