Prebuffering time drastically decreased

This commit is contained in:
Master Kwoth 2017-07-03 12:46:51 +02:00
parent a609e17717
commit 99049a6ace
2 changed files with 6 additions and 1 deletions

View File

@ -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; }

View File

@ -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");
}