Set ATIP to be a class to ensure it is nulled properly.. Fixes #352

This commit is contained in:
2020-11-01 20:10:20 +00:00
parent b2458f3db9
commit 080ad0ed51
9 changed files with 23 additions and 21 deletions

View File

@@ -67,12 +67,12 @@ namespace Aaru.Core.Devices.Dumping
if(!sense) if(!sense)
{ {
ATIP.CDATIP? atip = ATIP.Decode(cmdBuf); ATIP.CDATIP atip = ATIP.Decode(cmdBuf);
if(atip.HasValue) if(atip != null)
{ {
// Only CD-R and CD-RW have ATIP // Only CD-R and CD-RW have ATIP
mediaType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR; mediaType = atip.DiscType ? MediaType.CDRW : MediaType.CDR;
tmpBuf = new byte[cmdBuf.Length - 4]; tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4); Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);

View File

@@ -1092,10 +1092,12 @@ namespace Aaru.Core.Media.Info
Atip = cmdBuf; Atip = cmdBuf;
DecodedAtip = ATIP.Decode(cmdBuf); DecodedAtip = ATIP.Decode(cmdBuf);
if(DecodedAtip.HasValue) if(DecodedAtip != null)
// Only CD-R and CD-RW have ATIP // Only CD-R and CD-RW have ATIP
MediaType = DecodedAtip.Value.DiscType ? MediaType.CDRW : MediaType.CDR; MediaType = DecodedAtip.DiscType ? MediaType.CDRW : MediaType.CDR;
else
Atip = null;
} }
// We got a TOC, get information about a recorded/mastered CD // We got a TOC, get information about a recorded/mastered CD
@@ -1489,7 +1491,7 @@ namespace Aaru.Core.Media.Info
public byte[] Pma { get; } public byte[] Pma { get; }
public byte[] CdTextLeadIn { get; } public byte[] CdTextLeadIn { get; }
public TOC.CDTOC? DecodedToc { get; } public TOC.CDTOC? DecodedToc { get; }
public ATIP.CDATIP? DecodedAtip { get; } public ATIP.CDATIP DecodedAtip { get; }
public Session.CDSessionInfo? DecodedSession { get; } public Session.CDSessionInfo? DecodedSession { get; }
public FullTOC.CDFullTOC? FullToc { get; } public FullTOC.CDFullTOC? FullToc { get; }
public CDTextOnLeadIn.CDText? DecodedCdTextLeadIn { get; } public CDTextOnLeadIn.CDText? DecodedCdTextLeadIn { get; }

View File

@@ -117,13 +117,13 @@ namespace Aaru.Core
Size = (ulong)image.ReadDiskTag(MediaTagType.CD_ATIP).Length Size = (ulong)image.ReadDiskTag(MediaTagType.CD_ATIP).Length
}; };
ATIP.CDATIP? atip = ATIP.Decode(image.ReadDiskTag(MediaTagType.CD_ATIP)); ATIP.CDATIP atip = ATIP.Decode(image.ReadDiskTag(MediaTagType.CD_ATIP));
if(atip.HasValue) if(atip != null)
if(atip.Value.DDCD) if(atip.DDCD)
dskType = atip.Value.DiscType ? MediaType.DDCDRW : MediaType.DDCDR; dskType = atip.DiscType ? MediaType.DDCDRW : MediaType.DDCDR;
else else
dskType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR; dskType = atip.DiscType ? MediaType.CDRW : MediaType.CDR;
break; break;
case MediaTagType.DVD_BCA: case MediaTagType.DVD_BCA:

View File

@@ -252,7 +252,7 @@ namespace Aaru.Gui.ViewModels.Panels
FullTOC.CDFullTOC? decodedFullToc = null; FullTOC.CDFullTOC? decodedFullToc = null;
byte[] pma = null; byte[] pma = null;
byte[] atip = null; byte[] atip = null;
ATIP.CDATIP? decodedAtip = null; ATIP.CDATIP decodedAtip = null;
byte[] cdtext = null; byte[] cdtext = null;
CDTextOnLeadIn.CDText? decodedCdText = null; CDTextOnLeadIn.CDText? decodedCdText = null;
string mediaCatalogueNumber = null; string mediaCatalogueNumber = null;

View File

@@ -55,7 +55,7 @@ namespace Aaru.Gui.ViewModels.Tabs
public CompactDiscInfoViewModel(byte[] toc, byte[] atip, byte[] compactDiscInformation, byte[] session, public CompactDiscInfoViewModel(byte[] toc, byte[] atip, byte[] compactDiscInformation, byte[] session,
byte[] rawToc, byte[] pma, byte[] cdTextLeadIn, TOC.CDTOC? decodedToc, byte[] rawToc, byte[] pma, byte[] cdTextLeadIn, TOC.CDTOC? decodedToc,
ATIP.CDATIP? decodedAtip, Session.CDSessionInfo? decodedSession, ATIP.CDATIP decodedAtip, Session.CDSessionInfo? decodedSession,
FullTOC.CDFullTOC? fullToc, CDTextOnLeadIn.CDText? decodedCdTextLeadIn, FullTOC.CDFullTOC? fullToc, CDTextOnLeadIn.CDText? decodedCdTextLeadIn,
DiscInformation.StandardDiscInformation? decodedCompactDiscInformation, DiscInformation.StandardDiscInformation? decodedCompactDiscInformation,
string mcn, Dictionary<byte, string> isrcs, Window view) string mcn, Dictionary<byte, string> isrcs, Window view)
@@ -92,7 +92,7 @@ namespace Aaru.Gui.ViewModels.Tabs
if(decodedCdTextLeadIn.HasValue) if(decodedCdTextLeadIn.HasValue)
CdTextText = CDTextOnLeadIn.Prettify(decodedCdTextLeadIn); CdTextText = CDTextOnLeadIn.Prettify(decodedCdTextLeadIn);
if(decodedAtip.HasValue) if(decodedAtip != null)
CdAtipText = ATIP.Prettify(atip); CdAtipText = ATIP.Prettify(atip);
if(!string.IsNullOrEmpty(mcn)) if(!string.IsNullOrEmpty(mcn))

View File

@@ -1046,9 +1046,9 @@ namespace Aaru.DiscImages
atipTmp[0] = (byte)((_atip.Length & 0xFF00) >> 8); atipTmp[0] = (byte)((_atip.Length & 0xFF00) >> 8);
atipTmp[1] = (byte)(_atip.Length & 0xFF); atipTmp[1] = (byte)(_atip.Length & 0xFF);
ATIP.CDATIP atip0 = ATIP.Decode(atipTmp).Value; ATIP.CDATIP atip0 = ATIP.Decode(atipTmp);
_imageInfo.MediaType = atip0.DiscType ? MediaType.CDRW : MediaType.CDR; _imageInfo.MediaType = atip0?.DiscType ?? false ? MediaType.CDRW : MediaType.CDR;
if(atip0.LeadInStartMin == 97) if(atip0.LeadInStartMin == 97)
{ {

View File

@@ -495,10 +495,10 @@ namespace Aaru.DiscImages
// Only CD-R and CD-RW have ATIP // Only CD-R and CD-RW have ATIP
if(_mediaTags.TryGetValue(MediaTagType.CD_ATIP, out byte[] atipBuf)) if(_mediaTags.TryGetValue(MediaTagType.CD_ATIP, out byte[] atipBuf))
{ {
ATIP.CDATIP? atip = ATIP.Decode(atipBuf); ATIP.CDATIP atip = ATIP.Decode(atipBuf);
if(atip.HasValue) if(atip != null)
_imageInfo.MediaType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR; _imageInfo.MediaType = atip.DiscType ? MediaType.CDRW : MediaType.CDR;
} }
if(_mediaTags.TryGetValue(MediaTagType.Floppy_LeadOut, out byte[] leadout)) if(_mediaTags.TryGetValue(MediaTagType.Floppy_LeadOut, out byte[] leadout))

View File

@@ -469,7 +469,7 @@ namespace Aaru.Commands.Media
DataFile.WriteTo("Media-Info command", outputPrefix, "_atip.bin", "SCSI READ TOC/PMA/ATIP", DataFile.WriteTo("Media-Info command", outputPrefix, "_atip.bin", "SCSI READ TOC/PMA/ATIP",
scsiInfo.Atip); scsiInfo.Atip);
if(scsiInfo.DecodedAtip.HasValue) if(scsiInfo.DecodedAtip != null)
AaruConsole.WriteLine("ATIP:\n{0}", ATIP.Prettify(scsiInfo.DecodedAtip)); AaruConsole.WriteLine("ATIP:\n{0}", ATIP.Prettify(scsiInfo.DecodedAtip));
} }