From 1ab32a2802e79ae39226f25fe81150fe80858757 Mon Sep 17 00:00:00 2001 From: waker Date: Thu, 11 Oct 2012 21:10:46 +0200 Subject: aac: fail adts parser if encountered many failed frames in a row --- plugins/aac/aac.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins/aac') diff --git a/plugins/aac/aac.c b/plugins/aac/aac.c index a7abece0..156e86f8 100644 --- a/plugins/aac/aac.c +++ b/plugins/aac/aac.c @@ -142,6 +142,9 @@ parse_aac_stream(DB_FILE *fp, int *psamplerate, int *pchannels, float *pduration int frame = 0; int scanframes = 1000; + + int nfail = 0; + if (fp->vfs->is_streaming ()) { scanframes = 1; } @@ -160,6 +163,11 @@ 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); + nfail++; + if (nfail > 100) { + trace ("aac: many failed sync attemps, aborted\n"); + return -1; + } if (deadbeef->ftell (fp) - initfpos > 2000) { // how many is enough to make sure? break; } @@ -168,6 +176,7 @@ parse_aac_stream(DB_FILE *fp, int *psamplerate, int *pchannels, float *pduration } else { // trace ("aac: frame #%d sync: %dch %d %d %d %d\n", frame, channels, samplerate, bitrate, samples, size); + nfail = 0; frame++; nsamples += samples; if (!stream_sr) { -- cgit v1.2.3