Skip to content

fix(AudioPlayer): process a seek requested while paused on resume - #152

Open
whoisdennis wants to merge 1 commit into
dimitris-c:mainfrom
whoisdennis:fix/seek-while-paused
Open

whoisdennis wants to merge 1 commit into
dimitris-c:mainfrom
whoisdennis:fix/seek-while-paused

Conversation

@whoisdennis

Copy link
Copy Markdown

Problem

seek(to:) while paused sets the seek request and dispatches processSource, which returns early because the player is paused. resume() restores the state and restarts the engine but never dispatches processSource again. Unless new data arrives from the source and triggers it, the seek stays pending: progress keeps returning the seek target and playback does not move, while state reports .playing.

It shows when the player stays paused for a moment between seek(to:) and resume() and the source has already been read to the end (local files, short or fully buffered streams).

Fix

Dispatch processSource on sourceQueue at the end of resume(), as pause() already does. A second pass is harmless: the seek is processed once, and seekRequest.version keeps a seek issued in between.

Tests

New SeekWhilePausedTests.testSeekWhilePausedLandsAfterResume: play an 8 s tone file, pause, seek to 5 s, stay paused for 1 s, resume, expect progress to move past the target. Fails 3/3 on 1.4.5, passes 3/3 with the fix.

swift build and swift test --parallel: 55 tests, 0 failures.

seek(to:) schedules processSource, which returns early while the player
is paused. resume() never scheduled it again, so unless new data arrived
the seek stayed pending: progress reported the target and playback did
not move. Schedule processSource on resume, as pause() already does.
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