Skip to content

Commit

Permalink
Bring back and make use of clearPreviousSamples()
Browse files Browse the repository at this point in the history
  • Loading branch information
Terochi committed Mar 23, 2023
1 parent 1478a26 commit e6f1ec5
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions osu.Game/Skinning/PoolableSkinnableSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable disable

using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
Expand Down Expand Up @@ -74,14 +75,29 @@ protected override void SkinChanged(ISkinSource skin)
updateSample();
}

private void updateSample()
/// <summary>
/// Whether this sample was playing before a skin source change.
/// </summary>
private bool wasPlaying;

private void clearPreviousSamples()
{
if (sampleInfo == null)
return;
// only run if the samples aren't already cleared.
// this ensures the "wasPlaying" state is stored correctly even if multiple clear calls are executed.
if (!sampleContainer.Any()) return;

bool wasPlaying = Playing;
wasPlaying = Playing;

sampleContainer.Clear();
Sample = null;
}

private void updateSample()
{
clearPreviousSamples();

if (sampleInfo == null)
return;

var sample = CurrentSkin.GetSample(sampleInfo);

Expand Down

0 comments on commit e6f1ec5

Please sign in to comment.