8000 Reset sound processing state after seeking. by zhouyunding · Pull Request #1196 · mackron/miniaudio · GitHub
[go: up one dir, main page]

Skip to content

Reset sound processing state after seeking. - #1196

Closed
zhouyunding wants to merge 1 commit into
mackron:devfrom
zhouyunding:fix/1186-seek-cache-reset
Closed

zhouyunding wants to merge 1 commit into
mackron:devfrom
zhouyunding:fix/1186-seek-cache-reset

Conversation

@zhouyunding
Copy link
Copy Markdown

Refs #1186.

Seeking leaves ma_sound playing stale audio from the pre-seek position when the source needs resampling: ma_data_source_seek_to_pcm_frame() only moves the data source cursor, while the sound node's read-ahead cache (processingCacheFramesRemaining) and resampler history still hold pre-seek state.

This clears both on a successful seek (MA_SUCCESS/MA_BUSY/MA_AT_END) in the engine's sound node layer, where that state lives. A rejected seek leaves the cache untouched — the fix suggested in the issue lacks this guard.

Measured 47/512 stale frames before the fix and 1/512 after (the remainder is resampler warm-up). Rejected seeks (INVALID_ARGS/NOT_IMPLEMENTED/INVALID_OPERATION) behave as before.

Pre-existing, not changed by this PR: with mismatched period/chunk sizes, 129/480 frames still come through stale (base: 311/480); seeking the underlying data source directly when base == head still leaves 454/512 stale.

Developed with AI assistance.

mackron added a commit that referenced this pull request Nov 10, 2026
@mackron
mackron commented Nov 10, 2026
Copy link
Copy Markdown
Owner

Thanks. This has been fixed manually.

@mackron mackron closed this Nov 10, 2026
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.

2 participants

0