diff --git a/CHANGELIST.md b/CHANGELIST.md
index 0bff0e43..29ef6383 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -60,6 +60,7 @@
- Update to DIC 20230606
- Update redumper to build 166
- Unblock Redumper DVD support
+- Support Redumper DVD layerbreak
### 2.5 (2023-03-12)
diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs
index 6edbe68f..9fd1062e 100644
--- a/MPF.Modules/Redumper/Parameters.cs
+++ b/MPF.Modules/Redumper/Parameters.cs
@@ -286,7 +286,8 @@ namespace MPF.Modules.Redumper
info.SizeAndChecksums.SHA1 = sha1;
}
- // TODO: Get layerbreak info
+ string layerbreak = GetLayerbreak($"{basePath}.log") ?? string.Empty;
+ info.SizeAndChecksums.Layerbreak = !string.IsNullOrEmpty(layerbreak) ? Int64.Parse(layerbreak) : default;
break;
}
@@ -1146,11 +1147,11 @@ namespace MPF.Modules.Redumper
}
///
- /// Get the non-zero data start from the input file, if possible
+ /// Get the layerbreak from the input file, if possible
///
/// Log file location
- /// Non-zero dta start if possible, null on error
- private static string GetRingNonZeroDataStart(string log)
+ /// Layerbreak if possible, null on error
+ private static string GetLayerbreak(string log)
{
// If the file doesn't exist, we can't get info from it
if (!File.Exists(log))
@@ -1160,16 +1161,33 @@ namespace MPF.Modules.Redumper
{
try
{
- // If we find the sample range, return the start value only
- string line;
+ // Fast forward to the disc structure lines
+ while (!sr.EndOfStream && !sr.ReadLine().Trim().StartsWith("layer 0")) ;
+ if (sr.EndOfStream)
+ return null;
+
+ // Now that we're at the relevant lines, find the error count
+ string layerbreak = null;
while (!sr.EndOfStream)
{
- line = sr.ReadLine().TrimStart();
- if (line.StartsWith("non-zero data sample range"))
- return line.Substring("non-zero data sample range: [".Length).Trim().Split(' ')[0];
+ string line = sr.ReadLine()?.Trim();
+
+ // Single-layer discs have no layerbreak
+ if (line.Contains("layers count: 1"))
+ {
+ return null;
+ }
+
+ // Dual-layer discs have a regular layerbreak
+ else if (line.StartsWith("data "))
+ {
+ // data { LBA: .. , length: , hLBA: .. }
+ string[] split = line.Split(' ').Where(s => !string.IsNullOrEmpty(s)).ToArray();
+ layerbreak = layerbreak == null ? split[7].TrimEnd(',') : layerbreak;
+ }
}
- // We couldn't detect it then
+ // If we get to the end, there's an issue
return null;
}
catch
@@ -1218,6 +1236,41 @@ namespace MPF.Modules.Redumper
}
}
+ ///
+ /// Get the non-zero data start from the input file, if possible
+ ///
+ /// Log file location
+ /// Non-zero dta start if possible, null on error
+ private static string GetRingNonZeroDataStart(string log)
+ {
+ // If the file doesn't exist, we can't get info from it
+ if (!File.Exists(log))
+ return null;
+
+ using (StreamReader sr = File.OpenText(log))
+ {
+ try
+ {
+ // If we find the sample range, return the start value only
+ string line;
+ while (!sr.EndOfStream)
+ {
+ line = sr.ReadLine().TrimStart();
+ if (line.StartsWith("non-zero data sample range"))
+ return line.Substring("non-zero data sample range: [".Length).Trim().Split(' ')[0];
+ }
+
+ // We couldn't detect it then
+ return null;
+ }
+ catch
+ {
+ // We don't care what the exception is right now
+ return null;
+ }
+ }
+ }
+
///
/// Get the build info from a Saturn disc, if possible
///