comparison data/fileio/MP3FileReader.cpp @ 1310:aa1b1fc2d018 mp3-gapless

Stop reporting sync errors only when we really are at eof, i.e. after the input callback has been called again (previously we just tested whether we'd buffered up all the input, which of course we do in one go at the start)
author Chris Cannam
date Tue, 29 Nov 2016 16:45:29 +0000
parents c84629395040
children 079e553dc16e
comparison
equal deleted inserted replaced
1309:2e7fcdd5f627 1310:aa1b1fc2d018
315 DecoderData data; 315 DecoderData data;
316 struct mad_decoder decoder; 316 struct mad_decoder decoder;
317 317
318 data.start = (unsigned char const *)mm; 318 data.start = (unsigned char const *)mm;
319 data.length = sz; 319 data.length = sz;
320 data.finished = false;
320 data.reader = this; 321 data.reader = this;
321 322
322 mad_decoder_init(&decoder, // decoder to initialise 323 mad_decoder_init(&decoder, // decoder to initialise
323 &data, // our own data block for callbacks 324 &data, // our own data block for callbacks
324 input_callback, // provides (entire) input to mad 325 input_callback, // provides (entire) input to mad
341 enum mad_flow 342 enum mad_flow
342 MP3FileReader::input_callback(void *dp, struct mad_stream *stream) 343 MP3FileReader::input_callback(void *dp, struct mad_stream *stream)
343 { 344 {
344 DecoderData *data = (DecoderData *)dp; 345 DecoderData *data = (DecoderData *)dp;
345 346
346 if (!data->length) return MAD_FLOW_STOP; 347 if (!data->length) {
348 data->finished = true;
349 return MAD_FLOW_STOP;
350 }
347 351
348 unsigned char const *start = data->start; 352 unsigned char const *start = data->start;
349 sv_frame_t length = data->length; 353 sv_frame_t length = data->length;
350 354
351 #ifdef HAVE_ID3TAG 355 #ifdef HAVE_ID3TAG
567 struct mad_frame *) 571 struct mad_frame *)
568 { 572 {
569 DecoderData *data = (DecoderData *)dp; 573 DecoderData *data = (DecoderData *)dp;
570 574
571 if (stream->error == MAD_ERROR_LOSTSYNC && 575 if (stream->error == MAD_ERROR_LOSTSYNC &&
572 data->length == 0) { 576 data->finished) {
573 // We are at end of file, losing sync is expected behaviour 577 // We are at end of file, losing sync is expected behaviour,
578 // don't report it
574 return MAD_FLOW_CONTINUE; 579 return MAD_FLOW_CONTINUE;
575 } 580 }
576 581
577 if (!data->reader->m_decodeErrorShown) { 582 if (!data->reader->m_decodeErrorShown) {
578 char buffer[256]; 583 char buffer[256];