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)
{
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
mediaType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR;
mediaType = atip.DiscType ? MediaType.CDRW : MediaType.CDR;
tmpBuf = new byte[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;
DecodedAtip = ATIP.Decode(cmdBuf);
if(DecodedAtip.HasValue)
if(DecodedAtip != null)
// 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
@@ -1489,7 +1491,7 @@ namespace Aaru.Core.Media.Info
public byte[] Pma { get; }
public byte[] CdTextLeadIn { get; }
public TOC.CDTOC? DecodedToc { get; }
public ATIP.CDATIP? DecodedAtip { get; }
public ATIP.CDATIP DecodedAtip { get; }
public Session.CDSessionInfo? DecodedSession { get; }
public FullTOC.CDFullTOC? FullToc { get; }
public CDTextOnLeadIn.CDText? DecodedCdTextLeadIn { get; }

View File

@@ -117,13 +117,13 @@ namespace Aaru.Core
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.Value.DDCD)
dskType = atip.Value.DiscType ? MediaType.DDCDRW : MediaType.DDCDR;
if(atip != null)
if(atip.DDCD)
dskType = atip.DiscType ? MediaType.DDCDRW : MediaType.DDCDR;
else
dskType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR;
dskType = atip.DiscType ? MediaType.CDRW : MediaType.CDR;
break;
case MediaTagType.DVD_BCA:

View File

@@ -252,7 +252,7 @@ namespace Aaru.Gui.ViewModels.Panels
FullTOC.CDFullTOC? decodedFullToc = null;
byte[] pma = null;
byte[] atip = null;
ATIP.CDATIP? decodedAtip = null;
ATIP.CDATIP decodedAtip = null;
byte[] cdtext = null;
CDTextOnLeadIn.CDText? decodedCdText = 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,
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,
DiscInformation.StandardDiscInformation? decodedCompactDiscInformation,
string mcn, Dictionary<byte, string> isrcs, Window view)
@@ -92,7 +92,7 @@ namespace Aaru.Gui.ViewModels.Tabs
if(decodedCdTextLeadIn.HasValue)
CdTextText = CDTextOnLeadIn.Prettify(decodedCdTextLeadIn);
if(decodedAtip.HasValue)
if(decodedAtip != null)
CdAtipText = ATIP.Prettify(atip);
if(!string.IsNullOrEmpty(mcn))

View File

@@ -1046,9 +1046,9 @@ namespace Aaru.DiscImages
atipTmp[0] = (byte)((_atip.Length & 0xFF00) >> 8);
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)
{

View File

@@ -495,10 +495,10 @@ namespace Aaru.DiscImages
// Only CD-R and CD-RW have ATIP
if(_mediaTags.TryGetValue(MediaTagType.CD_ATIP, out byte[] atipBuf))
{
ATIP.CDATIP? atip = ATIP.Decode(atipBuf);
ATIP.CDATIP atip = ATIP.Decode(atipBuf);
if(atip.HasValue)
_imageInfo.MediaType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR;
if(atip != null)
_imageInfo.MediaType = atip.DiscType ? MediaType.CDRW : MediaType.CDR;
}
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",
scsiInfo.Atip);
if(scsiInfo.DecodedAtip.HasValue)
if(scsiInfo.DecodedAtip != null)
AaruConsole.WriteLine("ATIP:\n{0}", ATIP.Prettify(scsiInfo.DecodedAtip));
}