audiomixer: Allow downstream caps with a non-default channel-mask

Instead of failing, take the downstream channel mask if the channel
count is 1.
This commit is contained in:
Olivier Crête 2015-04-01 20:32:41 -04:00
parent 90028d68fe
commit 34a921c31b
2 changed files with 29 additions and 2 deletions

View file

@ -350,11 +350,12 @@ static gboolean
gst_audiomixer_setcaps (GstAudioMixer * audiomixer, GstPad * pad, gst_audiomixer_setcaps (GstAudioMixer * audiomixer, GstPad * pad,
GstCaps * orig_caps) GstCaps * orig_caps)
{ {
GstAggregator *agg = GST_AGGREGATOR (audiomixer);
GstAudioAggregator *aagg = GST_AUDIO_AGGREGATOR (audiomixer); GstAudioAggregator *aagg = GST_AUDIO_AGGREGATOR (audiomixer);
GstCaps *caps; GstCaps *caps;
GstAudioInfo info; GstAudioInfo info;
GstStructure *s; GstStructure *s;
gint channels; gint channels = 0;
gboolean ret; gboolean ret;
caps = gst_caps_copy (orig_caps); caps = gst_caps_copy (orig_caps);
@ -367,6 +368,31 @@ gst_audiomixer_setcaps (GstAudioMixer * audiomixer, GstPad * pad,
if (!gst_audio_info_from_caps (&info, caps)) if (!gst_audio_info_from_caps (&info, caps))
goto invalid_format; goto invalid_format;
if (channels == 1) {
GstCaps *filter;
GstCaps *downstream_caps;
if (audiomixer->filter_caps)
filter = gst_caps_intersect_full (caps, audiomixer->filter_caps,
GST_CAPS_INTERSECT_FIRST);
else
filter = gst_caps_ref (caps);
downstream_caps = gst_pad_peer_query_caps (agg->srcpad, filter);
gst_caps_unref (filter);
if (downstream_caps) {
gst_caps_unref (caps);
caps = downstream_caps;
if (gst_caps_is_empty (caps)) {
gst_caps_unref (caps);
return FALSE;
}
caps = gst_caps_fixate (caps);
}
}
GST_OBJECT_LOCK (audiomixer); GST_OBJECT_LOCK (audiomixer);
/* don't allow reconfiguration for now; there's still a race between the /* don't allow reconfiguration for now; there's still a race between the
* different upstream threads doing query_caps + accept_caps + sending * different upstream threads doing query_caps + accept_caps + sending

View file

@ -89,7 +89,8 @@ GST_START_TEST (test_filter_caps)
filter_caps = gst_caps_new_simple ("audio/x-raw", filter_caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32), "format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"layout", G_TYPE_STRING, "interleaved", "layout", G_TYPE_STRING, "interleaved",
"rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1, NULL); "rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1,
"channel-mask", GST_TYPE_BITMASK, 0x04, NULL);
/* build pipeline */ /* build pipeline */
pipeline = gst_pipeline_new ("pipeline"); pipeline = gst_pipeline_new ("pipeline");