Close iPad magnetic cover results in permanently stopped audio stream

When I close my iPad’s magnetic cover while my JUCE7 iOS app is running, after 1 second the audio stream stops. This coincides with a audioSessionChangedInterruptionType call of type AVAudioSessionInterruptionTypeBegan. AVAudioSessionInterruptionTypeEnded is never received.

I have BACKGROUND_AUDIO_ENABLED TRUE in my CMake build definition and this works fine for ordinary locking and unlocking of the screen. The app keeps playing audio while in normal lock.

My app is 100% open source and CMake so you can try it yourself: GitHub - izzyreal/vmpc-juce: JUCE implementation of VMPC2000XL

Also tried on develop branch.

I’ll try to create a minimal reproduction and add it to this post.

Strangely processBlock doesn’t get called in my own app after the magnetic cover is closed, but it does for JUCE example AUv3SynthPlugin.

When I disable microphone permissions in iOS for my app, processBlock continues to get called. So it looks like we must do some fancy footwork to unhook or stop processing inputs upon a hook like AVAudioSessionInterruptionTypeBegan or applicationDidEnterBackground, and pick it up again in applicationWillEnterForeground.