Fail closed when FFmpeg seek fails - #117
Draft
Blackspirits wants to merge 1 commit into
Draft
Blackspirits wants to merge 1 commit into
Blackspirits wants to merge 1 commit into
Conversation
Blackspirits
force-pushed
the
audit/ffmpeg-failed-seek-state-3e4d
branch
from
September 15, 2026 08:21
5983d4d to
bf672ab
Compare
Blackspirits
commented
Sep 15, 2026
Blackspirits
left a comment
Owner
Author
There was a problem hiding this comment.
Final adversarial review on the frozen HEAD after CI SubtitleEdit#248. Rechecked failed-seek rollback, concurrent newer-seek preservation, EOF-state preservation, Play-from-EOF behavior for video and audio-only media, and the serial/queue commit boundary. No blocking defect found in this tranche. CI SubtitleEdit#248 passed build + full suite on this exact HEAD; retry was not used. This remains an audit draft only: no merge/promotion intended.
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Third independent follow-up to merged upstream PR SubtitleEdit#14878 ("FFmpeg player: fix eight teardown, seek and clock defects") on the audited base
3e4d052adc78464e71bbd5154880d935fd592960.The upstream main is now
4ecc74a92a630e62824e92c8f64aa42c7de1b84d, four commits ahead of that audit base. Those commits touch Italian localization, Batch Convert, and Auto Translate only; there is no drift inFfmpegPlayer.csor its FFmpeg tests, so this tranche stays on the common #115/#116 base to keep the FFmpeg follow-ups isolated and directly comparable.Finding fixed
Failed
av_seek_frame()committed a seek that never happenedBefore this PR,
PerformSeek()logged a native seek failure and then continued as if it had succeeded:_currentSerialto the failed request;The public
Seek()path also optimistically assigned_pausedPositionto the requested target and cleared_endReachedbefore libavformat had accepted the seek.That leaves the player reporting and scheduling from a destination the demuxer never reached, while throwing away the still-valid pre-seek pipeline.
FFmpeg's own
ffplayonly flushes packet queues and resets the external clock inside the successful-seek branch; a failed seek logs the error and leaves those committed playback structures alone.Transactional seek behavior
This PR makes the seek state fail closed:
Seek()now records only the requested serial/target and wakes demux; committed playhead/end state is left untouched.PerformSeek()returns success/failure._endReached = falsehappen only afterav_seek_frame()succeeds._requestedSerial/_requestedTargetback to the still-current pipeline state.av_seek_frame()was blocked, failure of the older seek does not erase the newer request.Play / EOF race closed
Keeping the committed end state until native success exposed an important concurrency edge that the old optimistic mutation had been masking:
av_seek_frame()returns, user presses Play;Seek(0), overwriting the user's requested destination.Play now refuses the auto-rewind while any seek is outstanding.
The presenter also keeps an old video EOS marker queued while a newer seek is outstanding. This prevents a video-only stream from calling
ReachEnd()during the native seek and losing the user's Play intent before the new serial commits.Audio-only playback has the same guard: its EOF tick cannot call
ReachEnd()while a seek is outstanding, so restarting an audio-only file from EOF no longer loses the Play intent before the seek commits.Regression coverage
Pure tests pin:
Scope / evidence
0252d55fd2f95752425c2e30b70363e6af7a93e83e4d052adc78464e71bbd5154880d935fd5929604ecc74a92a630e62824e92c8f64aa42c7de1b84d(no relevant FFmpeg drift)bf672abc87e812560af43da5bda4dc3912895c6bFinal CI
Authoritative run: SubtitleEdit#248 on
bf672abc87e812560af43da5bda4dc3912895c6bCompiler warnings are confined to pre-existing accessibility/VoiceManager files outside this PR's changed set.
AI assistance: ChatGPT was used for adversarial seek-state/concurrency review, comparison with FFmpeg's ffplay behavior, and focused regression design.