The Free Software Media System - Server Backend & API
add probe property
Luke Pulverentif3c3c74d84d8
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.csindex 02a8d69387..9bb5b4fd7d 100644--- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs@@ -224,7 +224,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHostsvar stream = await GetChannelStream(host, channelId, streamId, cancellationToken).ConfigureAwait(false);- //await AddMediaInfo(stream, false, resourcePool, cancellationToken).ConfigureAwait(false);+ if (EnableMediaProbing)+ {+ await AddMediaInfo(stream, false, resourcePool, cancellationToken).ConfigureAwait(false);+ }+return new Tuple<MediaSourceInfo, SemaphoreSlim>(stream, resourcePool);}catch (Exception ex)@@ -239,6 +243,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHoststhrow new LiveTvConflictException();}+ protected virtual bool EnableMediaProbing+ {+ get { return false; }+ }+protected async Task<bool> IsAvailable(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken){try@@ -268,6 +277,25 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHostsreturn _semaphoreLocks.GetOrAdd(url, key => new SemaphoreSlim(1, 1));}+ private async Task AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio, SemaphoreSlim resourcePool, CancellationToken cancellationToken)+ {+ await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);++ try+ {+ await AddMediaInfoInternal(mediaSource, isAudio, cancellationToken).ConfigureAwait(false);++ // Leave the resource locked. it will be released upstream+ }+ catch (Exception)+ {+ // Release the resource if there's some kind of failure.+ resourcePool.Release();++ throw;+ }+ }+private async Task AddMediaInfoInternal(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken){var originalRuntime = mediaSource.RunTimeTicks;