Decode on a single background thread; add intro skip key

PlaybackEngine now runs one daemon decode thread that routes packets into
bounded queues, while the video/audio presenter threads only consume and
pace. This removes the demuxer contention that caused stutter, bursts, and
the speed-up/catch-up behavior.

Press S (or media next) during playback to skip the current playlist and
advance the menu's intro chain quickly.
This commit is contained in:
2026-09-16 00:04:25 -04:00
parent 3ded804b94
commit 9a1e048264
2 changed files with 101 additions and 54 deletions
@@ -64,6 +64,7 @@ public final class PlayerApp extends Application {
private final WritableImage[] videoImages = new WritableImage[2];
private final int[][] argbBuffers = new int[2][];
private int videoBufferIndex = 0;
private volatile boolean skipRequested = false;
@Override
public void start(Stage stage) {
@@ -114,6 +115,10 @@ public final class PlayerApp extends Application {
togglePause();
return;
}
case S, TRACK_NEXT -> {
skipRequested = true;
return;
}
default -> { }
}
@@ -202,6 +207,10 @@ public final class PlayerApp extends Application {
PlaybackEngine.VideoFrame frame;
while ((frame = engine.nextVideoFrame()) != null) {
if (skipRequested) {
skipRequested = false;
break;
}
int index = videoBufferIndex++ & 1;
int[] argb = argbBuffers[index];
int pixelCount = frame.width() * frame.height();