From 3c540f41b0fa586b876325cdde84ed2f5fedf39f Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 1 Nov 2020 20:10:09 +0000 Subject: [PATCH] Set ATIP to be a class to ensure it is nulled properly.. Fixes #352 --- CD/ATIP.cs | 96 ++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/CD/ATIP.cs b/CD/ATIP.cs index 85a4ad90d..32c205aae 100644 --- a/CD/ATIP.cs +++ b/CD/ATIP.cs @@ -55,7 +55,7 @@ namespace Aaru.Decoders.CD SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")] public static class ATIP { - public static CDATIP? Decode(byte[] CDATIPResponse) + public static CDATIP Decode(byte[] CDATIPResponse) { if(CDATIPResponse == null || CDATIPResponse.Length <= 4) @@ -113,22 +113,20 @@ namespace Aaru.Decoders.CD decoded.Reserved9 = CDATIPResponse[27]; if(CDATIPResponse.Length < 32) - return decoded.AlwaysOne ? decoded : (CDATIP?)null; + return decoded.AlwaysOne ? decoded : null; decoded.S4Values = new byte[3]; Array.Copy(CDATIPResponse, 28, decoded.S4Values, 0, 3); decoded.Reserved10 = CDATIPResponse[31]; - return decoded.AlwaysOne ? decoded : (CDATIP?)null; + return decoded.AlwaysOne ? decoded : null; } - public static string Prettify(CDATIP? CDATIPResponse) + public static string Prettify(CDATIP response) { - if(CDATIPResponse == null) + if(response == null) return null; - CDATIP response = CDATIPResponse.Value; - var sb = new StringBuilder(); if(response.DDCD) @@ -320,7 +318,7 @@ namespace Aaru.Decoders.CD public static string Prettify(byte[] CDATIPResponse) { - CDATIP? decoded = Decode(CDATIPResponse); + CDATIP decoded = Decode(CDATIPResponse); return Prettify(decoded); } @@ -595,72 +593,72 @@ namespace Aaru.Decoders.CD return ""; } - public struct CDATIP + public class CDATIP { - /// Bytes 1 to 0 Total size of returned session information minus this field - public ushort DataLength; - /// Byte 2 Reserved - public byte Reserved1; - /// Byte 3 Reserved - public byte Reserved2; - /// Byte 4, bits 7 to 4 Indicative target writing power - public byte ITWP; - /// Byte 4, bit 3 Set if DDCD - public bool DDCD; - /// Byte 4, bits 2 to 0 Reference speed - public byte ReferenceSpeed; - /// Byte 5, bit 7 Always unset - public bool AlwaysZero; - /// Byte 5, bit 6 Unrestricted media - public bool URU; - /// Byte 5, bits 5 to 0 Reserved - public byte Reserved3; - /// Byte 6, bit 7 Always set - public bool AlwaysOne; - /// Byte 6, bit 6 Set if rewritable (CD-RW or DDCD-RW) - public bool DiscType; - /// Byte 6, bits 5 to 3 Disc subtype - public byte DiscSubType; /// Byte 6, bit 2 A1 values are valid public bool A1Valid; + /// Bytes 16 to 18 A1 values + public byte[] A1Values; /// Byte 6, bit 1 A2 values are valid public bool A2Valid; + /// Bytes 20 to 22 A2 values + public byte[] A2Values; /// Byte 6, bit 0 A3 values are valid public bool A3Valid; - /// Byte 7 Reserved - public byte Reserved4; + /// Bytes 24 to 26 A3 values + public byte[] A3Values; + /// Byte 6, bit 7 Always set + public bool AlwaysOne; + /// Byte 5, bit 7 Always unset + public bool AlwaysZero; + /// Bytes 1 to 0 Total size of returned session information minus this field + public ushort DataLength; + /// Byte 4, bit 3 Set if DDCD + public bool DDCD; + /// Byte 6, bits 5 to 3 Disc subtype + public byte DiscSubType; + /// Byte 6, bit 6 Set if rewritable (CD-RW or DDCD-RW) + public bool DiscType; + /// Byte 4, bits 7 to 4 Indicative target writing power + public byte ITWP; + /// Byte 10 ATIP Start time of Lead-In (Frame) + public byte LeadInStartFrame; /// Byte 8 ATIP Start time of Lead-In (Minute) public byte LeadInStartMin; /// Byte 9 ATIP Start time of Lead-In (Second) public byte LeadInStartSec; - /// Byte 10 ATIP Start time of Lead-In (Frame) - public byte LeadInStartFrame; - /// Byte 11 Reserved - public byte Reserved5; + /// Byte 14 ATIP Last possible start time of Lead-Out (Frame) + public byte LeadOutStartFrame; /// Byte 12 ATIP Last possible start time of Lead-Out (Minute) public byte LeadOutStartMin; /// Byte 13 ATIP Last possible start time of Lead-Out (Second) public byte LeadOutStartSec; - /// Byte 14 ATIP Last possible start time of Lead-Out (Frame) - public byte LeadOutStartFrame; + /// Byte 4, bits 2 to 0 Reference speed + public byte ReferenceSpeed; + /// Byte 2 Reserved + public byte Reserved1; + /// Byte 31 Reserved + public byte Reserved10; + /// Byte 3 Reserved + public byte Reserved2; + /// Byte 5, bits 5 to 0 Reserved + public byte Reserved3; + /// Byte 7 Reserved + public byte Reserved4; + /// Byte 11 Reserved + public byte Reserved5; /// Byte 15 Reserved public byte Reserved6; - /// Bytes 16 to 18 A1 values - public byte[] A1Values; /// Byte 19 Reserved public byte Reserved7; - /// Bytes 20 to 22 A2 values - public byte[] A2Values; /// Byte 23 Reserved public byte Reserved8; - /// Bytes 24 to 26 A3 values - public byte[] A3Values; /// Byte 27 Reserved public byte Reserved9; /// Bytes 28 to 30 S4 values public byte[] S4Values; - /// Byte 31 Reserved - public byte Reserved10; + /// Byte 5, bit 6 Unrestricted media + public bool URU; } } } \ No newline at end of file