You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Api/Playback/EndlessStreamCopy.cs

33 lines
909 B

using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Api.Playback
{
public class EndlessStreamCopy
{
public async Task CopyStream(Stream source, Stream target, CancellationToken cancellationToken)
{
long position = 0;
while (!cancellationToken.IsCancellationRequested)
{
await source.CopyToAsync(target, 81920, cancellationToken).ConfigureAwait(false);
var fsPosition = source.Position;
var bytesRead = fsPosition - position;
//Logger.Debug("Streamed {0} bytes from file {1}", bytesRead, path);
if (bytesRead == 0)
{
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
}
position = fsPosition;
}
}
}
}