diff --git a/osu.Game.Tests/Visual/TestCasePreviewTrackManager.cs b/osu.Game.Tests/Visual/TestCasePreviewTrackManager.cs index 7d02519007..d711d501fe 100644 --- a/osu.Game.Tests/Visual/TestCasePreviewTrackManager.cs +++ b/osu.Game.Tests/Visual/TestCasePreviewTrackManager.cs @@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual AddStep("get track", () => track = getOwnedTrack()); AddStep("start", () => track.Start()); - AddStep("stop by owner", () => trackManager.Stop(this)); + AddStep("stop by owner", () => trackManager.StopAnyPlaying(this)); AddAssert("stopped", () => !track.IsRunning); } @@ -77,9 +77,9 @@ namespace osu.Game.Tests.Visual AddStep("get track", () => AddInternal(owner = new TestTrackOwner(track = getTrack()))); AddStep("start", () => track.Start()); - AddStep("attempt stop", () => trackManager.Stop(this)); + AddStep("attempt stop", () => trackManager.StopAnyPlaying(this)); AddAssert("not stopped", () => track.IsRunning); - AddStep("stop by true owner", () => trackManager.Stop(owner)); + AddStep("stop by true owner", () => trackManager.StopAnyPlaying(owner)); AddAssert("stopped", () => !track.IsRunning); } diff --git a/osu.Game/Audio/PreviewTrackManager.cs b/osu.Game/Audio/PreviewTrackManager.cs index 56bedc9dd2..07fbe86ff4 100644 --- a/osu.Game/Audio/PreviewTrackManager.cs +++ b/osu.Game/Audio/PreviewTrackManager.cs @@ -60,7 +60,7 @@ namespace osu.Game.Audio } /// - /// Stops the currently playing . + /// Stops any currently playing . /// /// /// Only the immediate owner (an object that implements ) of the playing @@ -68,12 +68,12 @@ namespace osu.Game.Audio /// can always stop the themselves through . /// /// The which may be the owner of the . - public void Stop(IPreviewTrackOwner source) + public void StopAnyPlaying(IPreviewTrackOwner source) { - if (current?.Owner != source) + if (current == null || current.Owner != source) return; - current?.Stop(); + current.Stop(); current = null; } diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index e3179b5631..d6b6595b69 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -82,7 +82,7 @@ namespace osu.Game.Graphics.Containers protected override void PopOut() { base.PopOut(); - previewTrackManager.Stop(this); + previewTrackManager.StopAnyPlaying(this); } } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index c28ecb3c9f..423211659d 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -262,7 +262,7 @@ namespace osu.Game.Overlays if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return; - previewTrackManager.Stop(this); + previewTrackManager.StopAnyPlaying(this); getSetsRequest = new SearchBeatmapSetsRequest(currentQuery.Value ?? string.Empty, ((FilterControl)Filter).Ruleset.Value,