From 4fa131f5a7f4eebc05020579c7e81af3a059a156 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 3 Apr 2019 11:55:20 +0100 Subject: [PATCH] Delete the current audio device when no inputs or outputs are specified in AudioDeviceManager::setAudioDeviceSetup() and ensure that the AudioDeviceSelectorComponent displays this correctly --- .../audio_io/juce_AudioDeviceManager.cpp | 10 +++++----- .../gui/juce_AudioDeviceSelectorComponent.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 29eb223d6a..7edbe713e6 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -463,10 +463,13 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup { jassert (&newSetup != ¤tSetup); // this will have no effect - if (newSetup == currentSetup && currentAudioDevice != nullptr) + if (newSetup != currentSetup) + sendChangeMessage(); + else if (currentAudioDevice != nullptr) return {}; - if (getCurrentDeviceTypeObject() == nullptr) + if (getCurrentDeviceTypeObject() == nullptr + || (newSetup.inputDeviceName.isEmpty() && newSetup.outputDeviceName.isEmpty())) { deleteCurrentDevice(); @@ -478,9 +481,6 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup stopDevice(); - if (newSetup != currentSetup) - sendChangeMessage(); - String error; if (currentSetup.inputDeviceName != newSetup.inputDeviceName diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index 1b58e08237..920330474f 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -542,7 +542,7 @@ private: auto* currentDevice = setup.manager->getCurrentAudioDevice(); auto index = type.getIndexOfDevice (currentDevice, isInput); - box->setSelectedId (index + 1, dontSendNotification); + box->setSelectedId (index < 0 ? index : index + 1, dontSendNotification); if (testButton != nullptr && ! isInput) testButton->setEnabled (index >= 0);