# \[Big Sur\] Audio playback freezes in desktop applications when disconnecting headphones

**URL:** <https://forum.juce.com/t/big-sur-audio-playback-freezes-in-desktop-applications-when-disconnecting-headphones/46230>\
**Category:** MacOSX and iOS\
**Created:** [May 27, 2021, 3:31pm UTC](https://forum.juce.com/t/big-sur-audio-playback-freezes-in-desktop-applications-when-disconnecting-headphones/46230 "2021-05-27T15:31:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkourousi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mkourousi](https://forum.juce.com/u/mkourousi)\
**Post date:** [May 27, 2021, 3:31pm UTC](https://forum.juce.com/t/big-sur-audio-playback-freezes-in-desktop-applications-when-disconnecting-headphones/46230/1 "2021-05-27T15:31:26Z")

</div>

This is reproducible with the juce tutorials (tested with [noise generator](https://docs.juce.com/master/tutorial_simple_synth_noise.html) and [audio player](https://docs.juce.com/master/tutorial_playing_sound_files.html)).

It seems that in Big Sur the headphones and the speakers are two different devices (as opposed to previous OSX versions).  
While the playback is enabled in the desktop app, if I try to remove the headphones then the application playback stops (`getNextAudioCallback` is not called anymore). If I try to plug in the headphones again nothing happens. What is more, I have to launch the app again to restore audio (this happens because the audio device is initialized correctly).

Based on other applications the expected behavior would be that the app should use the Speakers device (since at least on my machine it’s the only available output device).

Has anyone faced this problem? Is there any quick fix?

Could it be related to the fact the the `currentSetup` should be a null pointer when the device is re-initialized? ([JUCE/juce\_AudioDeviceManager.cpp at master · juce-framework/JUCE · GitHub](https://github.com/juce-framework/JUCE/blob/master/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp#L156))

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [May 28, 2021, 1:26pm UTC](https://forum.juce.com/t/big-sur-audio-playback-freezes-in-desktop-applications-when-disconnecting-headphones/46230/2 "2021-05-28T13:26:30Z")

</div>

I’m unable to reproduce this on the lastest `develop` tip on macOS 11.4 using the `SimpleSynthNoiseTutorial`, building on Xcode 12.5 against the macOS 11.3 SDK with a deployment target of 10.11. If I disconnect the headphones whilst the application is running the output switches to the speakers and when plugging the headphones back in playback switches to the headphones as expected. `getNextAudioBlock()` is called continuously.

Can you stick a breakpoint on [this line](https://github.com/juce-framework/JUCE/blob/1634d9f428879492e93a773522adf7ae33a5d8c6/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp#L872) in the CoreAudio internals? I get a `kAudioDevicePropertyDeviceHasChanged` property changed callback when plugging the headphones back in (not when unplugging them) which causes the audio device to be reinitialised and `prepareToPlay()` to be called. Perhaps you are missing that callback for some reason so the device is not being reinitialised.

---

<div class="post-metadata">

**Author:** ![ttg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ttg/32/14456_2.png) [@ttg](https://forum.juce.com/u/ttg)\
**Post date:** [May 29, 2021, 8:20am UTC](https://forum.juce.com/t/big-sur-audio-playback-freezes-in-desktop-applications-when-disconnecting-headphones/46230/3 "2021-05-29T08:20:36Z")

</div>

Are you sure this is a Big Sur thing or specific hardware?

I’ve seen similar issues with T2 based Macs (2018+) and M1/Apple Silicon.But it’s agnostic to OS (I have exact same issue with Mojave).

Not sure about freezing, but the need to actually switch device for the CoreAudio output exists also in Logic.

About stuttering/freeze.  
JUCE uses its own combinator that can cause dropouts.  
For 10.9 or newer Apple’s aggregated device seems to work much better.

> <https://github.com/soundradix/JUCE/commit/c7cf92b51198cdbe55dda7b2c7298b626f094cfd#diff-33fe8ca2f94f335880888d61ac760a17e3ae9f2f36b321dccd195889047a50bb>
