comparison 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
comparison
equal deleted inserted replaced
1311:90ac1df228aa 1312:079e553dc16e
570 struct mad_stream *stream, 570 struct mad_stream *stream,
571 struct mad_frame *) 571 struct mad_frame *)
572 { 572 {
573 DecoderData *data = (DecoderData *)dp; 573 DecoderData *data = (DecoderData *)dp;
574 574
575 sv_frame_t ix = stream->this_frame - data->start;
576
575 if (stream->error == MAD_ERROR_LOSTSYNC && 577 if (stream->error == MAD_ERROR_LOSTSYNC &&
576 data->finished) { 578 (data->finished || ix >= data->length)) {
577 // We are at end of file, losing sync is expected behaviour, 579 // We are at end of file, losing sync is expected behaviour,
578 // don't report it 580 // don't report it
579 return MAD_FLOW_CONTINUE; 581 return MAD_FLOW_CONTINUE;
580 } 582 }
581 583
582 if (!data->reader->m_decodeErrorShown) { 584 if (!data->reader->m_decodeErrorShown) {
583 char buffer[256]; 585 char buffer[256];
584 snprintf(buffer, 255, 586 snprintf(buffer, 255,
585 "MP3 decoding error 0x%04x (%s) at byte offset %lu", 587 "MP3 decoding error 0x%04x (%s) at byte offset %lu",
586 stream->error, mad_stream_errorstr(stream), 588 stream->error, mad_stream_errorstr(stream), ix);
587 (unsigned long)(stream->this_frame - data->start));
588 SVCERR << "Warning: in file \"" << data->reader->m_path << "\": " 589 SVCERR << "Warning: in file \"" << data->reader->m_path << "\": "
589 << buffer << " (continuing; will not report any further decode errors for this file)" << endl; 590 << buffer << " (continuing; will not report any further decode errors for this file)" << endl;
590 data->reader->m_decodeErrorShown = true; 591 data->reader->m_decodeErrorShown = true;
591 } 592 }
592 593