diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index f97372e9b6..c6827d4197 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -264,15 +264,23 @@ namespace osu.Game.Tests.Visual.Gameplay } [Test] - public void TestMutedNotificationMasterVolume() + public void TestMutedNotificationLowMusicVolume() { - addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, () => audioManager.Volume.Value == 0.5); + addVolumeSteps("master and music volumes", () => + { + audioManager.Volume.Value = 0.6; + audioManager.VolumeTrack.Value = 0.01; + }, () => Precision.AlmostEquals(audioManager.Volume.Value, 0.6) && Precision.AlmostEquals(audioManager.VolumeTrack.Value, 0.5)); } [Test] - public void TestMutedNotificationTrackVolume() + public void TestMutedNotificationLowMasterVolume() { - addVolumeSteps("music volume", () => audioManager.VolumeTrack.Value = 0, () => audioManager.VolumeTrack.Value == 0.5); + addVolumeSteps("master and music volumes", () => + { + audioManager.Volume.Value = 0.01; + audioManager.VolumeTrack.Value = 0.6; + }, () => Precision.AlmostEquals(audioManager.Volume.Value, 0.5) && Precision.AlmostEquals(audioManager.VolumeTrack.Value, 0.6)); } [Test] @@ -281,9 +289,10 @@ namespace osu.Game.Tests.Visual.Gameplay addVolumeSteps("mute button", () => { // Importantly, in the case the volume is muted but the user has a volume level set, it should be retained. - audioManager.VolumeTrack.Value = 0.5f; + audioManager.Volume.Value = 0.5; + audioManager.VolumeTrack.Value = 0.5; volumeOverlay.IsMuted.Value = true; - }, () => !volumeOverlay.IsMuted.Value && audioManager.VolumeTrack.Value == 0.5f); + }, () => !volumeOverlay.IsMuted.Value && audioManager.Volume.Value == 0.5 && audioManager.VolumeTrack.Value == 0.5); } /// diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 232de53ac3..aa62256348 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Framework.Screens; using osu.Framework.Threading; +using osu.Framework.Utils; using osu.Game.Audio; using osu.Game.Audio.Effects; using osu.Game.Configuration; @@ -550,8 +551,10 @@ namespace osu.Game.Screens.Play { if (!muteWarningShownOnce.Value) { + double aggregateVolumeTrack = audioManager.Volume.Value * audioManager.VolumeTrack.Value; + // Checks if the notification has not been shown yet and also if master volume is muted, track/music volume is muted or if the whole game is muted. - if (volumeOverlay?.IsMuted.Value == true || audioManager.Volume.Value <= volume_requirement || audioManager.VolumeTrack.Value <= volume_requirement) + if (volumeOverlay?.IsMuted.Value == true || Precision.AlmostBigger(volume_requirement, aggregateVolumeTrack)) { notificationOverlay?.Post(new MutedNotification()); muteWarningShownOnce.Value = true; @@ -582,10 +585,8 @@ namespace osu.Game.Screens.Play // Check values before resetting, as the user may have only had mute enabled, in which case we might not need to adjust volumes. // Note that we only restore halfway to ensure the user isn't suddenly overloaded by unexpectedly high volume. - if (audioManager.Volume.Value <= volume_requirement) - audioManager.Volume.Value = 0.5f; - if (audioManager.VolumeTrack.Value <= volume_requirement) - audioManager.VolumeTrack.Value = 0.5f; + audioManager.Volume.Value = Math.Max(audioManager.Volume.Value, 0.5); + audioManager.VolumeTrack.Value = Math.Max(audioManager.VolumeTrack.Value, 0.5); return true; };