Dynamic-FPS icon indicating copy to clipboard operation
Dynamic-FPS copied to clipboard

Fix setting sound volume to 0

Open Scotsguy opened this issue 2 years ago • 7 comments

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.

Scotsguy avatar May 15 '22 14:05 Scotsguy

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?

juliand665 avatar May 17 '22 13:05 juliand665

Hmm, haven't tested it with sounds that happen while minimized. I'll try it out, and report back.

Scotsguy avatar May 17 '22 13:05 Scotsguy

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.

Scotsguy avatar May 17 '22 14:05 Scotsguy

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.

juliand665 avatar May 17 '22 14:05 juliand665

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.

Scotsguy avatar May 17 '22 14:05 Scotsguy

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.

Scotsguy avatar May 17 '22 14:05 Scotsguy

Hm yeah, that seems like a decent tradeoff. I'll have to give it a spin myself!

juliand665 avatar May 17 '22 15:05 juliand665

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 🦫

LostLuma avatar Sep 03 '23 12:09 LostLuma

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.

juliand665 avatar Sep 03 '23 13:09 juliand665