From 3f6a868f7e7ba732f36078be4f42d9b502b19991 Mon Sep 17 00:00:00 2001 From: Vineeth TM Date: Fri, 26 Jun 2015 13:24:17 +0900 Subject: flacdec: improve error handling for files which have corrupted header, libflac is not able to process the metadata properly. We just try to ignore the error and continue with the processing, since metadata parsing is not making much of a difference to libflac https://bugzilla.gnome.org/show_bug.cgi?id=751334 --- ext/flac/gstflacdec.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ext/flac') diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index 49436ddf7..62ac391dc 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -100,6 +100,8 @@ static FLAC__StreamDecoderWriteStatus gst_flac_dec_write_stream (const FLAC__StreamDecoder * decoder, const FLAC__Frame * frame, const FLAC__int32 * const buffer[], void *client_data); +static gboolean +gst_flac_dec_handle_decoder_error (GstFlacDec * dec, gboolean msg); static void gst_flac_dec_metadata_cb (const FLAC__StreamDecoder * decoder, const FLAC__StreamMetadata * metadata, void *client_data); static void gst_flac_dec_error_cb (const FLAC__StreamDecoder * @@ -275,6 +277,14 @@ gst_flac_dec_set_format (GstAudioDecoder * dec, GstCaps * caps) GST_DEBUG_OBJECT (dec, "Processing headers and metadata"); if (!FLAC__stream_decoder_process_until_end_of_metadata (flacdec->decoder)) { GST_WARNING_OBJECT (dec, "process_until_end_of_metadata failed"); + if (FLAC__stream_decoder_get_state (flacdec->decoder) == + FLAC__STREAM_DECODER_ABORTED) { + GST_WARNING_OBJECT (flacdec, "Read callback caused internal abort"); + /* allow recovery */ + gst_adapter_clear (flacdec->adapter); + FLAC__stream_decoder_flush (flacdec->decoder); + gst_flac_dec_handle_decoder_error (flacdec, TRUE); + } } GST_INFO_OBJECT (dec, "headers and metadata are now processed"); return TRUE; @@ -781,6 +791,14 @@ gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec, GstBuffer * buf) if (!FLAC__stream_decoder_process_single (dec->decoder)) { GST_INFO_OBJECT (dec, "process_single failed"); + if (FLAC__stream_decoder_get_state (dec->decoder) == + FLAC__STREAM_DECODER_ABORTED) { + GST_WARNING_OBJECT (dec, "Read callback caused internal abort"); + /* allow recovery */ + gst_adapter_clear (dec->adapter); + FLAC__stream_decoder_flush (dec->decoder); + gst_flac_dec_handle_decoder_error (dec, TRUE); + } } return dec->last_flow; -- cgit v1.2.1