Qt: Save audio output latency value separately to minimal flag
This commit is contained in:
parent
e7765d26fb
commit
864b0ad5fe
|
@ -4873,19 +4873,8 @@ void FullscreenUI::DrawAudioSettingsPage()
|
|||
DrawIntRangeSetting(bsi, FSUI_CSTR("Buffer Size"),
|
||||
FSUI_CSTR("Determines the amount of audio buffered before being pulled by the host API."),
|
||||
"Audio", "BufferMS", AudioStreamParameters::DEFAULT_BUFFER_MS, 10, 500, FSUI_CSTR("%d ms"));
|
||||
|
||||
const u32 output_latency =
|
||||
GetEffectiveUIntSetting(bsi, "Audio", "OutputLatencyMS", AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MS);
|
||||
bool output_latency_minimal = (output_latency == 0);
|
||||
if (ToggleButton(FSUI_CSTR("Minimal Output Latency"),
|
||||
FSUI_CSTR("When enabled, the minimum supported output latency will be used for the host API."),
|
||||
&output_latency_minimal))
|
||||
{
|
||||
bsi->SetUIntValue("Audio", "OutputLatencyMS",
|
||||
output_latency_minimal ? 0 : AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MS);
|
||||
SetSettingsChanged(bsi);
|
||||
}
|
||||
if (!output_latency_minimal)
|
||||
if (!GetEffectiveBoolSetting(bsi, "Audio", "OutputLatencyMinimal",
|
||||
AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MINIMAL))
|
||||
{
|
||||
DrawIntRangeSetting(
|
||||
bsi, FSUI_CSTR("Output Latency"),
|
||||
|
@ -4893,6 +4882,9 @@ void FullscreenUI::DrawAudioSettingsPage()
|
|||
"played through speakers."),
|
||||
"Audio", "OutputLatencyMS", AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MS, 1, 500, FSUI_CSTR("%d ms"));
|
||||
}
|
||||
DrawToggleSetting(bsi, FSUI_CSTR("Minimal Output Latency"),
|
||||
FSUI_CSTR("When enabled, the minimum supported output latency will be used for the host API."),
|
||||
"Audio", "OutputLatencyMinimal", AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MINIMAL);
|
||||
|
||||
EndMenuButtons();
|
||||
}
|
||||
|
|
|
@ -431,10 +431,11 @@ void SPU::Initialize()
|
|||
void SPU::CreateOutputStream()
|
||||
{
|
||||
Log_InfoFmt(
|
||||
"Creating '{}' audio stream, sample rate = {}, expansion = {}, buffer = {}, latency = {}, stretching = {}",
|
||||
"Creating '{}' audio stream, sample rate = {}, expansion = {}, buffer = {}, latency = {}{}, stretching = {}",
|
||||
AudioStream::GetBackendName(g_settings.audio_backend), static_cast<u32>(SAMPLE_RATE),
|
||||
AudioStream::GetExpansionModeName(g_settings.audio_stream_parameters.expansion_mode),
|
||||
g_settings.audio_stream_parameters.buffer_ms, g_settings.audio_stream_parameters.output_latency_ms,
|
||||
g_settings.audio_stream_parameters.output_latency_minimal ? " (or minimal)" : "",
|
||||
AudioStream::GetStretchModeName(g_settings.audio_stream_parameters.stretch_mode));
|
||||
|
||||
Error error;
|
||||
|
|
|
@ -49,6 +49,8 @@ AudioSettingsWidget::AudioSettingsWidget(SettingsWindow* dialog, QWidget* parent
|
|||
AudioStreamParameters::DEFAULT_BUFFER_MS);
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.outputLatencyMS, "Audio", "OutputLatencyMS",
|
||||
AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MS);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.outputLatencyMinimal, "Audio", "OutputLatencyMinimal",
|
||||
AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MINIMAL);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.muteCDAudio, "CDROM", "MuteCDAudio", false);
|
||||
connect(m_ui.audioBackend, &QComboBox::currentIndexChanged, this, &AudioSettingsWidget::updateDriverNames);
|
||||
connect(m_ui.expansionMode, &QComboBox::currentIndexChanged, this, &AudioSettingsWidget::onExpansionModeChanged);
|
||||
|
@ -256,7 +258,8 @@ void AudioSettingsWidget::updateLatencyLabel()
|
|||
m_dialog->getEffectiveIntValue("Audio", "BufferMS", AudioStreamParameters::DEFAULT_BUFFER_MS);
|
||||
const u32 config_output_latency_ms =
|
||||
m_dialog->getEffectiveIntValue("Audio", "OutputLatencyMS", AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MS);
|
||||
const bool minimal_output = (config_output_latency_ms == 0);
|
||||
const bool minimal_output = m_dialog->getEffectiveBoolValue("Audio", "OutputLatencyMinimal",
|
||||
AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MINIMAL);
|
||||
|
||||
//: Preserve the %1 variable, adapt the latter ms (and/or any possible spaces in between) to your language's ruleset.
|
||||
m_ui.outputLatencyLabel->setText(minimal_output ? tr("N/A") : tr("%1 ms").arg(config_output_latency_ms));
|
||||
|
@ -296,20 +299,6 @@ void AudioSettingsWidget::updateLatencyLabel()
|
|||
m_ui.bufferingLabel->setText(tr("Maximum Latency: %1 ms (minimum output latency unknown)").arg(config_buffer_ms));
|
||||
}
|
||||
}
|
||||
|
||||
const u32 value =
|
||||
m_dialog->getEffectiveIntValue("Audio", "OutputLatencyMS", AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MS);
|
||||
|
||||
{
|
||||
QSignalBlocker sb(m_ui.outputLatencyMS);
|
||||
m_ui.outputLatencyMS->setValue(value);
|
||||
m_ui.outputLatencyMS->setEnabled(value != 0);
|
||||
}
|
||||
|
||||
{
|
||||
QSignalBlocker sb(m_ui.outputLatencyMinimal);
|
||||
m_ui.outputLatencyMinimal->setChecked(value == 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSettingsWidget::updateVolumeLabel()
|
||||
|
@ -320,9 +309,8 @@ void AudioSettingsWidget::updateVolumeLabel()
|
|||
|
||||
void AudioSettingsWidget::onMinimalOutputLatencyChecked(Qt::CheckState state)
|
||||
{
|
||||
const u32 value = (state == Qt::Checked) ? 0u : AudioStreamParameters::DEFAULT_OUTPUT_LATENCY_MS;
|
||||
m_dialog->setIntSettingValue("Audio", "OutputLatencyMS", value);
|
||||
|
||||
const bool minimal = m_dialog->getEffectiveBoolValue("SPU2/Output", "OutputLatencyMinimal", false);
|
||||
m_ui.outputLatencyMS->setEnabled(!minimal);
|
||||
updateLatencyLabel();
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,9 @@
|
|||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QSlider" name="outputLatencyMS">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>500</number>
|
||||
</property>
|
||||
|
|
|
@ -971,6 +971,7 @@ void AudioStreamParameters::Load(SettingsInterface& si, const char* section)
|
|||
#endif
|
||||
output_latency_ms = static_cast<u16>(std::min<u32>(
|
||||
si.GetUIntValue(section, "OutputLatencyMS", DEFAULT_OUTPUT_LATENCY_MS), std::numeric_limits<u16>::max()));
|
||||
output_latency_minimal = si.GetBoolValue(section, "OutputLatencyMinimal", DEFAULT_OUTPUT_LATENCY_MINIMAL);
|
||||
buffer_ms = static_cast<u16>(
|
||||
std::min<u32>(si.GetUIntValue(section, "BufferMS", DEFAULT_BUFFER_MS), std::numeric_limits<u16>::max()));
|
||||
|
||||
|
@ -1011,6 +1012,7 @@ void AudioStreamParameters::Save(SettingsInterface& si, const char* section) con
|
|||
si.SetStringValue(section, "ExpansionMode", AudioStream::GetExpansionModeName(expansion_mode));
|
||||
si.SetUIntValue(section, "BufferMS", buffer_ms);
|
||||
si.SetUIntValue(section, "OutputLatencyMS", output_latency_ms);
|
||||
si.SetBoolValue(section, "OutputLatencyMinimal", output_latency_minimal);
|
||||
|
||||
si.SetUIntValue(section, "StretchSequenceLengthMS", stretch_sequence_length_ms);
|
||||
si.SetUIntValue(section, "StretchSeekWindowMS", stretch_seekwindow_ms);
|
||||
|
@ -1036,6 +1038,7 @@ void AudioStreamParameters::Clear(SettingsInterface& si, const char* section)
|
|||
si.DeleteValue(section, "ExpansionMode");
|
||||
si.DeleteValue(section, "BufferMS");
|
||||
si.DeleteValue(section, "OutputLatencyMS");
|
||||
si.DeleteValue(section, "OutputLatencyMinimal");
|
||||
|
||||
si.DeleteValue(section, "StretchSequenceLengthMS");
|
||||
si.DeleteValue(section, "StretchSeekWindowMS");
|
||||
|
|
|
@ -63,6 +63,8 @@ struct AudioStreamParameters
|
|||
AudioExpansionMode expansion_mode = DEFAULT_EXPANSION_MODE;
|
||||
u16 buffer_ms = DEFAULT_BUFFER_MS;
|
||||
u16 output_latency_ms = DEFAULT_OUTPUT_LATENCY_MS;
|
||||
bool output_latency_minimal = DEFAULT_OUTPUT_LATENCY_MINIMAL;
|
||||
bool pad1 = false;
|
||||
|
||||
u16 stretch_sequence_length_ms = DEFAULT_STRETCH_SEQUENCE_LENGTH;
|
||||
u16 stretch_seekwindow_ms = DEFAULT_STRETCH_SEEKWINDOW;
|
||||
|
@ -90,6 +92,7 @@ struct AudioStreamParameters
|
|||
static constexpr u16 DEFAULT_BUFFER_MS = 100;
|
||||
static constexpr u16 DEFAULT_OUTPUT_LATENCY_MS = 20;
|
||||
#endif
|
||||
static constexpr bool DEFAULT_OUTPUT_LATENCY_MINIMAL = false;
|
||||
static constexpr u16 DEFAULT_EXPAND_BLOCK_SIZE = 2048;
|
||||
static constexpr float DEFAULT_EXPAND_CIRCULAR_WRAP = 90.0f;
|
||||
static constexpr float DEFAULT_EXPAND_SHIFT = 0.0f;
|
||||
|
|
|
@ -186,7 +186,7 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
|||
|
||||
const u32 minimum_latency_ms = GetMSForBufferSize(m_sample_rate, min_latency_frames);
|
||||
Log_DevFmt("Minimum latency: {} ms ({} audio frames)", minimum_latency_ms, min_latency_frames);
|
||||
if (m_parameters.output_latency_ms == 0)
|
||||
if (m_parameters.output_latency_minimal)
|
||||
{
|
||||
// use minimum
|
||||
latency_frames = min_latency_frames;
|
||||
|
|
Loading…
Reference in New Issue