mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 09:42:57 +08:00
Merge pull request #23888 from peppy/fix-intro-playing-twice
Fix music sometimes restarting twice if exiting song select with no beatmap selected
This commit is contained in:
commit
0ce4d17e30
@ -316,6 +316,8 @@ namespace osu.Game.Overlays
|
|||||||
var queuedTrack = getQueuedTrack();
|
var queuedTrack = getQueuedTrack();
|
||||||
|
|
||||||
var lastTrack = CurrentTrack;
|
var lastTrack = CurrentTrack;
|
||||||
|
lastTrack.Completed -= onTrackCompleted;
|
||||||
|
|
||||||
CurrentTrack = queuedTrack;
|
CurrentTrack = queuedTrack;
|
||||||
|
|
||||||
// At this point we may potentially be in an async context from tests. This is extremely dangerous but we have to make do for now.
|
// At this point we may potentially be in an async context from tests. This is extremely dangerous but we have to make do for now.
|
||||||
@ -344,16 +346,12 @@ namespace osu.Game.Overlays
|
|||||||
// Important to keep this in its own method to avoid inadvertently capturing unnecessary variables in the callback.
|
// Important to keep this in its own method to avoid inadvertently capturing unnecessary variables in the callback.
|
||||||
// Can lead to leaks.
|
// Can lead to leaks.
|
||||||
var queuedTrack = new DrawableTrack(current.LoadTrack());
|
var queuedTrack = new DrawableTrack(current.LoadTrack());
|
||||||
queuedTrack.Completed += () => onTrackCompleted(current);
|
queuedTrack.Completed += onTrackCompleted;
|
||||||
return queuedTrack;
|
return queuedTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTrackCompleted(WorkingBeatmap workingBeatmap)
|
private void onTrackCompleted()
|
||||||
{
|
{
|
||||||
// the source of track completion is the audio thread, so the beatmap may have changed before firing.
|
|
||||||
if (current != workingBeatmap)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!CurrentTrack.Looping && !beatmap.Disabled)
|
if (!CurrentTrack.Looping && !beatmap.Disabled)
|
||||||
NextTrack();
|
NextTrack();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
if (nextBackground == background)
|
if (nextBackground == background)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Logger.Log("🌅 Background change queued");
|
Logger.Log(@"🌅 Global background change queued");
|
||||||
|
|
||||||
cancellationTokenSource?.Cancel();
|
cancellationTokenSource?.Cancel();
|
||||||
cancellationTokenSource = new CancellationTokenSource();
|
cancellationTokenSource = new CancellationTokenSource();
|
||||||
@ -94,6 +94,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
nextTask?.Cancel();
|
nextTask?.Cancel();
|
||||||
nextTask = Scheduler.AddDelayed(() =>
|
nextTask = Scheduler.AddDelayed(() =>
|
||||||
{
|
{
|
||||||
|
Logger.Log(@"🌅 Global background loading");
|
||||||
LoadComponentAsync(nextBackground, displayNext, cancellationTokenSource.Token);
|
LoadComponentAsync(nextBackground, displayNext, cancellationTokenSource.Token);
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user