fix(gfx): audio_play / audio_play_loop accept VAL_BUFFER samples (#578)#587
Merged
Merged
Conversation
audio_convert_samples was list-only, silently returning channel 0 for a buffer — the type the language recommends for bulk samples and what a DAW render produces. Buffers now convert directly off their C double array (same clamping and 64 MB cap as lists); empty buffers rejected like empty lists. Gfx-suite checks: play, play_loop, clamping, queued length, empty-buffer rejection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
audio_convert_samples (src/ext_gfx.c) accepted only VAL_LIST, so audio_play / audio_play_loop silently returned channel 0 when handed a buffer — the type the language itself recommends for bulk samples and what every DeslanStudio render produces. Downstream, a DAW render had to be converted buffer→list per play (~16M appends + VAL_NUM allocations for a 3-minute stereo render) just for the C side to immediately re-walk it into int16.
Fix
audio_convert_samples takes a VAL_BUFFER branch reading straight off the buffer's C double array — same [-1, 1] clamping and 64 MB cap as the list path; empty buffers are rejected (return 0) exactly like empty lists. Both audio_play and audio_play_loop get the fast path through the shared converter; DeslanStudio's sink_audio_interleave workaround can be dropped.
Tests
Device-gated mixer block of tests/test_audio.eigs (runs under SDL_AUDIODRIVER=dummy): buffer play returns a channel id, buffer play_loop plays and stops, queued length matches the buffer count, out-of-range buffer samples clamp, empty buffer rejected.
Gates
detect_leaks=12866/2866, tally 0, [87] cleanmake jit-smokegreen (freestanding-check not run — no core file touched; ext_gfx.c is in no default build)Closes #578
🤖 Generated with Claude Code