Open Same Output with Multiple Device Managers in CoreAudio

I’m attempting to open the same output from two different audio device managers. My intent is to allow my user to play different audio streams for different purposes, but allow them to select a single output device if they wish. Consider the following test code:

    toneGenerator1.reset(new ToneGenerator(440.0));
    toneGenerator2.reset(new ToneGenerator(660.0));

    audioDeviceManager1.initialise(0, 2, nullptr, true, {}, nullptr);
    audioDeviceManager2.initialise(0, 2, nullptr, true, {}, nullptr);



When I run this using Windows Audio or DirectSound, both generated tones play as a mix to a single device. However, when I run the same code on macOS with CoreAudio, only the first tone is played. If I do not initialize the first device manager, then the second tone is played. If I add both callbacks to the first device manager, then both tones are played.

I am hoping to avoid writing my own layer logic on top of the Juce framework to detect when the user has selected the same device twice and reuse that device manager. It is more convenient and safe if Juce can simply mix the device manager outputs for me when necessary. Is what I am trying to do possible with Juce in a cross-platform agnostic manner, or do I need to create my own solution?

I am running with Juce 6.0 7.

This is a follow-up for those attempting to accomplish the same thing I am.

I did not find a means to allow two device managers on Windows to open the same output. Instead, I implement logic to share a single device manager and its associated output when my user selects the same output two different purposes. Adding multiple callbacks to the same device manager does mix the output with simple summing of audio.

This solution is probably better than my original intended approach, because it would likely not work in the case of Windows Audio Exclusive Mode and ASIO drivers. These driver APIs would fail to open the same device twice. Opening once and mixing the output works well for all cases.