mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 03:48:06 +02:00
update tuner pooling
This commit is contained in:
parent
0f743205c4
commit
21a2160fca
3 changed files with 19 additions and 52 deletions
|
@ -109,14 +109,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
foreach (var host in hostsWithChannel)
|
foreach (var host in hostsWithChannel)
|
||||||
{
|
{
|
||||||
// Check to make sure the tuner is available
|
try
|
||||||
// If there's only one tuner, don't bother with the check and just let the tuner be the one to throw an error
|
|
||||||
if (hostsWithChannel.Count > 1 && !await IsAvailable(host, channelId, cancellationToken).ConfigureAwait(false))
|
|
||||||
{
|
{
|
||||||
Logger.Error("Tuner is not currently available");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var mediaSources = await GetChannelStreamMediaSources(host, channelId, cancellationToken).ConfigureAwait(false);
|
var mediaSources = await GetChannelStreamMediaSources(host, channelId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
// Prefix the id with the host Id so that we can easily find it
|
// Prefix the id with the host Id so that we can easily find it
|
||||||
|
@ -127,6 +121,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
return mediaSources;
|
return mediaSources;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error("Error opening tuner", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new List<MediaSourceInfo>();
|
return new List<MediaSourceInfo>();
|
||||||
|
@ -163,18 +162,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
foreach (var host in hostsWithChannel)
|
foreach (var host in hostsWithChannel)
|
||||||
{
|
{
|
||||||
// Check to make sure the tuner is available
|
try
|
||||||
// If there's only one tuner, don't bother with the check and just let the tuner be the one to throw an error
|
|
||||||
// If a streamId is specified then availibility has already been checked in GetChannelStreamMediaSources
|
|
||||||
if (string.IsNullOrWhiteSpace(streamId) && hostsWithChannel.Count > 1)
|
|
||||||
{
|
{
|
||||||
if (!await IsAvailable(host, channelId, cancellationToken).ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
Logger.Error("Tuner is not currently available");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var stream = await GetChannelStream(host, channelId, streamId, cancellationToken).ConfigureAwait(false);
|
var stream = await GetChannelStream(host, channelId, streamId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
|
@ -182,26 +171,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error("Error opening tuner", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new LiveTvConflictException();
|
throw new LiveTvConflictException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task<bool> IsAvailable(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return await IsAvailableInternal(tuner, channelId, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.ErrorException("Error checking tuner availability", ex);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken);
|
|
||||||
|
|
||||||
protected abstract bool IsValidChannelId(string channelId);
|
protected abstract bool IsValidChannelId(string channelId);
|
||||||
|
|
||||||
protected LiveTvOptions GetConfiguration()
|
protected LiveTvOptions GetConfiguration()
|
||||||
|
|
|
@ -398,12 +398,5 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
await GetChannels(info, false, CancellationToken.None).ConfigureAwait(false);
|
await GetChannels(info, false, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var info = await GetTunerInfos(tuner, cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
return info.Any(i => i.Status == LiveTvTunerStatus.Available || string.Equals(i.ChannelId, channelId, StringComparison.OrdinalIgnoreCase));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,10 +190,5 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
||||||
}
|
}
|
||||||
return new List<MediaSourceInfo> { };
|
return new List<MediaSourceInfo> { };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
return Task.FromResult(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue