Audio output randomly shuts down on iOS

Hello everyone,


I've recently started to have troubles with my iOS audio apps. All apps concerned are based on AUGraph with a unique AudioUnit RemoteIO, sending output audio through a custom render callback (basic scheme you can find on several sample codes and guides from Apple documentation).

Sometimes, though rarely, the physical audio output simply shuts down, apparently for no reason, while the render callback continues to be called as normal.

I'm still struggling to identify a reproducible scenario. I already saw it happen with a sound generating app (AVAudioSessionCategoryPlayback) on background, without anything happening. I found a way to restart audio (without restarting the app) by resetting

- the AudioSession's category, buffer duration and sample rate,

- and the stream format of the Bus 0 input on the RemoteIO Audio Unit.

But still, I don't know :

- Why this happens? It seems that the AudioSession and/or RemoteIO enter in some kind of weird state which prevents them to work properly.

- How to get noticed when this happens.

- How to prevent this to happen (which is the most important obviously)?

Does anyone have any clue on what happens here?

Thank you all for your help 🙂

Best,

😎 Tom 😎

Replies

I'm just guessing here, but iOS 11 has this feature https://developer.apple.com/documentation/avfoundation/avaudioengine/2879211-isautoshutdownenabled


It's disabled by default on AVAudioEngine, but not sure how this affects AUGraph.

Hi,


Thanks for the answer.

I'm not sure this is linked to my problem. In my case, when this happens (rarely and apparently randomly), the audio render callback is still called regularly and still sends some audio data, but the physical output (either speaker or headphones) just stops producing sound. My guess is that something goes wrong in the low-level layers of the RemoteIO and/or AUGraph and/or AVAudioSession, but the big questions are: How? Why? How to prevent it?