mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioDeviceSelector: Fix a bug with the input and output device selectors
The bug presented when selecting none for either input or output, when the opposite input or output was a device that had the same name for both the input and output
This commit is contained in:
parent
bce68c2b11
commit
2fc532ccac
1 changed files with 29 additions and 14 deletions
|
|
@ -439,9 +439,8 @@ public:
|
|||
|
||||
error = setup.manager->setAudioDeviceSetup (config, true);
|
||||
|
||||
showCorrectDeviceName (inputDeviceDropDown.get(), true);
|
||||
showCorrectDeviceName (outputDeviceDropDown.get(), false);
|
||||
|
||||
updateSelectedInput();
|
||||
updateSelectedOutput();
|
||||
updateControlPanelButton();
|
||||
resized();
|
||||
}
|
||||
|
|
@ -610,18 +609,34 @@ private:
|
|||
std::unique_ptr<Component> inputLevelMeter;
|
||||
std::unique_ptr<TextButton> showUIButton, showAdvancedSettingsButton, resetDeviceButton;
|
||||
|
||||
int findSelectedDeviceIndex (bool isInput) const
|
||||
{
|
||||
const auto device = setup.manager->getAudioDeviceSetup();
|
||||
const auto deviceName = isInput ? device.inputDeviceName : device.outputDeviceName;
|
||||
return type.getDeviceNames (isInput).indexOf (deviceName);
|
||||
}
|
||||
|
||||
void updateSelectedInput()
|
||||
{
|
||||
showCorrectDeviceName (inputDeviceDropDown.get(), true);
|
||||
}
|
||||
|
||||
void updateSelectedOutput()
|
||||
{
|
||||
constexpr auto isInput = false;
|
||||
showCorrectDeviceName (outputDeviceDropDown.get(), isInput);
|
||||
|
||||
if (testButton != nullptr)
|
||||
testButton->setEnabled (findSelectedDeviceIndex (isInput) >= 0);
|
||||
}
|
||||
|
||||
void showCorrectDeviceName (ComboBox* box, bool isInput)
|
||||
{
|
||||
if (box != nullptr)
|
||||
{
|
||||
auto* currentDevice = setup.manager->getCurrentAudioDevice();
|
||||
auto index = type.getIndexOfDevice (currentDevice, isInput);
|
||||
if (box == nullptr)
|
||||
return;
|
||||
|
||||
const auto index = findSelectedDeviceIndex (isInput);
|
||||
box->setSelectedId (index < 0 ? index : index + 1, dontSendNotification);
|
||||
|
||||
if (testButton != nullptr && ! isInput)
|
||||
testButton->setEnabled (index >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
void addNamesToDeviceBox (ComboBox& combo, bool isInputs)
|
||||
|
|
@ -711,7 +726,7 @@ private:
|
|||
addNamesToDeviceBox (*outputDeviceDropDown, false);
|
||||
}
|
||||
|
||||
showCorrectDeviceName (outputDeviceDropDown.get(), false);
|
||||
updateSelectedOutput();
|
||||
}
|
||||
|
||||
void updateInputsComboBox()
|
||||
|
|
@ -734,7 +749,7 @@ private:
|
|||
addNamesToDeviceBox (*inputDeviceDropDown, true);
|
||||
}
|
||||
|
||||
showCorrectDeviceName (inputDeviceDropDown.get(), true);
|
||||
updateSelectedInput();
|
||||
}
|
||||
|
||||
void updateSampleRateComboBox (AudioIODevice* currentDevice)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue