From 7b8becfa40c20693c80479fbe68c42ad5bad69bb Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 31 Dec 2024 21:41:32 -0500 Subject: [PATCH] Update RedumpLib to 1.6.4 (fixes #805) --- CHANGELIST.md | 1 + MPF.CLI/MPF.CLI.csproj | 2 +- MPF.Check/MPF.Check.csproj | 2 +- .../MPF.ExecutionContexts.Test.csproj | 2 +- .../MPF.ExecutionContexts.csproj | 2 +- MPF.Frontend.Test/MPF.Frontend.Test.csproj | 2 +- MPF.Frontend/MPF.Frontend.csproj | 2 +- MPF.Frontend/ViewModels/MainViewModel.cs | 3 +- .../MPF.Processors.Test.csproj | 2 +- MPF.Processors.Test/RedumperTests.cs | 29 ++++++++++++++ .../TestData/Redumper/CDROM/test.log | 4 ++ MPF.Processors/MPF.Processors.csproj | 2 +- MPF.Processors/Redumper.cs | 38 +++++++++++++++++++ MPF.UI/MPF.UI.csproj | 2 +- MPF.UI/Windows/DiscInformationWindow.xaml | 2 + MPF.UI/Windows/DiscInformationWindow.xaml.cs | 3 ++ 16 files changed, 88 insertions(+), 10 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index ad1c401d..df808e8f 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -157,6 +157,7 @@ - Add and use internal program short names - Fix BinaryObjectScanner update - Fix short name test +- Update RedumpLib to 1.6.4 ### 3.2.4 (2024-11-24) diff --git a/MPF.CLI/MPF.CLI.csproj b/MPF.CLI/MPF.CLI.csproj index b09399f6..fcfd123d 100644 --- a/MPF.CLI/MPF.CLI.csproj +++ b/MPF.CLI/MPF.CLI.csproj @@ -43,7 +43,7 @@ - + \ No newline at end of file diff --git a/MPF.Check/MPF.Check.csproj b/MPF.Check/MPF.Check.csproj index 8905af41..5bda70a0 100644 --- a/MPF.Check/MPF.Check.csproj +++ b/MPF.Check/MPF.Check.csproj @@ -43,7 +43,7 @@ - + \ No newline at end of file diff --git a/MPF.ExecutionContexts.Test/MPF.ExecutionContexts.Test.csproj b/MPF.ExecutionContexts.Test/MPF.ExecutionContexts.Test.csproj index 13a0592c..00a1b262 100644 --- a/MPF.ExecutionContexts.Test/MPF.ExecutionContexts.Test.csproj +++ b/MPF.ExecutionContexts.Test/MPF.ExecutionContexts.Test.csproj @@ -17,7 +17,7 @@ - + diff --git a/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj b/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj index 22540d70..cb1f4e3e 100644 --- a/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj +++ b/MPF.ExecutionContexts/MPF.ExecutionContexts.csproj @@ -32,7 +32,7 @@ - + \ No newline at end of file diff --git a/MPF.Frontend.Test/MPF.Frontend.Test.csproj b/MPF.Frontend.Test/MPF.Frontend.Test.csproj index b68eb4dc..fcb5deef 100644 --- a/MPF.Frontend.Test/MPF.Frontend.Test.csproj +++ b/MPF.Frontend.Test/MPF.Frontend.Test.csproj @@ -17,7 +17,7 @@ - + diff --git a/MPF.Frontend/MPF.Frontend.csproj b/MPF.Frontend/MPF.Frontend.csproj index 4fd63653..6538892b 100644 --- a/MPF.Frontend/MPF.Frontend.csproj +++ b/MPF.Frontend/MPF.Frontend.csproj @@ -43,7 +43,7 @@ - + \ No newline at end of file diff --git a/MPF.Frontend/ViewModels/MainViewModel.cs b/MPF.Frontend/ViewModels/MainViewModel.cs index b200fe96..704cd7f0 100644 --- a/MPF.Frontend/ViewModels/MainViewModel.cs +++ b/MPF.Frontend/ViewModels/MainViewModel.cs @@ -867,7 +867,8 @@ namespace MPF.Frontend.ViewModels CommentsSpecialFields = new Dictionary() { [SiteCode.ISBN] = "ISBN", - [SiteCode.RingNonZeroDataStart] = "+123" + [SiteCode.RingNonZeroDataStart] = "+123", + [SiteCode.RingPerfectAudioOffset] = "+0" }, Contents = "Special contents 1\r\nSpecial contents 2", ContentsSpecialFields = new Dictionary() diff --git a/MPF.Processors.Test/MPF.Processors.Test.csproj b/MPF.Processors.Test/MPF.Processors.Test.csproj index e89c7e7f..4b49d10e 100644 --- a/MPF.Processors.Test/MPF.Processors.Test.csproj +++ b/MPF.Processors.Test/MPF.Processors.Test.csproj @@ -27,7 +27,7 @@ - + diff --git a/MPF.Processors.Test/RedumperTests.cs b/MPF.Processors.Test/RedumperTests.cs index c295335c..f7b29e97 100644 --- a/MPF.Processors.Test/RedumperTests.cs +++ b/MPF.Processors.Test/RedumperTests.cs @@ -816,6 +816,35 @@ namespace MPF.Processors.Test #endregion + #region GetRingPerfectAudioOffset + + [Fact] + public void GetRingPerfectAudioOffset_Empty_Null() + { + string log = string.Empty; + string? actual = Redumper.GetRingPerfectAudioOffset(log); + Assert.Null(actual); + } + + [Fact] + public void GetRingPerfectAudioOffset_Invalid_Null() + { + string log = "INVALID"; + string? actual = Redumper.GetRingPerfectAudioOffset(log); + Assert.Null(actual); + } + + [Fact] + public void GetRingPerfectAudioOffset_Valid_Filled() + { + string? expected = "+0"; + string log = Path.Combine(Environment.CurrentDirectory, "TestData", "Redumper", "CDROM", "test.log"); + string? actual = Redumper.GetRingPerfectAudioOffset(log); + Assert.Equal(expected, actual); + } + + #endregion + #region GetSaturnBuildInfo [Fact] diff --git a/MPF.Processors.Test/TestData/Redumper/CDROM/test.log b/MPF.Processors.Test/TestData/Redumper/CDROM/test.log index e01d6abb..b2fe2044 100644 --- a/MPF.Processors.Test/TestData/Redumper/CDROM/test.log +++ b/MPF.Processors.Test/TestData/Redumper/CDROM/test.log @@ -98,6 +98,10 @@ PVD: << GetRingNonZeroDataStart >> non-zero data sample range: [12345 23456] +<< GetRingPerfectAudioOffset >> +Perfect Audio Offset (silence level: 0): [-2553 .. +10213] +fallback offset 0 applied + << GetSaturnHeader >> SS [ build date: date diff --git a/MPF.Processors/MPF.Processors.csproj b/MPF.Processors/MPF.Processors.csproj index 2caf7db3..456b9aa3 100644 --- a/MPF.Processors/MPF.Processors.csproj +++ b/MPF.Processors/MPF.Processors.csproj @@ -43,7 +43,7 @@ - + diff --git a/MPF.Processors/Redumper.cs b/MPF.Processors/Redumper.cs index 7249c7a7..86c380ff 100644 --- a/MPF.Processors/Redumper.cs +++ b/MPF.Processors/Redumper.cs @@ -82,6 +82,8 @@ namespace MPF.Processors { string ringNonZeroDataStart = GetRingNonZeroDataStart($"{basePath}.log") ?? string.Empty; info.CommonDiscInfo.CommentsSpecialFields![SiteCode.RingNonZeroDataStart] = ringNonZeroDataStart; + string ringPerfectAudioOffset = GetRingPerfectAudioOffset($"{basePath}.log") ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields![SiteCode.RingPerfectAudioOffset] = ringPerfectAudioOffset; } break; @@ -1602,6 +1604,42 @@ namespace MPF.Processors } } + /// + /// Get the perfect audio offset from the input file, if possible + /// + /// Log file location + /// Non-zero dta start if possible, null on error + internal static string? GetRingPerfectAudioOffset(string log) + { + // If the file doesn't exist, we can't get info from it + if (string.IsNullOrEmpty(log)) + return null; + if (!File.Exists(log)) + return null; + + try + { + // If we fallback offset, only return if the value is 0 + using var sr = File.OpenText(log); + while (!sr.EndOfStream) + { + string? line = sr.ReadLine()?.TrimStart(); + if (line?.StartsWith("fallback offset 0 applied") == true) + return "+0"; + else if (line?.StartsWith("fallback offset") == true) + return null; // TODO: Return all fallback offsets? + } + + // 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 /// diff --git a/MPF.UI/MPF.UI.csproj b/MPF.UI/MPF.UI.csproj index 64888ad4..9865f880 100644 --- a/MPF.UI/MPF.UI.csproj +++ b/MPF.UI/MPF.UI.csproj @@ -70,7 +70,7 @@ - + diff --git a/MPF.UI/Windows/DiscInformationWindow.xaml b/MPF.UI/Windows/DiscInformationWindow.xaml index 157acf43..c14d9b6f 100644 --- a/MPF.UI/Windows/DiscInformationWindow.xaml +++ b/MPF.UI/Windows/DiscInformationWindow.xaml @@ -490,6 +490,8 @@ VerticalContentAlignmentValue="Top" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/> + diff --git a/MPF.UI/Windows/DiscInformationWindow.xaml.cs b/MPF.UI/Windows/DiscInformationWindow.xaml.cs index f7f0bf76..9a3b01cc 100644 --- a/MPF.UI/Windows/DiscInformationWindow.xaml.cs +++ b/MPF.UI/Windows/DiscInformationWindow.xaml.cs @@ -79,6 +79,7 @@ namespace MPF.UI.Windows private UserInput? PIC => ItemHelper.FindChild(this, "PIC"); private UserInput? PVD => ItemHelper.FindChild(this, "PVD"); private UserInput? RingNonZeroDataStart => ItemHelper.FindChild(this, "RingNonZeroDataStart"); + private UserInput? RingPerfectAudioOffset => ItemHelper.FindChild(this, "RingPerfectAudioOffset"); private UserInput? SecuROMData => ItemHelper.FindChild(this, "SecuROMData"); private UserInput? SSHash => ItemHelper.FindChild(this, "SSHash"); private UserInput? SecuritySectorRanges => ItemHelper.FindChild(this, "SecuritySectorRanges"); @@ -261,6 +262,8 @@ namespace MPF.UI.Windows PVD!.Visibility = Visibility.Collapsed; if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.RingNonZeroDataStart) != true) RingNonZeroDataStart!.Visibility = Visibility.Collapsed; + if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.RingPerfectAudioOffset) != true) + RingPerfectAudioOffset!.Visibility = Visibility.Collapsed; if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.SecuROMData)) SecuROMData!.Visibility = Visibility.Collapsed; if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSHash) != true)