Split lead-out dump from CD dump method.

This commit is contained in:
2019-12-31 20:26:27 +00:00
parent 1c8df12c9a
commit c781029ed8
4 changed files with 203 additions and 105 deletions

View File

@@ -1645,111 +1645,9 @@ namespace DiscImageChef.Core.Devices.Dumping
EndProgress?.Invoke();
// TODO: Enable when underlying images support lead-outs
/*
if(persistent)
{
UpdateStatus?.Invoke("Reading lead-outs");
dumpLog.WriteLine("Reading lead-outs");
InitProgress?.Invoke();
foreach(Tuple<ulong, ulong> leadout in leadOutExtents.ToArray())
for(ulong i = leadout.Item1; i <= leadout.Item2; i++)
{
if(aborted)
{
currentTry.Extents = ExtentsConverter.ToMetadata(extents);
dumpLog.WriteLine("Aborted!");
break;
}
double cmdDuration = 0;
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
if(currentSpeed > maxSpeed && currentSpeed != 0) maxSpeed = currentSpeed;
if(currentSpeed < minSpeed && currentSpeed != 0) minSpeed = currentSpeed;
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
PulseProgress?.Invoke(string.Format("Reading sector {0} at lead-out ({1:F3} MiB/sec.)", i, blocks,
currentSpeed));
if(readcd)
{
sense = dev.ReadCd(out cmdBuf, out senseBuf, (uint)i, blockSize, 1,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
true, true, MmcErrorField.None, supportedSubchannel, dev.Timeout,
out cmdDuration);
totalDuration += cmdDuration;
}
else if(read16)
sense = dev.Read16(out cmdBuf, out senseBuf, 0, false, true, false, i, blockSize, 0, 1,
false, dev.Timeout, out cmdDuration);
else if(read12)
sense = dev.Read12(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i,
blockSize, 0, 1, false, dev.Timeout, out cmdDuration);
else if(read10)
sense = dev.Read10(out cmdBuf, out senseBuf, 0, false, true, false, false, (uint)i,
blockSize, 0, 1, dev.Timeout, out cmdDuration);
else if(read6)
sense = dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, dev.Timeout,
out cmdDuration);
if(!sense && !dev.Error)
{
mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, blocksToRead, true);
leadOutExtents.Remove(i);
DateTime writeStart = DateTime.Now;
if(supportedSubchannel != MmcSubchannel.None)
{
byte[] data = new byte[SECTOR_SIZE * blocksToRead];
byte[] sub = new byte[subSize * blocksToRead];
for(int b = 0; b < blocksToRead; b++)
{
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, SECTOR_SIZE * b,
SECTOR_SIZE);
Array.Copy(cmdBuf, (int)(SECTOR_SIZE + b * blockSize), sub, subSize * b,
subSize);
}
outputPlugin.WriteSectorsLong(data, i, blocksToRead);
outputPlugin.WriteSectorsTag(sub, i, blocksToRead, SectorTagType.CdSectorSubchannel);
}
else outputPlugin.WriteSectors(cmdBuf, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
}
else
{
// TODO: Reset device after X errors
if(stopOnError) return; // TODO: Return more cleanly
// Write empty data
DateTime writeStart = DateTime.Now;
if(supportedSubchannel != MmcSubchannel.None)
{
outputPlugin.WriteSectorsLong(new byte[SECTOR_SIZE * skip], i, 1);
outputPlugin.WriteSectorsTag(new byte[subSize * skip], i, 1,
SectorTagType.CdSectorSubchannel);
}
else outputPlugin.WriteSectors(new byte[blockSize * skip], i, 1);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0);
}
double newSpeed =
(double)blockSize * blocksToRead / 1048576 / (cmdDuration / 1000);
if(!double.IsInfinity(newSpeed)) currentSpeed = newSpeed;
resume.NextBlock = i + 1;
}
EndProgress?.Invoke();
}*/
DumpCdLeadOuts(blocks, blockSize, ref currentSpeed, currentTry, extents, ibgLog, ref imageWriteDuration,
leadOutExtents, ref maxSpeed, mhddLog, ref minSpeed, read6, read10, read12, read16, readcd,
supportedSubchannel, subSize, ref totalDuration);
end = DateTime.UtcNow;
mhddLog.Close();