Skip to content

Commit

Permalink
Do not attempt to stop preview tracks when arriving from a "track com…
Browse files Browse the repository at this point in the history
…pleted" sync

This fixes an issue identified with the WASAPI implementation in
ppy/osu-framework#6088. It has no real effect
on current `master`, but fixes a deadlock that occurs with the
aforementioned framework branch when one lets a preview track play out
to the end - at this point all audio will stop and an attempt to perform
any synchronous BASS operation (playing another track, seeking) will
result in a deadlock.

It isn't terribly clear as to why this is happening precisely, but
there does not appear to be any need to stop and seek at that point,
so this feels like a decent workaround even if the actual issue is
upstream (and will unblock pushing out WASAPI support to users).
  • Loading branch information
bdach committed Dec 25, 2023
1 parent dde88bb commit f84b07e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions osu.Game/Audio/PreviewTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ public void Stop()

hasStarted = false;

Track.Stop();
if (!Track.HasCompleted)
{
Track.Stop();

// Ensure the track is reset immediately on stopping, so the next time it is started it has a correct time value.
Track.Seek(0);
// Ensure the track is reset immediately on stopping, so the next time it is started it has a correct time value.
Track.Seek(0);
}

Stopped?.Invoke();
}
Expand Down

0 comments on commit f84b07e

Please sign in to comment.