mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-19 19:14:48 +00:00
Merge d54696b126
into 69777e2ffa
This commit is contained in:
commit
15b8381ee8
3 changed files with 37 additions and 4 deletions
|
@ -71,6 +71,8 @@ static bool isFpsColor = true;
|
|||
static bool isSeparateLogFilesEnabled = false;
|
||||
static s16 cursorState = HideCursorState::Idle;
|
||||
static int cursorHideTimeout = 5; // 5 seconds (default)
|
||||
static bool muteVolume = false;
|
||||
static int audioVolume = 100;
|
||||
static double trophyNotificationDuration = 6.0;
|
||||
static bool useUnifiedInputConfig = true;
|
||||
static bool overrideControllerColor = false;
|
||||
|
@ -211,6 +213,14 @@ int getCursorHideTimeout() {
|
|||
return cursorHideTimeout;
|
||||
}
|
||||
|
||||
bool muteAudio() {
|
||||
return muteVolume;
|
||||
}
|
||||
|
||||
int getAudioVolume() {
|
||||
return audioVolume;
|
||||
}
|
||||
|
||||
double getTrophyNotificationDuration() {
|
||||
return trophyNotificationDuration;
|
||||
}
|
||||
|
@ -790,6 +800,13 @@ void load(const std::filesystem::path& path) {
|
|||
useUnifiedInputConfig = toml::find_or<bool>(input, "useUnifiedInputConfig", true);
|
||||
}
|
||||
|
||||
if (data.contains("Audio")) {
|
||||
const toml::value& audio = data.at("Audio");
|
||||
|
||||
muteVolume = toml::find_or<bool>(audio, "muteAudio", false);
|
||||
audioVolume = toml::find_or<int>(audio, "audioVolume", 100);
|
||||
}
|
||||
|
||||
if (data.contains("GPU")) {
|
||||
const toml::value& gpu = data.at("GPU");
|
||||
|
||||
|
@ -900,8 +917,8 @@ void load(const std::filesystem::path& path) {
|
|||
|
||||
void sortTomlSections(toml::ordered_value& data) {
|
||||
toml::ordered_value ordered_data;
|
||||
std::vector<std::string> section_order = {"General", "Input", "GPU", "Vulkan",
|
||||
"Debug", "Keys", "GUI", "Settings"};
|
||||
std::vector<std::string> section_order = {"General", "Input", "Audio", "GPU", "Vulkan",
|
||||
"Debug", "Keys", "GUI", "Settings"};
|
||||
|
||||
for (const auto& section : section_order) {
|
||||
if (data.contains(section)) {
|
||||
|
@ -976,6 +993,8 @@ void save(const std::filesystem::path& path) {
|
|||
data["Input"]["specialPadClass"] = specialPadClass;
|
||||
data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled;
|
||||
data["Input"]["useUnifiedInputConfig"] = useUnifiedInputConfig;
|
||||
data["Audio"]["muteAudio"] = muteVolume;
|
||||
data["Audio"]["audioVolume"] = audioVolume;
|
||||
data["GPU"]["screenWidth"] = screenWidth;
|
||||
data["GPU"]["screenHeight"] = screenHeight;
|
||||
data["GPU"]["nullGpu"] = isNullGpu;
|
||||
|
|
|
@ -60,6 +60,9 @@ void SetOverrideControllerColor(bool enable);
|
|||
int* GetControllerCustomColor();
|
||||
void SetControllerCustomColor(int r, int b, int g);
|
||||
|
||||
bool muteAudio();
|
||||
int getAudioVolume();
|
||||
|
||||
u32 getScreenWidth();
|
||||
u32 getScreenHeight();
|
||||
s32 getGpuId();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#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"
|
||||
#include "core/libraries/audio/audioout_backend.h"
|
||||
|
@ -76,8 +77,18 @@ public:
|
|||
return;
|
||||
}
|
||||
// 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)) {
|
||||
// const auto vol = *std::ranges::max_element(ch_volumes);
|
||||
|
||||
float volume = 0;
|
||||
if (Config::muteAudio()) {
|
||||
volume = 0;
|
||||
} else {
|
||||
// For the user the volume is from 0 to 100 but for us it is from 0 to 10000.
|
||||
// So let's multiply by 100.
|
||||
volume = Config::getAudioVolume() * 100;
|
||||
}
|
||||
|
||||
if (!SDL_SetAudioStreamGain(stream, volume / SCE_AUDIO_OUT_VOLUME_0DB)) {
|
||||
LOG_WARNING(Lib_AudioOut, "Failed to change SDL audio stream volume: {}",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue