stop works properly now, was causing memory leaks
This commit is contained in:
parent
a3d9914d36
commit
d1bce790df
@ -42,5 +42,15 @@ namespace NadekoBot.Classes.Music {
|
|||||||
CurrentSong.Start();
|
CurrentSong.Start();
|
||||||
Console.WriteLine("starting");
|
Console.WriteLine("starting");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void RemoveAllSongs() {
|
||||||
|
lock (SongQueue) {
|
||||||
|
foreach (var kvp in SongQueue) {
|
||||||
|
if(kvp != null)
|
||||||
|
kvp.Cancel();
|
||||||
|
}
|
||||||
|
SongQueue.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,10 +168,10 @@ namespace NadekoBot.Classes.Music {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer.Length > 5.MB()) { // if buffer is over 10 MB, create new one
|
if (buffer.readPos > 10.MiB()) { // if buffer is over 10 MiB, create new one
|
||||||
Console.WriteLine("Buffer over 10 megs, clearing.");
|
Console.WriteLine("Buffer over 10 megs, clearing.");
|
||||||
|
|
||||||
var skip = 2.MB();
|
var skip = 10.MB(); //remove only 10 MB, just in case
|
||||||
byte[] data = buffer.ToArray().Skip(skip).ToArray();
|
byte[] data = buffer.ToArray().Skip(skip).ToArray();
|
||||||
|
|
||||||
lock (_bufferLock) {
|
lock (_bufferLock) {
|
||||||
|
@ -71,7 +71,7 @@ namespace NadekoBot.Modules {
|
|||||||
.Do(e => {
|
.Do(e => {
|
||||||
if (musicPlayers.ContainsKey(e.Server) == false) return;
|
if (musicPlayers.ContainsKey(e.Server) == false) return;
|
||||||
var player = musicPlayers[e.Server];
|
var player = musicPlayers[e.Server];
|
||||||
player.SongQueue.Clear();
|
player.RemoveAllSongs();
|
||||||
if (player.CurrentSong != null) {
|
if (player.CurrentSong != null) {
|
||||||
player.CurrentSong.Cancel();
|
player.CurrentSong.Cancel();
|
||||||
player.CurrentSong = null;
|
player.CurrentSong = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user