Add live-input mic permission, audio-input entitlement, and engine-config review fixes
Live input was silent on macOS because the apps ran under hardened runtime without the microphone entitlement, so AUHAL input received silent zeros and the OS never prompted. Fixes: - Add com.apple.security.device.audio-input entitlement to the macOS Builder and Demo apps (CODE_SIGN_ENTITLEMENTS wired in both targets). - Add MicrophonePermission helper (AVCaptureDevice.requestAccess) and gate live-input selection through it in the Builder view and Demo controller; deny falls back to the test loop with an explanatory alert. - Fix ShoeGazeDemo inputChannels 6 -> 1 (built-in mics are mono; 6 made CoreAudio deliver silence). Engine-config review fixes: - installScopeTap now requires the engine stopped (precondition) and reconfigureEngine reinstalls the tap on every exit path via defer, so engine.scopeTap never points at a stale channel layout. - EngineConfigView stops the engine on a post-start (iOS) sample-rate mismatch instead of running pitch-shifted, and surfaces non-mismatch start errors through the alert. - Remove redundant installScopeTap call in the demo controller (ShoeGaze.init already installs it). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,11 @@ extension ShoeGaze {
|
||||
) throws {
|
||||
guard !engine.isRunning else { throw SynthesisEngineConfigError.engineIsRunning }
|
||||
|
||||
// The tapped bus indices depend on the channel layout (input buses follow the output
|
||||
// buses), so the scope tap must be rebuilt for the final configuration — on every exit
|
||||
// path, including a thrown rebuild, so `engine.scopeTap` never points at a stale layout.
|
||||
defer { installScopeTap() }
|
||||
|
||||
let snapshot: ShoeGazeState = captureState()
|
||||
|
||||
// Tear the rig down BEFORE reconfiguring: changing the channel counts re-partitions the
|
||||
@@ -53,10 +58,6 @@ extension ShoeGaze {
|
||||
}
|
||||
|
||||
try rebuildAllBoards(from: snapshot)
|
||||
|
||||
// The tapped bus indices depend on the channel layout (input buses follow the output
|
||||
// buses), so rebuild the scope tap for the new configuration.
|
||||
installScopeTap()
|
||||
}
|
||||
|
||||
/// Default samples-per-frame captured by the scope tap.
|
||||
@@ -73,6 +74,10 @@ extension ShoeGaze {
|
||||
///
|
||||
/// - Parameter bufferSize: Samples per channel per display frame. Defaults to 2048.
|
||||
public func installScopeTap(bufferSize: Int = ShoeGaze.defaultScopeBufferSize) {
|
||||
// `SynthesisEngine` caches its scope tap as `_rtScopeTap` at `start()`; assigning a new tap
|
||||
// while running would silently diverge the RT thread's cached tap from `engine.scopeTap`.
|
||||
precondition(!engine.isRunning, "installScopeTap must be called while the engine is stopped")
|
||||
|
||||
let numOut: Int = engine.numOutputChannels
|
||||
let numIn: Int = engine.numInputChannels
|
||||
|
||||
|
||||
Reference in New Issue
Block a user