ALSA duplex bridge example (hardware testing Setup 1)#20
Merged
Conversation
examples/alsa_bridge.cpp implements the two-device real-clock harness from docs/HARDWARE_TESTING.md Setup 1: a capture thread blocks on snd_pcm_readi (paced by the input device's crystal) and feeds asrc.push(), a playback thread feeds snd_pcm_writei from asrc.pull() (paced by the output device's crystal). Per-second status line on stdout, optional --csv telemetry log, optional --dump of the post-ASRC float stream for offline analysis, and --tone <hz> to push a synthetic sine still paced by the input device's real clock. Negotiates FLOAT_LE with S16_LE fallback, recovers from xruns via snd_pcm_recover, clean SIGINT shutdown. examples/CMakeLists.txt guards the new srt_alsa_bridge target behind find_package(ALSA QUIET) so non-Linux CI configures unchanged; verified with -DCMAKE_DISABLE_FIND_PACKAGE_ALSA=ON. Built warning-clean under the srt_warnings flags (-Wall -Wextra -Wpedantic -Wconversion -Wshadow); smoke-tested --help, bad-option handling, and graceful failure when no audio device exists. https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
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.
The Setup 1 deliverable from docs/HARDWARE_TESTING.md: a real-clock test harness bridging two independent ALSA devices through the converter — the canonical two-USB-dongle Raspberry Pi soak test.
What's in here
examples/alsa_bridge.cpp: capture thread (blockingsnd_pcm_readi→push()) and playback thread (pull()→snd_pcm_writei); CLI for devices/rate/channels/period/latency; once-per-second status line plus optional--csvtelemetry log (time_s,state,ppm,fill,underruns,overruns,resyncs) and--dumpof the post-ASRC float stream for offline analysis with the notebook tooling;--tonemode keeps the read cadence on the input device's real crystal but pushes a synthetic sine (clean-signal soak without trusting dongle analog); SIGINT-clean shutdown.snd_pcm_recover, fatal only if recovery fails; non-exactset_rate_nearis a hard error (both domains must be nominally equal for a near-unity ASRC).examples/CMakeLists.txt: built only whenfind_package(ALSA)succeeds — macOS/Windows/no-ALSA configures verified unaffected (including with-DCMAKE_DISABLE_FIND_PACKAGE_ALSA=ON).Verified
Warning-clean under the project flags;
--help/bad-args/no-device paths exit gracefully. Not verified: actual audio I/O — no hardware here. This is the piece you point at a Pi with two dongles; the README's hardware-testing doc now references the workflow.https://claude.ai/code/session_01HuAFfoeD5a5Xe5aGNA16M9
Generated by Claude Code