mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Fix dumping correct data when reading subchannels in Plextor drives.
This commit is contained in:
@@ -258,19 +258,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
if(_supportsPlextorD8 && !inData)
|
||||
{
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead,
|
||||
supportedPlextorSubchannel, 0, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
// As a workaround for some firmware bugs, seek far away.
|
||||
_dev.PlextorReadCdDa(out _, out senseBuf, firstSectorToRead - 32, blockSize, blocksToRead,
|
||||
supportedPlextorSubchannel, 0, out _);
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, firstSectorToRead, blockSize,
|
||||
blocksToRead, supportedPlextorSubchannel, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
}
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, firstSectorToRead, blockSize,
|
||||
blocksToRead, supportedPlextorSubchannel, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
@@ -336,22 +325,10 @@ namespace Aaru.Core.Devices.Dumping
|
||||
if(offsetBytes < 0)
|
||||
adjustment = -sectorsForOffset;
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf,
|
||||
(uint)(firstSectorToRead + r + adjustment), blockSize,
|
||||
(uint)sectorsForOffset + 1, supportedPlextorSubchannel, 0,
|
||||
out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
// As a workaround for some firmware bugs, seek far away.
|
||||
_dev.PlextorReadCdDa(out _, out senseBuf, firstSectorToRead - 32, blockSize,
|
||||
blocksToRead, supportedPlextorSubchannel, 0, out _);
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf,
|
||||
(uint)(firstSectorToRead + r + adjustment), blockSize,
|
||||
(uint)sectorsForOffset + 1, supportedPlextorSubchannel,
|
||||
_dev.Timeout, out cmdDuration);
|
||||
}
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf,
|
||||
(uint)(firstSectorToRead + r + adjustment), blockSize,
|
||||
(uint)sectorsForOffset + 1,
|
||||
supportedPlextorSubchannel, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
|
||||
|
||||
@@ -222,19 +222,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
if(_supportsPlextorD8 && audioExtents.Contains(badSector))
|
||||
{
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, badSectorToReRead, blockSize,
|
||||
sectorsToReRead, supportedPlextorSubchannel, 0, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
// As a workaround for some firmware bugs, seek far away.
|
||||
_dev.PlextorReadCdDa(out _, out _, badSectorToReRead - 32, blockSize, sectorsToReRead,
|
||||
supportedPlextorSubchannel, 0, out _);
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, badSectorToReRead, blockSize,
|
||||
sectorsToReRead, supportedPlextorSubchannel, _dev.Timeout,
|
||||
out cmdDuration);
|
||||
}
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, badSectorToReRead, blockSize,
|
||||
sectorsToReRead, supportedPlextorSubchannel, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
|
||||
86
Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs
Normal file
86
Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using Aaru.Devices;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping
|
||||
{
|
||||
partial class Dump
|
||||
{
|
||||
bool ReadPlextorWithSubchannel(out byte[] cmdBuf, out byte[] senseBuf, uint firstSectorToRead, uint blockSize,
|
||||
uint blocksToRead, PlextorSubchannel supportedPlextorSubchannel,
|
||||
out double cmdDuration)
|
||||
{
|
||||
bool sense;
|
||||
cmdBuf = null;
|
||||
|
||||
if(supportedPlextorSubchannel == PlextorSubchannel.None)
|
||||
{
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead,
|
||||
supportedPlextorSubchannel, 0, out cmdDuration);
|
||||
|
||||
if(!sense)
|
||||
return false;
|
||||
|
||||
// As a workaround for some firmware bugs, seek far away.
|
||||
_dev.PlextorReadCdDa(out _, out senseBuf, firstSectorToRead - 32, blockSize, blocksToRead,
|
||||
supportedPlextorSubchannel, 0, out _);
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead,
|
||||
supportedPlextorSubchannel, _dev.Timeout, out cmdDuration);
|
||||
|
||||
return sense;
|
||||
}
|
||||
|
||||
byte[] subBuf;
|
||||
|
||||
uint subSize = supportedPlextorSubchannel == PlextorSubchannel.Q16 ? 16u : 96u;
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out byte[] dataBuf, out senseBuf, firstSectorToRead, 2352, blocksToRead,
|
||||
PlextorSubchannel.None, 0, out cmdDuration);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
sense = _dev.PlextorReadCdDa(out subBuf, out senseBuf, firstSectorToRead, subSize, blocksToRead,
|
||||
supportedPlextorSubchannel, 0, out cmdDuration);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
cmdBuf = new byte[(2352 * blocksToRead) + (subSize * blocksToRead)];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(dataBuf, 2352 * b, cmdBuf, (2352 + subSize) * b, 2352);
|
||||
Array.Copy(subBuf, subSize * b, cmdBuf, ((2352 + subSize) * b) + 2352, subSize);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// As a workaround for some firmware bugs, seek far away.
|
||||
_dev.PlextorReadCdDa(out _, out senseBuf, firstSectorToRead - 32, blockSize, blocksToRead,
|
||||
supportedPlextorSubchannel, 0, out _);
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out dataBuf, out senseBuf, firstSectorToRead, 2352, blocksToRead,
|
||||
PlextorSubchannel.None, 0, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
return true;
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out subBuf, out senseBuf, firstSectorToRead, subSize, blocksToRead,
|
||||
supportedPlextorSubchannel, 0, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
return true;
|
||||
|
||||
cmdBuf = new byte[(2352 * blocksToRead) + (subSize * blocksToRead)];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(dataBuf, 2352 * b, cmdBuf, (2352 + subSize) * b, 2352);
|
||||
Array.Copy(subBuf, subSize * b, cmdBuf, ((2352 + subSize) * b) + 2352, subSize);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -491,9 +491,9 @@ namespace Aaru.Core.Devices.Dumping
|
||||
previousPregapIsPreviousTrack = false;
|
||||
|
||||
// Pregap according to Q position
|
||||
posQ = ((subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9]) - 150;
|
||||
int diff = posQ - lba;
|
||||
int pregapQ = (int)track.TrackStartSector - lba;
|
||||
posQ = ((subBuf[7] * 60 * 75) + (subBuf[8] * 75) + subBuf[9]) - 150;
|
||||
int diff = posQ - lba;
|
||||
int pregapQ = (int)track.TrackStartSector - lba;
|
||||
|
||||
if(diff != 0)
|
||||
{
|
||||
@@ -593,16 +593,12 @@ namespace Aaru.Core.Devices.Dumping
|
||||
else if(dbDev?.ATAPI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true ||
|
||||
dbDev?.SCSI?.RemovableMedias?.Any(d => d.SupportsPlextorReadCDDA == true) == true ||
|
||||
dev.Manufacturer.ToLowerInvariant() == "plextor")
|
||||
sense = dev.PlextorReadCdDa(out cmdBuf, out _, lba, 2448, 1, PlextorSubchannel.All, dev.Timeout,
|
||||
sense = dev.PlextorReadCdDa(out cmdBuf, out _, lba, 96, 1, PlextorSubchannel.All, dev.Timeout,
|
||||
out _);
|
||||
|
||||
{
|
||||
if(!sense)
|
||||
{
|
||||
byte[] tmpBuf = new byte[96];
|
||||
Array.Copy(cmdBuf, 0, tmpBuf, 0, 96);
|
||||
subBuf = DeinterleaveQ(tmpBuf);
|
||||
}
|
||||
subBuf = DeinterleaveQ(cmdBuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,18 +125,8 @@ namespace Aaru.Core.Devices.Dumping
|
||||
|
||||
if(_supportsPlextorD8 && audioExtents.Contains(badSector))
|
||||
{
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out _, badSectorToRead, blockSize, sectorsToTrim,
|
||||
supportedPlextorSubchannel, 0, out cmdDuration);
|
||||
|
||||
if(sense)
|
||||
{
|
||||
// As a workaround for some firmware bugs, seek far away.
|
||||
_dev.PlextorReadCdDa(out _, out _, badSectorToRead - 32, blockSize, sectorsToTrim,
|
||||
supportedPlextorSubchannel, 0, out _);
|
||||
|
||||
sense = _dev.PlextorReadCdDa(out cmdBuf, out _, badSectorToRead, blockSize, sectorsToTrim,
|
||||
supportedPlextorSubchannel, _dev.Timeout, out cmdDuration);
|
||||
}
|
||||
sense = ReadPlextorWithSubchannel(out cmdBuf, out _, badSectorToRead, blockSize, sectorsToTrim,
|
||||
supportedPlextorSubchannel, out cmdDuration);
|
||||
|
||||
totalDuration += cmdDuration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user