mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Implemented decoding mode page 0Eh.
This commit is contained in:
@@ -2618,7 +2618,6 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
public byte SelectedCompression;
|
||||
}
|
||||
|
||||
|
||||
public static ModePage_10? DecodeModePage_10(byte[] pageResponse)
|
||||
{
|
||||
if (pageResponse == null)
|
||||
@@ -2763,6 +2762,249 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion Mode Page 0x10: Device configuration page
|
||||
|
||||
#region Mode Page 0x0E: CD-ROM audio control parameters page
|
||||
/// <summary>
|
||||
/// CD-ROM audio control parameters
|
||||
/// Page code 0x0E
|
||||
/// 16 bytes in SCSI-2
|
||||
/// </summary>
|
||||
public struct ModePage_0E
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters can be saved
|
||||
/// </summary>
|
||||
public bool PS;
|
||||
/// <summary>
|
||||
/// Return status as soon as playback operation starts
|
||||
/// </summary>
|
||||
public bool Immed;
|
||||
/// <summary>
|
||||
/// Stop on track crossing
|
||||
/// </summary>
|
||||
public bool SOTC;
|
||||
/// <summary>
|
||||
/// Indicates <see cref="BlocksPerSecondOfAudio"/> is valid
|
||||
/// </summary>
|
||||
public bool APRVal;
|
||||
/// <summary>
|
||||
/// Multiplier for <see cref="BlocksPerSecondOfAudio"/>
|
||||
/// </summary>
|
||||
public byte LBAFormat;
|
||||
/// <summary>
|
||||
/// LBAs per second of audio
|
||||
/// </summary>
|
||||
public ushort BlocksPerSecondOfAudio;
|
||||
/// <summary>
|
||||
/// Channels output on this port
|
||||
/// </summary>
|
||||
public byte OutputPort0ChannelSelection;
|
||||
/// <summary>
|
||||
/// Volume level for this port
|
||||
/// </summary>
|
||||
public byte OutputPort0Volume;
|
||||
/// <summary>
|
||||
/// Channels output on this port
|
||||
/// </summary>
|
||||
public byte OutputPort1ChannelSelection;
|
||||
/// <summary>
|
||||
/// Volume level for this port
|
||||
/// </summary>
|
||||
public byte OutputPort1Volume;
|
||||
/// <summary>
|
||||
/// Channels output on this port
|
||||
/// </summary>
|
||||
public byte OutputPort2ChannelSelection;
|
||||
/// <summary>
|
||||
/// Volume level for this port
|
||||
/// </summary>
|
||||
public byte OutputPort2Volume;
|
||||
/// <summary>
|
||||
/// Channels output on this port
|
||||
/// </summary>
|
||||
public byte OutputPort3ChannelSelection;
|
||||
/// <summary>
|
||||
/// Volume level for this port
|
||||
/// </summary>
|
||||
public byte OutputPort3Volume;
|
||||
}
|
||||
|
||||
public static ModePage_0E? DecodeModePage_0E(byte[] pageResponse)
|
||||
{
|
||||
if (pageResponse == null)
|
||||
return null;
|
||||
|
||||
if ((pageResponse[0] & 0x3F) != 0x0E)
|
||||
return null;
|
||||
|
||||
if (pageResponse[1] + 2 != pageResponse.Length)
|
||||
return null;
|
||||
|
||||
if (pageResponse.Length < 16)
|
||||
return null;
|
||||
|
||||
ModePage_0E decoded = new ModePage_0E();
|
||||
|
||||
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
|
||||
decoded.Immed |= (pageResponse[2] & 0x04) == 0x04;
|
||||
decoded.SOTC |= (pageResponse[2] & 0x02) == 0x02;
|
||||
decoded.APRVal |= (pageResponse[5] & 0x80) == 0x80;
|
||||
decoded.LBAFormat = (byte)(pageResponse[5] & 0x0F);
|
||||
decoded.BlocksPerSecondOfAudio = (ushort)((pageResponse[6] << 8) + pageResponse[7]);
|
||||
decoded.OutputPort0ChannelSelection = (byte)(pageResponse[8] & 0x0F);
|
||||
decoded.OutputPort0Volume = pageResponse[9];
|
||||
decoded.OutputPort1ChannelSelection = (byte)(pageResponse[10] & 0x0F);
|
||||
decoded.OutputPort1Volume = pageResponse[11];
|
||||
decoded.OutputPort2ChannelSelection = (byte)(pageResponse[12] & 0x0F);
|
||||
decoded.OutputPort2Volume = pageResponse[13];
|
||||
decoded.OutputPort3ChannelSelection = (byte)(pageResponse[14] & 0x0F);
|
||||
decoded.OutputPort3Volume = pageResponse[15];
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
public static string PrettifyModePage_0E(byte[] pageResponse)
|
||||
{
|
||||
return PrettifyModePage_0E(DecodeModePage_0E(pageResponse));
|
||||
}
|
||||
|
||||
public static string PrettifyModePage_0E(ModePage_0E? modePage)
|
||||
{
|
||||
if (!modePage.HasValue)
|
||||
return null;
|
||||
|
||||
ModePage_0E page = modePage.Value;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("SCSI CD-ROM audio control parameters page:");
|
||||
|
||||
if (page.PS)
|
||||
sb.AppendLine("\tParameters can be saved");
|
||||
if (page.Immed)
|
||||
sb.AppendLine("\tDrive will return from playback command immediately");
|
||||
else
|
||||
sb.AppendLine("\tDrive will return from playback command when playback ends");
|
||||
if (page.SOTC)
|
||||
sb.AppendLine("\tDrive will stop playback on track end");
|
||||
|
||||
if (page.APRVal)
|
||||
{
|
||||
double blocks;
|
||||
if (page.LBAFormat == 8)
|
||||
blocks = page.BlocksPerSecondOfAudio * (1 / 256);
|
||||
else
|
||||
blocks = page.BlocksPerSecondOfAudio;
|
||||
|
||||
sb.AppendFormat("\tThere are {0} blocks per each second of audio", blocks).AppendLine();
|
||||
}
|
||||
|
||||
if (page.OutputPort0ChannelSelection > 0)
|
||||
{
|
||||
sb.Append("Output port 0 has channels ");
|
||||
if ((page.OutputPort0ChannelSelection & 0x01) == 0x01)
|
||||
sb.Append("0 ");
|
||||
if ((page.OutputPort0ChannelSelection & 0x02) == 0x02)
|
||||
sb.Append("1 ");
|
||||
if ((page.OutputPort0ChannelSelection & 0x04) == 0x04)
|
||||
sb.Append("2 ");
|
||||
if ((page.OutputPort0ChannelSelection & 0x08) == 0x08)
|
||||
sb.Append("3 ");
|
||||
|
||||
switch (page.OutputPort0Volume)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendLine("muted");
|
||||
break;
|
||||
case 0xFF:
|
||||
sb.AppendLine("at maximum volume");
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("at volume {0}", page.OutputPort0Volume).AppendLine();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (page.OutputPort1ChannelSelection > 0)
|
||||
{
|
||||
sb.Append("Output port 1 has channels ");
|
||||
if ((page.OutputPort1ChannelSelection & 0x01) == 0x01)
|
||||
sb.Append("0 ");
|
||||
if ((page.OutputPort1ChannelSelection & 0x02) == 0x02)
|
||||
sb.Append("1 ");
|
||||
if ((page.OutputPort1ChannelSelection & 0x04) == 0x04)
|
||||
sb.Append("2 ");
|
||||
if ((page.OutputPort1ChannelSelection & 0x08) == 0x08)
|
||||
sb.Append("3 ");
|
||||
|
||||
switch (page.OutputPort1Volume)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendLine("muted");
|
||||
break;
|
||||
case 0xFF:
|
||||
sb.AppendLine("at maximum volume");
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("at volume {0}", page.OutputPort1Volume).AppendLine();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (page.OutputPort2ChannelSelection > 0)
|
||||
{
|
||||
sb.Append("Output port 2 has channels ");
|
||||
if ((page.OutputPort2ChannelSelection & 0x01) == 0x01)
|
||||
sb.Append("0 ");
|
||||
if ((page.OutputPort2ChannelSelection & 0x02) == 0x02)
|
||||
sb.Append("1 ");
|
||||
if ((page.OutputPort2ChannelSelection & 0x04) == 0x04)
|
||||
sb.Append("2 ");
|
||||
if ((page.OutputPort2ChannelSelection & 0x08) == 0x08)
|
||||
sb.Append("3 ");
|
||||
|
||||
switch (page.OutputPort2Volume)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendLine("muted");
|
||||
break;
|
||||
case 0xFF:
|
||||
sb.AppendLine("at maximum volume");
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("at volume {0}", page.OutputPort2Volume).AppendLine();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (page.OutputPort3ChannelSelection > 0)
|
||||
{
|
||||
sb.Append("Output port 3 has channels ");
|
||||
if ((page.OutputPort3ChannelSelection & 0x01) == 0x01)
|
||||
sb.Append("0 ");
|
||||
if ((page.OutputPort3ChannelSelection & 0x02) == 0x02)
|
||||
sb.Append("1 ");
|
||||
if ((page.OutputPort3ChannelSelection & 0x04) == 0x04)
|
||||
sb.Append("2 ");
|
||||
if ((page.OutputPort3ChannelSelection & 0x08) == 0x08)
|
||||
sb.Append("3 ");
|
||||
|
||||
switch (page.OutputPort3Volume)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendLine("muted");
|
||||
break;
|
||||
case 0xFF:
|
||||
sb.AppendLine("at maximum volume");
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("at volume {0}", page.OutputPort3Volume).AppendLine();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion Mode Page 0x0E: CD-ROM audio control parameters page
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user