audiodecoder: error out if no frames are decoded before eos

Raise an error in case no frames are decoded before EOS and we
have input, meaning that data was received but it was somehow invalid.

Based on the videodecoder change, merged here for consistency.

https://bugzilla.gnome.org/show_bug.cgi?id=711094
This commit is contained in:
Sebastian Dröge 2013-11-26 12:29:30 +01:00
parent b0788ce054
commit f8477e6b88

View file

@ -192,6 +192,9 @@ typedef struct _GstAudioDecoderContext
gboolean eos;
gboolean sync;
gboolean had_output_data;
gboolean had_input_data;
/* misc */
gint delay;
@ -494,6 +497,8 @@ gst_audio_decoder_reset (GstAudioDecoder * dec, gboolean full)
gst_audio_info_init (&dec->priv->ctx.info);
dec->priv->ctx.max_errors = GST_AUDIO_DECODER_MAX_ERRORS;
dec->priv->ctx.had_output_data = FALSE;
dec->priv->ctx.had_input_data = FALSE;
}
g_queue_foreach (&dec->priv->frames, (GFunc) gst_buffer_unref, NULL);
@ -826,6 +831,8 @@ gst_audio_decoder_push_forward (GstAudioDecoder * dec, GstBuffer * buf)
return GST_FLOW_OK;
}
ctx->had_output_data = TRUE;
GST_LOG_OBJECT (dec,
"clipping buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
@ -1646,6 +1653,8 @@ gst_audio_decoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GST_AUDIO_DECODER_STREAM_LOCK (dec);
dec->priv->ctx.had_input_data = TRUE;
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
gint64 samples, ts;
@ -1836,6 +1845,12 @@ gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event)
gst_audio_decoder_drain (dec);
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
if (dec->priv->ctx.had_input_data && !dec->priv->ctx.had_output_data) {
GST_ELEMENT_ERROR (dec, STREAM, DECODE,
("No valid frames decoded before end of stream"),
("no valid frames found"));
}
/* Forward EOS because no buffer or serialized event will come after
* EOS and nothing could trigger another _finish_frame() call. */
ret = gst_audio_decoder_push_event (dec, event);