update closing of live streams

This commit is contained in:
Luke Pulverenti 2016-09-27 13:51:01 -04:00
parent 64d63c1b4b
commit 68268cfb73
4 changed files with 22 additions and 3 deletions

View File

@ -73,6 +73,7 @@ namespace MediaBrowser.Model.Configuration
/// </summary> /// </summary>
/// <value>The metadata path.</value> /// <value>The metadata path.</value>
public string MetadataPath { get; set; } public string MetadataPath { get; set; }
public string MetadataNetworkPath { get; set; }
public string LastVersion { get; set; } public string LastVersion { get; set; }

View File

@ -2550,9 +2550,25 @@ namespace MediaBrowser.Server.Implementations.Library
} }
} }
var metadataPath = ConfigurationManager.Configuration.MetadataPath;
var metadataNetworkPath = ConfigurationManager.Configuration.MetadataNetworkPath;
if (!string.IsNullOrWhiteSpace(metadataPath) && !string.IsNullOrWhiteSpace(metadataNetworkPath))
{
var metadataSubstitutionResult = SubstitutePathInternal(path, metadataPath, metadataNetworkPath);
if (metadataSubstitutionResult.Item2)
{
return metadataSubstitutionResult.Item1;
}
}
foreach (var map in ConfigurationManager.Configuration.PathSubstitutions) foreach (var map in ConfigurationManager.Configuration.PathSubstitutions)
{ {
path = SubstitutePath(path, map.From, map.To); var substitutionResult = SubstitutePathInternal(path, map.From, map.To);
if (substitutionResult.Item2)
{
return substitutionResult.Item1;
}
} }
return path; return path;

View File

@ -908,6 +908,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
try try
{ {
await stream.Close().ConfigureAwait(false); await stream.Close().ConfigureAwait(false);
_logger.Info("Live stream {0} closed successfully", id);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -22,6 +22,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private readonly IServerApplicationHost _appHost; private readonly IServerApplicationHost _appHost;
private readonly CancellationTokenSource _liveStreamCancellationTokenSource = new CancellationTokenSource(); private readonly CancellationTokenSource _liveStreamCancellationTokenSource = new CancellationTokenSource();
private readonly TaskCompletionSource<bool> _liveStreamTaskCompletionSource = new TaskCompletionSource<bool>();
public HdHomerunLiveStream(MediaSourceInfo mediaSource, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost) public HdHomerunLiveStream(MediaSourceInfo mediaSource, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost)
: base(mediaSource) : base(mediaSource)
@ -62,7 +63,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{ {
_liveStreamCancellationTokenSource.Cancel(); _liveStreamCancellationTokenSource.Cancel();
return base.Close(); return _liveStreamTaskCompletionSource.Task;
} }
private async Task StartStreamingToTempFile(Stream outputStream, string tempFilePath, string url, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken) private async Task StartStreamingToTempFile(Stream outputStream, string tempFilePath, string url, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)
@ -120,7 +121,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
} }
} }
await Task.Delay(5000).ConfigureAwait(false); _liveStreamTaskCompletionSource.TrySetResult(true);
DeleteTempFile(tempFilePath); DeleteTempFile(tempFilePath);