Commit c91615bd authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

audio{de,en}coder: delay input caps processing until processing data

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=680614
parent 8ab19ba9
......@@ -232,6 +232,8 @@ struct _GstAudioDecoderPrivate
gboolean drained;
/* subclass currently being forcibly drained */
gboolean force;
/* need to handle changed input caps */
gboolean do_caps;
/* input bps estimatation */
/* global in bytes seen */
......@@ -1499,6 +1501,18 @@ gst_audio_decoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
dec = GST_AUDIO_DECODER (parent);
if (G_UNLIKELY (dec->priv->do_caps)) {
GstCaps *caps = gst_pad_get_current_caps (dec->sinkpad);
if (caps) {
if (!gst_audio_decoder_sink_setcaps (dec, caps)) {
gst_caps_unref (caps);
goto not_negotiated;
}
gst_caps_unref (caps);
}
dec->priv->do_caps = FALSE;
}
if (G_UNLIKELY (!gst_pad_has_current_caps (pad) && dec->priv->needs_format))
goto not_negotiated;
......@@ -1684,7 +1698,8 @@ gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event)
GstCaps *caps;
gst_event_parse_caps (event, &caps);
ret = gst_audio_decoder_sink_setcaps (dec, caps);
ret = TRUE;
dec->priv->do_caps = TRUE;
gst_event_unref (event);
break;
}
......
......@@ -231,6 +231,8 @@ struct _GstAudioEncoderPrivate
gboolean drained;
/* subclass currently being forcibly drained */
gboolean force;
/* need to handle changed input caps */
gboolean do_caps;
/* output bps estimatation */
/* global in samples seen */
......@@ -1029,6 +1031,17 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GST_AUDIO_ENCODER_STREAM_LOCK (enc);
if (G_UNLIKELY (priv->do_caps)) {
GstCaps *caps = gst_pad_get_current_caps (enc->sinkpad);
if (!caps)
goto not_negotiated;
if (!gst_audio_encoder_sink_setcaps (enc, caps)) {
gst_caps_unref (caps);
goto not_negotiated;
}
priv->do_caps = FALSE;
}
/* should know what is coming by now */
if (!ctx->info.bpf)
goto not_negotiated;
......@@ -1508,7 +1521,8 @@ gst_audio_encoder_sink_event_default (GstAudioEncoder * enc, GstEvent * event)
GstCaps *caps;
gst_event_parse_caps (event, &caps);
res = gst_audio_encoder_sink_setcaps (enc, caps);
enc->priv->do_caps = TRUE;
res = TRUE;
gst_event_unref (event);
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment