mirror of
https://github.com/osukey/osukey.git
synced 2025-05-07 06:37:18 +09:00
Merge pull request #15821 from peppy/reapply-preview-track-workaround
Fix potential crashes when playing preview tracks in single thread mode
This commit is contained in:
commit
ed5f7039d5
@ -97,6 +97,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
if (previewTrack == null)
|
if (previewTrack == null)
|
||||||
{
|
{
|
||||||
toggleLoading(true);
|
toggleLoading(true);
|
||||||
|
|
||||||
LoadComponentAsync(previewTrack = previewTrackManager.Get(beatmapSetInfo), onPreviewLoaded);
|
LoadComponentAsync(previewTrack = previewTrackManager.Get(beatmapSetInfo), onPreviewLoaded);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -111,6 +112,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onPreviewLoaded(PreviewTrack loadedPreview)
|
private void onPreviewLoaded(PreviewTrack loadedPreview)
|
||||||
|
{
|
||||||
|
// Make sure that we schedule to after the next audio frame to fix crashes in single-threaded execution.
|
||||||
|
// See: https://github.com/ppy/osu-framework/issues/4692
|
||||||
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
// another async load might have completed before this one.
|
// another async load might have completed before this one.
|
||||||
// if so, do not make any changes.
|
// if so, do not make any changes.
|
||||||
@ -124,6 +129,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
|||||||
|
|
||||||
if (Playing.Value)
|
if (Playing.Value)
|
||||||
tryStartPreview();
|
tryStartPreview();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryStartPreview()
|
private void tryStartPreview()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user