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
18/*#define MINIMP3_SEEK_IDX_LINEAR_SEARCH*/ /* define to use linear index search instead of binary search on seek */18/*#define MINIMP3_SEEK_IDX_LINEAR_SEARCH*/ /* define to use linear index search instead of binary search on seek */
19#define MINIMP3_IO_SIZE (128*1024) /* io buffer size for streaming functions, must be greater than MINIMP3_BUF_SIZE */19#define MINIMP3_IO_SIZE (128*1024) /* io buffer size for streaming functions, must be greater than MINIMP3_BUF_SIZE */
20#define MINIMP3_BUF_SIZE (16*1024) /* buffer which can hold minimum 10 consecutive mp3 frames (~16KB) worst case */20#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 */
21#define MINIMP3_ENABLE_RING 0 /* WIP enable hardware magic ring buffer if available, to make less input buffer memmove(s) in callback IO mode */22#define MINIMP3_ENABLE_RING 0 /* WIP enable hardware magic ring buffer if available, to make less input buffer memmove(s) in callback IO mode */
22 23
23/* return error codes */24/* return error codes */
@@ -845,7 +846,11 @@ do_exit: · 821 unmodified lines
845size_t mp3dec_ex_read(mp3dec_ex_t *dec, mp3d_sample_t *buf, size_t samples)846size_t mp3dec_ex_read(mp3dec_ex_t *dec, mp3d_sample_t *buf, size_t samples)
846{847{
847 if (!dec || !buf)848 if (!dec || !buf)
848 return MP3D_E_PARAM;849 {
850 if (dec)
851 dec->last_error = MP3D_E_PARAM;
852 return 0;
853 }
849 uint64_t end_offset = dec->end_offset ? dec->end_offset : dec->file.size;854 uint64_t end_offset = dec->end_offset ? dec->end_offset : dec->file.size;
850 size_t samples_requested = samples;855 size_t samples_requested = samples;
851 int eof = 0;856 int eof = 0;
minimp3_test.c+2−2
@@ -531,9 +531,9 @@ static int self_test(const char *input_file_name) · 530 unmodified lines
531 ASSERT(MP3D_E_PARAM == ret);531 ASSERT(MP3D_E_PARAM == ret);
532 532
533 ret = mp3dec_ex_read(0, (mp3d_sample_t*)buf, 10);533 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 */
535 ret = mp3dec_ex_read(&dec, 0, 10);535 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 */
537 537
538 ret = mp3dec_load(0, input_file_name, &finfo, 0, 0);538 ret = mp3dec_load(0, input_file_name, &finfo, 0, 0);
539 ASSERT(MP3D_E_PARAM == ret);539 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