AudioDeviceSelectorComponent's Test button causes crash (iMac running Windows)!


I'm trying to get the Audio Settings to come up in their own window/dialog-box.

I create a fresh "audio application", and add the following code at the start:

class AudioSettings 
    static AudioDeviceManager& getSharedAudioDeviceManager() {
        static AudioDeviceManager* sharedAudioDeviceManager;
        if (sharedAudioDeviceManager == nullptr) {
            sharedAudioDeviceManager = new AudioDeviceManager();
            sharedAudioDeviceManager->initialise(2, 2, 0, true, String(), 0);
        return *sharedAudioDeviceManager;
    static void launch() {
        auto& deviceManager = getSharedAudioDeviceManager();
        // Present an audio settings dialog box.
        AudioDeviceSelectorComponent* settings = new AudioDeviceSelectorComponent(
            0, 0, 1, 2,
            true, // showMidiInputOptions
            true, // showMidiOutputSelector
            true, // showChannelsAsStereoPairs
            true  // hideAdvancedOptions
        settings->setSize(600, 400);
        DialogWindow::LaunchOptions options;
        options.dialogTitle = "Audio Settings";
        options.dialogBackgroundColour = Colours::lightgrey;
        options.escapeKeyTriggersCloseButton = true;
        options.useNativeTitleBar = true;
        options.resizable = true;
        DialogWindow* dw = options.launchAsync();
        dw->centreWithSize(450, 350);
class MainContentComponent   : public AudioAppComponent
    MainContentComponent() {
        setSize (800, 600);
        setAudioChannels (2, 2);

When I run this, the dialog shows:

Pressing the "Test" button correctly sounds, but then it crashes with:

Exception thrown: read access violation.
juce::Array<juce::AudioIODeviceCallback *,juce::DummyCriticalSection,0>::getUnchecked(...)-> was 0x1.
If there is a handler for this exception, the program may be safely continued.


What's going wrong?



Hm. I tested the exact code you posted here, on Xcode 7 and Visual Studio 2015, and I don't get any kind of crash.

Maybe it's something else? Something with your audio device driver? Does it also crash if you use the built-in output?


This seems like a bug that was previously reported and what might be fixed if you update your Juce to the latest one.


Yes! That's the problem! I was still using modules from the old JUCE.

That's careless on my part, I thought I was using the latest JUCE, but I wasn't. Sorry for the noise!

Thanks Xenakios!


Yes, I am suspecting this as well, because I cannot reproduce your situation...

Does this only happen with a particular device? What if you select the default audio I/O? What if you connect some other sound card?


you should use a SharedResourcePointer instead of a static.