summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-04-14 21:36:42 +0200
committerGravatar waker <wakeroid@gmail.com>2011-04-14 21:36:42 +0200
commit6a323590965cd38ad1d2ef47bad99740613211ce (patch)
tree08a0c77d3d1037f179b2206cdf8e46d589a88f2b /plugins
parent665c42a1675dc450b56052ee664b01ee650f8658 (diff)
mp3 parser: don't get parameters from frames coming after corrupted frames
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mpgmad/mpgmad.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index 3f8c4260..2dc0bf9a 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -221,10 +221,14 @@ cmp3_scan_stream (buffer_t *buffer, int sample) {
buffer->startoffset = initpos;
}
+ int had_invalid_frames = 0;
int lastframe_valid = 0;
int64_t offs = -1;
for (;;) {
+ if (!lastframe_valid && valid_frames > 0) {
+ had_invalid_frames = 1;
+ }
if (!lastframe_valid && offs >= 0) {
deadbeef->fseek (buffer->file, offs+1, SEEK_SET);
}
@@ -386,16 +390,19 @@ cmp3_scan_stream (buffer_t *buffer, int sample) {
if (sample == 0 && lastframe_valid) {
return 0;
}
- buffer->version = ver;
- buffer->layer = layer;
- buffer->bitrate = bitrate;
- buffer->samplerate = samplerate;
- buffer->packetlength = packetlength;
- if (nchannels > buffer->channels) {
- buffer->channels = nchannels;
+ // don't get parameters from frames coming after any bad frame
+ if (!had_invalid_frames) {
+ buffer->version = ver;
+ buffer->layer = layer;
+ buffer->bitrate = bitrate;
+ buffer->samplerate = samplerate;
+ buffer->packetlength = packetlength;
+ if (nchannels > buffer->channels) {
+ buffer->channels = nchannels;
+ }
+ buffer->bitspersample = 16;
+ trace ("frame %d mpeg v%d layer %d bitrate %d samplerate %d packetlength %d channels %d\n", nframe, ver, layer, bitrate, samplerate, packetlength, nchannels);
}
- buffer->bitspersample = 16;
- trace ("frame %d mpeg v%d layer %d bitrate %d samplerate %d packetlength %d channels %d\n", nframe, ver, layer, bitrate, samplerate, packetlength, nchannels);
}
lastframe_valid = 1;
// try to read xing/info tag (only on initial scans)