mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General code cleanup and style refactor.
This commit is contained in:
@@ -30,13 +30,13 @@
|
||||
// Copyright © 2011-2022 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace Aaru.Devices;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Devices;
|
||||
|
||||
public partial class Device
|
||||
{
|
||||
/// <summary>Sends the MMC GET CONFIGURATION command for all Features</summary>
|
||||
@@ -72,7 +72,7 @@ public partial class Device
|
||||
MmcGetConfigurationRt rt, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
buffer = new byte[8];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.GetConfiguration;
|
||||
@@ -91,7 +91,7 @@ public partial class Device
|
||||
if(sense)
|
||||
return true;
|
||||
|
||||
var confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4);
|
||||
ushort confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4);
|
||||
buffer = new byte[confLength];
|
||||
cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8);
|
||||
cdb[8] = (byte)(buffer.Length & 0xFF);
|
||||
@@ -125,7 +125,7 @@ public partial class Device
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[12];
|
||||
byte[] cdb = new byte[12];
|
||||
buffer = new byte[8];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadDiscStructure;
|
||||
@@ -148,19 +148,19 @@ public partial class Device
|
||||
if(sense)
|
||||
return true;
|
||||
|
||||
var strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
|
||||
ushort strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2);
|
||||
|
||||
// WORKAROUND: Some drives return incorrect length information. As these structures are fixed length just apply known length.
|
||||
if(mediaType == MmcDiscStructureMediaType.Bd)
|
||||
buffer = format switch
|
||||
{
|
||||
MmcDiscStructureFormat.DiscInformation => new byte[4100],
|
||||
MmcDiscStructureFormat.BdBurstCuttingArea => new byte[68],
|
||||
MmcDiscStructureFormat.BdDds => new byte[strctLength < 100 ? 100 : strctLength],
|
||||
MmcDiscStructureFormat.CartridgeStatus => new byte[8],
|
||||
MmcDiscStructureFormat.BdSpareAreaInformation => new byte[16],
|
||||
_ => new byte[strctLength]
|
||||
};
|
||||
{
|
||||
MmcDiscStructureFormat.DiscInformation => new byte[4100],
|
||||
MmcDiscStructureFormat.BdBurstCuttingArea => new byte[68],
|
||||
MmcDiscStructureFormat.BdDds => new byte[strctLength < 100 ? 100 : strctLength],
|
||||
MmcDiscStructureFormat.CartridgeStatus => new byte[8],
|
||||
MmcDiscStructureFormat.BdSpareAreaInformation => new byte[16],
|
||||
_ => new byte[strctLength]
|
||||
};
|
||||
else
|
||||
buffer = new byte[strctLength];
|
||||
|
||||
@@ -273,7 +273,7 @@ public partial class Device
|
||||
byte trackSessionNumber, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
|
||||
byte[] tmpBuffer = (format & 0x0F) == 5 ? new byte[32768] : new byte[1536];
|
||||
|
||||
@@ -292,7 +292,7 @@ public partial class Device
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
var strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||
buffer = new byte[strctLength];
|
||||
|
||||
if(buffer.Length <= tmpBuffer.Length)
|
||||
@@ -343,8 +343,8 @@ public partial class Device
|
||||
uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[10];
|
||||
var tmpBuffer = new byte[804];
|
||||
byte[] cdb = new byte[10];
|
||||
byte[] tmpBuffer = new byte[804];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadDiscInformation;
|
||||
cdb[1] = (byte)dataType;
|
||||
@@ -356,7 +356,7 @@ public partial class Device
|
||||
|
||||
Error = LastError != 0;
|
||||
|
||||
var strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||
uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2);
|
||||
|
||||
if(strctLength > tmpBuffer.Length)
|
||||
strctLength = (uint)tmpBuffer.Length;
|
||||
@@ -395,7 +395,7 @@ public partial class Device
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[12];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCd;
|
||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||
@@ -465,7 +465,7 @@ public partial class Device
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[12];
|
||||
byte[] cdb = new byte[12];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadCdMsf;
|
||||
cdb[1] = (byte)((byte)expectedSectorType << 2);
|
||||
@@ -493,7 +493,7 @@ public partial class Device
|
||||
|
||||
cdb[10] = (byte)subchannel;
|
||||
|
||||
var transferLength = (uint)((cdb[6] - cdb[3]) * 60 * 75 + (cdb[7] - cdb[4]) * 75 + (cdb[8] - cdb[5]));
|
||||
uint transferLength = (uint)(((cdb[6] - cdb[3]) * 60 * 75) + ((cdb[7] - cdb[4]) * 75) + (cdb[8] - cdb[5]));
|
||||
|
||||
buffer = new byte[blockSize * transferLength];
|
||||
|
||||
@@ -537,7 +537,7 @@ public partial class Device
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.PreventAllowMediumRemoval;
|
||||
@@ -607,7 +607,7 @@ public partial class Device
|
||||
bool changeFormatLayer, bool loadEject, bool start, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[6];
|
||||
byte[] cdb = new byte[6];
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.StartStopUnit;
|
||||
@@ -655,7 +655,7 @@ public partial class Device
|
||||
public bool ReadMcn(out string mcn, out byte[] buffer, out byte[] senseBuffer, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
mcn = null;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadSubChannel;
|
||||
@@ -695,7 +695,7 @@ public partial class Device
|
||||
out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
isrc = null;
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadSubChannel;
|
||||
@@ -736,7 +736,7 @@ public partial class Device
|
||||
ushort writeSpeed, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[12];
|
||||
byte[] cdb = new byte[12];
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.SetCdRomSpeed;
|
||||
@@ -771,7 +771,7 @@ public partial class Device
|
||||
uint address, uint timeout, out double duration)
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
var cdb = new byte[10];
|
||||
byte[] cdb = new byte[10];
|
||||
buffer = new byte[48];
|
||||
|
||||
cdb[0] = (byte)ScsiCommands.ReadTrackInformation;
|
||||
|
||||
Reference in New Issue
Block a user