summaryrefslogtreecommitdiff
path: root/plugins/aac
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-10-11 21:10:46 +0200
committerGravatar waker <wakeroid@gmail.com>2012-10-11 21:10:46 +0200
commit1ab32a2802e79ae39226f25fe81150fe80858757 (patch)
tree9f4f9a3d0e533d9dd44f2042258a3a6e52e1712e /plugins/aac
parenta67ded6a23c08127b119d4559c1e524ab6668620 (diff)
aac: fail adts parser if encountered many failed frames in a row
Diffstat (limited to 'plugins/aac')
-rw-r--r--plugins/aac/aac.c9
1 files changed, 9 insertions, 0 deletions
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) {