iOS 0.2.1: don't touch the engine's input node (microphone privacy crash); log benchmark

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-15 22:35:18 +01:00
co-authored by Claude Opus 5.5
parent 7f231c8f79
commit 47588990ce
3 changed files with 23 additions and 5 deletions
+14 -3
View File
@@ -67,6 +67,7 @@ static NSError *hostError(NSString *msg) {
AVAudioEngine *_engine;
AVAudioUnit *_instNode;
AVAudioUnit *_fxNode;
NSMutableArray<AVAudioNode *> *_attached; // what rebuild attached, to detach next time
MIDIClientRef _midiClient;
MIDIPortRef _midiPort;
NSArray<NSString *> *_midiSources;
@@ -87,6 +88,7 @@ static NSError *hostError(NSString *msg) {
if (!self) return nil;
registerDevices();
_engine = [AVAudioEngine new];
_attached = [NSMutableArray array];
_midiSources = @[];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
@@ -109,15 +111,20 @@ static NSError *hostError(NSString *msg) {
}];
}
/// Detach what the last rebuild attached, then wire instrument → effect → mixer.
/// Never touch the engine's inputNode: merely reading it opens the microphone,
/// which iOS treats as a privacy access (0.2.0 was killed for exactly that).
- (void)rebuild {
[_engine stop];
for (AVAudioNode *n in [_engine.attachedNodes copy])
if (n != _engine.mainMixerNode && n != _engine.outputNode && n != _engine.inputNode) [_engine detachNode:n];
for (AVAudioNode *n in _attached) [_engine detachNode:n];
[_attached removeAllObjects];
if (!_instNode) return;
[_engine attachNode:_instNode];
[_attached addObject:_instNode];
AVAudioNode *last = _instNode;
if (_fxNode) {
[_engine attachNode:_fxNode];
[_attached addObject:_fxNode];
[_engine connect:_instNode to:_fxNode format:nil];
last = _fxNode;
}
@@ -295,7 +302,11 @@ static double timeRender(SizzleDeviceAU *au, BOOL instrument, double seconds) {
}
- (void)benchmark:(void (^)(NSString *))line done:(void (^)(void))done {
void (^say)(NSString *) = ^(NSString *s) { dispatch_async(dispatch_get_main_queue(), ^{ line(s); }); };
// Also to the system log ("SizzleBench …"), so results can be read over USB.
void (^say)(NSString *) = ^(NSString *s) {
NSLog(@"SizzleBench %@", s);
dispatch_async(dispatch_get_main_queue(), ^{ line(s); });
};
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
say([NSString stringWithFormat:@"%@ · %lu cores · 10 s of 44.1 kHz audio per device",
machine(), (unsigned long)NSProcessInfo.processInfo.activeProcessorCount]);