mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Calculate track sizes and pregaps in media info.
This commit is contained in:
@@ -33,15 +33,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.Linq;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Core;
|
||||
using DiscImageChef.Database;
|
||||
using DiscImageChef.Database.Models;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using DiscImageChef.Decoders.PCMCIA;
|
||||
using DiscImageChef.Decoders.SCSI;
|
||||
using DiscImageChef.Decoders.SCSI.MMC;
|
||||
using DiscImageChef.Decoders.SCSI.SSC;
|
||||
using DiscImageChef.Devices;
|
||||
using Command = System.CommandLine.Command;
|
||||
using Device = DiscImageChef.Devices.Device;
|
||||
using DeviceInfo = DiscImageChef.Core.Devices.Info.DeviceInfo;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
@@ -1066,6 +1071,33 @@ namespace DiscImageChef.Commands
|
||||
|
||||
dev.Close();
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
// Open master database
|
||||
var ctx = DicContext.Create(Settings.Settings.MasterDbPath);
|
||||
|
||||
// Search for device in master database
|
||||
Database.Models.Device dbDev =
|
||||
ctx.Devices.FirstOrDefault(d => d.Manufacturer == dev.Manufacturer && d.Model == dev.Model &&
|
||||
d.Revision == dev.Revision);
|
||||
|
||||
if(dbDev is null)
|
||||
DicConsole.WriteLine("Device not in database, please create a device report and attach it to a Github issue.");
|
||||
else
|
||||
{
|
||||
DicConsole.WriteLine($"Device in database since {dbDev.LastSynchronized}.");
|
||||
|
||||
if(dbDev.OptimalMultipleSectorsRead > 0)
|
||||
DicConsole.WriteLine($"Optimal multiple read is {dbDev.LastSynchronized} sectors.");
|
||||
}
|
||||
|
||||
// Search for read offset in master database
|
||||
CdOffset cdOffset =
|
||||
ctx.CdOffsets.FirstOrDefault(d => d.Manufacturer == dev.Manufacturer && d.Model == dev.Model);
|
||||
|
||||
DicConsole.WriteLine(cdOffset is null ? "CD reading offset not found in database."
|
||||
: $"CD reading offset is {cdOffset.Offset} samples ({cdOffset.Offset * 4} bytes).");
|
||||
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,10 @@ using System.Collections.Generic;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Core;
|
||||
using DiscImageChef.Core.Devices.Dumping;
|
||||
using DiscImageChef.Core.Media.Info;
|
||||
using DiscImageChef.Decoders.Bluray;
|
||||
using DiscImageChef.Decoders.CD;
|
||||
@@ -50,6 +52,7 @@ using BCA = DiscImageChef.Decoders.Bluray.BCA;
|
||||
using Cartridge = DiscImageChef.Decoders.DVD.Cartridge;
|
||||
using DDS = DiscImageChef.Decoders.DVD.DDS;
|
||||
using DMI = DiscImageChef.Decoders.Xbox.DMI;
|
||||
using Session = DiscImageChef.Decoders.CD.Session;
|
||||
using Spare = DiscImageChef.Decoders.DVD.Spare;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
@@ -530,6 +533,38 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.WriteLine("Media identified as {0}", scsiInfo.MediaType);
|
||||
Statistics.AddMedia(scsiInfo.MediaType, true);
|
||||
|
||||
if(scsiInfo.Toc != null ||
|
||||
scsiInfo.RawToc != null)
|
||||
{
|
||||
uint blockSize = 2352;
|
||||
|
||||
Track[] tracks = Dump.GetCdTracks(ref blockSize, dev, scsiInfo.MediaType, null, false,
|
||||
out long lastSector, null, null, null, TrackSubchannelType.None,
|
||||
out _, null, null);
|
||||
|
||||
if(tracks != null)
|
||||
{
|
||||
bool supportsPqSubchannel = Dump.SupportsPqSubchannel(dev, null, null);
|
||||
bool supportsRwSubchannel = Dump.SupportsRwSubchannel(dev, null, null);
|
||||
|
||||
Dump.SolveTrackPregaps(dev, null, null, tracks, supportsPqSubchannel, supportsRwSubchannel);
|
||||
|
||||
for(int t = 1; t < tracks.Length; t++)
|
||||
tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
|
||||
|
||||
tracks[tracks.Length - 1].TrackEndSector = (ulong)lastSector;
|
||||
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Track calculations:");
|
||||
|
||||
foreach(Track track in tracks)
|
||||
DicConsole.
|
||||
WriteLine("Track {0} starts at LBA {1}, ends at LBA {2}, has a pregap of {3} sectors and is of type {4}",
|
||||
track.TrackSequence, track.TrackStartSector, track.TrackEndSector,
|
||||
track.TrackPregap, track.TrackType);
|
||||
}
|
||||
}
|
||||
|
||||
dev.Close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user