Strange behaviour when plugging/unplugging headphones M1 Mac

We discovered this on a big application at first, but then I managed to reproduce it on a simple JUCE test app, which made me thing it could be a JUCE issue.

In both apps we use AudioDeviceSelectorComponent to manage audio devices. It only happens on Mac M1.

Here are some repro steps:

  1. launch the app while headphones are disconnected; sound will play through the speakers and the devices look like this:

  1. now connect the headphones; notice the output device changed to “external headphones” but, at least in my/our case, the sound keeps coming out of the speakers.

  1. for more weirdness, try e.g. to manually select the speakers from the drop down, it will not do anything!

  1. bonus: once an output device is selected (try e.g. with a device that is NOT headphones nor speakers… it could be the ZoomAudioDevice in my case, or whatever you have) try plugging and unplugging the headphones and observe the Output device field: it seems to be flipping between the currently selected device and the previous one… E.g. in my example it could flip between the zoom device and None…

I hope the above gives an idea of what’s happening… Any input will be appreciated, thank you!

1 Like

Can confirm this is what is happening! Work around is to select << none >> and then External Headphones to make stuff come out of your headphones.

1 Like

Additional anecdatapoint:

this happens for me sometimes with 2019 Macbook Pro 16" Intel - Big Sur - JUCE 7.0.5 master branch

Doesn’t seem to be consistent though, although have the same symptom of not being able to switch to headphones/speakers without first going through another device choice.

1 Like

Could someone on the JUCE team tell us what’s supposed to be happening here, is this a bug or do we need to find some work around? How does it end up showing the head phones as the current device even though it’s not using it?

Bump

1 Like

bump

3 Likes

Thanks for reporting. Apologies this hasn’t had any attention until now!

This certainly strikes me as a potential JUCE bug I’ll try and take a look later today and keep you posted on my findings.

1 Like

OK I think I’ve tracked down the source of the bug. It appears our wrapper around a CoreAudio device effectively caches its index into the array of all the audio devices, so when the combo-box asks for the device at a particular index (after a device has been added or removed) it can get the wrong one. This means it displays a different device, it also means the device names shown and the indexes associated aren’t always correct, hence the selection going wrong too.

I’ll probably need to do some more extensive testing and I’ll try and see if this issue might exist on other platforms too.

Thanks again for reporting.

3 Likes

Thanks for your patience on this one. This should be fixed in this commit.

Thanks for reporting.

2 Likes

I think there is a jassertfalse in AudioDeviceSettingsPanel::resize with your modification
as updateAllControls was called when you were in the widget hierarchy and it’s not the case anymore

Thanks I’ll take a look.