Skip to content

Commit 66749ac

Browse files
authored
Merge pull request #6305 from jepler/fix-audacity-mp3
Fix audacity mp3 (erroneous EOF detected)
2 parents 3885bc9 + df5f7bc commit 66749ac

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

shared-module/audiomp3/MP3Decoder.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
*/
5454
STATIC bool mp3file_update_inbuf_always(audiomp3_mp3file_obj_t *self) {
5555
// If we didn't previously reach the end of file, we can try reading now
56-
if (!self->eof) {
56+
if (!self->eof && self->inbuf_offset != 0) {
5757

5858
// Move the unconsumed portion of the buffer to the start
5959
uint8_t *end_of_buffer = self->inbuf + self->inbuf_length;
@@ -356,15 +356,19 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t *
356356
return GET_BUFFER_DONE;
357357
}
358358

359+
self->samples_decoded += *buffer_length / sizeof(int16_t);
360+
361+
mp3file_skip_id3v2(self);
362+
int result = mp3file_find_sync_word(self) ? GET_BUFFER_MORE_DATA : GET_BUFFER_DONE;
363+
359364
if (self->inbuf_offset >= 512) {
360365
background_callback_add(
361366
&self->inbuf_fill_cb,
362367
mp3file_update_inbuf_cb,
363368
self);
364369
}
365370

366-
self->samples_decoded += *buffer_length / sizeof(int16_t);
367-
return mp3file_find_sync_word(self) ? GET_BUFFER_MORE_DATA : GET_BUFFER_DONE;
371+
return result;
368372
}
369373

370374
void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t *self, bool single_channel_output,

0 commit comments

Comments
 (0)