AudioDeviceManager::setAudioDeviceSetup sends changes early


Here is the beginning of setAudioDeviceSetup:

String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup,
                                                const bool treatAsChosenDevice)

    jassert (&newSetup != &currentSetup);    // this will have no effect

    if (newSetup == currentSetup && currentAudioDevice != nullptr)
        return String();

    if (! (newSetup == currentSetup))

Is there a reason why sendChangeMessage() is called so early in the function?

I've set a class up to listen to my AudioDeviceManager instance so that I can display some information on the selected input and output channels, but when I call:

    void changeListenerCallback(ChangeBroadcaster *source)
      AudioDeviceManager::AudioDeviceSetup setup;

the changes that I have applied to my AudioDeviceSetup before calling setAudioDeviceSetup are not there anymore.

Am I using it wrong?


The message is asynchronous - it doesn't matter where it gets sent within the function, the result is the same.


Well the callback is asyncronous so it doesn't matter when the sendChangeMessage() is posted, it will never callback untill after
AudioDeviceManager::setAudioDeviceSetup has finished. Your setup probably isn't being applied for some reason. I'd step through it, mabe putting a watchpoint on the setup to see if it gets changed correctly.