mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add memory usage snapshots in debug console when opening dicformat.
This commit is contained in:
@@ -58,6 +58,7 @@ namespace DiscImageChef.DiscImages
|
||||
{
|
||||
public bool Open(IFilter imageFilter)
|
||||
{
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
imageStream = imageFilter.GetDataForkStream();
|
||||
imageStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
@@ -74,6 +75,7 @@ namespace DiscImageChef.DiscImages
|
||||
imageInfo.ApplicationVersion = $"{header.applicationMajorVersion}.{header.applicationMinorVersion}";
|
||||
imageInfo.Version = $"{header.imageMajorVersion}.{header.imageMinorVersion}";
|
||||
imageInfo.MediaType = header.mediaType;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
// Read the index header
|
||||
imageStream.Position = (long)header.indexOffset;
|
||||
@@ -85,6 +87,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Index at {0} contains {1} entries",
|
||||
header.indexOffset, idxHeader.entries);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
// Fill in-memory index
|
||||
index = new List<IndexEntry>();
|
||||
@@ -98,6 +101,7 @@ namespace DiscImageChef.DiscImages
|
||||
entry.dataType, entry.offset);
|
||||
index.Add(entry);
|
||||
}
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
imageInfo.ImageSize = 0;
|
||||
|
||||
@@ -148,6 +152,7 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
"Found data block type {0} at position {1}", entry.dataType,
|
||||
entry.offset);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
// Decompress media tag
|
||||
if(blockHeader.compression == CompressionType.Lzma || blockHeader.compression ==
|
||||
@@ -181,11 +186,13 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
"Took {0} seconds to decompress block",
|
||||
(endDecompress - startDecompress).TotalSeconds);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
}
|
||||
else if(blockHeader.compression == CompressionType.None)
|
||||
{
|
||||
data = new byte[blockHeader.length];
|
||||
imageStream.Read(data, 0, (int)blockHeader.length);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -221,6 +228,7 @@ namespace DiscImageChef.DiscImages
|
||||
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
|
||||
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
|
||||
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case DataType.CdSectorSuffix:
|
||||
case DataType.CdSectorSuffixCorrected:
|
||||
@@ -241,11 +249,13 @@ namespace DiscImageChef.DiscImages
|
||||
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ);
|
||||
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
|
||||
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case DataType.CdSectorSubchannel:
|
||||
sectorSubchannel = data;
|
||||
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
|
||||
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case DataType.AppleProfileTag:
|
||||
case DataType.AppleSonyTag:
|
||||
@@ -253,9 +263,11 @@ namespace DiscImageChef.DiscImages
|
||||
sectorSubchannel = data;
|
||||
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
|
||||
imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case DataType.CompactDiscMode2Subheader:
|
||||
mode2Subheaders = data;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
default:
|
||||
MediaTagType mediaTagType = GetMediaTagTypeForDataType(blockHeader.type);
|
||||
@@ -270,6 +282,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
|
||||
mediaTags.Add(mediaTagType, data);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -287,6 +300,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
imageInfo.Sectors = ddtHeader.entries;
|
||||
shift = ddtHeader.shift;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
// Check for DDT compression
|
||||
switch(ddtHeader.compression)
|
||||
@@ -310,10 +324,12 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
"Took {0} seconds to decompress DDT",
|
||||
(ddtEnd - ddtStart).TotalSeconds);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case CompressionType.None:
|
||||
inMemoryDdt = false;
|
||||
outMemoryDdtPosition = (long)entry.offset;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
default:
|
||||
throw new
|
||||
@@ -334,6 +350,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
uint[] cdDdt = new uint[ddtHeader.entries];
|
||||
byte[] decompressedDdt = new byte[ddtHeader.length];
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
// Check for DDT compression
|
||||
switch(ddtHeader.compression)
|
||||
@@ -354,9 +371,11 @@ namespace DiscImageChef.DiscImages
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
"Took {0} seconds to decompress DDT",
|
||||
(ddtEnd - ddtStart).TotalSeconds);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case CompressionType.None:
|
||||
imageStream.Read(decompressedDdt, 0, decompressedDdt.Length);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
default:
|
||||
throw new
|
||||
@@ -367,6 +386,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
if(entry.dataType == DataType.CdSectorPrefixCorrected) sectorPrefixDdt = cdDdt;
|
||||
else if(entry.dataType == DataType.CdSectorSuffixCorrected) sectorSuffixDdt = cdDdt;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -384,6 +404,7 @@ namespace DiscImageChef.DiscImages
|
||||
imageInfo.Cylinders = geometryBlock.cylinders;
|
||||
imageInfo.Heads = geometryBlock.heads;
|
||||
imageInfo.SectorsPerTrack = geometryBlock.sectorsPerTrack;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -554,6 +575,7 @@ namespace DiscImageChef.DiscImages
|
||||
imageInfo.DriveFirmwareRevision);
|
||||
}
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
// Optical disc tracks block
|
||||
case BlockType.TracksBlock:
|
||||
@@ -614,6 +636,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
imageInfo.HasPartitions = true;
|
||||
imageInfo.HasSessions = true;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
// CICM XML metadata block
|
||||
case BlockType.CicmBlock:
|
||||
@@ -625,6 +648,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
"Found CICM XML metadata block at position {0}", entry.offset);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
byte[] cicmBytes = new byte[cicmBlock.length];
|
||||
imageStream.Read(cicmBytes, 0, cicmBytes.Length);
|
||||
@@ -643,6 +667,7 @@ namespace DiscImageChef.DiscImages
|
||||
CicmMetadata = null;
|
||||
}
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
// Dump hardware block
|
||||
case BlockType.DumpHardwareBlock:
|
||||
@@ -654,6 +679,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin",
|
||||
"Found dump hardware block at position {0}", entry.offset);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
structureBytes = new byte[dumpBlock.length];
|
||||
imageStream.Read(structureBytes, 0, structureBytes.Length);
|
||||
@@ -763,6 +789,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
|
||||
if(DumpHardware.Count == 0) DumpHardware = null;
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -784,16 +811,19 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
imageInfo.XmlMediaType = GetXmlMediaType(header.mediaType);
|
||||
imageInfo.ReadableMediaTags.AddRange(mediaTags.Keys);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
// Initialize caches
|
||||
blockCache = new Dictionary<ulong, byte[]>();
|
||||
blockHeaderCache = new Dictionary<ulong, BlockHeader>();
|
||||
currentCacheSize = 0;
|
||||
if(!inMemoryDdt) ddtEntryCache = new Dictionary<ulong, ulong>();
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
// Initialize tracks, sessions and partitions
|
||||
if(imageInfo.XmlMediaType == XmlMediaType.OpticalDisc)
|
||||
{
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
if(Tracks == null || Tracks.Count == 0)
|
||||
{
|
||||
Tracks = new List<Track>
|
||||
@@ -816,6 +846,7 @@ namespace DiscImageChef.DiscImages
|
||||
trackFlags = new Dictionary<byte, byte> {{1, (byte)CdFlags.DataTrack}};
|
||||
trackIsrcs = new Dictionary<byte, string>();
|
||||
}
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
Sessions = new List<Session>();
|
||||
for(int i = 1; i <= Tracks.Max(t => t.TrackSession); i++)
|
||||
@@ -828,6 +859,7 @@ namespace DiscImageChef.DiscImages
|
||||
Tracks.Where(t => t.TrackSession == i).Min(t => t.TrackStartSector),
|
||||
EndSector = Tracks.Where(t => t.TrackSession == i).Max(t => t.TrackEndSector)
|
||||
});
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
ulong currentTrackOffset = 0;
|
||||
Partitions = new List<Partition>();
|
||||
@@ -848,6 +880,7 @@ namespace DiscImageChef.DiscImages
|
||||
currentTrackOffset += (track.TrackEndSector - track.TrackStartSector + 1) *
|
||||
(ulong)track.TrackBytesPerSector;
|
||||
}
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
Track[] tracks = Tracks.ToArray();
|
||||
for(int i = 0; i < tracks.Length; i++)
|
||||
@@ -866,8 +899,10 @@ namespace DiscImageChef.DiscImages
|
||||
tracks[i].TrackSubchannelFilter = tracks[i].TrackFilter;
|
||||
tracks[i].TrackSubchannelType = TrackSubchannelType.Raw;
|
||||
}
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
|
||||
Tracks = tracks.ToList();
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -880,6 +915,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
if(sectorSuffixDdt != null) EccInit();
|
||||
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -922,11 +958,13 @@ namespace DiscImageChef.DiscImages
|
||||
blockHeader = Marshal.SpanToStructureLittleEndian<BlockHeader>(structureBytes);
|
||||
|
||||
// Decompress block
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
switch(blockHeader.compression)
|
||||
{
|
||||
case CompressionType.None:
|
||||
block = new byte[blockHeader.length];
|
||||
imageStream.Read(block, 0, (int)blockHeader.length);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case CompressionType.Lzma:
|
||||
byte[] compressedBlock = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH];
|
||||
@@ -939,6 +977,7 @@ namespace DiscImageChef.DiscImages
|
||||
lzmaBlock.Read(block, 0, (int)blockHeader.length);
|
||||
lzmaBlock.Close();
|
||||
compressedBlockMs.Close();
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
case CompressionType.Flac:
|
||||
byte[] flacBlock = new byte[blockHeader.cmpLength];
|
||||
@@ -951,6 +990,7 @@ namespace DiscImageChef.DiscImages
|
||||
flakeReader.Read(audioBuffer, samples);
|
||||
flakeReader.Close();
|
||||
flacMs.Close();
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
break;
|
||||
default:
|
||||
throw new
|
||||
@@ -972,6 +1012,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
sector = new byte[blockHeader.sectorSize];
|
||||
Array.Copy(block, (long)(offset * blockHeader.sectorSize), sector, 0, blockHeader.sectorSize);
|
||||
DicConsole.DebugWriteLine("DiscImageChef format plugin", "Memory snapshot: {0} bytes", GC.GetTotalMemory(false));
|
||||
return sector;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user