diff options
| author | cvium <clausvium@gmail.com> | 2021-09-07 08:54:58 +0200 |
|---|---|---|
| committer | cvium <clausvium@gmail.com> | 2021-09-07 08:54:58 +0200 |
| commit | fdab8eebc906f18b75dd85a0f3416d74a98a24fe (patch) | |
| tree | 94921909a6ac2222904211681e4187ca27918a8c /Jellyfin.Api/Controllers/VideoHlsController.cs | |
| parent | ec35b8b4255b32ff792d4f957fd160533bb0df3d (diff) | |
Fix disposed exception when ffmpeg exits early in GetLiveHlsStream
Diffstat (limited to 'Jellyfin.Api/Controllers/VideoHlsController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/VideoHlsController.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Jellyfin.Api/Controllers/VideoHlsController.cs b/Jellyfin.Api/Controllers/VideoHlsController.cs index 8560df2ea..8810a12fb 100644 --- a/Jellyfin.Api/Controllers/VideoHlsController.cs +++ b/Jellyfin.Api/Controllers/VideoHlsController.cs @@ -267,6 +267,9 @@ namespace Jellyfin.Api.Controllers // CTS lifecycle is managed internally. var cancellationTokenSource = new CancellationTokenSource(); + // Due to CTS.Token calling ThrowIfDisposed (https://github.com/dotnet/runtime/issues/29970) we have to "cache" the token + // since it gets disposed when ffmpeg exits + var cancellationToken = cancellationTokenSource.Token; using var state = await StreamingHelpers.GetStreamingState( streamingRequest, Request, @@ -281,7 +284,7 @@ namespace Jellyfin.Api.Controllers _deviceManager, _transcodingJobHelper, TranscodingJobType, - cancellationTokenSource.Token) + cancellationToken) .ConfigureAwait(false); TranscodingJobDto? job = null; @@ -290,7 +293,7 @@ namespace Jellyfin.Api.Controllers if (!System.IO.File.Exists(playlistPath)) { var transcodingLock = _transcodingJobHelper.GetTranscodingLock(playlistPath); - await transcodingLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false); + await transcodingLock.WaitAsync(cancellationToken).ConfigureAwait(false); try { if (!System.IO.File.Exists(playlistPath)) @@ -317,7 +320,7 @@ namespace Jellyfin.Api.Controllers minSegments = state.MinSegments; if (minSegments > 0) { - await HlsHelpers.WaitForMinimumSegmentCount(playlistPath, minSegments, _logger, cancellationTokenSource.Token).ConfigureAwait(false); + await HlsHelpers.WaitForMinimumSegmentCount(playlistPath, minSegments, _logger, cancellationToken).ConfigureAwait(false); } } } |
