Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes queue items correlation when playable track identifier differs … #169

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Lavalink4NET/Players/LavalinkPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class LavalinkPlayer : ILavalinkPlayer, ILavalinkPlayerListener
private volatile ITrackQueueItem? _currentItem;
private volatile ITrackQueueItem? _replacedItem;
private volatile ITrackQueueItem? _nextItem;
private volatile string? _nextOverridenPlayableItemIdentifier;
private UpDownCounter<int>? _previousStateCounter;
private string? _previousVoiceServer;

Expand Down Expand Up @@ -218,9 +219,10 @@ ValueTask ILavalinkPlayerListener.NotifyTrackStartedAsync(LavalinkTrack track, C
ArgumentNullException.ThrowIfNull(track);

var nextTrack = Interlocked.Exchange(ref _nextItem, null) ?? CurrentItem;
Debug.Assert(track.Identifier == nextTrack?.Identifier);
var nextTrackIdentifier = Interlocked.Exchange(ref _nextOverridenPlayableItemIdentifier, null) ?? nextTrack?.Identifier;
Debug.Assert(track.Identifier == nextTrackIdentifier);

CurrentItem = track.Identifier == nextTrack?.Identifier
CurrentItem = track.Identifier == nextTrackIdentifier
? nextTrack
: new TrackQueueItem(new TrackReference(track));

Expand Down Expand Up @@ -265,7 +267,7 @@ public virtual async ValueTask PlayAsync(ITrackQueueItem trackQueueItem, TrackPl
.GetPlayableTrackAsync(cancellationToken)
.ConfigureAwait(false);

updateProperties.TrackData = playableTrack.ToString();
updateProperties.TrackData = _nextOverridenPlayableItemIdentifier = playableTrack.ToString();
}
else
{
Expand Down
Loading