AudioStream: Reset resampler state on emptying buffers

This commit is contained in:
Connor McLaughlin 2021-01-11 03:58:14 +10:00
parent 43d01776dc
commit bc5fb850d4
3 changed files with 10 additions and 6 deletions

View file

@ -252,6 +252,7 @@ void AudioStream::EmptyBuffers()
std::unique_lock<std::mutex> lock(m_buffer_mutex);
m_buffer.Clear();
m_underflow_flag.store(false);
ResetResampler();
}
void AudioStream::CreateResampler()
@ -273,6 +274,8 @@ void AudioStream::DestroyResampler()
void AudioStream::ResetResampler()
{
m_resampled_buffer.Clear();
m_resample_in_buffer.clear();
m_resample_out_buffer.clear();
src_reset(static_cast<SRC_STATE*>(m_resampler_state));
}

View file

@ -77,10 +77,11 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
dialog->registerWidgetHelp(
m_ui.turboSpeed, tr("Turbo Speed"), "100%",
tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled."));
dialog->registerWidgetHelp(m_ui.syncToHostRefreshRate, tr("Sync To Host Refresh Rate"), "100%",
tr("Adjusts the emulation speed so the console's refresh rate matches the host's refresh "
"rate, when VSync is enabled. This results in the smoothest animations possible, at "
"the cost of potentially increasing the emulation speed by less than 1%."));
dialog->registerWidgetHelp(
m_ui.syncToHostRefreshRate, tr("Sync To Host Refresh Rate"), "100%",
tr("Adjusts the emulation speed so the console's refresh rate matches the host's refresh rate, when VSync and "
"Audio Resampling is enabled. This results in the smoothest animations possible, at the cost of potentially "
"increasing the emulation speed by less than 1%."));
m_ui.cpuClockSpeed->setEnabled(m_ui.enableCPUClockSpeedControl->checkState() == Qt::Checked);
m_ui.cdromReadSpeedup->setCurrentIndex(m_host_interface->GetIntSettingValue("CDROM", "ReadSpeedup", 1) - 1);

View file

@ -609,8 +609,8 @@ void CommonHostInterface::UpdateSpeedLimiterState()
(m_fast_forward_enabled ? g_settings.fast_forward_speed : g_settings.emulation_speed);
m_speed_limiter_enabled = (target_speed != 0.0f);
if (g_settings.sync_to_host_refresh_rate && target_speed == 1.0f && g_settings.video_sync_enabled && m_display &&
System::IsRunning())
if (g_settings.sync_to_host_refresh_rate && g_settings.audio_resampling && target_speed == 1.0f &&
g_settings.video_sync_enabled && m_display && System::IsRunning())
{
float host_refresh_rate;
if (m_display->GetHostRefreshRate(&host_refresh_rate))