summaryrefslogtreecommitdiff
path: root/ext/flac
diff options
context:
space:
mode:
authorVineeth TM <vineeth.tm@samsung.com>2015-06-26 13:24:17 +0900
committerLuis de Bethencourt <luis@debethencourt.com>2015-07-06 14:57:11 +0100
commit3f6a868f7e7ba732f36078be4f42d9b502b19991 (patch)
treea95fe444408a82338ba63b406b398e6c849819e7 /ext/flac
parentc5c7e7e084e9d6d8b5c2ff446c0fcb07739a19bc (diff)
downloadgstreamer-plugins-good-3f6a868f7e7ba732f36078be4f42d9b502b19991.tar.gz
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
Diffstat (limited to 'ext/flac')
-rw-r--r--ext/flac/gstflacdec.c18
1 files changed, 18 insertions, 0 deletions
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;