diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index b8b0cb73c1..63356a8451 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -941,21 +941,20 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV await _liveStreamsSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); - var result = _liveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase)); - - if (result != null && result.EnableStreamSharing) + try { - var openedMediaSource = CloneMediaSource(result.OpenedMediaSource, result.EnableStreamSharing); - result.SharedStreamIds.Add(openedMediaSource.Id); - _liveStreamsSemaphore.Release(); + var result = _liveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase)); - _logger.Info("Live stream {0} consumer count is now {1}", streamId, result.ConsumerCount); + if (result != null && result.EnableStreamSharing) + { + var openedMediaSource = CloneMediaSource(result.OpenedMediaSource, result.EnableStreamSharing); + result.SharedStreamIds.Add(openedMediaSource.Id); - return new Tuple(result, openedMediaSource, result.TunerHost); - } + _logger.Info("Live stream {0} consumer count is now {1}", streamId, result.ConsumerCount); + + return new Tuple(result, openedMediaSource, result.TunerHost); + } - try - { foreach (var hostInstance in _liveTvManager.TunerHosts) { try @@ -1271,6 +1270,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV try { + var recorder = await GetRecorder().ConfigureAwait(false); + var allMediaSources = await GetChannelStreamMediaSources(timer.ChannelId, CancellationToken.None).ConfigureAwait(false); var liveStreamInfo = await GetChannelStreamInternal(timer.ChannelId, allMediaSources[0].Id, CancellationToken.None) @@ -1282,8 +1283,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV // HDHR doesn't seem to release the tuner right away after first probing with ffmpeg //await Task.Delay(3000, cancellationToken).ConfigureAwait(false); - var recorder = await GetRecorder().ConfigureAwait(false); - recordPath = recorder.GetOutputPath(mediaStreamInfo, recordPath); recordPath = EnsureFileUnique(recordPath, timer.Id);