From 28a2700a28cef48e28fca4db7e9a47bd57593cbf Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 20 May 2025 16:05:04 +0100 Subject: [PATCH] AudioDeviceSelectorComponent: Tweak buffer size combo box to display the actual buffer size, even it it does not match any reported available buffer size --- .../gui/juce_AudioDeviceSelectorComponent.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index 131ebe3861..bfaf7e6f81 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -804,12 +804,19 @@ private: currentRate = 48000.0; for (auto bs : currentDevice->getAvailableBufferSizes()) - bufferSizeDropDown->addItem (String (bs) + " samples (" + String (bs * 1000.0 / currentRate, 1) + " ms)", bs); + bufferSizeDropDown->addItem (getBufferSizeText (bs, currentRate), bs); + + const auto bufferSizeSamples = currentDevice->getCurrentBufferSizeSamples(); + bufferSizeDropDown->setText (getBufferSizeText (bufferSizeSamples, currentRate), dontSendNotification); - bufferSizeDropDown->setSelectedId (currentDevice->getCurrentBufferSizeSamples(), dontSendNotification); bufferSizeDropDown->onChange = [this] { updateConfig (false, false, false, true); }; } + String getBufferSizeText (int bs, double currentRate) const + { + return String (bs) + " samples (" + String (bs * 1000.0 / currentRate, 1) + " ms)"; + } + public: //============================================================================== class ChannelSelectorListBox final : public ListBox,