Reflect input-channel count in the input picker before Start
Engine config edits (In/Out/Rate) now apply to the stopped engine immediately rather than only at Start, so the input-source picker — which lists 0..<engine.numInputChannels — updates as soon as the In stepper changes, letting the user choose the input before starting. No-op while running (controls are disabled). Reuses the existing onConfigApplied refresh path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,32 @@ public struct EngineConfigView: View {
|
|||||||
pendingInputs = shoeGaze.engine.numInputChannels
|
pendingInputs = shoeGaze.engine.numInputChannels
|
||||||
pendingOutputs = shoeGaze.engine.numOutputChannels
|
pendingOutputs = shoeGaze.engine.numOutputChannels
|
||||||
}
|
}
|
||||||
|
// Apply config edits to the (stopped) engine immediately so dependent UI — notably the
|
||||||
|
// input-source picker, which lists `0..<engine.numInputChannels` — reflects the new channel
|
||||||
|
// counts before Start. While running, the controls are disabled, so these never fire then.
|
||||||
|
.onChange(of: pendingInputs) { applyConfigWhileStopped() }
|
||||||
|
.onChange(of: pendingOutputs) { applyConfigWhileStopped() }
|
||||||
|
.onChange(of: pendingSampleRate) { applyConfigWhileStopped() }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reconfigures the stopped engine with the pending values and notifies the host so views that
|
||||||
|
/// read non-observable engine state refresh. No-op while the engine is running.
|
||||||
|
private func applyConfigWhileStopped() {
|
||||||
|
guard !shoeGaze.engine.isRunning else { return }
|
||||||
|
do {
|
||||||
|
if let applyConfig: (Double, Int, Int) throws -> Void = applyConfig {
|
||||||
|
try applyConfig(pendingSampleRate, pendingInputs, pendingOutputs)
|
||||||
|
} else {
|
||||||
|
try shoeGaze.reconfigureEngine(
|
||||||
|
sampleRate: pendingSampleRate,
|
||||||
|
inputChannels: pendingInputs,
|
||||||
|
outputChannels: pendingOutputs
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onConfigApplied()
|
||||||
|
} catch {
|
||||||
|
print("[EngineConfigView] live reconfigure failed: \(error)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func label(_ text: String) -> some View {
|
private func label(_ text: String) -> some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user