From 36d2d7b7e059110661d6e69817375d6384161c2c Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 19 Apr 2022 22:57:21 -0700 Subject: [PATCH] MAD Input: Fixed gapless handling on file start This error was caused by the necessary fix of the previous commit, only it caused something completely different. Due to the fact that MP3 is included in the list of formats supported for embedded CUE Sheets, the open stage performs a seek to the file start after opening the file, even if there is no sheet embedded. And the resulting seek was supposed to be a null operation, since the file was already at the start. But, as a result, this reset the start skip counter to zero, and because the offset wasn't backwards, but to the same position, it didn't reset the skip counter to the start of track delay. So, as a result, start of track delay wasn't being removed, introducing a gap. Now, this change bypasses the seek function altogether if seeking would do nothing from the current playback position. Whew. Fixes #250 and MP3 gaplessness in general, surprised I didn't notice this sooner myself, but I guess I didn't bother to verify whether my change would break anything. Whoops. Signed-off-by: Christopher Snowhill --- Plugins/MAD/MADDecoder.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/MAD/MADDecoder.m b/Plugins/MAD/MADDecoder.m index 58298bc4d..f0975f6ee 100644 --- a/Plugins/MAD/MADDecoder.m +++ b/Plugins/MAD/MADDecoder.m @@ -686,6 +686,10 @@ } - (long)seek:(long)frame { + if(frame == _framesDecoded) { + return frame; + } + if(frame > totalFrames) frame = totalFrames;