From 28314c4372859f96841d10ce67407a0a27c7e8c9 Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Wed, 16 Oct 2024 10:56:24 -0700 Subject: [PATCH] Fix seeking --- backends/playback/zsm/zsm_backend.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backends/playback/zsm/zsm_backend.cpp b/backends/playback/zsm/zsm_backend.cpp index 394ac77..ae40b82 100644 --- a/backends/playback/zsm/zsm_backend.cpp +++ b/backends/playback/zsm/zsm_backend.cpp @@ -95,6 +95,7 @@ void ZsmBackend::switch_stream(int idx) { for (uint8_t i = 0; i < 16; i++) { psg_writereg(i * 4 + 2, 0); } + file->seek(music_data_start, SeekType::SET); this->cpuClocks = 0.0; this->delayTicks = 0.0; this->ticks = 0.0; @@ -330,6 +331,7 @@ void ZsmBackend::seek_internal(double position, bool loop) { this->position = std::floor(this->position * PSG_FREQ) / PSG_FREQ; position = std::floor(position * PSG_FREQ) / PSG_FREQ; if (this->position > position) { + switch_stream(0); file->seek(music_data_start, SeekType::SET); this->cpuClocks = 0.0; this->delayTicks = 0; @@ -338,8 +340,6 @@ void ZsmBackend::seek_internal(double position, bool loop) { } else if (this->position == position) { audio_buf.clear(); return; - } else { - switch_stream(0); } while (this->position < position) { audio_buf.clear();