Fixed: Avoid simultaneous read on cd drive

This commit is contained in:
Tichau committed 2016-04-14 19:19:48 +02:00
1 parent 03fa599a9b
commit a8741693f5
4 files changed
+34 -11

No files matched your search

@@ -9,6 +9,6 @@ namespace FileConverter.ConversionJobs
{
None = 0x00,
CdaExtraction = 0x01,
CdDriveExtraction = 0x01,
}
}
@@ -141,7 +141,7 @@ namespace FileConverter.ConversionJobs
public virtual bool CanStartConversion(ConversionFlags conversionFlags)
{
return true;
return (conversionFlags & ConversionFlags.CdDriveExtraction) == 0;
}
public void PrepareConversion(string inputFilePath, string outputFilePath = null)
@@ -225,6 +225,12 @@ namespace FileConverter.ConversionJobs
return;
}
// Check if the input file is located on a cd drive.
if (PathHelpers.IsOnCDDrive(this.InputFilePath))
{
this.StateFlags = ConversionFlags.CdDriveExtraction;
}
this.Initialize();
if (this.State == ConversionState.Unknown)
@@ -252,7 +258,7 @@ namespace FileConverter.ConversionJobs
Debug.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
this.State = ConversionState.InProgress;
try
{
this.Convert();
@@ -262,6 +268,8 @@ namespace FileConverter.ConversionJobs
this.ConversionFailed(exception.Message);
}
this.StateFlags = ConversionFlags.None;
if (this.State == ConversionState.Failed)
{
this.OnConversionFailed();
@@ -35,12 +35,7 @@ namespace FileConverter.ConversionJobs
return InputPostConversionAction.None;
}
}
public override bool CanStartConversion(ConversionFlags conversionFlags)
{
return (conversionFlags & ConversionFlags.CdaExtraction) == 0;
}
protected override void Initialize()
{
base.Initialize();
@@ -108,8 +103,6 @@ namespace FileConverter.ConversionJobs
this.compressionConversionJob = ConversionJobFactory.Create(this.ConversionPreset, this.intermediateFilePath);
this.compressionConversionJob.PrepareConversion(this.intermediateFilePath, this.OutputFilePath);
this.compressionThread = new Thread(this.CompressAsync);
this.StateFlags = ConversionFlags.CdaExtraction;
}
protected override void Convert()
+22
View File
@@ -23,6 +23,28 @@ namespace FileConverter
return PathHelpers.driveLetterRegex.Match(path).Groups[0].Value;
}
public static bool IsOnCDDrive(string path)
{
string pathDriveLetter = GetPathDriveLetter(path);
if (string.IsNullOrEmpty(pathDriveLetter))
{
return false;
}
char driveLetter = pathDriveLetter[0];
char[] driveLetters = Ripper.CDDrive.GetCDDriveLetters();
for (int index = 0; index < driveLetters.Length; index++)
{
if (driveLetters[index] == driveLetter)
{
return true;
}
}
return false;
}
public static int GetCDATrackNumber(string path)
{
Match match = PathHelpers.cdaTrackNumberRegex.Match(path);