mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
Qt: Fix audio sliders not applying correctly
This commit is contained in:
parent
b3fd07e1b5
commit
b5ffbfe826
|
@ -445,7 +445,7 @@ void AndroidHostInterface::EmulationThreadLoop(JNIEnv* env)
|
||||||
{
|
{
|
||||||
System::UpdatePerformanceCounters();
|
System::UpdatePerformanceCounters();
|
||||||
|
|
||||||
if (m_speed_limiter_enabled)
|
if (m_throttler_enabled)
|
||||||
System::Throttle();
|
System::Throttle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1233,6 +1233,11 @@ void RunFrame()
|
||||||
g_gpu->ResetGraphicsAPIState();
|
g_gpu->ResetGraphicsAPIState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GetTargetSpeed()
|
||||||
|
{
|
||||||
|
return s_target_speed;
|
||||||
|
}
|
||||||
|
|
||||||
void SetTargetSpeed(float speed)
|
void SetTargetSpeed(float speed)
|
||||||
{
|
{
|
||||||
s_target_speed = speed;
|
s_target_speed = speed;
|
||||||
|
|
|
@ -149,6 +149,7 @@ void SingleStepCPU();
|
||||||
void RunFrame();
|
void RunFrame();
|
||||||
|
|
||||||
/// Sets target emulation speed.
|
/// Sets target emulation speed.
|
||||||
|
float GetTargetSpeed();
|
||||||
void SetTargetSpeed(float speed);
|
void SetTargetSpeed(float speed);
|
||||||
|
|
||||||
/// Adjusts the throttle frequency, i.e. how many times we should sleep per second.
|
/// Adjusts the throttle frequency, i.e. how many times we should sleep per second.
|
||||||
|
|
|
@ -99,7 +99,6 @@ void AudioSettingsWidget::updateVolumeLabel()
|
||||||
void AudioSettingsWidget::onOutputVolumeChanged(int new_value)
|
void AudioSettingsWidget::onOutputVolumeChanged(int new_value)
|
||||||
{
|
{
|
||||||
m_host_interface->SetIntSettingValue("Audio", "OutputVolume", new_value);
|
m_host_interface->SetIntSettingValue("Audio", "OutputVolume", new_value);
|
||||||
if (!m_ui.muted->isChecked() && !QtHostInterface::GetInstance()->IsFastForwardEnabled())
|
|
||||||
m_host_interface->setAudioOutputVolume(new_value, m_ui.fastForwardVolume->value());
|
m_host_interface->setAudioOutputVolume(new_value, m_ui.fastForwardVolume->value());
|
||||||
|
|
||||||
updateVolumeLabel();
|
updateVolumeLabel();
|
||||||
|
@ -108,7 +107,6 @@ void AudioSettingsWidget::onOutputVolumeChanged(int new_value)
|
||||||
void AudioSettingsWidget::onFastForwardVolumeChanged(int new_value)
|
void AudioSettingsWidget::onFastForwardVolumeChanged(int new_value)
|
||||||
{
|
{
|
||||||
m_host_interface->SetIntSettingValue("Audio", "FastForwardVolume", new_value);
|
m_host_interface->SetIntSettingValue("Audio", "FastForwardVolume", new_value);
|
||||||
if (!m_ui.muted->isChecked() && QtHostInterface::GetInstance()->IsFastForwardEnabled())
|
|
||||||
m_host_interface->setAudioOutputVolume(m_ui.volume->value(), new_value);
|
m_host_interface->setAudioOutputVolume(m_ui.volume->value(), new_value);
|
||||||
|
|
||||||
updateVolumeLabel();
|
updateVolumeLabel();
|
||||||
|
|
|
@ -1226,11 +1226,11 @@ void QtHostInterface::setAudioOutputVolume(int volume, int fast_forward_volume)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_audio_stream)
|
|
||||||
m_audio_stream->SetOutputVolume(m_speed_limiter_enabled ? volume : fast_forward_volume);
|
|
||||||
|
|
||||||
g_settings.audio_output_volume = volume;
|
g_settings.audio_output_volume = volume;
|
||||||
g_settings.audio_fast_forward_volume = fast_forward_volume;
|
g_settings.audio_fast_forward_volume = fast_forward_volume;
|
||||||
|
|
||||||
|
if (m_audio_stream)
|
||||||
|
m_audio_stream->SetOutputVolume(GetAudioOutputVolume());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::setAudioOutputMuted(bool muted)
|
void QtHostInterface::setAudioOutputMuted(bool muted)
|
||||||
|
@ -1400,7 +1400,7 @@ void QtHostInterface::threadEntryPoint()
|
||||||
|
|
||||||
System::UpdatePerformanceCounters();
|
System::UpdatePerformanceCounters();
|
||||||
|
|
||||||
if (m_speed_limiter_enabled)
|
if (m_throttler_enabled)
|
||||||
System::Throttle();
|
System::Throttle();
|
||||||
|
|
||||||
m_worker_thread_event_loop->processEvents(QEventLoop::AllEvents);
|
m_worker_thread_event_loop->processEvents(QEventLoop::AllEvents);
|
||||||
|
|
|
@ -1877,7 +1877,7 @@ void SDLHostInterface::Run()
|
||||||
{
|
{
|
||||||
System::UpdatePerformanceCounters();
|
System::UpdatePerformanceCounters();
|
||||||
|
|
||||||
if (m_speed_limiter_enabled)
|
if (m_throttler_enabled)
|
||||||
System::Throttle();
|
System::Throttle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,7 @@ std::unique_ptr<AudioStream> CommonHostInterface::CreateAudioStream(AudioBackend
|
||||||
|
|
||||||
s32 CommonHostInterface::GetAudioOutputVolume() const
|
s32 CommonHostInterface::GetAudioOutputVolume() const
|
||||||
{
|
{
|
||||||
return g_settings.GetAudioOutputVolume(!m_speed_limiter_enabled);
|
return g_settings.GetAudioOutputVolume(IsRunningAtNonStandardSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonHostInterface::UpdateControllerInterface()
|
void CommonHostInterface::UpdateControllerInterface()
|
||||||
|
@ -602,12 +602,21 @@ bool CommonHostInterface::ResumeSystemFromMostRecentState()
|
||||||
return LoadState(path.c_str());
|
return LoadState(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CommonHostInterface::IsRunningAtNonStandardSpeed() const
|
||||||
|
{
|
||||||
|
if (!System::IsValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const float target_speed = System::GetTargetSpeed();
|
||||||
|
return (target_speed <= 0.95f || target_speed >= 1.05f);
|
||||||
|
}
|
||||||
|
|
||||||
void CommonHostInterface::UpdateSpeedLimiterState()
|
void CommonHostInterface::UpdateSpeedLimiterState()
|
||||||
{
|
{
|
||||||
float target_speed = m_turbo_enabled ?
|
float 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_speed_limiter_enabled = (target_speed != 0.0f);
|
m_throttler_enabled = (target_speed != 0.0f);
|
||||||
|
|
||||||
bool syncing_to_host = false;
|
bool syncing_to_host = false;
|
||||||
if (g_settings.sync_to_host_refresh_rate && g_settings.audio_resampling && target_speed == 1.0f &&
|
if (g_settings.sync_to_host_refresh_rate && g_settings.audio_resampling && target_speed == 1.0f &&
|
||||||
|
@ -627,15 +636,21 @@ void CommonHostInterface::UpdateSpeedLimiterState()
|
||||||
|
|
||||||
const bool is_non_standard_speed = (std::abs(target_speed - 1.0f) > 0.05f);
|
const bool is_non_standard_speed = (std::abs(target_speed - 1.0f) > 0.05f);
|
||||||
const bool audio_sync_enabled =
|
const bool audio_sync_enabled =
|
||||||
!System::IsRunning() || (m_speed_limiter_enabled && g_settings.audio_sync_enabled && !is_non_standard_speed);
|
!System::IsRunning() || (m_throttler_enabled && g_settings.audio_sync_enabled && !is_non_standard_speed);
|
||||||
const bool video_sync_enabled =
|
const bool video_sync_enabled =
|
||||||
!System::IsRunning() || (m_speed_limiter_enabled && g_settings.video_sync_enabled && !is_non_standard_speed);
|
!System::IsRunning() || (m_throttler_enabled && g_settings.video_sync_enabled && !is_non_standard_speed);
|
||||||
const float max_display_fps = m_speed_limiter_enabled ? 0.0f : g_settings.display_max_fps;
|
const float max_display_fps = m_throttler_enabled ? 0.0f : g_settings.display_max_fps;
|
||||||
Log_InfoPrintf("Target speed: %f%%", target_speed * 100.0f);
|
Log_InfoPrintf("Target speed: %f%%", target_speed * 100.0f);
|
||||||
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
|
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
|
||||||
(audio_sync_enabled && video_sync_enabled) ? " and video" : (video_sync_enabled ? "video" : ""));
|
(audio_sync_enabled && video_sync_enabled) ? " and video" : (video_sync_enabled ? "video" : ""));
|
||||||
Log_InfoPrintf("Max display fps: %f", max_display_fps);
|
Log_InfoPrintf("Max display fps: %f", max_display_fps);
|
||||||
|
|
||||||
|
if (System::IsValid())
|
||||||
|
{
|
||||||
|
System::SetTargetSpeed(target_speed);
|
||||||
|
System::ResetPerformanceCounters();
|
||||||
|
}
|
||||||
|
|
||||||
if (m_audio_stream)
|
if (m_audio_stream)
|
||||||
{
|
{
|
||||||
const u32 input_sample_rate = (target_speed == 0.0f || !g_settings.audio_resampling) ?
|
const u32 input_sample_rate = (target_speed == 0.0f || !g_settings.audio_resampling) ?
|
||||||
|
@ -657,16 +672,10 @@ void CommonHostInterface::UpdateSpeedLimiterState()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_settings.increase_timer_resolution)
|
if (g_settings.increase_timer_resolution)
|
||||||
SetTimerResolutionIncreased(m_speed_limiter_enabled);
|
SetTimerResolutionIncreased(m_throttler_enabled);
|
||||||
|
|
||||||
if (System::IsValid())
|
|
||||||
{
|
|
||||||
System::SetTargetSpeed(m_speed_limiter_enabled ? target_speed : 1.0f);
|
|
||||||
System::ResetPerformanceCounters();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syncing_to_host)
|
if (syncing_to_host)
|
||||||
m_speed_limiter_enabled = false;
|
m_throttler_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonHostInterface::RecreateSystem()
|
void CommonHostInterface::RecreateSystem()
|
||||||
|
|
|
@ -183,8 +183,8 @@ public:
|
||||||
/// Parses a fullscreen mode into its components (width * height @ refresh hz)
|
/// Parses a fullscreen mode into its components (width * height @ refresh hz)
|
||||||
static bool ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate);
|
static bool ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate);
|
||||||
|
|
||||||
/// Returns true if fast forwarding is currently active.
|
/// Returns true if fast forwarding or slow motion is currently active.
|
||||||
bool IsFastForwardEnabled() const { return m_fast_forward_enabled; }
|
bool IsRunningAtNonStandardSpeed() const;
|
||||||
|
|
||||||
/// Requests the specified size for the render window. Not guaranteed to succeed (e.g. if in fullscreen).
|
/// Requests the specified size for the render window. Not guaranteed to succeed (e.g. if in fullscreen).
|
||||||
virtual bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height);
|
virtual bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height);
|
||||||
|
@ -351,7 +351,7 @@ protected:
|
||||||
bool m_fast_forward_enabled = false;
|
bool m_fast_forward_enabled = false;
|
||||||
bool m_turbo_enabled = false;
|
bool m_turbo_enabled = false;
|
||||||
bool m_timer_resolution_increased = false;
|
bool m_timer_resolution_increased = false;
|
||||||
bool m_speed_limiter_enabled = true;
|
bool m_throttler_enabled = true;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeUserDirectory();
|
void InitializeUserDirectory();
|
||||||
|
|
Loading…
Reference in a new issue