Repository navigation
Conversation
A sketch enables audio with ConfigKey::AudioEnabled before init(). Seedling then builds the context and graph at startup and we open the stream during init(); without the flag no device is opened and the audio functions return AudioNotEnabled. We manage the cpal stream ourselves instead of seedling's CpalPlatformPlugin: - one output and one optional input device (none by default, so no microphone prompt), by name or index; - a named output is never swapped for another device: if it disappears the stream stops, and it resumes on the same graph when the device returns; - device, sample rate and block size can change while running; - status, info and stream events (lost/restored devices, xruns, restarts). Tests run on a mock backend that pulls blocks without audio hardware, including restarts at changing block sizes.
This branch has not been deployed
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.
Stacked on #300. Adds audio device handling and the audio stream.
Audio is opt-in at init. Set
ConfigKey::AudioEnabledto"true"beforeinit(). Seedling then builds the context and graph at startup, and the stream is open by the timeinit()returns. Without the flag no device is opened, nothing runs per frame, and the audio functions returnAudioNotEnabled(device listing still works).Device handling (
device.rs) replaces seedling'sCpalPlatformPlugin:ConfigKey::Audio*) or index (audio_set_*_device_index). The input defaults to none, so no microphone permission prompt unless a sketch asks for an input.audio_status,audio_infoandaudio_events(lost/restored devices, xruns, restarts).Review notes
lib.rs: the plugin, the opt-in check and the public functions.device.rs: device selection, stream lifecycle and reconnection.tests.rsadds a mock backend that pulls blocks without audio hardware. It's used here for startup and repeated restarts at changing block sizes; later PRs add graph tests on top of it.Testing
cargo test -p processing_audioStack created with GitHub Stacks CLI • Give Feedback 💬