emulationstation: navigation sounds toggle takes effect without reboot

A user reported (and it reproduces on hardware) that turning "ENABLE
NAVIGATION SOUNDS" on in Sound Settings does nothing until the device is
rebooted.

Root cause: Sound::init() loaded the WAV sample only when EnableSounds was
already true:

    if (!Settings::getInstance()->getBool("EnableSounds"))
        return;
    mSampleData = Mix_LoadWAV(...);

So when the frontend starts with sounds disabled, every Sound keeps a null
sample; flipping the menu switch only writes the setting and never reloads
the samples, so play() bails on the null sample. Only the next boot re-runs
init() with the setting true and finally loads them.

Sound::play() already checks the live EnableSounds value, so the init-time
gate is redundant for correctness and harmful for runtime toggling. Drop it
(new patch, first under this package's patches/) so samples always load and
the toggle works immediately, both directions, no reboot. Memory cost is a
handful of small navigation WAVs.

Pending validation: takes effect after the ES package is rebuilt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Douglas Teles
2026-06-25 22:47:54 -03:00
parent 3d1ad6e278
commit f152192961
@@ -0,0 +1,23 @@
sound: load navigation sounds regardless of EnableSounds
Sound::init() loaded the WAV only when EnableSounds was already true, so
toggling "ENABLE NAVIGATION SOUNDS" on in Sound Settings left every Sound
with a null sample until the next reboot (when init() re-ran with the
setting now true). Sound::play() already gates on the live EnableSounds
value, so loading the sample unconditionally is enough and makes the menu
toggle take effect immediately, in both directions, with no reboot.
Reported by a user and reproduced on hardware.
--- a/es-core/src/Sound.cpp
+++ b/es-core/src/Sound.cpp
@@ -67,9 +67,6 @@
if (mPath.empty() || !Utils::FileSystem::exists(mPath))
return;
- if (!Settings::getInstance()->getBool("EnableSounds"))
- return;
-
//load wav file via SDL
mSampleData = Mix_LoadWAV(mPath.c_str());
if (mSampleData == nullptr)