Skip to content

Commit 343eff3

Browse files
committed
Fix wrong state of SampleChannelBass by adding userRequestedStop
Before this commit, calling Stop makes playing false, which in turn makes IsAlive false.
1 parent da1c2ec commit 343eff3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

osu.Framework/Audio/Sample/SampleChannelBass.cs

+17
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public override bool Playing
4040
/// </summary>
4141
private volatile bool userRequestedPlay;
4242

43+
/// <summary>
44+
/// <c>true</c> if the user last called <see cref="Stop"/>.
45+
/// <c>false</c> if the user last called <see cref="Play"/> or this channel finished playback.
46+
/// </summary>
47+
private volatile bool userRequestedStop;
48+
4349
/// <summary>
4450
/// Whether the playback start has been enqueued.
4551
/// </summary>
@@ -55,6 +61,8 @@ public override bool Looping
5561
}
5662
}
5763

64+
public override bool IsAlive => base.IsAlive && (Playing || userRequestedStop);
65+
5866
private bool hasChannel => channel != 0;
5967

6068
public override ChannelAmplitudes CurrentAmplitudes => (bassAmplitudeProcessor ??= new BassAmplitudeProcessor(this)).CurrentAmplitudes;
@@ -99,8 +107,13 @@ protected override void UpdateState()
99107
playing = true;
100108
break;
101109

110+
case PlaybackState.Paused when userRequestedStop:
111+
playing = false;
112+
break;
113+
102114
default:
103115
playing = false;
116+
userRequestedStop = false;
104117
break;
105118
}
106119
}
@@ -119,6 +132,8 @@ public override void Play()
119132
{
120133
userRequestedPlay = true;
121134

135+
userRequestedStop = false;
136+
122137
// Pin Playing and IsAlive to true so that the channel isn't killed by the next update. This is only reset after playback is started.
123138
enqueuedPlaybackStart = true;
124139

@@ -138,6 +153,8 @@ public override void Stop()
138153
{
139154
userRequestedPlay = false;
140155

156+
userRequestedStop = true;
157+
141158
base.Stop();
142159

143160
EnqueueAction(() =>

0 commit comments

Comments
 (0)