Xbox Cloud Gaming app for PS5 Homebrew
C
Microphone gain: the setting's choice mapped to 50 / 100 / 150 %
Rafael Abud Ferreiradd6f829c9936
diff --git a/src/app/settings.cpp b/src/app/settings.cppindex 1085695..3d606b9 100644--- a/src/app/settings.cpp+++ b/src/app/settings.cpp@@ -121,6 +121,11 @@ bool Settings::load(const std::string& path) {return true;}+float Settings::micGainFactor() const {+ static constexpr float kFactors[] = {0.5f, 1.0f, 1.5f};+ return kFactors[std::clamp(micGain, 0, 2)];+}+GameProfile Settings::defaultProfile() const {GameProfile p;p.sharpness = sharpness;diff --git a/src/app/settings.h b/src/app/settings.hindex 5bd8a5a..8c669cb 100644--- a/src/app/settings.h+++ b/src/app/settings.h@@ -97,6 +97,9 @@ struct Settings {// Per-game profiles overriding the general settings (productId or titleId -> profile).std::map<std::string, GameProfile> perGame;+ // micGain as the microphone's gain (StreamPlayer::setMicGain): 0.5, 1 or 1.5.+ float micGainFactor() const;+GameProfile defaultProfile() const;GameProfile profileForGame(const std::string& productId, const std::string& titleId, bool* hasCustom = nullptr) const;diff --git a/src/app/stream_screen.cpp b/src/app/stream_screen.cppindex ccdbb04..d888e3f 100644--- a/src/app/stream_screen.cpp+++ b/src/app/stream_screen.cpp@@ -134,7 +134,7 @@ void StreamScreen::update(const input::ControllerState& pad, ui::NavInput nav, bmedia::audioSetRoute(static_cast<media::AudioRoute>(g_settings.audioRoute));if (g_player) {- g_player->setMicGain(g_settings.micGain);+ g_player->setMicGain(g_settings.micGainFactor());}overlaySeq_ = 0;diff --git a/src/app/worker.cpp b/src/app/worker.cppindex 401057a..6fa2a7a 100644--- a/src/app/worker.cpp+++ b/src/app/worker.cpp@@ -71,7 +71,7 @@ std::string stream(xcloud::GssvClient& gssv) {player.setHwDecodeProbe(g_autoplay.hwDecode);{std::lock_guard<std::mutex> lock(g_settingsMutex);- player.setMicGain(g_settings.micGain);+ player.setMicGain(g_settings.micGainFactor());player.setMicEnabled(g_settings.micEnabled);player.setMaxBitrate(g_settings.maxBitrateMbps);media::audioSetVolume(g_settings.gameVolume / 100.0f);diff --git a/tests/test_main.cpp b/tests/test_main.cppindex 32054f9..f43f387 100644--- a/tests/test_main.cpp+++ b/tests/test_main.cpp@@ -304,6 +304,18 @@ static void testSettingsMigration() {std::remove(path.c_str());}+// The microphone's gain is stored as a choice (0..2), not as the factor.+static void testMicGain() {+ app::Settings s;+ CHECK(s.micGain == 1 && s.micGainFactor() == 1.0f);+ s.micGain = 0;+ CHECK(s.micGainFactor() == 0.5f);+ s.micGain = 2;+ CHECK(s.micGainFactor() == 1.5f);+ s.micGain = 7; // out of range (a hand-edited file): the nearest choice+ CHECK(s.micGainFactor() == 1.5f);+}+static void testPerGameSettings() {std::string path = "/tmp/xcloud-tests-pergame.json";xc::app::Settings s;@@ -1170,6 +1182,7 @@ int main() {testVersions();testStreamMenu();testSettingsMigration();+ testMicGain();testPerGameSettings();testStrings();testRegions();