From 83a43121af862051c0d414b1ca7ef6c389088e0b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 6 Nov 2017 16:32:44 -0500 Subject: [PATCH] fix hdhr stream returning too quickly --- Emby.Server.Implementations/Dto/DtoService.cs | 2 -- .../TunerHosts/HdHomerun/HdHomerunHttpStream.cs | 14 ++++++-------- MediaBrowser.Controller/Entities/Audio/Audio.cs | 5 ----- .../Entities/IHasMediaSources.cs | 1 - MediaBrowser.Controller/Entities/Video.cs | 5 ----- MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 5 ----- MediaBrowser.Model/Dto/BaseItemDto.cs | 1 - SharedVersion.cs | 2 +- 8 files changed, 7 insertions(+), 28 deletions(-) diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 2fa09c2b1..0a316fcf1 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -373,8 +373,6 @@ namespace Emby.Server.Implementations.Dto } NormalizeMediaSourceContainers(dto); - - dto.SupportsMediaSourceSelection = hasMediaSources.SupportsMediaSourceSelection(); } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs index 1ea77d505..ddbbda737 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs @@ -57,7 +57,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun Logger.Info("Opened HDHR stream from {0}", url); - StartStreaming(response, LiveStreamCancellationTokenSource.Token); + var taskCompletionSource = new TaskCompletionSource(); + StartStreaming(response, taskCompletionSource, LiveStreamCancellationTokenSource.Token); //OpenedMediaSource.Protocol = MediaProtocol.File; //OpenedMediaSource.Path = tempFile; @@ -71,6 +72,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun //OpenedMediaSource.SupportsDirectPlay = false; //OpenedMediaSource.SupportsDirectStream = true; //OpenedMediaSource.SupportsTranscoding = true; + await taskCompletionSource.Task.ConfigureAwait(false); } protected override void CloseInternal() @@ -78,7 +80,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun LiveStreamCancellationTokenSource.Cancel(); } - private Task StartStreaming(HttpResponseInfo response, CancellationToken cancellationToken) + private Task StartStreaming(HttpResponseInfo response, TaskCompletionSource openTaskCompletionSource, CancellationToken cancellationToken) { return Task.Run(async () => { @@ -90,10 +92,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun { 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)) { - 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 openTaskCompletionSource) { - Task.Run(() => - { - openTaskCompletionSource.TrySetResult(true); - }); + openTaskCompletionSource.TrySetResult(true); } } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 8ef1060d1..16fd75d2e 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -51,11 +51,6 @@ namespace MediaBrowser.Controller.Entities.Audio return 1; } - public bool SupportsMediaSourceSelection() - { - return false; - } - [IgnoreDataMember] public override bool SupportsPlayedStatus { diff --git a/MediaBrowser.Controller/Entities/IHasMediaSources.cs b/MediaBrowser.Controller/Entities/IHasMediaSources.cs index 399fe9f5a..54786134f 100644 --- a/MediaBrowser.Controller/Entities/IHasMediaSources.cs +++ b/MediaBrowser.Controller/Entities/IHasMediaSources.cs @@ -13,6 +13,5 @@ namespace MediaBrowser.Controller.Entities /// Task{IEnumerable{MediaSourceInfo}}. List GetMediaSources(bool enablePathSubstitution); List GetMediaStreams(); - bool SupportsMediaSourceSelection(); } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 60db53f79..52f1dd051 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -109,11 +109,6 @@ namespace MediaBrowser.Controller.Entities get { return true; } } - public bool SupportsMediaSourceSelection() - { - return SourceType == SourceType.Library; - } - /// /// Gets or sets the timestamp. /// diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index ac961d757..16010b7f5 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -24,11 +24,6 @@ namespace MediaBrowser.Controller.LiveTv return list; } - public bool SupportsMediaSourceSelection() - { - return false; - } - public override UnratedItem GetBlockUnratedType() { return UnratedItem.LiveTvChannel; diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 7cacb96ee..ba975db44 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -75,7 +75,6 @@ namespace MediaBrowser.Model.Dto public bool? CanDownload { get; set; } public bool? HasSubtitles { get; set; } - public bool? SupportsMediaSourceSelection { get; set; } public string PreferredMetadataLanguage { get; set; } public string PreferredMetadataCountryCode { get; set; } diff --git a/SharedVersion.cs b/SharedVersion.cs index 0750f469e..82dd0b72e 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.36.2")] +[assembly: AssemblyVersion("3.2.36.3")]