mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user