diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 1a30064e15..cd1ade5874 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -445,16 +445,15 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup stopDevice(); - if (! newSetup.useDefaultInputChannels) numInputChansNeeded = newSetup.inputChannels.countNumberOfSetBits(); - if (! newSetup.useDefaultOutputChannels) numOutputChansNeeded = newSetup.outputChannels.countNumberOfSetBits(); + if (! newSetup.useDefaultInputChannels) + numInputChansNeeded = newSetup.inputChannels.countNumberOfSetBits(); - auto newInputDeviceName (numInputChansNeeded == 0 ? String() : newSetup.inputDeviceName); - auto newOutputDeviceName (numOutputChansNeeded == 0 ? String() : newSetup.outputDeviceName); + if (! newSetup.useDefaultOutputChannels) + numOutputChansNeeded = newSetup.outputChannels.countNumberOfSetBits(); - String error; auto* type = getCurrentDeviceTypeObject(); - if (type == nullptr || (newInputDeviceName.isEmpty() && newOutputDeviceName.isEmpty())) + if (type == nullptr) { deleteCurrentDevice(); @@ -464,20 +463,22 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup return {}; } - if (currentSetup.inputDeviceName != newInputDeviceName - || currentSetup.outputDeviceName != newOutputDeviceName - || currentAudioDevice == nullptr) + String error; + + if (currentSetup.inputDeviceName != newSetup.inputDeviceName + || currentSetup.outputDeviceName != newSetup.outputDeviceName + || currentAudioDevice == nullptr) { deleteCurrentDevice(); scanDevicesIfNeeded(); - if (newOutputDeviceName.isNotEmpty() && ! deviceListContains (type, false, newOutputDeviceName)) - return "No such device: " + newOutputDeviceName; + if (newSetup.outputDeviceName.isNotEmpty() && ! deviceListContains (type, false, newSetup.outputDeviceName)) + return "No such device: " + newSetup.outputDeviceName; - if (newInputDeviceName.isNotEmpty() && ! deviceListContains (type, true, newInputDeviceName)) - return "No such device: " + newInputDeviceName; + if (newSetup.inputDeviceName.isNotEmpty() && ! deviceListContains (type, true, newSetup.inputDeviceName)) + return "No such device: " + newSetup.inputDeviceName; - currentAudioDevice.reset (type->createDevice (newOutputDeviceName, newInputDeviceName)); + currentAudioDevice.reset (type->createDevice (newSetup.outputDeviceName, newSetup.inputDeviceName)); if (currentAudioDevice == nullptr) error = "Can't open the audio device!\n\n" @@ -504,12 +505,15 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup outputChannels.setRange (0, numOutputChansNeeded, true); } - if (newInputDeviceName.isEmpty()) inputChannels.clear(); - if (newOutputDeviceName.isEmpty()) outputChannels.clear(); + if (newSetup.inputDeviceName.isEmpty()) inputChannels.clear(); + if (newSetup.outputDeviceName.isEmpty()) outputChannels.clear(); } - if (! newSetup.useDefaultInputChannels) inputChannels = newSetup.inputChannels; - if (! newSetup.useDefaultOutputChannels) outputChannels = newSetup.outputChannels; + if (! newSetup.useDefaultInputChannels) + inputChannels = newSetup.inputChannels; + + if (! newSetup.useDefaultOutputChannels) + outputChannels = newSetup.outputChannels; currentSetup = newSetup; diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index ee22972aca..2cc3b19d41 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -60,8 +60,9 @@ struct SimpleDeviceManagerInputLevelMeter : public Component, void paint (Graphics& g) override { + // (add a bit of a skew to make the level more obvious) getLookAndFeel().drawLevelMeter (g, getWidth(), getHeight(), - (float) std::exp (std::log (level) / 3.0)); // (add a bit of a skew to make the level more obvious) + (float) std::exp (std::log (level) / 3.0)); } AudioDeviceManager& manager; @@ -904,12 +905,7 @@ public: } } - auto error = setup.manager->setAudioDeviceSetup (config, true); - - if (error.isNotEmpty()) - { - //xxx - } + setup.manager->setAudioDeviceSetup (config, true); } } diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h index a589f9c415..8fb221de15 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.h @@ -95,6 +95,12 @@ public: private: //============================================================================== + void handleBluetoothButton(); + void updateDeviceType(); + void updateMidiOutput(); + void changeListenerCallback (ChangeBroadcaster*) override; + void updateAllControls(); + std::unique_ptr deviceTypeDropDown; std::unique_ptr