More graceful handling of Ctrl-C by FLACCL

This commit is contained in:
Grigory Chudov
2013-04-07 22:05:21 -04:00
parent ef5f5e6d4c
commit f7fee0139c

View File

@@ -73,7 +73,7 @@ namespace CUETools.FLACCL.cmd
TextWriter stdout = Console.Out; TextWriter stdout = Console.Out;
Console.SetOut(Console.Error); Console.SetOut(Console.Error);
var settings = new FLACCLWriterSettings(); var settings = new FLACCLWriterSettings() { AllowNonSubset = true };
TimeSpan lastPrint = TimeSpan.FromMilliseconds(0); TimeSpan lastPrint = TimeSpan.FromMilliseconds(0);
bool debug = false, quiet = false; bool debug = false, quiet = false;
string stereo_method = null; string stereo_method = null;
@@ -305,6 +305,16 @@ namespace CUETools.FLACCL.cmd
Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.PCM.SampleRate, audioSource.PCM.ChannelCount, audioSource.PCM.BitsPerSample, TimeSpan.FromSeconds(audioSource.Length * 1.0 / audioSource.PCM.SampleRate)); Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.PCM.SampleRate, audioSource.PCM.ChannelCount, audioSource.PCM.BitsPerSample, TimeSpan.FromSeconds(audioSource.Length * 1.0 / audioSource.PCM.SampleRate));
} }
bool keepRunning = true;
Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
{
keepRunning = false;
if (e.SpecialKey == ConsoleSpecialKey.ControlC)
e.Cancel = true;
else
audioDest.Delete();
};
DateTime start = DateTime.Now; DateTime start = DateTime.Now;
try try
{ {
@@ -327,7 +337,9 @@ namespace CUETools.FLACCL.cmd
lastPrint = elapsed; lastPrint = elapsed;
} }
} }
} if (!keepRunning)
throw new Exception("Aborted");
}
audioDest.Close(); audioDest.Close();
} }
catch (OpenCLNet.OpenCLBuildException ex) catch (OpenCLNet.OpenCLBuildException ex)