From 383e6ac85cce5ae60826fe0f92019416d27b2f17 Mon Sep 17 00:00:00 2001 From: SpinDizzy Date: Tue, 5 Feb 2019 10:30:50 +0000 Subject: [PATCH] Fixed MPEG music looping glitch. --- Src/Sound/MPEG/getbits.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Src/Sound/MPEG/getbits.cpp b/Src/Sound/MPEG/getbits.cpp index da9bfb8..9ceab86 100644 --- a/Src/Sound/MPEG/getbits.cpp +++ b/Src/Sound/MPEG/getbits.cpp @@ -99,14 +99,18 @@ int m1fread(unsigned char *buf, int size1, int size2, void *f) // if past the end, do the xfer in 2 pieces if ((total + offset) > end) { - memcpy(buf, fstart + offset, end-offset); - buf += (end-offset); - total -= (end-offset); + int temp = end - offset; // this part could be removed + if (temp > 0) // since music lenght + { // + memcpy(buf, fstart + offset, temp); // always multiple + buf += temp; // of 0x240 + total -= temp; // I let this as is in case + } // + + offset = 0; + fstart = lstart; + end = lend; } - - fstart = lstart; - offset = 0; - end = lend; } }