Skip to content

Pad audio underruns with silence and preserve render buffer sizes - #9

Open
clopezadereso wants to merge 1 commit into
OpenEmu:masterfrom
clopezadereso:fix/audio-buffer-underruns
Open

clopezadereso wants to merge 1 commit into
OpenEmu:masterfrom
clopezadereso:fix/audio-buffer-underruns

Conversation

@clopezadereso

@clopezadereso clopezadereso commented Nov 16, 2026 •

Copy link
Copy Markdown

When a core's audio ring buffer returns fewer bytes than requested, the source-node callback currently shrinks mDataByteSize and leaves the unread portion untouched. That violates the render-block requirement that buffer sizes match frameCount, and can expose stale samples during an underrun.

Pad short reads with zeroes, retain the requested buffer length and channel layout, and set the silence hint for empty reads. Add regression tests for full, partial and empty reads, plus a request smaller than the available buffer capacity.

Validation: compiled the modified production GameAudio2.swift against OpenEmuBase and ran all four buffer cases locally. The integration suite for OpenEmu 2.4.1's pinned OpenEmuKit (2bc0ee9), with this patch and the current upstream audio availability guard applied, passed 32 tests with 0 failures, including both new regression tests: Xcode test run.

This is a buffer-contract fix discovered while investigating save-state loading from a network library. It does not claim to fix the separate caulk/EABLImpl::create initialization trap on macOS 26.5 under Rosetta, which also reproduces with a standalone silent audio graph and no file access.

Reference: AVAudioSourceNodeRenderBlock.

@clopezadereso
clopezadereso marked this pull request as ready for review November 16, 2026 21:02
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