The Free Software Media System - Server Backend & API
update DirectRecorder
Luke Pulverenti0f1d253278c1
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.csindex dcfaaa9d70..2a2e1886f6 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs@@ -94,17 +94,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}private const int BufferSize = 81920;- public static Task CopyUntilCancelled(Stream source, Stream target, CancellationToken cancellationToken)- {- return CopyUntilCancelled(source, target, null, cancellationToken);- }- public static async Task CopyUntilCancelled(Stream source, Stream target, Action onStarted, CancellationToken cancellationToken)+ public static async Task CopyUntilCancelled(Stream source, Stream target, CancellationToken cancellationToken){+ byte[] buffer = new byte[BufferSize];+while (!cancellationToken.IsCancellationRequested){- var bytesRead = await CopyToAsyncInternal(source, target, BufferSize, onStarted, cancellationToken).ConfigureAwait(false);-- onStarted = null;+ var bytesRead = await CopyToAsyncInternal(source, target, buffer, cancellationToken).ConfigureAwait(false);//var position = fs.Position;//_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);@@ -116,23 +112,16 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV}}- private static async Task<int> CopyToAsyncInternal(Stream source, Stream destination, Int32 bufferSize, Action onStarted, CancellationToken cancellationToken)+ private static async Task<int> CopyToAsyncInternal(Stream source, Stream destination, byte[] buffer, CancellationToken cancellationToken){- byte[] buffer = new byte[bufferSize];int bytesRead;int totalBytesRead = 0;while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0){- await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);+ destination.Write(buffer, 0, bytesRead);totalBytesRead += bytesRead;-- if (onStarted != null)- {- onStarted();- }- onStarted = null;}return totalBytesRead;