mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
System: Fix volume after toggling fast forward
This commit is contained in:
parent
5b2c18e27c
commit
3abf1df362
|
@ -2192,15 +2192,16 @@ void System::ResetPerformanceCounters()
|
||||||
|
|
||||||
void System::UpdateSpeedLimiterState()
|
void System::UpdateSpeedLimiterState()
|
||||||
{
|
{
|
||||||
float target_speed = m_turbo_enabled ?
|
const float old_target_speed = s_target_speed;
|
||||||
|
s_target_speed = m_turbo_enabled ?
|
||||||
g_settings.turbo_speed :
|
g_settings.turbo_speed :
|
||||||
(m_fast_forward_enabled ? g_settings.fast_forward_speed : g_settings.emulation_speed);
|
(m_fast_forward_enabled ? g_settings.fast_forward_speed : g_settings.emulation_speed);
|
||||||
m_throttler_enabled = (target_speed != 0.0f);
|
m_throttler_enabled = (s_target_speed != 0.0f);
|
||||||
m_display_all_frames = !m_throttler_enabled || g_settings.display_all_frames;
|
m_display_all_frames = !m_throttler_enabled || g_settings.display_all_frames;
|
||||||
|
|
||||||
bool syncing_to_host = false;
|
bool syncing_to_host = false;
|
||||||
if (g_settings.sync_to_host_refresh_rate && (g_settings.audio_stretch_mode != AudioStretchMode::Off) &&
|
if (g_settings.sync_to_host_refresh_rate && (g_settings.audio_stretch_mode != AudioStretchMode::Off) &&
|
||||||
target_speed == 1.0f && IsValid())
|
s_target_speed == 1.0f && IsValid())
|
||||||
{
|
{
|
||||||
float host_refresh_rate;
|
float host_refresh_rate;
|
||||||
if (g_host_display->GetHostRefreshRate(&host_refresh_rate))
|
if (g_host_display->GetHostRefreshRate(&host_refresh_rate))
|
||||||
|
@ -2210,7 +2211,7 @@ void System::UpdateSpeedLimiterState()
|
||||||
Log_InfoPrintf("Refresh rate: Host=%fhz Guest=%fhz Ratio=%f - %s", host_refresh_rate,
|
Log_InfoPrintf("Refresh rate: Host=%fhz Guest=%fhz Ratio=%f - %s", host_refresh_rate,
|
||||||
System::GetThrottleFrequency(), ratio, syncing_to_host ? "can sync" : "can't sync");
|
System::GetThrottleFrequency(), ratio, syncing_to_host ? "can sync" : "can't sync");
|
||||||
if (syncing_to_host)
|
if (syncing_to_host)
|
||||||
target_speed *= ratio;
|
s_target_speed *= ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2218,18 +2219,18 @@ void System::UpdateSpeedLimiterState()
|
||||||
|
|
||||||
if (IsValid())
|
if (IsValid())
|
||||||
{
|
{
|
||||||
|
// Update audio output.
|
||||||
AudioStream* stream = SPU::GetOutputStream();
|
AudioStream* stream = SPU::GetOutputStream();
|
||||||
if (g_settings.audio_fast_forward_volume != g_settings.audio_output_volume)
|
|
||||||
stream->SetOutputVolume(GetAudioOutputVolume());
|
stream->SetOutputVolume(GetAudioOutputVolume());
|
||||||
|
|
||||||
// Adjust nominal rate when resampling, or syncing to host.
|
// Adjust nominal rate when resampling, or syncing to host.
|
||||||
const bool rate_adjust =
|
const bool rate_adjust =
|
||||||
(syncing_to_host || g_settings.audio_stretch_mode == AudioStretchMode::Resample) && target_speed > 0.0f;
|
(syncing_to_host || g_settings.audio_stretch_mode == AudioStretchMode::Resample) && s_target_speed > 0.0f;
|
||||||
stream->SetNominalRate(rate_adjust ? target_speed : 1.0f);
|
stream->SetNominalRate(rate_adjust ? s_target_speed : 1.0f);
|
||||||
if (s_target_speed < target_speed)
|
|
||||||
stream->UpdateTargetTempo(target_speed);
|
if (old_target_speed < s_target_speed)
|
||||||
|
stream->UpdateTargetTempo(s_target_speed);
|
||||||
|
|
||||||
s_target_speed = target_speed;
|
|
||||||
UpdateThrottlePeriod();
|
UpdateThrottlePeriod();
|
||||||
ResetThrottler();
|
ResetThrottler();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue