Standalone: persist the requested sample rate, and validate it on an input-only stream - #563
Merged
Merged
Conversation
…he device granted captureAudioSettings() wrote back the resolved rate, so one launch on a device without it replaced the user's choice permanently.
Only the output path checked the requested rate against the device, so a hand-edited .conf reached openStream() and raised a startup dialog.
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.
Closes #555. Two commits, independently reviewable.
1. Persist what the user asked for.
captureAudioSettings()wrote back the resolved rate, so saving 96 kHz and launching once on a 48 kHz-only device lost 96 kHz permanently — the same failure SA-2 (5ab316e) fixed for device names. Sample rate now follows that established intent-versus-runtime split:settings.sampleRateis written only at the point of choice (the frontend), and the resolved rate stays incurrentSampleRate.2. Validate on the input-only path. SA-3 clamped
bufferSizebecause the.confis hand-editable; sample rate was left tostartAudioThreadOn, which only validates it when output is in use. Input-only streams passed it straight toopenStream(). Both branches now share arateOfferedBy()helper.While there, a latent bug this makes reachable: the last-resort guard was
sampleRate < 0, but0is the "device preferred" sentinel and theStandaloneSettingsdefault. The output path caught 0 incidentally (0 is never in a device's rate list, so it fell through to preferred); input-only did not, and sent 0 toopenStream(). Now<= 0. This matters more after commit 1, since fresh configs now carry 0.Scope note.
standalone_host_audio.cppis touched becausestartAudioThreadOnImpllives there — the validation cannot be done fromapplyAudioSettings(), since the frontends callstartAudioThreadOndirectly with an arbitrary rate.Windows. Two single statements in
windows_standalone.cpp: persisting the chosen rate in theAudioSampleratehandler (mirroring the existing device-name handlers), and arefreshSampleRates()afterstartAudio()— without it, commit 1 leaves a fresh.confshowing combo index 0 while the stream runs at the device's preferred rate. Not compilable on macOS; CI is the first thing to build it.Build-gated on
clap-first-distortion_standalone(which needsSTANDALONE_CONFIGURATIONSenabled locally — not part of this PR), clean.