From 7de15bf444a73b0fda2f2eed86b2ac6eecbfc30e Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sun, 2 Jul 2017 10:58:04 +0200 Subject: [PATCH] magic numbers --- src/NadekoBot/Services/Music/MusicPlayer.cs | 4 ++-- src/NadekoBot/Services/Music/SongBuffer.cs | 23 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/NadekoBot/Services/Music/MusicPlayer.cs b/src/NadekoBot/Services/Music/MusicPlayer.cs index 535cfe34..1ac0cbad 100644 --- a/src/NadekoBot/Services/Music/MusicPlayer.cs +++ b/src/NadekoBot/Services/Music/MusicPlayer.cs @@ -101,10 +101,10 @@ namespace NadekoBot.Services.Music // i don't want to spam connection attempts continue; } - var pcm = ac.CreatePCMStream(AudioApplication.Music, bufferMillis: 250); + var pcm = ac.CreatePCMStream(AudioApplication.Music, bufferMillis: 1000); OnStarted?.Invoke(this, data.Song); - byte[] buffer = new byte[3840]; + byte[] buffer = new byte[38400]; int bytesRead = 0; try { diff --git a/src/NadekoBot/Services/Music/SongBuffer.cs b/src/NadekoBot/Services/Music/SongBuffer.cs index 7c2a68ff..64fe4750 100644 --- a/src/NadekoBot/Services/Music/SongBuffer.cs +++ b/src/NadekoBot/Services/Music/SongBuffer.cs @@ -43,17 +43,17 @@ namespace NadekoBot.Services.Music while (!cancelToken.IsCancellationRequested) { var toRead = buffer.Length; - var remCap = _outStream.RemainingCapacity; - if (remCap < readSize) - { - if (_outStream.RemainingCapacity == 0) - { - Console.WriteLine("Buffer full, not gonnna read from ffmpeg"); - await Task.Delay(20); - continue; - } - toRead = remCap; - } + //var remCap = _outStream.RemainingCapacity; + //if (remCap < readSize) + //{ + // if (_outStream.RemainingCapacity == 0) + // { + // Console.WriteLine("Buffer full, not gonnna read from ffmpeg"); + // await Task.Delay(20); + // continue; + // } + // toRead = remCap; + //} int bytesRead = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, toRead, cancelToken).ConfigureAwait(false); if (bytesRead == 0) @@ -88,6 +88,7 @@ namespace NadekoBot.Services.Music public void Dispose() { + Console.WriteLine("DISPOSING"); try { this.p.Kill(); } catch { } _outStream.Dispose();