Dispose pcm
This commit is contained in:
parent
b4cf9fee84
commit
54a91b4a79
@ -180,14 +180,13 @@ namespace NadekoBot.Services.Music
|
|||||||
// i don't want to spam connection attempts
|
// i don't want to spam connection attempts
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pcm = ac.CreatePCMStream(AudioApplication.Music, bufferMillis: 500);
|
|
||||||
OnStarted?.Invoke(this, data);
|
OnStarted?.Invoke(this, data);
|
||||||
|
|
||||||
byte[] buffer = new byte[3840];
|
byte[] buffer = new byte[3840];
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
|
|
||||||
while ((bytesRead = b.Read(buffer, 0, buffer.Length)) > 0
|
while ((bytesRead = b.Read(buffer, 0, buffer.Length)) > 0
|
||||||
&& (MaxPlaytimeSeconds <= 0 || MaxPlaytimeSeconds >= CurrentTime.TotalSeconds))
|
&& (MaxPlaytimeSeconds <= 0 || MaxPlaytimeSeconds >= CurrentTime.TotalSeconds))
|
||||||
{
|
{
|
||||||
//AdjustVolume(buffer, Volume);
|
//AdjustVolume(buffer, Volume);
|
||||||
await pcm.WriteAsync(buffer, 0, bytesRead, cancelToken).ConfigureAwait(false);
|
await pcm.WriteAsync(buffer, 0, bytesRead, cancelToken).ConfigureAwait(false);
|
||||||
@ -215,6 +214,7 @@ namespace NadekoBot.Services.Music
|
|||||||
var flushDelay = Task.Delay(1000, flushToken);
|
var flushDelay = Task.Delay(1000, flushToken);
|
||||||
await Task.WhenAny(flushDelay, pcm.FlushAsync(flushToken));
|
await Task.WhenAny(flushDelay, pcm.FlushAsync(flushToken));
|
||||||
flushCancel.Cancel();
|
flushCancel.Cancel();
|
||||||
|
pcm.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
OnCompleted?.Invoke(this, data.Song);
|
OnCompleted?.Invoke(this, data.Song);
|
||||||
|
Loading…
Reference in New Issue
Block a user