diff --git a/CHANGELOG.md b/CHANGELOG.md index e423e183c..037e9429e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Fix some cases of 404s from Plex when files were replaced and scanning the library from ETV didn't help - Fix more wildcard search phrase queries (when wildcards are used in quotes, like `title:"law & order*"`) +- Fix bug where channels would unnecessarily wait on each other + - e.g. in-progress streams would delay responding with a playlist when new streams were starting ## [0.8.6-beta] - 2024-04-03 ### Added diff --git a/ErsatzTV.Application/Streaming/HlsSessionWorker.cs b/ErsatzTV.Application/Streaming/HlsSessionWorker.cs index e4778dc42..dcc188ea6 100644 --- a/ErsatzTV.Application/Streaming/HlsSessionWorker.cs +++ b/ErsatzTV.Application/Streaming/HlsSessionWorker.cs @@ -20,8 +20,8 @@ namespace ErsatzTV.Application.Streaming; public class HlsSessionWorker : IHlsSessionWorker { - private static readonly SemaphoreSlim Slim = new(1, 1); private static int _workAheadCount; + private readonly SemaphoreSlim _slim = new(1, 1); private readonly IClient _client; private readonly IConfigElementRepository _configElementRepository; private readonly IHlsPlaylistFilter _hlsPlaylistFilter; @@ -66,14 +66,14 @@ public class HlsSessionWorker : IHlsSessionWorker { _logger.LogInformation("API termination request for HLS session for channel {Channel}", _channelNumber); - await Slim.WaitAsync(cancellationToken); + await _slim.WaitAsync(cancellationToken); try { await _cancellationTokenSource.CancelAsync(); } finally { - Slim.Release(); + _slim.Release(); } } @@ -97,7 +97,7 @@ public class HlsSessionWorker : IHlsSessionWorker try { var sw = Stopwatch.StartNew(); - await Slim.WaitAsync(cancellationToken); + await _slim.WaitAsync(cancellationToken); try { Option maybeLines = await ReadPlaylistLines(cancellationToken); @@ -117,7 +117,7 @@ public class HlsSessionWorker : IHlsSessionWorker } finally { - Slim.Release(); + _slim.Release(); sw.Stop(); // _logger.LogDebug("TrimPlaylist took {Duration}", sw.Elapsed); } @@ -535,7 +535,7 @@ public class HlsSessionWorker : IHlsSessionWorker private async Task TrimAndDelete(CancellationToken cancellationToken) { - await Slim.WaitAsync(cancellationToken); + await _slim.WaitAsync(cancellationToken); try { Option maybeLines = await ReadPlaylistLines(cancellationToken); @@ -555,7 +555,7 @@ public class HlsSessionWorker : IHlsSessionWorker } finally { - Slim.Release(); + _slim.Release(); } } @@ -606,7 +606,7 @@ public class HlsSessionWorker : IHlsSessionWorker private async Task GetPtsOffset(string channelNumber, CancellationToken cancellationToken) { - await Slim.WaitAsync(cancellationToken); + await _slim.WaitAsync(cancellationToken); try { long result = 0; @@ -635,7 +635,7 @@ public class HlsSessionWorker : IHlsSessionWorker } finally { - Slim.Release(); + _slim.Release(); } } diff --git a/ErsatzTV.Application/Streaming/HlsSessionWorkerV2.cs b/ErsatzTV.Application/Streaming/HlsSessionWorkerV2.cs index 0d3b8c8ce..d75dee762 100644 --- a/ErsatzTV.Application/Streaming/HlsSessionWorkerV2.cs +++ b/ErsatzTV.Application/Streaming/HlsSessionWorkerV2.cs @@ -18,7 +18,7 @@ namespace ErsatzTV.Application.Streaming; public class HlsSessionWorkerV2 : IHlsSessionWorker { - private static readonly SemaphoreSlim Slim = new(1, 1); + private readonly SemaphoreSlim _slim = new(1, 1); //private static int _workAheadCount; private readonly IConfigElementRepository _configElementRepository; @@ -65,14 +65,14 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker { _logger.LogInformation("API termination request for HLS session for channel {Channel}", _channelNumber); - await Slim.WaitAsync(cancellationToken); + await _slim.WaitAsync(cancellationToken); try { await _cancellationTokenSource.CancelAsync(); } finally { - Slim.Release(); + _slim.Release(); } } @@ -369,7 +369,7 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker private async Task GetPtsOffset(string channelNumber, CancellationToken cancellationToken) { - await Slim.WaitAsync(cancellationToken); + await _slim.WaitAsync(cancellationToken); try { long result = 0; @@ -398,7 +398,7 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker } finally { - Slim.Release(); + _slim.Release(); } } diff --git a/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs b/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs index 97cff1786..f0e6bd2b2 100644 --- a/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs +++ b/ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs @@ -466,7 +466,7 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< case CustomDeadAirFallback custom: maybeFallback = new FillerPreset { - AllowWatermarks = true, + AllowWatermarks = false, // TODO: does this need to be configurable? CollectionType = custom.CollectionType, CollectionId = custom.CollectionId, MediaItemId = custom.MediaItemId,