Skip to content

Commit

Permalink
Fix intermittent Playing state on short looping samples
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Jul 11, 2024
1 parent 4f51628 commit c7b5052
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion osu.Framework/Audio/Sample/SampleChannelBass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ internal sealed class SampleChannelBass : SampleChannel, IBassAudioChannel
/// <remarks>
/// This is set to <c>true</c> immediately upon <see cref="Play"/>, but the channel may not be audibly playing yet.
/// </remarks>
public override bool Playing => playing || enqueuedPlaybackStart;
public override bool Playing
{
get
{
// When short samples loop (especially within mixers), there's a small window where the ChannelIsActive state could be Stopped.
// In order to not provide a "stale" value here, we'll not trust the internal playing state from BASS.
if (Looping && userRequestedPlay)
return true;

return playing || enqueuedPlaybackStart;
}
}

private volatile bool playing;

Expand Down

0 comments on commit c7b5052

Please sign in to comment.