From f8477e6b88fdb364809bef70ac3909aba878978f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 26 Nov 2013 12:29:30 +0100 Subject: [PATCH] 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 --- gst-libs/gst/audio/gstaudiodecoder.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index febe71d2b5..12df4850c1 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -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);