Dynamic-FPS
Dynamic-FPS copied to clipboard
Fix setting sound volume to 0
Instead of actually setting it to 0, just pause it instead.
Fixes #55
Also updates to 1.18.2, because quilt mappings for 1.18.1 is no longer available on the maven
~~quilt-mappings-on-loom
3.1.1 is also not available, but i got that to build to mavenLocal.~~ Fixed!
Still works on 1.18.1.
Ooh, thanks for this! Thanks also for updating the mappings :)
With this change, what happens if you open the inventory or something, then minimize the game (or do anything that would make dynamic fps silence it)? Are newly-started sounds suppressed or do they come through anyway?
Hmm, haven't tested it with sounds that happen while minimized. I'll try it out, and report back.
Tested it: unfortunately, sounds can still start after all channels are paused. The SoundSystem doesn't keep track of whether it's paused, calling pauseAll just iterates over all sound sources and then pauses those. Not immediately sure how to work around this.
Oof, yeah. I was thinking back to why I didn't go for pausing originally, and I think this was the reason why. Perhaps a mixin into SoundManager
would help?
Though I think the real issue is that, when the game isn't pausing by itself, sounds shouldn't be paused (except maybe songs), since their sources would keep running.
In that case, we could avoid the whole mess by cirumventing the volume == 0 -> stop soundsystem check entirely by not calling SoundManager#updateSoundVolume, but SoundSystem#updateSoundVolume, a method i only now discovered exists. I'll try it.
Well, it... works? However, there are even more checks to see if volume == 0, so sounds will never be started if the master volume is zero, i.e. when minimized. This is probably preferable, could be avoided with a mixin though.
Hm yeah, that seems like a decent tradeoff. I'll have to give it a spin myself!
What's the reason this did not get merged originally @juliand665? I'm also curious whether you're still interested in fixing this bug in general @Scotsguy? Otherwise I'll look at it soonish 🦫
Good question! I think I just got too busy with other things and never thought to check back on this new approach. Plus testing can be pretty time-consuming with this sound stuff, e.g. I think I remember only realizing there was a bug after leaving my game hidden for several minutes while in the main menu, when a new song decided to play despite the sound supposedly being muted by the mod.