Try ignoring errors

This commit is contained in:
Master Kwoth 2017-07-04 12:38:01 +02:00
parent b1a4aa6a21
commit a6d432de7f

View File

@ -40,7 +40,7 @@ namespace NadekoBot.Services.Music
return Process.Start(new ProcessStartInfo return Process.Start(new ProcessStartInfo
{ {
FileName = "ffmpeg", FileName = "ffmpeg",
Arguments = $"-ss {skipTo:F4} -i {songUri} -f s16le -ar 48000 -vn -ac 2 pipe:1 -loglevel error -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", Arguments = $"-ss {skipTo:F4} -err_detect ignore_err -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5 -i {songUri} -f s16le -ar 48000 -vn -ac 2 pipe:1 -loglevel error",
UseShellExecute = false, UseShellExecute = false,
RedirectStandardOutput = true, RedirectStandardOutput = true,
RedirectStandardError = true, RedirectStandardError = true,
@ -64,24 +64,24 @@ namespace NadekoBot.Services.Music
var toReturn = new TaskCompletionSource<bool>(); var toReturn = new TaskCompletionSource<bool>();
var _ = Task.Run(async () => var _ = Task.Run(async () =>
{ {
int maxLoopsPerSec = 25; //int maxLoopsPerSec = 25;
var sw = Stopwatch.StartNew(); var sw = Stopwatch.StartNew();
var delay = 1000 / maxLoopsPerSec; //var delay = 1000 / maxLoopsPerSec;
int currentLoops = 0; int currentLoops = 0;
int _bytesSent = 0; int _bytesSent = 0;
try try
{ {
do //do
{ //{
if (restart) // if (restart)
{ // {
var cur = _bytesSent / 3840 / (1000 / 20.0f); // var cur = _bytesSent / 3840 / (1000 / 20.0f);
_log.Info("Restarting"); // _log.Info("Restarting");
try { this.p.StandardOutput.Dispose(); } catch { } // try { this.p.StandardOutput.Dispose(); } catch { }
try { this.p.Dispose(); } catch { } // try { this.p.Dispose(); } catch { }
this.p = StartFFmpegProcess(SongUri, cur); // this.p = StartFFmpegProcess(SongUri, cur);
} // }
restart = false; // restart = false;
++currentLoops; ++currentLoops;
byte[] buffer = new byte[readSize]; byte[] buffer = new byte[readSize];
int bytesRead = 1; int bytesRead = 1;
@ -117,8 +117,8 @@ namespace NadekoBot.Services.Music
if (restart) if (restart)
_log.Info("Lets do some magix"); _log.Info("Lets do some magix");
} //}
while (restart && !cancelToken.IsCancellationRequested); //while (restart && !cancelToken.IsCancellationRequested);
} }
catch (System.ComponentModel.Win32Exception) catch (System.ComponentModel.Win32Exception)
{ {