diff data/fileio/MP3FileReader.cpp @ 1312:079e553dc16e 3.0-integration

Another check to ensure sync error suppressed at eof
author Chris Cannam
date Tue, 29 Nov 2016 17:09:07 +0000
parents aa1b1fc2d018
children ff9697592bef
line wrap: on
line diff
--- a/data/fileio/MP3FileReader.cpp	Tue Nov 29 16:45:53 2016 +0000
+++ b/data/fileio/MP3FileReader.cpp	Tue Nov 29 17:09:07 2016 +0000
@@ -572,8 +572,10 @@
 {
     DecoderData *data = (DecoderData *)dp;
 
+    sv_frame_t ix = stream->this_frame - data->start;
+    
     if (stream->error == MAD_ERROR_LOSTSYNC &&
-        data->finished) {
+        (data->finished || ix >= data->length)) {
         // We are at end of file, losing sync is expected behaviour,
         // don't report it
         return MAD_FLOW_CONTINUE;
@@ -583,8 +585,7 @@
         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));
+                 stream->error, mad_stream_errorstr(stream), ix);
         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;