shithub: mp3dec

Download patch

ref: daf2bf42f75488f8675a5556a969ff7681346393
parent: eb485bc761d67ea22733384ebb863ecdff4871f4
author: lieff <lieff@users.noreply.github.com>
date: Wed Jun 5 16:56:00 EDT 2019

mp3dec_load: return error if no frames readed,
so app do not confuses with zero values from mp3dec_file_info_t.
Closes https://github.com/lieff/minimp3/issues/56

--- a/minimp3_ex.h
+++ b/minimp3_ex.h
@@ -341,7 +341,7 @@
         return ret;
     mp3dec_load_buf(dec, map_info.buffer, map_info.size, info, progress_cb, user_data);
     mp3dec_close_file(&map_info);
-    return 0;
+    return info->samples ? 0 : -1;
 }
 
 int mp3dec_iterate(const char *file_name, MP3D_ITERATE_CB callback, void *user_data)
--- a/minimp3_test.c
+++ b/minimp3_test.c
@@ -108,8 +108,11 @@
     if (mp3dec_load(&mp3d, input_file_name, &info, 0, 0))
 #endif
     {
-        printf("error: file not found or read error");
-        exit(1);
+        if (ref_size)
+        {
+            printf("error: file not found or read error");
+            exit(1);
+        }
     }
 #ifdef MINIMP3_FLOAT_OUTPUT
     int16_t *buffer = malloc(info.samples*sizeof(int16_t));