diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2020-11-06 15:27:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-06 15:27:51 +0100 |
| commit | 83d7e0a2657f4fb955366d71ab93d17f5a769cd4 (patch) | |
| tree | af2fc3617635f6674050dfca47cb31eb4332dbdc /Jellyfin.Api/Helpers/ProgressiveFileStream.cs | |
| parent | f172b37401585bbcc72708bd1b34f4875ced1a76 (diff) | |
| parent | 41b38c6735e4dc2ccb9b5c277950bf6c079d983b (diff) | |
Merge pull request #4392 from crobibero/livetv-ts-fix
Fix LiveTV TS playback
Diffstat (limited to 'Jellyfin.Api/Helpers/ProgressiveFileStream.cs')
| -rw-r--r-- | Jellyfin.Api/Helpers/ProgressiveFileStream.cs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs index b3566b6f8..824870c7e 100644 --- a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs +++ b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs @@ -82,20 +82,23 @@ namespace Jellyfin.Api.Helpers int totalBytesRead = 0; int remainingBytesToRead = count; + int newOffset = offset; while (remainingBytesToRead > 0) { cancellationToken.ThrowIfCancellationRequested(); int bytesRead; if (_allowAsyncFileRead) { - bytesRead = await _fileStream.ReadAsync(buffer, offset, remainingBytesToRead, cancellationToken).ConfigureAwait(false); + bytesRead = await _fileStream.ReadAsync(buffer, newOffset, remainingBytesToRead, cancellationToken).ConfigureAwait(false); } else { - bytesRead = _fileStream.Read(buffer, offset, remainingBytesToRead); + bytesRead = _fileStream.Read(buffer, newOffset, remainingBytesToRead); } remainingBytesToRead -= bytesRead; + newOffset += bytesRead; + if (bytesRead > 0) { _bytesWritten += bytesRead; @@ -108,12 +111,13 @@ namespace Jellyfin.Api.Helpers } else { - if (_job == null || _job.HasExited) + // If the job is null it's a live stream and will require user action to close + if (_job?.HasExited ?? false) { break; } - await Task.Delay(100, cancellationToken).ConfigureAwait(false); + await Task.Delay(50, cancellationToken).ConfigureAwait(false); } } |
