From 2621ec7831b1ef272fa096d556ec2330407792b6 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Sun, 8 Nov 2026 08:50:57 -0600 Subject: [PATCH 1/2] jk: a pause during a cutscene keeps the sound in order and in sync (OpenJKDF2 46ccc6d) The cutscene clocks are wall time, so after a pause the cutscene took the whole pause for lag and decoded every frame it had missed at once: the sound played out of order and looped, and the picture ended up ahead of it. jk_esp_park_point() now moves the cutscene clocks past the time it was parked (both park points: between frames and inside the engine's menus). The mixer also keeps running until the engine has actually parked (it can finish a frame after the pause request), so the sound stops with the picture. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/jk/OpenJKDF2 | 2 +- components/jk/src/jk.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/components/jk/OpenJKDF2 b/components/jk/OpenJKDF2 index 330f270..46ccc6d 160000 --- a/components/jk/OpenJKDF2 +++ b/components/jk/OpenJKDF2 @@ -1 +1 @@ -Subproject commit 330f270e71a6c13fd652b13fab2f3607490e08f9 +Subproject commit 46ccc6d06c4260c971c833273c88a043674c5b98 diff --git a/components/jk/src/jk.cpp b/components/jk/src/jk.cpp index 9caec48..b1a342e 100644 --- a/components/jk/src/jk.cpp +++ b/components/jk/src/jk.cpp @@ -116,6 +116,7 @@ bool request(Request req, const std::string &path = {}, const std::string &label } std::unique_ptr g_audio_task; extern "C" void stdSound_ESP32_Pump(void); +extern "C" void jkCutscene_ESP32_SkipTime(uint64_t us); constexpr size_t ENGINE_STACK_BYTES = 1024 * 1024; int g_native_w = CONFIG_JK_INTERNAL_WIDTH; int g_native_h = CONFIG_JK_INTERNAL_HEIGHT; @@ -405,6 +406,7 @@ int jk_esp_park_point(void) { if (!g_paused) { return 0; } + const uint64_t park_start_us = esp_timer_get_time(); g_parked = true; while (g_paused && !g_engine_stop && !jk_esp_quit_requested) { // the pause menu's save / load / reset arrive while parked here: serve @@ -413,6 +415,11 @@ int jk_esp_park_point(void) { run_pending_request(); vTaskDelay(pdMS_TO_TICKS(10)); } +#if CONFIG_JK_ENGINE + // a cutscene keeps time by the wall clock: without this it takes the pause + // for lag and decodes every frame it missed at once + jkCutscene_ESP32_SkipTime(esp_timer_get_time() - park_start_us); +#endif g_parked = false; return 1; } @@ -1082,7 +1089,9 @@ bool init(const Config &config) { g_audio_task = espp::Task::make_unique({ .callback = [](std::mutex &m, std::condition_variable &cv, bool &task_notified) { - if (!g_paused) { + // mix until the engine has actually parked, so the sound stops + // with the picture (it can finish a frame after the pause) + if (!g_parked) { stdSound_ESP32_Pump(); } std::unique_lock lk(m); From 2e8324eefacb7789e7f212bcadbbce91261325bb Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Sun, 8 Nov 2026 09:03:24 -0600 Subject: [PATCH 2/2] jk: OpenJKDF2 5b5c037 (no clock shift while the cutscene's own pause is on) Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/jk/OpenJKDF2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jk/OpenJKDF2 b/components/jk/OpenJKDF2 index 46ccc6d..5b5c037 160000 --- a/components/jk/OpenJKDF2 +++ b/components/jk/OpenJKDF2 @@ -1 +1 @@ -Subproject commit 46ccc6d06c4260c971c833273c88a043674c5b98 +Subproject commit 5b5c0375cfe6cc15c1be4b23445e24a7cad3616a