1
0
Fork 0
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:
Tom Poole 2018-12-04 14:23:18 +00:00
parent 3b8686aa97
commit faf7fb1960
3 changed files with 31 additions and 31 deletions

View file

@ -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;