Skip to content

fix(gfx): audio_play / audio_play_loop accept VAL_BUFFER samples (#578)#587

Merged
InauguralPhysicist merged 1 commit into
mainfrom
fix/578-audio-buffer-samples
Jul 13, 2026
Merged

fix(gfx): audio_play / audio_play_loop accept VAL_BUFFER samples (#578)#587
InauguralPhysicist merged 1 commit into
mainfrom
fix/578-audio-buffer-samples

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

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

  • gfx-build full suite 2886/2886 (audio section: 25 checks + mixer/buffer block, SDL dummy driver)
  • default release suite 2862/2862; ASan+UBSan detect_leaks=1 2866/2866, tally 0, [87] clean
  • make jit-smoke green (freestanding-check not run — no core file touched; ext_gfx.c is in no default build)

Closes #578

🤖 Generated with Claude Code

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>
@InauguralPhysicist InauguralPhysicist merged commit 28a9ced into main Jul 13, 2026
17 checks passed
@InauguralPhysicist InauguralPhysicist deleted the fix/578-audio-buffer-samples branch July 13, 2026 03:08
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.

gfx audio: audio_play / audio_play_loop reject VAL_BUFFER samples (list-only)

1 participant