shithub: mp3dec

Download patch

ref: c65e366f67e3975a2a0ea5f97af49511cfa6136b
parent: d607115bdbfbcb45824b9e415291efe7c8a42b0e
author: lieff <lieff@users.noreply.github.com>
date: Mon Feb 24 10:59:09 EST 2020

test: interrupt from progress_cb

--- a/minimp3_test.c
+++ b/minimp3_test.c
@@ -124,6 +124,15 @@
     return 0;
 }
 
+static int progress_cb(void *user_data, size_t file_size, uint64_t offset, mp3dec_frame_info_t *info)
+{
+    (void)user_data;
+    (void)file_size;
+    (void)offset;
+    (void)info;
+    return MP3D_E_USER;
+}
+
 static void decode_file(const char *input_file_name, const unsigned char *buf_ref, int ref_size, FILE *file_out)
 {
     mp3dec_t mp3d;
@@ -372,6 +381,7 @@
     ASSERT(MP3D_E_PARAM == ret);
     ret = mp3dec_load_buf(&mp3d, buf, size, 0, 0, 0);
     ASSERT(MP3D_E_PARAM == ret);
+
     memset(&finfo, 0xff, sizeof(finfo));
     ret = mp3dec_load_buf(&mp3d, buf, 0, &finfo, 0, 0);
     ASSERT(0 == ret && 0 == finfo.samples);
@@ -443,6 +453,11 @@
     ASSERT(MP3D_E_PARAM == ret);
     ret = mp3dec_load(&mp3d, "not_foud", &finfo, 0, 0);
     ASSERT(MP3D_E_IOERROR == ret);
+
+    memset(&mp3d, 0xff, sizeof(mp3d));
+    memset(&finfo, 0xff, sizeof(finfo));
+    ret = mp3dec_load(&mp3d, input_file_name, &finfo, progress_cb, 0);
+    ASSERT(MP3D_E_USER == ret && 2304 == finfo.samples);
 
     ret = mp3dec_iterate(0, frames_iterate_cb, 0);
     ASSERT(MP3D_E_PARAM == ret);