aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
diff options
context:
space:
mode:
authorcvium <clausvium@gmail.com>2020-09-26 19:03:23 +0200
committercvium <clausvium@gmail.com>2020-09-26 19:03:23 +0200
commit146cad61505147ee1e118135a396eb6ed3e0fc78 (patch)
treea593438d874da2b88927b20a42fb4a2632e12ac4 /Jellyfin.Api/Helpers/ProgressiveFileStream.cs
parent6ca313abc186d45aef8b6d949432a4c9ef9cc1d2 (diff)
Remove EOF counter
Diffstat (limited to 'Jellyfin.Api/Helpers/ProgressiveFileStream.cs')
-rw-r--r--Jellyfin.Api/Helpers/ProgressiveFileStream.cs34
1 files changed, 16 insertions, 18 deletions
diff --git a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
index e09f3dca9..b3566b6f8 100644
--- a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
+++ b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
@@ -79,13 +79,10 @@ namespace Jellyfin.Api.Helpers
/// <inheritdoc />
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
- var eofCount = 0;
- const int EmptyReadLimit = 20;
-
int totalBytesRead = 0;
int remainingBytesToRead = count;
- while (eofCount < EmptyReadLimit && remainingBytesToRead > 0)
+ while (remainingBytesToRead > 0)
{
cancellationToken.ThrowIfCancellationRequested();
int bytesRead;
@@ -109,20 +106,15 @@ namespace Jellyfin.Api.Helpers
_job.BytesDownloaded = Math.Max(_job.BytesDownloaded ?? _bytesWritten, _bytesWritten);
}
}
-
- if (bytesRead == 0)
+ else
{
if (_job == null || _job.HasExited)
{
- eofCount++;
+ break;
}
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
}
- else
- {
- eofCount = 0;
- }
}
return totalBytesRead;
@@ -148,17 +140,23 @@ namespace Jellyfin.Api.Helpers
return;
}
- if (disposing)
+ try
{
- _fileStream.Dispose();
-
- if (_job != null)
+ if (disposing)
{
- _transcodingJobHelper.OnTranscodeEndRequest(_job);
+ _fileStream.Dispose();
+
+ if (_job != null)
+ {
+ _transcodingJobHelper.OnTranscodeEndRequest(_job);
+ }
}
}
-
- _disposed = true;
+ finally
+ {
+ _disposed = true;
+ base.Dispose(disposing);
+ }
}
}
}