Skip to content

Commit

Permalink
MP3Decode: fixed decode error loop
Browse files Browse the repository at this point in the history
  • Loading branch information
espressif2022 committed Dec 13, 2023
1 parent fcb709b commit d228ac6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions audio_mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ DECODE_STATUS decode_mp3(HMP3Decoder mp3_decoder, FILE *fp, decode_data *pData,
pInstance->bytes_in_data_buf = unread_bytes + nRead;
pInstance->read_ptr = pInstance->data_buf;

if (nRead == 0)
{
if ((nRead == 0) || feof(fp)) {
pInstance->eof_reached = true;
}

Expand Down Expand Up @@ -119,8 +118,10 @@ DECODE_STATUS decode_mp3(HMP3Decoder mp3_decoder, FILE *fp, decode_data *pData,
frame_info.outputSamps,
starting_unread_bytes - unread_bytes);
} else {
if(mp3_dec_err == ERR_MP3_MAINDATA_UNDERFLOW)
{
if (pInstance->eof_reached) {
ESP_LOGE(TAG, "status error %d, but EOF", mp3_dec_err);
return DECODE_STATUS_DONE;
} else if (mp3_dec_err == ERR_MP3_MAINDATA_UNDERFLOW) {
// underflow indicates MP3Decode should be called again
LOGI_1("underflow read ptr is 0x%p", read_ptr);
return DECODE_STATUS_NO_DATA_CONTINUE;
Expand Down

0 comments on commit d228ac6

Please sign in to comment.