How to NOT use default audio device on MAC

I just wanted to check if the following is already implemented or can be done in some easy way.
I have a standalone app on OSX.
When the user selects audio device I would like it not to change.
Here is what happens now:

  • User selects audio device.
  • If audio device is disconnected or has other problems, the program defaults to “built in output”
    -When the “real”, the selected device gets back, the app still uses built-in output.
    Is there a simple way to have it A, don’t go to default output, but rather to No device, and B go back to the last used device when it gets plugged back in.?

Same problem here – this is exactly what I complained about in this thread: How to fallback to the default audio device using AudioDeviceManager? . For me the fix was to remove this block of code from AudioDeviceManager::audioDeviceListChanged:

auto isCurrentDeviceStillAvailable = [&]
    for (auto* dt : availableDeviceTypes)
        if (currentAudioDevice->getTypeName() == dt->getTypeName())
            for (auto& dn : dt->getDeviceNames())
                if (currentAudioDevice->getName() == dn)
                    return true;

    return false;

if (! isCurrentDeviceStillAvailable())

    std::unique_ptr<XmlElement> e (createStateXml());

    if (e == nullptr)
        initialiseDefault (preferredDeviceName, &currentSetup);
        initialiseFromXML (*e, true, preferredDeviceName, &currentSetup);

Great that I’m not alone.
Yes, I also found that piece of code right after I posted.
In my case I just commented out:

if (auto e = createStateXml())
initialiseFromXML (*e, true, preferredDeviceName, &currentSetup);
initialiseDefault (preferredDeviceName, &currentSetup);

That is inside

if (! isCurrentDeviceStillAvailable())

Now I’m trying to mod it, so that it will actually go back to the selected device once it gets back “online”