diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-08-08 10:40:44 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-08-08 10:40:44 +0200 |
commit | 52ea6f243c5156ac1f5964c896ef47417f964ece (patch) | |
tree | 960f5a820aa1d761aeba7dc2151b62c4616bea66 /plugins | |
parent | 6d8e42e93cb17f30de1f3193fc2d6af58bd206bd (diff) |
better error handling on non-aac m4a files
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/aac/aac.c | 11 | ||||
-rw-r--r-- | plugins/aac/aac_parser.c | 7 |
2 files changed, 12 insertions, 6 deletions
diff --git a/plugins/aac/aac.c b/plugins/aac/aac.c index e4e80619..8f7bfcad 100644 --- a/plugins/aac/aac.c +++ b/plugins/aac/aac.c @@ -31,8 +31,8 @@ #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) -#define trace(...) { fprintf(stderr, __VA_ARGS__); } -//#define trace(fmt,...) +//#define trace(...) { fprintf(stderr, __VA_ARGS__); } +#define trace(fmt,...) static DB_decoder_t plugin; static DB_functions_t *deadbeef; @@ -86,7 +86,8 @@ aac_fs_seek (void *user_data, uint64_t position) { static int parse_aac_stream(DB_FILE *fp, int *psamplerate, int *pchannels, float *pduration, int *ptotalsamples) { - int framepos = deadbeef->ftell (fp);; + size_t framepos = deadbeef->ftell (fp); + size_t initfpos = framepos; int firstframepos = -1; int fsize = -1; int offs = 0; @@ -132,6 +133,9 @@ parse_aac_stream(DB_FILE *fp, int *psamplerate, int *pchannels, float *pduration memmove (buf, buf+1, sizeof (buf)-1); bufsize--; trace ("aac_sync fail, framepos: %d\n", framepos); + if (deadbeef->ftell (fp) - initfpos > 2000) { // how many is enough to make sure? + break; + } framepos++; continue; } @@ -669,7 +673,6 @@ aac_insert (DB_playItem_t *after, const char *fname) { ftype = plugin.filetypes[0]; } else { - int skip = deadbeef->junk_get_leading_size (fp); if (skip >= 0) { deadbeef->fseek (fp, skip, SEEK_SET); diff --git a/plugins/aac/aac_parser.c b/plugins/aac/aac_parser.c index a09eca84..230dec9e 100644 --- a/plugins/aac/aac_parser.c +++ b/plugins/aac/aac_parser.c @@ -22,8 +22,8 @@ #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) -#define trace(...) { fprintf(stderr, __VA_ARGS__); } -//#define trace(fmt,...) +//#define trace(...) { fprintf(stderr, __VA_ARGS__); } +#define trace(fmt,...) static const int aac_sample_rates[16] = { 96000, 88200, 64000, 48000, 44100, 32000, @@ -94,6 +94,9 @@ aac_sync(const uint8_t *buf, int *channels, int *sample_rate, int *bit_rate, int *channels = aac_channels[channel_conf]; *sample_rate = aac_sample_rates[sample_freq_index]; *samples = rdb * 1024; + if (*channels <= 0 || *sample_rate <= 0 || *samples <= 0) { + return 0; + } *bit_rate = size * 8 * *sample_rate / *samples; return size; |