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

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=680614
This commit is contained in:
Mark Nauwelaerts 2012-07-26 14:27:38 +02:00
parent 8ab19ba9ca
commit c91615bd82
2 changed files with 31 additions and 2 deletions

View file

@ -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;
}

View file

@ -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;
}