From d13f4f8b4797d531b7428f37bc1cd8d7fba4d163 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 14 Jun 2020 00:41:14 +0100 Subject: [PATCH] Print position in subchannel log when a fix is applied. --- .../Devices/Dumping/CompactDisc/Subchannel.cs | 28 ++--- Aaru.Core/Logging/SubchannelLog.cs | 113 ++++++------------ 2 files changed, 48 insertions(+), 93 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs index 21da6a6ad..cb47a4c26 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Subchannel.cs @@ -96,6 +96,7 @@ namespace Aaru.Core.Devices.Dumping // Check subchannel for(int subPos = 0; subPos < deSub.Length; subPos += 96) { + long lba = (long)sectorAddress + (subPos / 96); bool @fixed = false; byte[] q = new byte[12]; Array.Copy(deSub, subPos + 12, q, 0, 12); @@ -155,7 +156,7 @@ namespace Aaru.Core.Devices.Dumping pOk = true; @fixed = true; - subLog.WritePFix(); + subLog.WritePFix(lba); } if(!rwOk && @@ -169,7 +170,7 @@ namespace Aaru.Core.Devices.Dumping rwOk = true; @fixed = true; - subLog.WriteRwFix(); + subLog.WriteRwFix(lba); } byte smin, ssec, amin, asec, aframe; @@ -193,34 +194,34 @@ namespace Aaru.Core.Devices.Dumping @fixed = true; if(fixedAdr) - subLog.WriteQAdrFix(); + subLog.WriteQAdrFix(lba); if(controlFix) - subLog.WriteQCtrlFix(); + subLog.WriteQCtrlFix(lba); if(fixedZero) - subLog.WriteQZeroFix(); + subLog.WriteQZeroFix(lba); if(fixedTno) - subLog.WriteQTnoFix(); + subLog.WriteQTnoFix(lba); if(fixedIndex) - subLog.WriteQIndexFix(); + subLog.WriteQIndexFix(lba); if(fixedRelPos) - subLog.WriteQRelPosFix(); + subLog.WriteQRelPosFix(lba); if(fixedAbsPos) - subLog.WriteQAbsPosFix(); + subLog.WriteQAbsPosFix(lba); if(fixedCrc) - subLog.WriteQCrcFix(); + subLog.WriteQCrcFix(lba); if(fixedMcn) - subLog.WriteQMcnFix(); + subLog.WriteQMcnFix(lba); if(fixedIsrc) - subLog.WriteQIsrcFix(); + subLog.WriteQIsrcFix(lba); } } @@ -265,8 +266,7 @@ namespace Aaru.Core.Devices.Dumping subchannelExtents.Remove(aPos); if(@fixed) - subLog?.WriteEntry(posSub, supportedSubchannel == MmcSubchannel.Raw, - (long)sectorAddress + (subPos / 96), 1); + subLog?.WriteEntry(posSub, supportedSubchannel == MmcSubchannel.Raw, lba, 1); } return indexesChanged; diff --git a/Aaru.Core/Logging/SubchannelLog.cs b/Aaru.Core/Logging/SubchannelLog.cs index 9c274920a..83f65e8b5 100644 --- a/Aaru.Core/Logging/SubchannelLog.cs +++ b/Aaru.Core/Logging/SubchannelLog.cs @@ -186,87 +186,42 @@ namespace Aaru.Core.Logging _logSw.Flush(); } - public void WritePFix() + public void WritePFix(long lba) => WriteMessageWithPosition(lba, "fixed P subchannel using weight average."); + + public void WriteRwFix(long lba) => WriteMessageWithPosition(lba, "fixed R-W subchannels writing empty data."); + + public void WriteQAdrFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with correct ADR."); + + public void WriteQCtrlFix(long lba) => + WriteMessageWithPosition(lba, "fixed Q subchannel with correct CONTROL."); + + public void WriteQZeroFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with correct ZERO."); + + public void WriteQTnoFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with correct TNO."); + + public void WriteQIndexFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with correct INDEX."); + + public void WriteQRelPosFix(long lba) => + WriteMessageWithPosition(lba, "fixed Q subchannel with correct RELATIVE POSITION."); + + public void WriteQAbsPosFix(long lba) => + WriteMessageWithPosition(lba, "fixed Q subchannel with correct ABSOLUTE POSITION."); + + public void WriteQCrcFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with correct CRC."); + + public void WriteQMcnFix(long lba) => WriteMessageWithPosition(lba, "fixed Q subchannel with known good MCN."); + + public void WriteQIsrcFix(long lba) => + WriteMessageWithPosition(lba, "fixed Q subchannel with known good ISRC."); + + public void WriteMessageWithPosition(long lba, string message) { - _logSw.WriteLine("Fixed P subchannel using weight average."); - - _logSw.Flush(); - } - - public void WriteRwFix() - { - _logSw.WriteLine("Fixed R-W subchannels writing empty data."); - - _logSw.Flush(); - } - - public void WriteQAdrFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct ADR."); - - _logSw.Flush(); - } - - public void WriteQCtrlFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct CONTROL."); - - _logSw.Flush(); - } - - public void WriteQZeroFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct ZERO."); - - _logSw.Flush(); - } - - public void WriteQTnoFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct TNO."); - - _logSw.Flush(); - } - - public void WriteQIndexFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct INDEX."); - - _logSw.Flush(); - } - - public void WriteQRelPosFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct RELATIVE POSITION."); - - _logSw.Flush(); - } - - public void WriteQAbsPosFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct ABSOLUTE POSITION."); - - _logSw.Flush(); - } - - public void WriteQCrcFix() - { - _logSw.WriteLine("Fixed Q subchannel with correct CRC."); - - _logSw.Flush(); - } - - public void WriteQMcnFix() - { - _logSw.WriteLine("Fixed Q subchannel with known good MCN."); - - _logSw.Flush(); - } - - public void WriteQIsrcFix() - { - _logSw.WriteLine("Fixed Q subchannel with known good ISRC."); + long minute = (lba + 150) / 4500; + long second = ((lba + 150) % 4500) / 75; + long frame = (lba + 150) % 4500 % 75; + string area = lba < 0 ? "Lead-In" : "Program"; + _logSw.WriteLine($"{minute:D2}:{second:D2}:{frame:D2} - LBA {lba,6}: {area} area, {message}"); _logSw.Flush(); } }