diff --git a/gst/playback/gstplaysinkconvertbin.c b/gst/playback/gstplaysinkconvertbin.c index d4f299cd41..644a6ba0ab 100644 --- a/gst/playback/gstplaysinkconvertbin.c +++ b/gst/playback/gstplaysinkconvertbin.c @@ -338,6 +338,15 @@ gst_play_sink_convert_bin_sink_setcaps (GstPlaySinkConvertBin * self, return TRUE; } +#define GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS(filter,caps) G_STMT_START { \ + if ((filter)) { \ + GstCaps *intersection = \ + gst_caps_intersect_full ((filter), (caps), GST_CAPS_INTERSECT_FIRST); \ + gst_caps_unref ((caps)); \ + (caps) = intersection; \ + } \ +} G_STMT_END + static GstCaps * gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter) { @@ -378,27 +387,24 @@ gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter) gst_caps_unref (downstream_filter); gst_object_unref (peer); if (self->converter_caps && is_raw_caps (peer_caps, self->audio)) { - ret = gst_caps_merge (peer_caps, gst_caps_ref (self->converter_caps)); + GstCaps *converter_caps = gst_caps_ref (self->converter_caps); + GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS (filter, converter_caps); + ret = gst_caps_merge (peer_caps, converter_caps); } else { ret = peer_caps; + GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS (filter, ret); } } else { ret = gst_caps_ref (self->converter_caps); + GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS (filter, ret); } } else { - ret = gst_caps_new_any (); + ret = filter ? gst_caps_ref (filter) : gst_caps_new_any (); } GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self); gst_object_unref (self); - if (filter) { - GstCaps *intersection = - gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST); - gst_caps_unref (ret); - ret = intersection; - } - GST_DEBUG_OBJECT (pad, "Returning caps %" GST_PTR_FORMAT, ret); return ret;