Skip sound playback when master volume is muted

Water splash and swimming sounds were bypassing mute because
ma_engine_set_volume(0) didn't fully prevent sound creation.
Now playSound2D and playSound3D early-return when masterVolume
is zero.
This commit is contained in:
Kelsi 2026-02-26 02:31:06 -08:00
parent c0c5b75e94
commit 5cb469e318

View file

@ -224,6 +224,7 @@ void AudioEngine::setListenerOrientation(const glm::vec3& forward, const glm::ve
bool AudioEngine::playSound2D(const std::vector<uint8_t>& wavData, float volume, float pitch) {
(void)pitch;
if (!initialized_ || !engine_ || wavData.empty()) return false;
if (masterVolume_ <= 0.0f) return false;
DecodedWavCacheEntry decoded;
if (!decodeWavCached(wavData, decoded) || !decoded.pcmData || decoded.frames == 0) {
@ -308,6 +309,7 @@ bool AudioEngine::playSound2D(const std::string& mpqPath, float volume, float pi
bool AudioEngine::playSound3D(const std::vector<uint8_t>& wavData, const glm::vec3& position,
float volume, float pitch, float maxDistance) {
if (!initialized_ || !engine_ || wavData.empty()) return false;
if (masterVolume_ <= 0.0f) return false;
DecodedWavCacheEntry decoded;
if (!decodeWavCached(wavData, decoded) || !decoded.pcmData || decoded.frames == 0) {