magic numbers

This commit is contained in:
Master Kwoth 2017-07-02 10:58:04 +02:00
parent bbe3ac66e3
commit 7de15bf444
2 changed files with 14 additions and 13 deletions

View File

@ -101,10 +101,10 @@ namespace NadekoBot.Services.Music
// i don't want to spam connection attempts // i don't want to spam connection attempts
continue; continue;
} }
var pcm = ac.CreatePCMStream(AudioApplication.Music, bufferMillis: 250); var pcm = ac.CreatePCMStream(AudioApplication.Music, bufferMillis: 1000);
OnStarted?.Invoke(this, data.Song); OnStarted?.Invoke(this, data.Song);
byte[] buffer = new byte[3840]; byte[] buffer = new byte[38400];
int bytesRead = 0; int bytesRead = 0;
try try
{ {

View File

@ -43,17 +43,17 @@ namespace NadekoBot.Services.Music
while (!cancelToken.IsCancellationRequested) while (!cancelToken.IsCancellationRequested)
{ {
var toRead = buffer.Length; var toRead = buffer.Length;
var remCap = _outStream.RemainingCapacity; //var remCap = _outStream.RemainingCapacity;
if (remCap < readSize) //if (remCap < readSize)
{ //{
if (_outStream.RemainingCapacity == 0) // if (_outStream.RemainingCapacity == 0)
{ // {
Console.WriteLine("Buffer full, not gonnna read from ffmpeg"); // Console.WriteLine("Buffer full, not gonnna read from ffmpeg");
await Task.Delay(20); // await Task.Delay(20);
continue; // continue;
} // }
toRead = remCap; // toRead = remCap;
} //}
int bytesRead = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, toRead, cancelToken).ConfigureAwait(false); int bytesRead = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, toRead, cancelToken).ConfigureAwait(false);
if (bytesRead == 0) if (bytesRead == 0)
@ -88,6 +88,7 @@ namespace NadekoBot.Services.Music
public void Dispose() public void Dispose()
{ {
Console.WriteLine("DISPOSING");
try { this.p.Kill(); } try { this.p.Kill(); }
catch { } catch { }
_outStream.Dispose(); _outStream.Dispose();