Преглед изворни кода

Merge pull request #3072 from JustAMan/fix-dead-livetv

Re-raise the exception that caused LiveTV stream to not open
dkanada пре 5 година
родитељ
комит
668a7b97c7
1 измењених фајлова са 19 додато и 2 уклоњено
  1. 19 2
      Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs

+ 19 - 2
Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs

@@ -2,6 +2,7 @@
 
 
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Globalization;
 using System.IO;
 using System.IO;
 using System.Net.Http;
 using System.Net.Http;
 using System.Threading;
 using System.Threading;
@@ -118,6 +119,17 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
             //OpenedMediaSource.SupportsDirectStream = true;
             //OpenedMediaSource.SupportsDirectStream = true;
             //OpenedMediaSource.SupportsTranscoding = true;
             //OpenedMediaSource.SupportsTranscoding = true;
             await taskCompletionSource.Task.ConfigureAwait(false);
             await taskCompletionSource.Task.ConfigureAwait(false);
+            if (taskCompletionSource.Task.Exception != null)
+            {
+                // Error happened while opening the stream so raise the exception again to inform the caller
+                throw taskCompletionSource.Task.Exception;
+            }
+
+            if (!taskCompletionSource.Task.Result)
+            {
+                Logger.LogWarning("Zero bytes copied from stream {0} to {1} but no exception raised", GetType().Name, TempFilePath);
+                throw new EndOfStreamException(String.Format(CultureInfo.InvariantCulture, "Zero bytes copied from stream {0}", GetType().Name));
+            }
         }
         }
 
 
         private Task StartStreaming(HttpResponseInfo response, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)
         private Task StartStreaming(HttpResponseInfo response, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)
@@ -139,14 +151,19 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
                             cancellationToken).ConfigureAwait(false);
                             cancellationToken).ConfigureAwait(false);
                     }
                     }
                 }
                 }
-                catch (OperationCanceledException)
+                catch (OperationCanceledException ex)
                 {
                 {
+                    Logger.LogInformation("Copying of {0} to {1} was canceled", GetType().Name, TempFilePath);
+                    openTaskCompletionSource.TrySetException(ex);
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
                 {
                 {
-                    Logger.LogError(ex, "Error copying live stream.");
+                    Logger.LogError(ex, "Error copying live stream {0} to {1}.", GetType().Name, TempFilePath);
+                    openTaskCompletionSource.TrySetException(ex);
                 }
                 }
 
 
+                openTaskCompletionSource.TrySetResult(false);
+
                 EnableStreamSharing = false;
                 EnableStreamSharing = false;
                 await DeleteTempFiles(new List<string> { TempFilePath }).ConfigureAwait(false);
                 await DeleteTempFiles(new List<string> { TempFilePath }).ConfigureAwait(false);
             });
             });