Bug Fix: Retry MP3 file a few times before failure

Give up after 10 tries.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-03-24 16:05:19 -07:00
parent f73cde09ee
commit 8f595af704

View file

@ -146,7 +146,11 @@ static int mp3_seek_callback(uint64_t position, void *user_data) {
_decoder_ex.samples = (totalFrames + _startPadding + _endPadding) * _decoder_ex.info.channels;
}
mp3d_sample_t *sample_ptr = NULL;
size_t samples = mp3dec_ex_read_frame(&_decoder_ex, &sample_ptr, &_decoder_info, MINIMP3_MAX_SAMPLES_PER_FRAME);
size_t samples = 0;
int retry = 10;
do {
samples = mp3dec_ex_read_frame(&_decoder_ex, &sample_ptr, &_decoder_info, MINIMP3_MAX_SAMPLES_PER_FRAME);
} while(!samples && --retry > 0);
if(samples && sample_ptr) {
samples_filled = samples / _decoder_info.channels;
memcpy(&_decoder_buffer_output[0], sample_ptr, sizeof(mp3d_sample_t) * samples);