From 191c8742d3cfde62ef837760fb5ca6d4bc226f1e Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 19 Dec 2017 23:13:34 -0500 Subject: [PATCH] festival: Don't forward all queries This fixes issues where wavparse would query the file size upstream and assert because the file size is way smaller then what the WAVE header says. This patch disable or cane a handful of queries that make no sense to forward. https://bugzilla.gnome.org/show_bug.cgi?id=791811 --- gst/festival/gstfestival.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gst/festival/gstfestival.c b/gst/festival/gstfestival.c index 73d492ab8c..407fa3bc2c 100644 --- a/gst/festival/gstfestival.c +++ b/gst/festival/gstfestival.c @@ -112,6 +112,8 @@ static void gst_festival_finalize (GObject * object); static GstFlowReturn gst_festival_chain (GstPad * pad, GstObject * parent, GstBuffer * buf); +static gboolean gst_festival_src_query (GstPad * pad, GstObject * parent, + GstQuery * query); static GstStateChangeReturn gst_festival_change_state (GstElement * element, GstStateChange transition); @@ -184,6 +186,7 @@ gst_festival_init (GstFestival * festival) festival->srcpad = gst_pad_new_from_static_template (&src_template_factory, "src"); + gst_pad_set_query_function (festival->srcpad, gst_festival_src_query); gst_element_add_pad (GST_ELEMENT (festival), festival->srcpad); festival->info = festival_default_info (); @@ -495,6 +498,29 @@ gst_festival_change_state (GstElement * element, GstStateChange transition) return GST_STATE_CHANGE_SUCCESS; } +static gboolean +gst_festival_src_query (GstPad * pad, GstObject * parent, GstQuery * query) +{ + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_POSITION: + /* Not supported */ + return FALSE; + case GST_QUERY_DURATION: + gst_query_set_duration (query, GST_FORMAT_BYTES, -1); + return TRUE; + case GST_QUERY_SEEKING: + gst_query_set_seeking (query, GST_FORMAT_BYTES, FALSE, 0, -1); + return TRUE; + case GST_QUERY_FORMATS: + gst_query_set_formats (query, 1, GST_FORMAT_BYTES); + return TRUE; + default: + break; + } + + return gst_pad_query_default (pad, parent, query); +} + static gboolean plugin_init (GstPlugin * plugin) {