CoreAudio Glitches After Sleep

It appears that when macOS goes to sleep, it doesn’t correctly shut down the audio device or restart it when it resumes from sleep. If you open the JUCE demo and go to the “File Playback” demo, play a file then put the machine to sleep, when you wake it back up the audio will be stuttery.

Is it possible to detect this and pause/stop the audio device and then restart it when the OS resumes?

Hmmm you are not going to like my answer but it seems to be ok on my MacBook Pro. I’m testing with the built-in audio output (no input). Are you doing this on any special audio hardware?

It does it on my MacBook Air as well, no special hardware.

Is it maybe related to this?