HostInterface: Add separate volume control for fast forwarding

This commit is contained in:
Connor McLaughlin 2020-12-09 00:48:00 +10:00
parent 6d45d4d579
commit 678146b907
13 changed files with 171 additions and 76 deletions

View file

@ -47,6 +47,8 @@
<string name="settings_summary_log_to_logcat">Writes log messages to the Android message logger. Only useful when attached to a computer with adb.</string> <string name="settings_summary_log_to_logcat">Writes log messages to the Android message logger. Only useful when attached to a computer with adb.</string>
<string name="settings_volume">Volume</string> <string name="settings_volume">Volume</string>
<string name="settings_summary_volume">Controls the volume of the emulator\'s sound output.</string> <string name="settings_summary_volume">Controls the volume of the emulator\'s sound output.</string>
<string name="settings_fast_forward_volume">Volume</string>
<string name="settings_summary_fast_forward_volume">Controls the volume of the emulator\'s sound output when fast forwarding.</string>
<string name="settings_mute_all_sound">Mute All Sound</string> <string name="settings_mute_all_sound">Mute All Sound</string>
<string name="settings_summary_mute_all_sound">Prevents the emulator from emitting any sound.</string> <string name="settings_summary_mute_all_sound">Prevents the emulator from emitting any sound.</string>
<string name="settings_mute_cd_audio">Mute CD Audio</string> <string name="settings_mute_cd_audio">Mute CD Audio</string>

View file

@ -26,6 +26,15 @@
app:min="0" app:min="0"
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:showSeekBarValue="true" /> app:showSeekBarValue="true" />
<SeekBarPreference
app:key="Audio/OutputVolume"
app:title="@string/settings_fast_forward_volume"
app:summary="@string/settings_summary_fast_forward_volume"
app:defaultValue="100"
android:max="100"
app:min="0"
app:iconSpaceReserved="false"
app:showSeekBarValue="true" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:key="Audio/OutputMuted" app:key="Audio/OutputMuted"
app:title="@string/settings_mute_all_sound" app:title="@string/settings_mute_all_sound"

View file

@ -70,7 +70,12 @@ void HostInterface::CreateAudioStream()
m_audio_stream->Reconfigure(AUDIO_SAMPLE_RATE, AUDIO_CHANNELS, g_settings.audio_buffer_size); m_audio_stream->Reconfigure(AUDIO_SAMPLE_RATE, AUDIO_CHANNELS, g_settings.audio_buffer_size);
} }
m_audio_stream->SetOutputVolume(g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume); m_audio_stream->SetOutputVolume(GetAudioOutputVolume());
}
s32 HostInterface::GetAudioOutputVolume() const
{
return g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume;
} }
bool HostInterface::BootSystem(const SystemBootParameters& parameters) bool HostInterface::BootSystem(const SystemBootParameters& parameters)
@ -479,6 +484,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetStringValue("Audio", "Backend", Settings::GetAudioBackendName(Settings::DEFAULT_AUDIO_BACKEND)); si.SetStringValue("Audio", "Backend", Settings::GetAudioBackendName(Settings::DEFAULT_AUDIO_BACKEND));
si.SetIntValue("Audio", "OutputVolume", 100); si.SetIntValue("Audio", "OutputVolume", 100);
si.SetIntValue("Audio", "FastForwardVolume", 100);
si.SetIntValue("Audio", "BufferSize", DEFAULT_AUDIO_BUFFER_SIZE); si.SetIntValue("Audio", "BufferSize", DEFAULT_AUDIO_BUFFER_SIZE);
si.SetIntValue("Audio", "OutputMuted", false); si.SetIntValue("Audio", "OutputMuted", false);
si.SetBoolValue("Audio", "Sync", true); si.SetBoolValue("Audio", "Sync", true);
@ -638,7 +644,7 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
CPU::ClearICache(); CPU::ClearICache();
} }
m_audio_stream->SetOutputVolume(g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume); m_audio_stream->SetOutputVolume(GetAudioOutputVolume());
if (g_settings.gpu_resolution_scale != old_settings.gpu_resolution_scale || if (g_settings.gpu_resolution_scale != old_settings.gpu_resolution_scale ||
g_settings.gpu_multisamples != old_settings.gpu_multisamples || g_settings.gpu_multisamples != old_settings.gpu_multisamples ||

View file

@ -144,6 +144,7 @@ protected:
virtual bool AcquireHostDisplay() = 0; virtual bool AcquireHostDisplay() = 0;
virtual void ReleaseHostDisplay() = 0; virtual void ReleaseHostDisplay() = 0;
virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) = 0; virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) = 0;
virtual s32 GetAudioOutputVolume() const;
virtual void OnSystemCreated(); virtual void OnSystemCreated();
virtual void OnSystemDestroyed(); virtual void OnSystemDestroyed();

View file

@ -196,6 +196,7 @@ void Settings::Load(SettingsInterface& si)
ParseAudioBackend(si.GetStringValue("Audio", "Backend", GetAudioBackendName(DEFAULT_AUDIO_BACKEND)).c_str()) ParseAudioBackend(si.GetStringValue("Audio", "Backend", GetAudioBackendName(DEFAULT_AUDIO_BACKEND)).c_str())
.value_or(DEFAULT_AUDIO_BACKEND); .value_or(DEFAULT_AUDIO_BACKEND);
audio_output_volume = si.GetIntValue("Audio", "OutputVolume", 100); audio_output_volume = si.GetIntValue("Audio", "OutputVolume", 100);
audio_fast_forward_volume = si.GetIntValue("Audio", "FastForwardVolume", 100);
audio_buffer_size = si.GetIntValue("Audio", "BufferSize", HostInterface::DEFAULT_AUDIO_BUFFER_SIZE); audio_buffer_size = si.GetIntValue("Audio", "BufferSize", HostInterface::DEFAULT_AUDIO_BUFFER_SIZE);
audio_output_muted = si.GetBoolValue("Audio", "OutputMuted", false); audio_output_muted = si.GetBoolValue("Audio", "OutputMuted", false);
audio_sync_enabled = si.GetBoolValue("Audio", "Sync", true); audio_sync_enabled = si.GetBoolValue("Audio", "Sync", true);
@ -327,6 +328,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetStringValue("Audio", "Backend", GetAudioBackendName(audio_backend)); si.SetStringValue("Audio", "Backend", GetAudioBackendName(audio_backend));
si.SetIntValue("Audio", "OutputVolume", audio_output_volume); si.SetIntValue("Audio", "OutputVolume", audio_output_volume);
si.SetIntValue("Audio", "FastForwardVolume", audio_fast_forward_volume);
si.SetIntValue("Audio", "BufferSize", audio_buffer_size); si.SetIntValue("Audio", "BufferSize", audio_buffer_size);
si.SetBoolValue("Audio", "OutputMuted", audio_output_muted); si.SetBoolValue("Audio", "OutputMuted", audio_output_muted);
si.SetBoolValue("Audio", "Sync", audio_sync_enabled); si.SetBoolValue("Audio", "Sync", audio_sync_enabled);

View file

@ -142,6 +142,7 @@ struct Settings
AudioBackend audio_backend = AudioBackend::Cubeb; AudioBackend audio_backend = AudioBackend::Cubeb;
s32 audio_output_volume = 100; s32 audio_output_volume = 100;
s32 audio_fast_forward_volume = 100;
u32 audio_buffer_size = 2048; u32 audio_buffer_size = 2048;
bool audio_output_muted = false; bool audio_output_muted = false;
bool audio_sync_enabled = true; bool audio_sync_enabled = true;
@ -200,6 +201,11 @@ struct Settings
!cpu_recompiler_memory_exceptions); !cpu_recompiler_memory_exceptions);
} }
ALWAYS_INLINE s32 GetAudioOutputVolume(bool fast_forwarding) const
{
return audio_output_muted ? 0 : (fast_forwarding ? audio_fast_forward_volume : audio_output_volume);
}
bool HasAnyPerGameMemoryCards() const; bool HasAnyPerGameMemoryCards() const;
static void CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator); static void CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator);

View file

@ -25,11 +25,13 @@ AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidge
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startDumpingOnBoot, "Audio", "DumpOnBoot"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startDumpingOnBoot, "Audio", "DumpOnBoot");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.muteCDAudio, "CDROM", "MuteCDAudio"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.muteCDAudio, "CDROM", "MuteCDAudio");
m_ui.volume->setValue(m_host_interface->GetIntSettingValue("Audio", "OutputVolume")); m_ui.volume->setValue(m_host_interface->GetIntSettingValue("Audio", "OutputVolume", 100));
m_ui.muted->setChecked(m_host_interface->GetBoolSettingValue("Audio", "OutputMuted")); m_ui.fastForwardVolume->setValue(m_host_interface->GetIntSettingValue("Audio", "FastForwardVolume", 100));
m_ui.muted->setChecked(m_host_interface->GetBoolSettingValue("Audio", "OutputMuted", false));
connect(m_ui.bufferSize, &QSlider::valueChanged, this, &AudioSettingsWidget::updateBufferingLabel); connect(m_ui.bufferSize, &QSlider::valueChanged, this, &AudioSettingsWidget::updateBufferingLabel);
connect(m_ui.volume, &QSlider::valueChanged, this, &AudioSettingsWidget::onOutputVolumeChanged); connect(m_ui.volume, &QSlider::valueChanged, this, &AudioSettingsWidget::onOutputVolumeChanged);
connect(m_ui.fastForwardVolume, &QSlider::valueChanged, this, &AudioSettingsWidget::onFastForwardVolumeChanged);
connect(m_ui.muted, &QCheckBox::stateChanged, this, &AudioSettingsWidget::onOutputMutedChanged); connect(m_ui.muted, &QCheckBox::stateChanged, this, &AudioSettingsWidget::onOutputMutedChanged);
updateBufferingLabel(); updateBufferingLabel();
@ -53,8 +55,11 @@ AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidge
dialog->registerWidgetHelp( dialog->registerWidgetHelp(
m_ui.startDumpingOnBoot, tr("Start Dumping On Boot"), tr("Unchecked"), m_ui.startDumpingOnBoot, tr("Start Dumping On Boot"), tr("Unchecked"),
tr("Start dumping audio to file as soon as the emulator is started. Mainly useful as a debug option.")); tr("Start dumping audio to file as soon as the emulator is started. Mainly useful as a debug option."));
dialog->registerWidgetHelp(m_ui.volume, tr("Volume"), "100", dialog->registerWidgetHelp(m_ui.volume, tr("Output Volume"), "100",
tr("Controls the volume of the audio played on the host. Values are in percentage.")); tr("Controls the volume of the audio played on the host. Values are in percentage."));
dialog->registerWidgetHelp(
m_ui.fastForwardVolume, tr("Fast Forward Volume"), "100",
tr("Controls the volume of the audio played on the host when fast forwarding. Values are in percentage."));
dialog->registerWidgetHelp(m_ui.muted, tr("Mute All Sound"), tr("Unchecked"), dialog->registerWidgetHelp(m_ui.muted, tr("Mute All Sound"), tr("Unchecked"),
tr("Prevents the emulator from producing any audible sound.")); tr("Prevents the emulator from producing any audible sound."));
dialog->registerWidgetHelp(m_ui.muteCDAudio, tr("Mute CD Audio"), tr("Unchecked"), dialog->registerWidgetHelp(m_ui.muteCDAudio, tr("Mute CD Audio"), tr("Unchecked"),
@ -83,13 +88,23 @@ void AudioSettingsWidget::updateBufferingLabel()
void AudioSettingsWidget::updateVolumeLabel() void AudioSettingsWidget::updateVolumeLabel()
{ {
m_ui.volumeLabel->setText(tr("%1%").arg(m_ui.volume->value())); m_ui.volumeLabel->setText(tr("%1%").arg(m_ui.volume->value()));
m_ui.fastForwardVolumeLabel->setText(tr("%1%").arg(m_ui.fastForwardVolume->value()));
} }
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()) if (!m_ui.muted->isChecked())
m_host_interface->setAudioOutputVolume(new_value); m_host_interface->setAudioOutputVolume(new_value, m_ui.fastForwardVolume->value());
updateVolumeLabel();
}
void AudioSettingsWidget::onFastForwardVolumeChanged(int new_value)
{
m_host_interface->SetIntSettingValue("Audio", "FastForwardVolume", new_value);
if (!m_ui.muted->isChecked())
m_host_interface->setAudioOutputVolume(m_ui.volume->value(), new_value);
updateVolumeLabel(); updateVolumeLabel();
} }

View file

@ -19,6 +19,7 @@ private Q_SLOTS:
void updateBufferingLabel(); void updateBufferingLabel();
void updateVolumeLabel(); void updateVolumeLabel();
void onOutputVolumeChanged(int new_value); void onOutputVolumeChanged(int new_value);
void onFastForwardVolumeChanged(int new_value);
void onOutputMutedChanged(int new_state); void onOutputMutedChanged(int new_state);
private: private:

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>502</width> <width>502</width>
<height>308</height> <height>312</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -123,66 +123,109 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Volume:</string> <string>Output Volume:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSlider" name="volume"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="maximum"> <item>
<number>100</number> <widget class="QSlider" name="volume">
</property> <property name="maximum">
<property name="value"> <number>100</number>
<number>100</number> </property>
</property> <property name="value">
<property name="orientation"> <number>100</number>
<enum>Qt::Horizontal</enum> </property>
</property> <property name="orientation">
<property name="tickPosition"> <enum>Qt::Horizontal</enum>
<enum>QSlider::TicksBothSides</enum> </property>
</property> <property name="tickPosition">
<property name="tickInterval"> <enum>QSlider::TicksBothSides</enum>
<number>10</number> </property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="volumeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>100%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="fastForwardVolume">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fastForwardVolumeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>100%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Fast Forward Volume:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="2" column="0">
<widget class="QCheckBox" name="muted"> <widget class="QCheckBox" name="muted">
<property name="text"> <property name="text">
<string>Mute All Sound</string> <string>Mute All Sound</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" column="0">
<widget class="QCheckBox" name="muteCDAudio"> <widget class="QCheckBox" name="muteCDAudio">
<property name="text"> <property name="text">
<string>Mute CD Audio</string> <string>Mute CD Audio</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="volumeLabel">
<property name="text">
<string>100%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -202,7 +245,7 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="resources/icons.qrc"/> <include location="resources/resources.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View file

@ -1162,18 +1162,19 @@ void QtHostInterface::saveState(bool global, qint32 slot, bool block_until_done
SaveState(global, slot); SaveState(global, slot);
} }
void QtHostInterface::setAudioOutputVolume(int value) void QtHostInterface::setAudioOutputVolume(int volume, int fast_forward_volume)
{ {
if (!isOnWorkerThread()) if (!isOnWorkerThread())
{ {
QMetaObject::invokeMethod(this, "setAudioOutputVolume", Q_ARG(int, value)); QMetaObject::invokeMethod(this, "setAudioOutputVolume", Q_ARG(int, volume), Q_ARG(int, fast_forward_volume));
return; return;
} }
if (m_audio_stream) if (m_audio_stream)
m_audio_stream->SetOutputVolume(value); m_audio_stream->SetOutputVolume(m_speed_limiter_enabled ? volume : fast_forward_volume);
g_settings.audio_output_volume = value; g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = fast_forward_volume;
} }
void QtHostInterface::setAudioOutputMuted(bool muted) void QtHostInterface::setAudioOutputMuted(bool muted)
@ -1185,7 +1186,7 @@ void QtHostInterface::setAudioOutputMuted(bool muted)
} }
if (m_audio_stream) if (m_audio_stream)
m_audio_stream->SetOutputVolume(muted ? 0 : g_settings.audio_output_volume); m_audio_stream->SetOutputVolume(GetAudioOutputVolume());
g_settings.audio_output_muted = muted; g_settings.audio_output_muted = muted;
} }

View file

@ -159,7 +159,7 @@ public Q_SLOTS:
void loadState(const QString& filename); void loadState(const QString& filename);
void loadState(bool global, qint32 slot); void loadState(bool global, qint32 slot);
void saveState(bool global, qint32 slot, bool block_until_done = false); void saveState(bool global, qint32 slot, bool block_until_done = false);
void setAudioOutputVolume(int value); void setAudioOutputVolume(int volume, int fast_forward_volume);
void setAudioOutputMuted(bool muted); void setAudioOutputMuted(bool muted);
void startDumpingAudio(); void startDumpingAudio();
void stopDumpingAudio(); void stopDumpingAudio();

View file

@ -474,6 +474,11 @@ std::unique_ptr<AudioStream> CommonHostInterface::CreateAudioStream(AudioBackend
} }
} }
s32 CommonHostInterface::GetAudioOutputVolume() const
{
return g_settings.GetAudioOutputVolume(!m_speed_limiter_enabled);
}
void CommonHostInterface::UpdateControllerInterface() void CommonHostInterface::UpdateControllerInterface()
{ {
const std::string backend_str = GetStringSettingValue( const std::string backend_str = GetStringSettingValue(
@ -615,6 +620,7 @@ void CommonHostInterface::UpdateSpeedLimiterState()
if (m_audio_stream) if (m_audio_stream)
{ {
m_audio_stream->SetOutputVolume(GetAudioOutputVolume());
m_audio_stream->SetSync(audio_sync_enabled); m_audio_stream->SetSync(audio_sync_enabled);
if (audio_sync_enabled) if (audio_sync_enabled)
m_audio_stream->EmptyBuffers(); m_audio_stream->EmptyBuffers();
@ -1670,19 +1676,19 @@ void CommonHostInterface::RegisterSaveStateHotkeys()
void CommonHostInterface::RegisterAudioHotkeys() void CommonHostInterface::RegisterAudioHotkeys()
{ {
RegisterHotkey( RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioMute"),
StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioMute"), StaticString(TRANSLATABLE("Hotkeys", "Toggle Mute")), [this](bool pressed) {
StaticString(TRANSLATABLE("Hotkeys", "Toggle Mute")), [this](bool pressed) { if (pressed && System::IsValid())
if (pressed && System::IsValid()) {
{ g_settings.audio_output_muted = !g_settings.audio_output_muted;
g_settings.audio_output_muted = !g_settings.audio_output_muted; const s32 volume = GetAudioOutputVolume();
m_audio_stream->SetOutputVolume(g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume); m_audio_stream->SetOutputVolume(volume);
if (g_settings.audio_output_muted) if (g_settings.audio_output_muted)
AddOSDMessage(TranslateStdString("OSDMessage", "Volume: Muted"), 2.0f); AddOSDMessage(TranslateStdString("OSDMessage", "Volume: Muted"), 2.0f);
else else
AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), g_settings.audio_output_volume); AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), volume);
} }
}); });
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioCDAudioMute"), RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioCDAudioMute"),
StaticString(TRANSLATABLE("Hotkeys", "Toggle CD Audio Mute")), [this](bool pressed) { StaticString(TRANSLATABLE("Hotkeys", "Toggle CD Audio Mute")), [this](bool pressed) {
if (pressed && System::IsValid()) if (pressed && System::IsValid())
@ -1698,22 +1704,24 @@ void CommonHostInterface::RegisterAudioHotkeys()
StaticString(TRANSLATABLE("Hotkeys", "Volume Up")), [this](bool pressed) { StaticString(TRANSLATABLE("Hotkeys", "Volume Up")), [this](bool pressed) {
if (pressed && System::IsValid()) if (pressed && System::IsValid())
{ {
g_settings.audio_output_volume = std::min<s32>(g_settings.audio_output_volume + 10, 100); const s32 volume = std::min<s32>(GetAudioOutputVolume() + 10, 100);
g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = volume;
g_settings.audio_output_muted = false; g_settings.audio_output_muted = false;
m_audio_stream->SetOutputVolume(g_settings.audio_output_volume); m_audio_stream->SetOutputVolume(volume);
AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), volume);
g_settings.audio_output_volume);
} }
}); });
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioVolumeDown"), RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioVolumeDown"),
StaticString(TRANSLATABLE("Hotkeys", "Volume Down")), [this](bool pressed) { StaticString(TRANSLATABLE("Hotkeys", "Volume Down")), [this](bool pressed) {
if (pressed && System::IsValid()) if (pressed && System::IsValid())
{ {
g_settings.audio_output_volume = std::max<s32>(g_settings.audio_output_volume - 10, 0); const s32 volume = std::max<s32>(GetAudioOutputVolume() - 10, 0);
g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = volume;
g_settings.audio_output_muted = false; g_settings.audio_output_muted = false;
m_audio_stream->SetOutputVolume(g_settings.audio_output_volume); m_audio_stream->SetOutputVolume(volume);
AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), volume);
g_settings.audio_output_volume);
} }
}); });
} }

View file

@ -230,6 +230,7 @@ protected:
virtual bool SetFullscreen(bool enabled); virtual bool SetFullscreen(bool enabled);
virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) override; virtual std::unique_ptr<AudioStream> CreateAudioStream(AudioBackend backend) override;
virtual s32 GetAudioOutputVolume() const override;
virtual void UpdateControllerInterface(); virtual void UpdateControllerInterface();
virtual void OnSystemCreated() override; virtual void OnSystemCreated() override;