GST_DEBUG_OBJECT (dec, "setting src caps %" GST_PTR_FORMAT, caps);
- GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
-
res = gst_pad_set_caps (dec->srcpad, caps);
gst_caps_unref (caps);
if (!res)
dec->priv->ctx.params = params;
done:
+ GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
+
if (query)
gst_query_unref (query);
GST_AUDIO_DECODER_STREAM_LOCK (dec);
+ if (G_UNLIKELY (gst_pad_check_reconfigure (dec->srcpad))) {
+ if (!gst_audio_decoder_set_output_format (dec, &ctx->info)) {
+ ret = GST_FLOW_NOT_NEGOTIATED;
+ goto exit;
+ }
+ }
+
if (buf && priv->pending_events) {
GList *pending_events, *l;
GstBuffer *
gst_audio_decoder_allocate_output_buffer (GstAudioDecoder * dec, gsize size)
{
- GstBuffer *buffer;
+ GstBuffer *buffer = NULL;
g_return_val_if_fail (size > 0, NULL);
GST_AUDIO_DECODER_STREAM_LOCK (dec);
+ if (G_UNLIKELY (GST_AUDIO_INFO_IS_VALID (&dec->priv->ctx.info)
+ && gst_pad_check_reconfigure (dec->srcpad))) {
+ if (!gst_audio_decoder_set_output_format (dec, &dec->priv->ctx.info))
+ goto done;
+ }
+
buffer =
gst_buffer_new_allocate (dec->priv->ctx.allocator, size,
&dec->priv->ctx.params);
+done:
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
return buffer;
"accepting %" G_GSIZE_FORMAT " bytes encoded data as %d samples",
buf ? gst_buffer_get_size (buf) : -1, samples);
+ if (G_UNLIKELY (gst_pad_check_reconfigure (enc->srcpad))) {
+ GstCaps *caps = gst_pad_get_current_caps (enc->srcpad);
+ if (!gst_audio_encoder_set_output_format (enc, caps)) {
+ ret = GST_FLOW_NOT_NEGOTIATED;
+ goto exit;
+ }
+ gst_caps_unref (caps);
+ }
+
/* mark subclass still alive and providing */
if (G_LIKELY (buf))
priv->got_data = TRUE;
GstBuffer *
gst_audio_encoder_allocate_output_buffer (GstAudioEncoder * enc, gsize size)
{
- GstBuffer *buffer;
+ GstBuffer *buffer = NULL;
g_return_val_if_fail (size > 0, NULL);
GST_AUDIO_ENCODER_STREAM_LOCK (enc);
+ if (G_UNLIKELY (gst_pad_has_current_caps (enc->srcpad)
+ && gst_pad_check_reconfigure (enc->srcpad))) {
+ GstCaps *caps = gst_pad_get_current_caps (enc->srcpad);
+ if (!gst_audio_encoder_set_output_format (enc, caps)) {
+ gst_caps_unref (caps);
+ goto done;
+ }
+ gst_caps_unref (caps);
+ }
+
buffer =
gst_buffer_new_allocate (enc->priv->ctx.allocator, size,
&enc->priv->ctx.params);
+done:
GST_AUDIO_ENCODER_STREAM_UNLOCK (enc);
return buffer;