Skip to content

fix: keep a seek near the end of the source and the position after seeking back - #328

Merged
devopvoid merged 1 commit into
mainfrom
fix/media-player-seek-and-position
Oct 5, 2026
Merged

devopvoid merged 1 commit into
mainfrom
fix/media-player-seek-and-position

Conversation

@devopvoid

Copy link
Copy Markdown
Owner

Summary

  • A seek made while the decode thread waited for the queue to play out (the last second or two of any source, and all of a short one) was taken for the end of the source. The seek emptied the queue, the wait saw it drained, and the player reported the end of the stream and stopped with the seek still pending. The wait now ends when a seek is pending, and the player carries the seek out instead of ending.
  • Audio only moves the position forward, so a position left over from before a backward seek held an audio-only source where it had been until the audio caught up. MediaPacer::Flush now takes the position to start from, and a seek passes its target (plus the loop offset, so getPositionUs() reads the target at once while looping).

Test plan

  • seekNearTheEndIsNotLost and positionFollowsABackwardSeekOfAudio fail on the old native code (11 frames and none after the seek; position still 1500000 us) and pass with the fix
  • Full media module suite with -Dwebrtc.test.hardwareDecoding=true: 56 tests, 0 failures
  • The new tests and the neighbouring seek, loop and pause tests, three more runs in a row

…eking back

A seek made while the decode thread waited for the queue to play out, which
is the last second or two of any source and all of a short one, was taken
for the end of the source: the seek emptied the queue, the wait saw it
drained, and the player reported the end of the stream and stopped, with the
seek still pending. The wait now ends when a seek is pending, and the player
carries the seek out instead of ending.

Audio only ever moves the position forward, so a position left over from
before a seek backwards held an audio-only source at where it had been until
the audio caught up. Flushing the pacer now sets the position, and a seek
passes its target.

The tests fail without the fixes: a seek to the start at 0.7 s of a two
second clip played no more frames, and 0.4 s after seeking an audio file
back from 1.5 s the position still read 1.5 s.
@devopvoid
devopvoid merged commit 1a54498 into main Oct 5, 2026
22 checks passed
@devopvoid
devopvoid deleted the fix/media-player-seek-and-position branch October 5, 2026 13:36
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.

1 participant