changeset 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 90ac1df228aa
children ff9697592bef
files data/fileio/MP3FileReader.cpp
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
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;