Volume slider that adjusts how loud games are on a global level (#3240)

* Update config.cpp

* Update config.h

* Update sdl_audio.cpp

* Update settings_dialog.cpp

* Update settings_dialog.h

* Update settings_dialog.ui

* Update gui_settings.h

* Update audioout.cpp

* Update audioout.h

* Update settings_dialog.cpp

* remove leftover settings_dialog.ui

* Update settings_dialog.ui

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
This commit is contained in:
UltraDaCat
2025-07-18 10:20:05 +02:00
committed by GitHub
parent e914099ae2
commit fafd3fb564
9 changed files with 304 additions and 168 deletions

View File

@@ -523,9 +523,24 @@ s32 PS4_SYSV_ABI sceAudioOutSetVolume(s32 handle, s32 flag, s32* vol) {
}
port.impl->SetVolume(port.volume);
}
AdjustVol();
return ORBIS_OK;
}
void AdjustVol() {
if (audio == nullptr) {
return;
}
for (int i = 0; i < ports_out.size(); i++) {
std::unique_lock lock{ports_out[i].mutex};
if (!ports_out[i].IsOpen()) {
continue;
}
ports_out[i].impl->SetVolume(ports_out[i].volume);
}
}
int PS4_SYSV_ABI sceAudioOutSetVolumeDown() {
LOG_ERROR(Lib_AudioOut, "(STUBBED) called");
return ORBIS_OK;

View File

@@ -181,5 +181,6 @@ int PS4_SYSV_ABI sceAudioOutSystemControlSet();
int PS4_SYSV_ABI sceAudioOutSparkControlSetEqCoef();
int PS4_SYSV_ABI sceAudioOutSetSystemDebugState();
void AdjustVol();
void RegisterLib(Core::Loader::SymbolsResolver* sym);
} // namespace Libraries::AudioOut

View File

@@ -4,6 +4,7 @@
#include <thread>
#include <SDL3/SDL_audio.h>
#include <SDL3/SDL_hints.h>
#include <common/config.h>
#include "common/logging/log.h"
#include "core/libraries/audio/audioout.h"
@@ -41,6 +42,7 @@ public:
stream = nullptr;
return;
}
SDL_SetAudioStreamGain(stream, Config::getVolumeSlider() / 100.0f);
}
~SDLPortBackend() override {
@@ -77,7 +79,8 @@ public:
}
// SDL does not have per-channel volumes, for now just take the maximum of the channels.
const auto vol = *std::ranges::max_element(ch_volumes);
if (!SDL_SetAudioStreamGain(stream, static_cast<float>(vol) / SCE_AUDIO_OUT_VOLUME_0DB)) {
if (!SDL_SetAudioStreamGain(stream, static_cast<float>(vol) / SCE_AUDIO_OUT_VOLUME_0DB *
Config::getVolumeSlider() / 100.0f)) {
LOG_WARNING(Lib_AudioOut, "Failed to change SDL audio stream volume: {}",
SDL_GetError());
}