mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add an interface for classes able to draw media status, like the spiral.
This commit is contained in:
Submodule Aaru.CommonTypes updated: 1123cae272...c057ea31d1
@@ -284,6 +284,8 @@ partial class Dump
|
||||
outputOptical.WriteSectorsLong(cmdBuf, i + r, 1);
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
|
||||
_opticalDiscSpiral?.PaintSectorGood(i + r);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -395,6 +397,10 @@ partial class Dump
|
||||
}
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
|
||||
if(_opticalDiscSpiral is not null)
|
||||
for(ulong p = 0; p < blocksToRead; p++)
|
||||
_opticalDiscSpiral?.PaintSectorGood(i + p);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -555,6 +555,8 @@ partial class Dump
|
||||
}
|
||||
}
|
||||
|
||||
_opticalDiscSpiral?.PaintSectorGood(i + r);
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
}
|
||||
else
|
||||
@@ -587,6 +589,8 @@ partial class Dump
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
|
||||
_opticalDiscSpiral?.PaintSectorBad(i + r);
|
||||
|
||||
_resume.BadBlocks.Add(i + r);
|
||||
|
||||
AaruConsole.DebugWriteLine("Dump-Media", Localization.Core.READ_error_0,
|
||||
@@ -714,6 +718,10 @@ partial class Dump
|
||||
}
|
||||
}
|
||||
|
||||
if(_opticalDiscSpiral is not null)
|
||||
for(int p = 0; p < blocksToRead; p++)
|
||||
_opticalDiscSpiral?.PaintSectorGood(i + (ulong)p);
|
||||
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -44,6 +44,7 @@ using Aaru.CommonTypes.Extents;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Graphics;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.Database.Models;
|
||||
@@ -1114,6 +1115,23 @@ sealed partial class Dump
|
||||
mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, _maximumReadable, _private);
|
||||
ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0008);
|
||||
|
||||
if(_createGraph)
|
||||
{
|
||||
Spiral.DiscParameters discSpiralParameters = Spiral.DiscParametersFromMediaType(dskType);
|
||||
|
||||
if(discSpiralParameters is not null)
|
||||
{
|
||||
_opticalDiscSpiral = new Spiral((int)_dimensions, (int)_dimensions, discSpiralParameters, blocks);
|
||||
|
||||
foreach(Tuple<ulong, ulong> e in extents.ToArray())
|
||||
for(ulong b = e.Item1; b <= e.Item2; b++)
|
||||
_opticalDiscSpiral?.PaintSectorGood(b);
|
||||
|
||||
foreach(ulong b in _resume.BadBlocks)
|
||||
_opticalDiscSpiral?.PaintSectorBad(b);
|
||||
}
|
||||
}
|
||||
|
||||
audioExtents = new ExtentsULong();
|
||||
|
||||
foreach(Track audioTrack in tracks.Where(t => t.Type == TrackType.Audio))
|
||||
|
||||
@@ -339,6 +339,7 @@ partial class Dump
|
||||
{
|
||||
_resume.BadBlocks.Remove(badSector);
|
||||
extents.Add(badSector);
|
||||
_opticalDiscSpiral?.PaintSectorGood(badSector);
|
||||
|
||||
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_sector_0_in_pass_1, badSector,
|
||||
pass));
|
||||
|
||||
@@ -77,6 +77,7 @@ partial class Dump
|
||||
tmpBuf = new byte[cmdBuf.Length - 4];
|
||||
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
|
||||
mediaTags.Add(MediaTagType.CD_ATIP, tmpBuf);
|
||||
_opticalDiscSpiral?.PaintRecordableInformationGood();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +111,7 @@ partial class Dump
|
||||
tmpBuf = new byte[cmdBuf.Length - 4];
|
||||
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
|
||||
mediaTags.Add(MediaTagType.CD_PMA, tmpBuf);
|
||||
_opticalDiscSpiral?.PaintRecordableInformationGood();
|
||||
}
|
||||
|
||||
_dumpLog.WriteLine(Localization.Core.Reading_Session_Information);
|
||||
|
||||
@@ -223,6 +223,7 @@ partial class Dump
|
||||
{
|
||||
_resume.BadBlocks.Remove(badSector);
|
||||
extents.Add(badSector);
|
||||
_opticalDiscSpiral?.PaintSectorGood(badSector);
|
||||
}
|
||||
|
||||
// Because one block has been partially used to fix the offset
|
||||
|
||||
@@ -41,6 +41,7 @@ using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Core.Graphics;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Database;
|
||||
using Aaru.Devices;
|
||||
@@ -95,11 +96,14 @@ public partial class Dump
|
||||
readonly bool _titleKeys;
|
||||
readonly bool _trim;
|
||||
bool _aborted;
|
||||
readonly bool _createGraph;
|
||||
AaruContext _ctx; // Main database context
|
||||
Database.Models.Device _dbDev; // Device database entry
|
||||
readonly uint _dimensions;
|
||||
bool _dumpFirstTrackPregap;
|
||||
bool _fixOffset;
|
||||
uint _maximumReadable; // Maximum number of sectors drive can read at once
|
||||
Spiral _opticalDiscSpiral;
|
||||
Resume _resume;
|
||||
Sidecar _sidecarClass;
|
||||
uint _skip;
|
||||
@@ -157,7 +161,8 @@ public partial class Dump
|
||||
bool fixOffset, bool debug, DumpSubchannel subchannel, int speed, bool @private,
|
||||
bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel, bool fixSubchannelCrc,
|
||||
bool skipCdireadyHole, ErrorLog errorLog, bool generateSubchannels, uint maximumReadable,
|
||||
bool useBufferedReads, bool storeEncrypted, bool titleKeys, uint ignoreCdrRunOuts)
|
||||
bool useBufferedReads, bool storeEncrypted, bool titleKeys, uint ignoreCdrRunOuts, bool createGraph,
|
||||
uint dimensions)
|
||||
{
|
||||
_doResume = doResume;
|
||||
_dev = dev;
|
||||
@@ -198,6 +203,8 @@ public partial class Dump
|
||||
_storeEncrypted = storeEncrypted;
|
||||
_titleKeys = titleKeys;
|
||||
_ignoreCdrRunOuts = ignoreCdrRunOuts;
|
||||
_createGraph = createGraph;
|
||||
_dimensions = dimensions;
|
||||
}
|
||||
|
||||
/// <summary>Starts dumping with the established fields and autodetecting the device type</summary>
|
||||
@@ -277,6 +284,17 @@ public partial class Dump
|
||||
_resume.LastWriteDate = DateTime.UtcNow;
|
||||
_resume.BadBlocks.Sort();
|
||||
|
||||
if(_createGraph && _opticalDiscSpiral is not null)
|
||||
{
|
||||
foreach(ulong b in _resume.BadBlocks)
|
||||
_opticalDiscSpiral?.PaintSectorBad(b);
|
||||
|
||||
string spiralFilename = $"{_outputPrefix}.graph.png";
|
||||
var spiralFs = new FileStream(spiralFilename, FileMode.Create);
|
||||
_opticalDiscSpiral.WriteToStream(spiralFs);
|
||||
spiralFs.Close();
|
||||
}
|
||||
|
||||
if(File.Exists(_outputPrefix + ".resume.xml"))
|
||||
File.Delete(_outputPrefix + ".resume.xml");
|
||||
|
||||
|
||||
@@ -214,6 +214,10 @@ partial class Dump
|
||||
outputFormat.WriteSectors(buffer, i, blocksToRead);
|
||||
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds;
|
||||
extents.Add(i, blocksToRead, true);
|
||||
|
||||
if(_opticalDiscSpiral is not null)
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
_opticalDiscSpiral.PaintSectorGood(i + (ulong)b);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -44,8 +44,10 @@ using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.CommonTypes.Structs;
|
||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Console;
|
||||
using Aaru.Core.Graphics;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Core.Media.Detection;
|
||||
using Aaru.Decoders.Bluray;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
@@ -702,6 +704,29 @@ partial class Dump
|
||||
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
|
||||
_private, _force);
|
||||
|
||||
if(_createGraph)
|
||||
{
|
||||
bool discIs80Mm =
|
||||
(mediaTags?.TryGetValue(MediaTagType.DVD_PFI, out byte[] pfiBytes) == true &&
|
||||
PFI.Decode(pfiBytes, dskType)?.DiscSize == DVDSize.Eighty) ||
|
||||
(mediaTags?.TryGetValue(MediaTagType.BD_DI, out byte[] diBytes) == true && DI.
|
||||
Decode(diBytes)?.Units?.Any(s => s.DiscSize == DI.BluSize.Eighty) == true);
|
||||
|
||||
Spiral.DiscParameters discSpiralParameters = Spiral.DiscParametersFromMediaType(dskType, discIs80Mm);
|
||||
|
||||
if(discSpiralParameters is not null)
|
||||
{
|
||||
_opticalDiscSpiral = new Spiral((int)_dimensions, (int)_dimensions, discSpiralParameters, blocks);
|
||||
|
||||
foreach(Tuple<ulong, ulong> e in extents.ToArray())
|
||||
for(ulong b = e.Item1; b <= e.Item2; b++)
|
||||
_opticalDiscSpiral?.PaintSectorGood(b);
|
||||
|
||||
foreach(ulong b in _resume.BadBlocks)
|
||||
_opticalDiscSpiral?.PaintSectorBad(b);
|
||||
}
|
||||
}
|
||||
|
||||
if(currentTry == null ||
|
||||
extents == null)
|
||||
{
|
||||
|
||||
@@ -278,6 +278,7 @@ partial class Dump
|
||||
_resume.BadBlocks.Remove(badSector);
|
||||
extents.Add(badSector);
|
||||
outputFormat.WriteSector(buffer, badSector);
|
||||
_opticalDiscSpiral?.PaintSectorGood(badSector);
|
||||
|
||||
UpdateStatus?.Invoke(string.Format(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector,
|
||||
pass));
|
||||
|
||||
@@ -91,6 +91,7 @@ partial class Dump
|
||||
_resume.BadBlocks.Remove(badSector);
|
||||
extents.Add(badSector);
|
||||
outputFormat.WriteSector(buffer, badSector);
|
||||
_opticalDiscSpiral?.PaintSectorGood(badSector);
|
||||
}
|
||||
|
||||
if(newBlank)
|
||||
|
||||
@@ -833,7 +833,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
||||
StopOnError, _resume, dumpLog, encoding, _outputPrefix, Destination, parsedOptions, _sidecar,
|
||||
(uint)Skipped, ExistingMetadata == false, Trim == false, Track1Pregap, true, false,
|
||||
DumpSubchannel.Any, 0, false, false, false, false, false, true, errorLog, false, 64, true,
|
||||
true, false, 10);
|
||||
true, false, 10, true, 1080);
|
||||
|
||||
new Thread(DoWork).Start();
|
||||
}
|
||||
|
||||
12
Aaru.Localization/UI.Designer.cs
generated
12
Aaru.Localization/UI.Designer.cs
generated
@@ -5865,5 +5865,17 @@ namespace Aaru.Localization {
|
||||
return ResourceManager.GetString("Verify_dimensions_paramater_help", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Create_graph_of_dumped_media {
|
||||
get {
|
||||
return ResourceManager.GetString("Create_graph_of_dumped_media", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Dump_graph_dimensions_argument_help {
|
||||
get {
|
||||
return ResourceManager.GetString("Dump_graph_dimensions_argument_help", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3006,4 +3006,10 @@ Do you want to continue?</value>
|
||||
<data name="Verify_dimensions_paramater_help" xml:space="preserve">
|
||||
<value>Dimensions, as a square, in pixels, for the graph of verified disc.</value>
|
||||
</data>
|
||||
<data name="Create_graph_of_dumped_media" xml:space="preserve">
|
||||
<value>Create graph of dumped media. Currently only supported for CD/DVD/BD/GD/UMD.</value>
|
||||
</data>
|
||||
<data name="Dump_graph_dimensions_argument_help" xml:space="preserve">
|
||||
<value>Dimensions in pixels of the square that will contain the graph of dumped media.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -203,6 +203,16 @@ sealed class DumpMediaCommand : Command
|
||||
"--ignore-cdr-runouts"
|
||||
}, () => 10, UI.How_many_CDRW_run_out_sectors_to_ignore_and_regenerate));
|
||||
|
||||
Add(new Option<bool>(new[]
|
||||
{
|
||||
"--create-graph", "-g"
|
||||
}, () => true, UI.Create_graph_of_dumped_media));
|
||||
|
||||
Add(new Option<uint>(new[]
|
||||
{
|
||||
"--dimensions"
|
||||
}, () => 1080, UI.Dump_graph_dimensions_argument_help));
|
||||
|
||||
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
|
||||
}
|
||||
|
||||
@@ -213,7 +223,7 @@ sealed class DumpMediaCommand : Command
|
||||
bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel,
|
||||
bool fixSubchannelCrc, bool generateSubchannels, bool skipCdiReadyHole, bool eject,
|
||||
uint maxBlocks, bool useBufferedReads, bool storeEncrypted, bool titleKeys,
|
||||
uint ignoreCdrRunOuts)
|
||||
uint ignoreCdrRunOuts, bool createGraph, uint dimensions)
|
||||
{
|
||||
MainClass.PrintCopyright();
|
||||
|
||||
@@ -282,6 +292,8 @@ sealed class DumpMediaCommand : Command
|
||||
AaruConsole.DebugWriteLine("Dump-Media command", "--store-encrypted={0}", storeEncrypted);
|
||||
AaruConsole.DebugWriteLine("Dump-Media command", "--title-keys={0}", titleKeys);
|
||||
AaruConsole.DebugWriteLine("Dump-Media command", "--ignore-cdr-runouts={0}", ignoreCdrRunOuts);
|
||||
AaruConsole.DebugWriteLine("Dump-Media command", "--create-graph={0}", createGraph);
|
||||
AaruConsole.DebugWriteLine("Dump-Media command", "--dimensions={0}", dimensions);
|
||||
|
||||
// TODO: Disabled temporarily
|
||||
//AaruConsole.DebugWriteLine("Dump-Media command", "--raw={0}", raw);
|
||||
@@ -557,7 +569,7 @@ sealed class DumpMediaCommand : Command
|
||||
fixOffset, debug, wantedSubchannel, speed, @private, fixSubchannelPosition,
|
||||
retrySubchannel, fixSubchannel, fixSubchannelCrc, skipCdiReadyHole, errorLog,
|
||||
generateSubchannels, maxBlocks, useBufferedReads, storeEncrypted, titleKeys,
|
||||
ignoreCdrRunOuts);
|
||||
ignoreCdrRunOuts, createGraph, dimensions);
|
||||
|
||||
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
|
||||
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
|
||||
|
||||
Reference in New Issue
Block a user