Skip to content

Standalone: persist the requested sample rate, and validate it on an input-only stream - #563

Merged
defiantnerd merged 2 commits into
nextfrom
fix-555-standalone-sample-rate
Sep 15, 2026
Merged

defiantnerd merged 2 commits into
nextfrom
fix-555-standalone-sample-rate

Conversation

@defiantnerd

Copy link
Copy Markdown
Collaborator

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.sampleRate is written only at the point of choice (the frontend), and the resolved rate stays in currentSampleRate.

2. Validate on the input-only path. SA-3 clamped bufferSize because the .conf is hand-editable; sample rate was left to startAudioThreadOn, which only validates it when output is in use. Input-only streams passed it straight to openStream(). Both branches now share a rateOfferedBy() helper.

While there, a latent bug this makes reachable: the last-resort guard was sampleRate < 0, but 0 is the "device preferred" sentinel and the StandaloneSettings default. 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 to openStream(). Now <= 0. This matters more after commit 1, since fresh configs now carry 0.

Scope note. standalone_host_audio.cpp is touched because startAudioThreadOnImpl lives there — the validation cannot be done from applyAudioSettings(), since the frontends call startAudioThreadOn directly with an arbitrary rate.

Windows. Two single statements in windows_standalone.cpp: persisting the chosen rate in the AudioSamplerate handler (mirroring the existing device-name handlers), and a refreshSampleRates() after startAudio() — without it, commit 1 leaves a fresh .conf showing 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 needs STANDALONE_CONFIGURATIONS enabled locally — not part of this PR), clean.

…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.
@defiantnerd
defiantnerd merged commit 3ad24da into next Sep 15, 2026
28 checks passed
@defiantnerd
defiantnerd deleted the fix-555-standalone-sample-rate branch September 15, 2026 04:57
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