From 7ee0551c05a7850f0a35d26ef8e4905fd6fc9784 Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Tue, 15 Oct 2024 15:28:59 -0700 Subject: [PATCH] Update zsm pcm --- backends/playback/zsm/zsm_backend.hpp | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/backends/playback/zsm/zsm_backend.hpp b/backends/playback/zsm/zsm_backend.hpp index 1db5771..3695620 100644 --- a/backends/playback/zsm/zsm_backend.hpp +++ b/backends/playback/zsm/zsm_backend.hpp @@ -86,21 +86,23 @@ class ZsmBackend : public PlaybackBackend { void audio_step(size_t samples) { if (samples == 0) return; while (pcm_fifo_avail() < samples && remain > 0) { - if (pcm_read_rate() == 0) break; - remain--; - size_t oldpos = file->get_pos(); - file->seek((cur++), SeekType::SET); - uint8_t sample; - file->read(&sample, 1, 1); - pcm_write_fifo(sample); - if (remain == 0) { - if (islooped) { - cur = loop; - remain = loop_rem; - } - } - file->seek(oldpos, SeekType::SET); - } + if (pcm_read_rate() == 0) break; + remain--; + if (remain == 0) { + if (islooped) { + cur = loop; + remain = loop_rem; + } else { + break; + } + } + size_t oldpos = file->get_pos(); + file->seek((cur++), SeekType::SET); + uint8_t sample; + file->read(&sample, 1, 1); + pcm_write_fifo(sample); + file->seek(oldpos, SeekType::SET); + } samples *= 2; int16_t *psg_ptr = psg_buf.get_item_sized(samples); int16_t *pcm_ptr = pcm_buf.get_item_sized(samples);