From fcb03ad8c269c04f32d9b17e3786abd0f20516a8 Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Tue, 26 May 2026 18:26:58 -0400 Subject: [PATCH] Fix pause/resume desync by stopping and restarting stream at offset instead of SIGSTOP/SIGCONT --- orb_stream_worker/server.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/orb_stream_worker/server.js b/orb_stream_worker/server.js index c538a52..5850ea2 100644 --- a/orb_stream_worker/server.js +++ b/orb_stream_worker/server.js @@ -563,22 +563,22 @@ const server = http.createServer(async (request, response) => { const action = String(body.action || "").trim(); if (action === "pause") { - if (!canPauseCommand(session.ffmpegCommand)) { - throw new Error("Pause is not available because FFmpeg is not active"); + if (session.playbackState !== "playing") { + throw new Error("Pause is not available because session is not playing"); } - session.positionSeconds = sessionPlaybackPosition(session); - session.startedAtSeconds = 0; - session.ffmpegCommand.ffmpegProc.kill("SIGSTOP"); + const pausedPos = sessionPlaybackPosition(session); + await stopSessionPlayback(session, false); + session.positionSeconds = pausedPos; session.playbackState = "paused"; session.workerStatus = "connected"; } else if (action === "resume") { - if (!canPauseCommand(session.ffmpegCommand)) { - throw new Error("Resume is not available because FFmpeg is not active"); + if (session.playbackState !== "paused") { + throw new Error("Resume is not available because session is not paused"); } - session.startedAtSeconds = nowSeconds(); - session.ffmpegCommand.ffmpegProc.kill("SIGCONT"); - session.playbackState = "playing"; - session.workerStatus = "streaming"; + if (!session.playback) { + throw new Error("Cannot resume because no playback metadata exists"); + } + await startPlayback(session, session.playback, session.positionSeconds); } else if (action === "stop" || action === "skip") { await stopSessionPlayback(session, true); } else if (action === "seek") {