Skip to content

cvc::gl::capture: SDL3 audio-capture source (audio-source family device member) - #534

Merged
transfix merged 4 commits into
masterfrom
feat/stream-audio-device
Oct 2, 2026
Merged

transfix merged 4 commits into
masterfrom
feat/stream-audio-device

Conversation

@transfix

@transfix transfix commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Stacked on #532 (shares the new capture/ dir + glob). Retarget to master once #532 lands.

Phase-3 holy-grail step (a): the device member of the audio-source family (tone/gain/mix are #533). open_audio_capture() / list_audio_capture_devices() wrap an SDL3 recording device (mic, line-in, any OS/virtual capture endpoint) as a cvc::ariadne::stream::frame_source emitting interleaved f32 PCM — so it composes with the pure members and feeds a stream exactly like any other source. The audio analogue of camera_source: SDL stays in cvcGL (its peripheral seam), gated on CVC_ENABLE_SDL, graceful no-op without it.

Design

  • Pull model (NULL callback + SDL_GetAudioStreamData); own device-sample-timeline pts.
  • Drops at source per the frame_source BACKPRESSURE contract: an SDL recording FIFO accumulates every sample, so when the backlog passes an ~80 ms latency ceiling fill() sheds the oldest down to the most-recent chunk and advances the pts over the dropped audio (keeps it ~wall-clock + monotonic) — the audio analogue of the camera handing back only its newest frame.
  • Subsystem refcount balanced on every path; join-before-free teardown; resume failure fails the open loudly instead of returning a silent dead source.

Testing: device-gated cvcgl_audio_source (enumeration always; live capture behind CVC_TEST_AUDIO), mirroring cvcgl_camera_source. Builds clean with SDL on; passes with graceful SKIP on a headless builder (no audio server). The transport layer and the pure audio sources are covered hardware-free by stream_test.

Folds an adversarial review: the back-pressure/unbounded-backlog defect (the one real finding) plus the resume-return and weak-monotonicity-assertion nits.

…io-source family)

open_audio_capture()/list_audio_capture_devices() wrap an SDL3 recording device
(microphone, line-in, or any OS/virtual capture endpoint) as a
cvc::ariadne::stream::frame_source producing interleaved f32 PCM — the device
member of the audio-source family, composing with the pure tone/gain/mix members
exactly like any other frame_source. The audio analogue of camera_source: SDL
lives in cvcGL (its peripheral seam), gated on CVC_ENABLE_SDL, graceful no-op
without it.

Pull model (NULL callback + SDL_GetAudioStreamData), own device-sample-timeline
pts. Drops at source per the frame_source BACKPRESSURE contract: an SDL recording
FIFO accumulates every captured sample, so when the backlog exceeds an ~80 ms
latency ceiling fill() sheds the oldest samples down to the most-recent chunk and
advances the pts over the dropped audio (keeps it ~wall-clock, stays monotonic) —
the audio analogue of the camera handing back only its newest frame. Subsystem
refcount balanced on every path; join-before-free teardown; resume failure fails
the open loudly rather than returning a silent dead source.

Device-gated test (enumeration always; live capture behind CVC_TEST_AUDIO),
mirroring cvcgl_camera_source; the transport and the pure audio sources are
covered hardware-free by stream_test.
@transfix
transfix changed the base branch from feat/stream-camera to master October 2, 2026 14:26
@transfix
transfix enabled auto-merge October 2, 2026 14:26
@transfix
transfix merged commit 7e84650 into master Oct 2, 2026
13 checks passed
transfix added a commit that referenced this pull request Oct 2, 2026
@transfix
transfix deleted the feat/stream-audio-device branch October 29, 2026 20:53
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