Skip to content

jk: a pause during a cutscene keeps the sound in order and in sync - #15

Merged
finger563 merged 2 commits into
mainfrom
fix/jk-cutscene-pause
Nov 8, 2026
Merged

finger563 merged 2 commits into
mainfrom
fix/jk-cutscene-pause

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Problem

Pausing Jedi Knight during a cutscene (from the emulator's pause menu) and resuming garbled the sound: out of order, partly looping. After a first fix, the sound was clean but the picture ended up noticeably ahead of it.

The cutscene keeps time by the wall clock, and the pause menu parks the engine without telling it. On resume, the cutscene took the whole pause for lag and decoded every frame it had missed back to back. That's seconds of audio at once, more than the 128-packet queue holds. Since #3 (cutscenes); not related to the espp update.

Fix

  • OpenJKDF2 46ccc6d (esp32p4): adds jkCutscene_ESP32_SkipTime(us), which moves the cutscene's clocks forward, as the cutscene's own pause (space) does.
  • jk_esp_park_point() calls it with the time it was parked. That covers both park points: between engine frames (the one a cutscene normally hits) and inside the engine's menu loops.
  • The mixer task keeps mixing until the engine has actually parked (g_parked), instead of stopping on the pause request. The engine can finish a frame after the request, and that frame's sound would otherwise fall behind its picture.

Tested on the Tab5

Paused and resumed during cutscenes: the sound stays in order and in sync with the picture ("works perfectly").

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

…penJKDF2 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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Copilot AI balanced review requested due to automatic review settings November 8, 2026 14:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The clock adjustment double-counts the emulator menu interval when the cutscene is already paused with Space, causing the video to stall after resuming.

1 open issue
What changed in this PR

This PR addresses Jedi Knight cutscene audio corruption and synchronization drift when resuming from the emulator’s pause menu.

Changes:

  • Measures engine park time and passes it to OpenJKDF2’s cutscene clock-adjustment hook.
  • Keeps the mixer running until the engine actually parks, rather than stopping immediately on a pause request.
File Description
components/​jk/​src/​jk.cpp Adjusts cutscene timing after parking and aligns mixer suspension with the engine’s parked state.

Review effort: Balanced

Comment thread components/jk/src/jk.cpp Resolved
…is on)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

ESP-IDF Size Report for 'Tab5 Emu'

Metric Base PR Delta
FLASH 0 bytes (0.00%) 0 bytes (0.00%) 0 bytes (0.00%)
DRAM 267,418 bytes (60.60%) 267,410 bytes (60.60%) ⬇️ -8 bytes (0.00%)
IRAM 0 bytes 0 bytes 0 bytes
RAM (DRAM+IRAM) 267,418 bytes 267,410 bytes ⬇️ -8 bytes (0.00%)

FLASH uses app .bin size or json2 flash sum. RAM sums DRAM+IRAM via idf_size. Percentages shown when totals are available.
DRAM/IRAM usage does not include memory used by the heap allocator at runtime.
This report was generated by esp-idf-size-delta.

@finger563
finger563 merged commit e2a17d6 into main Nov 8, 2026
1 check passed
@finger563
finger563 deleted the fix/jk-cutscene-pause branch November 8, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants