diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs index 42069a12c..15b8e919d 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs @@ -122,6 +122,7 @@ namespace Aaru.Core.Devices.Dumping InitProgress?.Invoke(); + int currentReadSpeed = _speed; bool crossingLeadOut = false; bool failedCrossingLeadOut = false; @@ -207,6 +208,31 @@ namespace Aaru.Core.Devices.Dumping } } + if(!inData && currentReadSpeed == 0xFFFF) + { + _dumpLog.WriteLine("Setting speed to 8x for audio reading."); + UpdateStatus?.Invoke("Setting speed to 8x for audio reading."); + + _dev.SetCdSpeed(out _, RotationalControl.ClvAndImpureCav, 1416, 0, _dev.Timeout, out _); + + currentReadSpeed = 1200; + } + + if(inData && currentReadSpeed != _speed) + { + _dumpLog.WriteLine($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}."); + UpdateStatus?.Invoke($"Setting speed to {(_speed == 0xFFFF ? "MAX for data reading" : $"{_speed}x")}."); + + _speed *= _speedMultiplier; + + if(_speed == 0 || + _speed > 0xFFFF) + _speed = 0xFFFF; + + _dev.SetCdSpeed(out _, RotationalControl.ClvAndImpureCav, (ushort)_speed, 0, + _dev.Timeout, out _); + } + #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator // ReSharper disable CompareOfFloatsByEqualityOperator diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index 714983fd2..b030c87a3 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -953,8 +953,8 @@ namespace Aaru.Core.Devices.Dumping // Set speed if(_speedMultiplier >= 0) { - _dumpLog.WriteLine($"Setting speed to {(_speed == 0 ? "MAX" : $"{_speed}x")}."); - UpdateStatus?.Invoke($"Setting speed to {(_speed == 0 ? "MAX" : $"{_speed}x")}."); + _dumpLog.WriteLine($"Setting speed to {(_speed == 0 ? "MAX for data reading" : $"{_speed}x")}."); + UpdateStatus?.Invoke($"Setting speed to {(_speed == 0 ? "MAX for data reading" : $"{_speed}x")}."); _speed *= _speedMultiplier; @@ -962,7 +962,8 @@ namespace Aaru.Core.Devices.Dumping _speed > 0xFFFF) _speed = 0xFFFF; - _dev.SetCdSpeed(out _, RotationalControl.ClvAndImpureCav, (ushort)_speed, 0, _dev.Timeout, out _); + _dev.SetCdSpeed(out _, RotationalControl.ClvAndImpureCav, (ushort)_speed, 0, _dev.Timeout, + out _); } // Start reading diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index b6dc1560d..b53b69072 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -266,7 +266,7 @@ namespace Aaru.Core.Devices.Dumping audioExtents.Contains(badSector) && offsetBytes != 0) { - int offsetFix = offsetBytes > 0 ? (int)(sectorSize - (offsetBytes * -1)) : offsetBytes; + int offsetFix = offsetBytes < 0 ? (int)(sectorSize - (offsetBytes * -1)) : offsetBytes; if(supportedSubchannel != MmcSubchannel.None) {