Repository navigation
cvc::gl::playback: SDL3 audio-output sink (f32 PCM playback) - #535
Merged
Merged
Conversation
open_audio_output()/list_audio_playback_devices() wrap an SDL3 playback device as an audio_output sink consuming interleaved f32 PCM — the output mirror of cvc::gl::capture::audio_source. Where a capture source is a frame_source a stream PULLS from, an audio_output is a push sink the app feeds: pull frames off a stream subscription on the app tick and hand each chunk to play(). Deliberately untied from the stream types (takes raw bytes), so it plays a live mic stream, a replayed recording, or any f32 the app holds — the holy-grail mic record/playback path. New src/cvcGL/playback/ dir (cvc::gl::playback), symmetric to capture/, its own glob in the cvcGL CMakeLists. SDL-gated on CVC_ENABLE_SDL, graceful no-op without it. Push model (SDL_PutAudioStreamData); queued_bytes() for pacing/"done"; flush() drops the queue. Subsystem refcount balanced on every path; resume failure fails the open loudly; dtor closes device then quits the subsystem. play() rejects a non-frame-aligned size and pushes in frame-aligned slices so a single buffer larger than INT_MAX queues whole instead of truncating. Device-gated test (enumeration always; live playback behind CVC_TEST_AUDIO) plays a generated tone and verifies the device queues then drains it. Folds an adversarial review: the size_t->int truncation fix plus the flush() device-buffer-tail caveat.
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.
Holy-grail step (b): the SDL3 audio playback sink — the output mirror of the capture source (device audio source is #534). Independent of the
#532→#534stack (needs only the merged stream substrate), so it targetsmasterdirectly.open_audio_output()/list_audio_playback_devices()wrap an SDL3 playback device as anaudio_outputsink that consumes interleaved f32 PCM. Where a capture source is aframe_sourcea stream pulls from, anaudio_outputis a push sink the app feeds: pull frames off a stream subscription on the app tick and hand each chunk toplay(). It's deliberately untied from the stream types (takes raw bytes), so it plays a live mic stream, a replayed recording, or any f32 PCM in hand — the record/playback half of the mic demo.Structure: new
src/cvcGL/playback/dir (cvc::gl::playback), symmetric tocapture/, with its own glob. SDL-gated onCVC_ENABLE_SDL, graceful no-op without it.API:
play(data, bytes)(push model,SDL_PutAudioStreamData),queued_bytes()(pacing / "done"),flush()(drop the queue). Subsystem refcount balanced on every path; resume failure fails the open loudly; dtor closes the device then quits the subsystem.Robustness:
play()rejects a non-frame-aligned size and pushes in frame-aligned slices, so a single buffer larger thanINT_MAX(~93 min of f32 stereo @ 48 kHz) queues whole instead of truncating.Testing: device-gated
cvcgl_audio_output(enumeration always; live playback behindCVC_TEST_AUDIO) plays a generated tone and verifies the device queues then drains it. Builds clean with SDL on; passes with graceful SKIP on a headless builder.Folds an adversarial review: the
size_t→inttruncation fix plus a documentedflush()device-buffer-tail caveat.