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
{
public:
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(
deviceManager,
0, 0, 1, 2,
true, // showMidiInputOptions
true, // showMidiOutputSelector
true, // showChannelsAsStereoPairs
true // hideAdvancedOptions
);
settings->setSize(600, 400);
DialogWindow::LaunchOptions options;
options.content.setOwned(settings);
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
{
public:
MainContentComponent() {
setSize (800, 600);
setAudioChannels (2, 2);
AudioSettings::launch();
}
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?
π
