Skip to content

Commit 78d9df6

Browse files
committed
Fix MP3 heuristic check:
- for short files that prematurely result in status 'MPG123_DONE', no erroneous reads should be allowed - for some files, mpg123_read might immediately return status 'MPG123_DONE' without actually reading anything -> add a check for output param 'done'
1 parent c9f1f25 commit 78d9df6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/decoder_mpg123.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ bool Mpg123Decoder::IsMp3(Filesystem_Stream::InputStream& stream) {
230230
// Read beginning of assumed MP3 file and count errors as an heuristic to detect MP3
231231
for (int i = 0; i < 10; ++i) {
232232
err = mpg123_read(decoder.handle.get(), buffer, 1024, &done);
233-
if (err == MPG123_DONE) {
234-
return true;
233+
if (err == MPG123_DONE && done != 0) {
234+
return err_count == 0;
235235
}
236236
if (err != MPG123_OK) {
237237
err_count += 1;

0 commit comments

Comments
 (0)