From 1195a4c9c8ecee1657eb4c19a97cf54c8f035b54 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 21 Jul 2016 14:07:26 +0200 Subject: [PATCH] resetting buffer? --- NadekoBot/Modules/Music/Classes/Song.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Music/Classes/Song.cs b/NadekoBot/Modules/Music/Classes/Song.cs index e718302e..025863e0 100644 --- a/NadekoBot/Modules/Music/Classes/Song.cs +++ b/NadekoBot/Modules/Music/Classes/Song.cs @@ -31,7 +31,7 @@ namespace NadekoBot.Modules.Music.Classes public SongInfo SongInfo { get; } public string QueuerName { get; set; } - private PoopyBuffer songBuffer { get; } = new PoopyBuffer(NadekoBot.Config.BufferSize); + private PoopyBuffer songBuffer { get; set; } private bool prebufferingComplete { get; set; } = false; public MusicPlayer MusicPlayer { get; set; } @@ -137,6 +137,9 @@ namespace NadekoBot.Modules.Music.Classes internal async Task Play(IAudioClient voiceClient, CancellationToken cancelToken) { + // initialize the buffer here because if this song was playing before (requeued), we must delete old buffer data + songBuffer = new PoopyBuffer(NadekoBot.Config.BufferSize); + var bufferTask = BufferSong(cancelToken).ConfigureAwait(false); var bufferAttempts = 0; const int waitPerAttempt = 500; @@ -145,7 +148,6 @@ namespace NadekoBot.Modules.Music.Classes { await Task.Delay(waitPerAttempt, cancelToken).ConfigureAwait(false); } - cancelToken.ThrowIfCancellationRequested(); Console.WriteLine($"Prebuffering done? in {waitPerAttempt * bufferAttempts}"); const int blockSize = 3840; var attempt = 0;