Qt: Fix audio volume/mute being lost when restarting emulation

This commit is contained in:
Connor McLaughlin 2020-07-24 02:55:00 +10:00
parent 4a3e5ed644
commit 5a955a4fdc
3 changed files with 18 additions and 1 deletions

View File

@ -79,5 +79,5 @@ void AudioSettingsWidget::onOutputMutedChanged(int new_state)
{
const bool muted = (new_state != 0);
m_host_interface->SetBoolSettingValue("Audio", "OutputMuted", muted);
m_host_interface->setAudioOutputVolume(muted ? 0 : m_ui.volume->value());
m_host_interface->setAudioOutputMuted(muted);
}

View File

@ -897,6 +897,22 @@ void QtHostInterface::setAudioOutputVolume(int value)
if (m_audio_stream)
m_audio_stream->SetOutputVolume(value);
m_settings.audio_output_volume = value;
}
void QtHostInterface::setAudioOutputMuted(bool muted)
{
if (!isOnWorkerThread())
{
QMetaObject::invokeMethod(this, "setAudioOutputMuted", Q_ARG(bool, muted));
return;
}
if (m_audio_stream)
m_audio_stream->SetOutputVolume(muted ? 0 : m_settings.audio_output_volume);
m_settings.audio_output_muted = muted;
}
void QtHostInterface::startDumpingAudio()

View File

@ -136,6 +136,7 @@ public Q_SLOTS:
void loadState(bool global, qint32 slot);
void saveState(bool global, qint32 slot, bool block_until_done = false);
void setAudioOutputVolume(int value);
void setAudioOutputMuted(bool muted);
void startDumpingAudio();
void stopDumpingAudio();
void saveScreenshot();