# HG changeset patch # User Chris Cannam # Date 1479902753 0 # Node ID 16a8e97179d7978bc467b983bb27448aced0092c # Parent 2f468f43c02c7c5689fae7c82832e3912dd79064 More error reporting updates diff -r 2f468f43c02c -r 16a8e97179d7 data/fileio/MP3FileReader.cpp --- a/data/fileio/MP3FileReader.cpp Wed Nov 23 10:38:53 2016 +0000 +++ b/data/fileio/MP3FileReader.cpp Wed Nov 23 12:05:53 2016 +0000 @@ -48,6 +48,7 @@ CodedAudioFileReader(mode, targetRate, normalised), m_source(source), m_path(source.getLocalFilename()), + m_decodeErrorShown(false), m_decodeThread(0) { SVDEBUG << "MP3FileReader: local path: \"" << m_path @@ -438,15 +439,16 @@ struct mad_stream *stream, struct mad_frame *) { - static bool errorShown = false; - - if (!errorShown) { - DecoderData *data = (DecoderData *)dp; - fprintf(stderr, "Warning: MP3 decoding error 0x%04x (%s) at byte offset %lu\n", - stream->error, mad_stream_errorstr(stream), - (unsigned long)(stream->this_frame - data->start)); - fprintf(stderr, "(Suppressing any further errors of this sort)\n"); - errorShown = true; + DecoderData *data = (DecoderData *)dp; + if (!data->reader->m_decodeErrorShown) { + char buffer[256]; + snprintf(buffer, 255, + "MP3 decoding error 0x%04x (%s) at byte offset %lu", + stream->error, mad_stream_errorstr(stream), + (unsigned long)(stream->this_frame - data->start)); + SVCERR << "Warning: in file \"" << data->reader->m_path << "\": " + << buffer << " (continuing; will not report any further decode errors for this file)" << endl; + data->reader->m_decodeErrorShown = true; } return MAD_FLOW_CONTINUE; diff -r 2f468f43c02c -r 16a8e97179d7 data/fileio/MP3FileReader.h --- a/data/fileio/MP3FileReader.h Wed Nov 23 10:38:53 2016 +0000 +++ b/data/fileio/MP3FileReader.h Wed Nov 23 12:05:53 2016 +0000 @@ -81,6 +81,8 @@ ProgressReporter *m_reporter; bool m_cancelled; + bool m_decodeErrorShown; + struct DecoderData { unsigned char const *start;