From 2e35c3b0c20b5c5f9d645f2c26f19cb4fcf6445d Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Mon, 21 Sep 2009 22:21:53 +0200 Subject: sample-accurate mp3 start/end points for cuesheets --- plugins/mpgmad/mpgmad.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index dc328f93..b014ac91 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -645,8 +645,8 @@ cmp3_decode (void) { int cachepos = (buffer.cachefill + buffer.cachepos) & CACHE_MASK; int len = synth.pcm.length; - if (buffer.currentsample + len >= buffer.totalsamples) { - len = buffer.totalsamples - buffer.currentsample; + if (buffer.currentsample + len > buffer.endsample) { + len = buffer.endsample - buffer.currentsample + 1; } int i = min (synth.pcm.length, buffer.skipsamples); if (buffer.skipsamples > 0) { @@ -682,8 +682,8 @@ cmp3_decode (void) { if (buffer.currentsample > buffer.totalsamples) { trace ("mpgmad: warning: extra samples were read after end of stream\n"); } - if (buffer.readsize <= 0 || eof || buffer.currentsample >= buffer.totalsamples) { - if (buffer.currentsample >= buffer.totalsamples) { + if (buffer.readsize <= 0 || eof || buffer.currentsample > buffer.endsample) { + if (buffer.endsample >= buffer.endsample) { trace ("finished at sample %d (%d)\n", buffer.currentsample, buffer.totalsamples); } break; -- cgit v1.2.3