diff options
Diffstat (limited to 'MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs')
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 45d560da7..a2e327f7d 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -393,21 +393,26 @@ namespace MediaBrowser.Api.Playback.Hls var segmentFilename = Path.GetFileName(segmentPath); - using (var fileStream = GetPlaylistFileStream(playlistPath)) + while (!cancellationToken.IsCancellationRequested) { - using (var reader = new StreamReader(fileStream)) + using (var fileStream = GetPlaylistFileStream(playlistPath)) { - while (!reader.EndOfStream) + using (var reader = new StreamReader(fileStream)) { - var text = await reader.ReadLineAsync().ConfigureAwait(false); - - // If it appears in the playlist, it's done - if (text.IndexOf(segmentFilename, StringComparison.OrdinalIgnoreCase) != -1) + while (!reader.EndOfStream) { - return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob); + var text = await reader.ReadLineAsync().ConfigureAwait(false); + + // If it appears in the playlist, it's done + if (text.IndexOf(segmentFilename, StringComparison.OrdinalIgnoreCase) != -1) + { + return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob); + } } } } + + await Task.Delay(100, cancellationToken).ConfigureAwait(false); } // if a different file is encoding, it's done @@ -417,34 +422,35 @@ namespace MediaBrowser.Api.Playback.Hls //return GetSegmentResult(segmentPath, segmentIndex); //} - // Wait for the file to stop being written to, then stream it - var length = new FileInfo(segmentPath).Length; - var eofCount = 0; - - while (eofCount < 10) - { - var info = new FileInfo(segmentPath); + //// Wait for the file to stop being written to, then stream it + //var length = new FileInfo(segmentPath).Length; + //var eofCount = 0; - if (!info.Exists) - { - break; - } - - var newLength = info.Length; - - if (newLength == length) - { - eofCount++; - } - else - { - eofCount = 0; - } - - length = newLength; - await Task.Delay(100, cancellationToken).ConfigureAwait(false); - } + //while (eofCount < 10) + //{ + // var info = new FileInfo(segmentPath); + + // if (!info.Exists) + // { + // break; + // } + + // var newLength = info.Length; + + // if (newLength == length) + // { + // eofCount++; + // } + // else + // { + // eofCount = 0; + // } + + // length = newLength; + // await Task.Delay(100, cancellationToken).ConfigureAwait(false); + //} + cancellationToken.ThrowIfCancellationRequested(); return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob); } |
