From 0c19ac0b4747b9c51373927b6a7c4989b9cdb2b1 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Mon, 23 Apr 2018 16:32:41 +0200 Subject: [PATCH] audioaggregator: fix filtered getcaps In the situation described in https://bugzilla.gnome.org/show_bug.cgi?id=795397, downstream_caps consists of two structures, the first with the preferred rate, if at all possible (44100), the second containing the full range of allowed rates, as audioresample correctly tries to negotiate passthrough caps. As audioaggregator cannot perform rate conversion, it wants to return a fixated rate in its getcaps implementation, however it previously directly used the first structure in the caps allowed downstream, without taking the filter into consideration, to determine the rate to fixate to. With this, we first intersect our downstream caps with the filter, in order not to fixate to an unsupported rate. --- gst-libs/gst/audio/gstaudioaggregator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gst-libs/gst/audio/gstaudioaggregator.c b/gst-libs/gst/audio/gstaudioaggregator.c index 7d5707f05d..a67547311b 100644 --- a/gst-libs/gst/audio/gstaudioaggregator.c +++ b/gst-libs/gst/audio/gstaudioaggregator.c @@ -650,6 +650,18 @@ gst_audio_aggregator_sink_getcaps (GstPad * pad, GstAggregator * agg, sink_template_caps = gst_caps_make_writable (sink_template_caps); s = gst_caps_get_structure (sink_template_caps, 0); + /* We will then use the rate in the first structure as the expected + * rate, we want to make sure only the compatible structures remain + * in downstream_caps + */ + if (downstream_caps && filter) { + GstCaps *tmp = gst_caps_intersect_full (downstream_caps, filter, + GST_CAPS_INTERSECT_FIRST); + + gst_caps_unref (downstream_caps); + downstream_caps = tmp; + } + if (downstream_caps && !gst_caps_is_empty (downstream_caps)) s2 = gst_caps_get_structure (downstream_caps, 0); else