aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
diff options
context:
space:
mode:
authorcvium <clausvium@gmail.com>2021-09-25 20:52:09 +0200
committercvium <clausvium@gmail.com>2021-09-25 20:52:09 +0200
commit30f3be1da0958dc9c129d09de13625b13f33a3a6 (patch)
tree0b61f595e1fe1699c85d87358ccbb75cbde961c0 /Jellyfin.Api/Helpers/ProgressiveFileStream.cs
parent3e5cb8e04e11d05b4af54e88686e829429305870 (diff)
parent17273a6075e2735642075c6060eb86fc910474a9 (diff)
Merge branch 'master' into keyframe_extraction_v1
Diffstat (limited to 'Jellyfin.Api/Helpers/ProgressiveFileStream.cs')
-rw-r--r--Jellyfin.Api/Helpers/ProgressiveFileStream.cs24
1 files changed, 2 insertions, 22 deletions
diff --git a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
index c57018351..61e18220a 100644
--- a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
+++ b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
@@ -17,7 +17,6 @@ namespace Jellyfin.Api.Helpers
private readonly TranscodingJobDto? _job;
private readonly TranscodingJobHelper? _transcodingJobHelper;
private readonly int _timeoutMs;
- private readonly bool _allowAsyncFileRead;
private int _bytesWritten;
private bool _disposed;
@@ -34,17 +33,7 @@ namespace Jellyfin.Api.Helpers
_transcodingJobHelper = transcodingJobHelper;
_timeoutMs = timeoutMs;
- var fileOptions = FileOptions.SequentialScan;
- _allowAsyncFileRead = false;
-
- // use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039
- if (AsyncFile.UseAsyncIO)
- {
- fileOptions |= FileOptions.Asynchronous;
- _allowAsyncFileRead = true;
- }
-
- _stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, fileOptions);
+ _stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous | FileOptions.SequentialScan);
}
/// <summary>
@@ -57,7 +46,6 @@ namespace Jellyfin.Api.Helpers
_job = null;
_transcodingJobHelper = null;
_timeoutMs = timeoutMs;
- _allowAsyncFileRead = AsyncFile.UseAsyncIO;
_stream = stream;
}
@@ -103,15 +91,7 @@ namespace Jellyfin.Api.Helpers
while (remainingBytesToRead > 0)
{
cancellationToken.ThrowIfCancellationRequested();
- int bytesRead;
- if (_allowAsyncFileRead)
- {
- bytesRead = await _stream.ReadAsync(buffer, newOffset, remainingBytesToRead, cancellationToken).ConfigureAwait(false);
- }
- else
- {
- bytesRead = _stream.Read(buffer, newOffset, remainingBytesToRead);
- }
+ int bytesRead = await _stream.ReadAsync(buffer, newOffset, remainingBytesToRead, cancellationToken).ConfigureAwait(false);
remainingBytesToRead -= bytesRead;
newOffset += bytesRead;