If my app is started and I initialise RemoteIO, and then turn on Sound Recognition (say via control centre), the RemoteIO input callback is not called thereafter, until I tear down the audio unit and set it back up. So something like the following:
Launch app
RemoteIO is initialised and working, can record
Turn on Sound Recognition via Settings or control centre widget
Start recording with already-set up RemoteIO
Recording callback is never again called
Though no input callbacks are seen, kAudioOutputUnitProperty_IsRunning is reported as true, so the audio unit thinks it is active
Tear down audio unit
Set up audio unit again
Recording works
Buffer size is changed, reflecting some effect on the audio session of the Sound Recognition feature
What could be going on here? Am I not handling a route change properly? There doesn’t seem to be a reliable sequence of events I can catch to know when to reset the audio unit.
The only fix I’ve found here is to hack in a timer that checks for callback activity shortly after starting recording, and resets the audio unit if no callback activity is seen. Better than nothing, but not super reliable.
The answer to this, ultimately, was to ditch using RemoteIO and use AVAudioEngine. It has a TON of its own quirks (have fun hunting down crashes when you make even the tiniest mistake with connections and formats or engine lifecycle), but if you respond to the engine reset event it mostly continues working when Sound Recognition is toggle on and off.