Qt/AudioSettings: Make auto buffer size a multiple of 128
This commit is contained in:
parent
392c7af738
commit
9bfa27d550
|
@ -65,10 +65,17 @@ AudioSettingsWidget::~AudioSettingsWidget() = default;
|
|||
|
||||
void AudioSettingsWidget::updateBufferingLabel()
|
||||
{
|
||||
const u32 buffer_size = static_cast<u32>(m_ui.bufferSize->value());
|
||||
const float max_latency = AudioStream::GetMaxLatency(HostInterface::AUDIO_SAMPLE_RATE, buffer_size);
|
||||
constexpr float step = 128;
|
||||
const u32 actual_buffer_size = static_cast<u32>(std::round(static_cast<float>(m_ui.bufferSize->value()) / step) * step);
|
||||
if (static_cast<u32>(m_ui.bufferSize->value()) != actual_buffer_size)
|
||||
{
|
||||
m_ui.bufferSize->setValue(static_cast<int>(actual_buffer_size));
|
||||
return;
|
||||
}
|
||||
|
||||
const float max_latency = AudioStream::GetMaxLatency(HostInterface::AUDIO_SAMPLE_RATE, actual_buffer_size);
|
||||
m_ui.bufferingLabel->setText(
|
||||
tr("Maximum latency: %1 frames (%2ms)").arg(buffer_size).arg(max_latency * 1000.0f, 0, 'f', 2));
|
||||
tr("Maximum latency: %1 frames (%2ms)").arg(actual_buffer_size).arg(max_latency * 1000.0f, 0, 'f', 2));
|
||||
}
|
||||
|
||||
void AudioSettingsWidget::updateVolumeLabel()
|
||||
|
|
Loading…
Reference in New Issue