mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed a bug in the AudioDeviceSelectorComponent when selecting zero channels
This commit is contained in:
parent
3b8686aa97
commit
faf7fb1960
3 changed files with 31 additions and 31 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,12 @@ public:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
void handleBluetoothButton();
|
||||
void updateDeviceType();
|
||||
void updateMidiOutput();
|
||||
void changeListenerCallback (ChangeBroadcaster*) override;
|
||||
void updateAllControls();
|
||||
|
||||
std::unique_ptr<ComboBox> deviceTypeDropDown;
|
||||
std::unique_ptr<Label> deviceTypeDropDownLabel;
|
||||
std::unique_ptr<Component> audioDeviceSettingsComp;
|
||||
|
|
@ -110,12 +116,6 @@ private:
|
|||
std::unique_ptr<Label> midiInputsLabel, midiOutputLabel;
|
||||
std::unique_ptr<TextButton> bluetoothButton;
|
||||
|
||||
void handleBluetoothButton();
|
||||
void updateDeviceType();
|
||||
void updateMidiOutput();
|
||||
void changeListenerCallback (ChangeBroadcaster*) override;
|
||||
void updateAllControls();
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue