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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user