aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-06-01 01:43:08 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-06-01 01:43:08 -0400
commit0f1d253278c159cebfd1838046bf11dc3bba6fd7 (patch)
treee9f60e189fa31688c245e4337a582848e760e4df
parent7e609b8fc50888fc5d8c3fa377014118526ebc06 (diff)
update DirectRecorder
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs23
1 files changed, 6 insertions, 17 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
index dcfaaa9d7..2a2e1886f 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;