Skip to content

Commit 683ece7

Browse files
committed
MP3Decoder: Accurately inform when no more data
Some audio implementations, notably samd, really don't like it when you return 0 samples of data. This was the case when reaching the end of an MP3 file. Now, we read forward in an MP3 file to the next sync word during "get_buffer", so that we can accurately return GET_BUFFER_DONE when the NEXT call WOULD HAVE resulted in 0 samples. Tested with @gamblor21's "laugh.mp3" file on a Trellis M4 Express.
1 parent faca1ec commit 683ece7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

shared-module/audiomp3/MP3Decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t *
364364
}
365365

366366
self->samples_decoded += *buffer_length / sizeof(int16_t);
367-
return GET_BUFFER_MORE_DATA;
367+
return mp3file_find_sync_word(self) ? GET_BUFFER_MORE_DATA : GET_BUFFER_DONE;
368368
}
369369

370370
void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t *self, bool single_channel_output,

0 commit comments

Comments
 (0)