Linux Audio App: Device setup applied in MainContentComponent constructor does not work (but works when changed later at runtime)

I’m facing a strange error with an audio app that was mainly developed on Mac OS but has also been ported to linux to be able to demonstrate it running on a pretty limited machine. There is currently no really good debugging solution on that Linux machine, the workflow until now was building a stable application on the mac, generating a Linux Makefile exporter in the Projucer and let it compile on the Linux target. No Projucer, no IDE is installed there. So before setting up debugging tools on that machine, maybe someone has an Idea what might go wrong.

The application has a combo box for choosing the audio device to use, the ComboBoxChanged callback looks like this:

String selectedInterface = interfaceSelector.getText();

AudioDeviceManager::AudioDeviceSetup currentSetup;
deviceManager.getAudioDeviceSetup(currentSetup);

currentSetup.outputDeviceName = selectedInterface;
currentSetup.inputDeviceName = selectedInterface;

deviceManager.setAudioDeviceSetup(currentSetup, true);

Changing the device this way works on both Mac OS and Linux.

Now as the Linux target is connected to a fixed hardware setup I want the linux binary built for this particular machine to chose the right device at startup. To do so, I added the following lines to my MainContentComponent constructor:

    AudioDeviceManager::AudioDeviceSetup currentAudioSetup;
    deviceManager.getAudioDeviceSetup (currentAudioSetup);
    currentAudioSetup.bufferSize = 2048;
#ifdef MY_SPECIAL_LINUX_TARGET
    currentAudioSetup.outputDeviceName = "US-4x4, USB Audio; Direct hardware device without any conversions";
    currentAudioSetup.inputDeviceName  = "US-4x4, USB Audio; Direct hardware device without any conversions";
#endif

    String setupResult = deviceManager.setAudioDeviceSetup (currentAudioSetup, true);
    if (setupResult.isEmpty())
        std::cout << "Sucessfully connected to audio device" << std::endl;
    else
        std::cout << "Error setting up audio device: " << setupResult << std::endl;

This leads to the following behaviour:

  • The setup is applied without errors
  • getNextAudioBlock gets called, audio input works
  • The audio interface doesn’t output anything
  • After changing to any other audio device and then changing back to this device the output works

I don’t really have any idea what could go wrong here and without a debugger I have even fewer ideas :grimacing: So if anyone sees an obvious mistake or knows about any limitation in setting audio devices I’m not aware of, I’d be happy :wink: