fix hdhr stream returning too quickly

This commit is contained in:
Luke Pulverenti 2017-11-06 16:32:44 -05:00
parent 5cb7469028
commit 83a43121af
8 changed files with 7 additions and 28 deletions

View File

@ -373,8 +373,6 @@ namespace Emby.Server.Implementations.Dto
} }
NormalizeMediaSourceContainers(dto); NormalizeMediaSourceContainers(dto);
dto.SupportsMediaSourceSelection = hasMediaSources.SupportsMediaSourceSelection();
} }
} }

View File

@ -57,7 +57,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
Logger.Info("Opened HDHR stream from {0}", url); Logger.Info("Opened HDHR stream from {0}", url);
StartStreaming(response, LiveStreamCancellationTokenSource.Token); var taskCompletionSource = new TaskCompletionSource<bool>();
StartStreaming(response, taskCompletionSource, LiveStreamCancellationTokenSource.Token);
//OpenedMediaSource.Protocol = MediaProtocol.File; //OpenedMediaSource.Protocol = MediaProtocol.File;
//OpenedMediaSource.Path = tempFile; //OpenedMediaSource.Path = tempFile;
@ -71,6 +72,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
//OpenedMediaSource.SupportsDirectPlay = false; //OpenedMediaSource.SupportsDirectPlay = false;
//OpenedMediaSource.SupportsDirectStream = true; //OpenedMediaSource.SupportsDirectStream = true;
//OpenedMediaSource.SupportsTranscoding = true; //OpenedMediaSource.SupportsTranscoding = true;
await taskCompletionSource.Task.ConfigureAwait(false);
} }
protected override void CloseInternal() protected override void CloseInternal()
@ -78,7 +80,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
LiveStreamCancellationTokenSource.Cancel(); LiveStreamCancellationTokenSource.Cancel();
} }
private Task StartStreaming(HttpResponseInfo response, CancellationToken cancellationToken) private Task StartStreaming(HttpResponseInfo response, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)
{ {
return Task.Run(async () => return Task.Run(async () =>
{ {
@ -90,10 +92,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{ {
Logger.Info("Beginning HdHomerunHttpStream stream to file"); Logger.Info("Beginning HdHomerunHttpStream stream to file");
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath));
using (var fileStream = FileSystem.GetFileStream(TempFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None)) using (var fileStream = FileSystem.GetFileStream(TempFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None))
{ {
StreamHelper.CopyTo(stream, fileStream, 81920, null, cancellationToken); StreamHelper.CopyTo(stream, fileStream, 81920, () => Resolve(openTaskCompletionSource), cancellationToken);
} }
} }
} }
@ -112,10 +113,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private void Resolve(TaskCompletionSource<bool> openTaskCompletionSource) private void Resolve(TaskCompletionSource<bool> openTaskCompletionSource)
{ {
Task.Run(() => openTaskCompletionSource.TrySetResult(true);
{
openTaskCompletionSource.TrySetResult(true);
});
} }
} }
} }

View File

@ -51,11 +51,6 @@ namespace MediaBrowser.Controller.Entities.Audio
return 1; return 1;
} }
public bool SupportsMediaSourceSelection()
{
return false;
}
[IgnoreDataMember] [IgnoreDataMember]
public override bool SupportsPlayedStatus public override bool SupportsPlayedStatus
{ {

View File

@ -13,6 +13,5 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns> /// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns>
List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution); List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution);
List<MediaStream> GetMediaStreams(); List<MediaStream> GetMediaStreams();
bool SupportsMediaSourceSelection();
} }
} }

View File

@ -109,11 +109,6 @@ namespace MediaBrowser.Controller.Entities
get { return true; } get { return true; }
} }
public bool SupportsMediaSourceSelection()
{
return SourceType == SourceType.Library;
}
/// <summary> /// <summary>
/// Gets or sets the timestamp. /// Gets or sets the timestamp.
/// </summary> /// </summary>

View File

@ -24,11 +24,6 @@ namespace MediaBrowser.Controller.LiveTv
return list; return list;
} }
public bool SupportsMediaSourceSelection()
{
return false;
}
public override UnratedItem GetBlockUnratedType() public override UnratedItem GetBlockUnratedType()
{ {
return UnratedItem.LiveTvChannel; return UnratedItem.LiveTvChannel;

View File

@ -75,7 +75,6 @@ namespace MediaBrowser.Model.Dto
public bool? CanDownload { get; set; } public bool? CanDownload { get; set; }
public bool? HasSubtitles { get; set; } public bool? HasSubtitles { get; set; }
public bool? SupportsMediaSourceSelection { get; set; }
public string PreferredMetadataLanguage { get; set; } public string PreferredMetadataLanguage { get; set; }
public string PreferredMetadataCountryCode { get; set; } public string PreferredMetadataCountryCode { get; set; }

View File

@ -1,3 +1,3 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("3.2.36.2")] [assembly: AssemblyVersion("3.2.36.3")]