audio: Always provide a buffer in gst_audio_(enc|dec)oder_allocate_output_buffer()

We have no way of tell the caller of the exact error (e.g. if we're flushing),
so will have to wait until the caller uses API that returns a GstFlowReturn,
for example when pushing this buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=700006
This commit is contained in:
Sebastian Dröge 2013-05-24 16:52:50 +02:00
parent 0c2c909497
commit b8c6413a8e
2 changed files with 27 additions and 6 deletions

View file

@ -2985,15 +2985,25 @@ gst_audio_decoder_allocate_output_buffer (GstAudioDecoder * dec, gsize size)
if (G_UNLIKELY (dec->priv->ctx.output_format_changed ||
(GST_AUDIO_INFO_IS_VALID (&dec->priv->ctx.info)
&& gst_pad_check_reconfigure (dec->srcpad)))) {
if (!gst_audio_decoder_negotiate (dec))
goto done;
if (!gst_audio_decoder_negotiate (dec)) {
GST_INFO_OBJECT (dec, "Failed to negotiate, fallback allocation");
goto fallback;
}
}
buffer =
gst_buffer_new_allocate (dec->priv->ctx.allocator, size,
&dec->priv->ctx.params);
if (!buffer) {
GST_INFO_OBJECT (dec, "couldn't allocate output buffer");
goto fallback;
}
done:
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
return buffer;
fallback:
buffer = gst_buffer_new_allocate (NULL, size, NULL);
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
return buffer;

View file

@ -2726,15 +2726,26 @@ gst_audio_encoder_allocate_output_buffer (GstAudioEncoder * enc, gsize size)
if (G_UNLIKELY (enc->priv->ctx.output_caps_changed || (enc->priv->ctx.caps
&& gst_pad_check_reconfigure (enc->srcpad)))) {
if (!gst_audio_encoder_negotiate (enc))
goto done;
if (!gst_audio_encoder_negotiate (enc)) {
GST_INFO_OBJECT (enc, "Failed to negotiate, fallback allocation");
goto fallback;
}
}
buffer =
gst_buffer_new_allocate (enc->priv->ctx.allocator, size,
&enc->priv->ctx.params);
if (!buffer) {
GST_INFO_OBJECT (enc, "couldn't allocate output buffer");
goto fallback;
}
done:
GST_AUDIO_ENCODER_STREAM_UNLOCK (enc);
return buffer;
fallback:
buffer = gst_buffer_new_allocate (NULL, size, NULL);
GST_AUDIO_ENCODER_STREAM_UNLOCK (enc);
return buffer;