diff --git a/src/NadekoBot/DataStructures/PoopyRingBuffer.cs b/src/NadekoBot/DataStructures/PoopyRingBuffer.cs index 28b391e6..a09af647 100644 --- a/src/NadekoBot/DataStructures/PoopyRingBuffer.cs +++ b/src/NadekoBot/DataStructures/PoopyRingBuffer.cs @@ -38,6 +38,11 @@ namespace NadekoBot.DataStructures } } + public int LightLength => + _readPos <= _writePos? + _writePos - _readPos : + Capacity - (_readPos - _writePos); + public int RemainingCapacity { get { lock (posLock) return Capacity - Length - 1; } diff --git a/src/NadekoBot/Services/Music/SongBuffer.cs b/src/NadekoBot/Services/Music/SongBuffer.cs index 9f26671d..08737c49 100644 --- a/src/NadekoBot/Services/Music/SongBuffer.cs +++ b/src/NadekoBot/Services/Music/SongBuffer.cs @@ -54,7 +54,7 @@ namespace NadekoBot.Services.Music bytesRead = await p.StandardOutput.BaseStream.ReadAsync(buffer, 0, readSize, cancelToken).ConfigureAwait(false); await _outStream.WriteAsync(buffer, 0, bytesRead, cancelToken); - if (_outStream.RemainingCapacity < _outStream.Capacity * 0.5f || bytesRead == 0) + if (_outStream.LightLength > 200_000 || bytesRead == 0) if (toReturn.TrySetResult(true)) _log.Info("Prebuffering finished"); }