History

Report MP3D_E_PARAM error in dec->last_error for mp3dec_ex_read.

lieff committed 6 years ago

Commit e0c78631 parent 30b3a2c2 files · +8 −3Browse files

Unified · Split

2 files
  1. minimp3_ex.h +6 −1
  2. minimp3_test.c +2 −2
minimp3_ex.h+6−1
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 /*#define MINIMP3_SEEK_IDX_LINEAR_SEARCH*/ /* define to use linear index search instead of binary search on seek */
1919 #define MINIMP3_IO_SIZE (128*1024) /* io buffer size for streaming functions, must be greater than MINIMP3_BUF_SIZE */
2020 #define MINIMP3_BUF_SIZE (16*1024) /* buffer which can hold minimum 10 consecutive mp3 frames (~16KB) worst case */
21+/*#define MINIMP3_SCAN_LIMIT (256*1024)*/ /* how many bytes will be scanned to search first valid mp3 frame, to prevent stall on large non-mp3 files */
2122 #define MINIMP3_ENABLE_RING 0 /* WIP enable hardware magic ring buffer if available, to make less input buffer memmove(s) in callback IO mode */
2223
2324 /* return error codes */
@@ -845,7 +846,11 @@ do_exit: · 821 unmodified lines
845846 size_t mp3dec_ex_read(mp3dec_ex_t *dec, mp3d_sample_t *buf, size_t samples)
846847 {
847848 if (!dec || !buf)
848− return MP3D_E_PARAM;
849+ {
850+ if (dec)
851+ dec->last_error = MP3D_E_PARAM;
852+ return 0;
853+ }
849854 uint64_t end_offset = dec->end_offset ? dec->end_offset : dec->file.size;
850855 size_t samples_requested = samples;
851856 int eof = 0;
minimp3_test.c+2−2
@@ -531,9 +531,9 @@ static int self_test(const char *input_file_name) · 530 unmodified lines
531531 ASSERT(MP3D_E_PARAM == ret);
532532
533533 ret = mp3dec_ex_read(0, (mp3d_sample_t*)buf, 10);
534− ASSERT(MP3D_E_PARAM == ret);
534+ ASSERT(0 == ret); /* invalid param case, no decoder structure to report an error */
535535 ret = mp3dec_ex_read(&dec, 0, 10);
536− ASSERT(MP3D_E_PARAM == ret);
536+ ASSERT(0 == ret && MP3D_E_PARAM == dec.last_error); /* invalid param case */
537537
538538 ret = mp3dec_load(0, input_file_name, &finfo, 0, 0);
539539 ASSERT(MP3D_E_PARAM == ret);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t