From 193e9aa7dcded7b6bc7c8a020a80993fb74e3132 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 8 Apr 2021 17:33:46 +1000 Subject: [PATCH] Put AviWriter and its imports (and usages) behind #if AVI_SUPPORT for now it's defined even on Linux, try removing it in /src/MainSlnCommon.props --- src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs | 8 +++++++- .../AVOut/SynclessRecordingTools.cs | 13 +++++++++++-- src/BizHawk.Client.EmuHawk/MainForm.Designer.cs | 1 - src/BizHawk.Client.EmuHawk/MainForm.Events.cs | 5 ----- src/BizHawk.Client.EmuHawk/MainForm.cs | 9 +++++++++ src/BizHawk.Common/Win32/AVIWriterImports.cs | 2 ++ src/MainSlnCommon.props | 1 + 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs index c13689a8cf..968e2173fa 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs @@ -1,4 +1,5 @@ -using System; +#if AVI_SUPPORT +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -460,10 +461,12 @@ namespace BizHawk.Client.EmuHawk public static void DeallocateAVICOMPRESSOPTIONS(ref AVIWriterImports.AVICOMPRESSOPTIONS opts) { +#endif #if false // test: increase stability by never freeing anything, ever if (opts.lpParms != IntPtr.Zero) Win32Imports.HeapFree(Win32Imports.GetProcessHeap(), 0, opts.lpParms); if (opts.lpFormat != IntPtr.Zero) Win32Imports.HeapFree(Win32Imports.GetProcessHeap(), 0, opts.lpFormat); #endif +#if AVI_SUPPORT opts.lpParms = IntPtr.Zero; opts.lpFormat = IntPtr.Zero; } @@ -985,6 +988,7 @@ namespace BizHawk.Client.EmuHawk public bool UsesVideo => true; +#endif #if false // API has changed private static void TestAVI() { @@ -1017,5 +1021,7 @@ namespace BizHawk.Client.EmuHawk aw.CloseFile(); } #endif +#if AVI_SUPPORT } } +#endif diff --git a/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs b/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs index d88e70e4b6..b91365563d 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs @@ -12,13 +12,18 @@ namespace BizHawk.Client.EmuHawk { public partial class SynclessRecordingTools : Form, IDialogParent { - private readonly List _mFrameInfos = new List(); private readonly Config _config; + private readonly IGameInfo _game; - private string _mSynclessConfigFile; +#if AVI_SUPPORT + private readonly List _mFrameInfos = new List(); + private string _mFramesDirectory; + private string _mSynclessConfigFile; +#endif + public IDialogController DialogController { get; } public SynclessRecordingTools(Config config, IGameInfo game, IDialogController dialogController) @@ -29,6 +34,7 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); } +#if AVI_SUPPORT public void Run() { var ofd = new OpenFileDialog @@ -97,9 +103,11 @@ namespace BizHawk.Client.EmuHawk public string WavPath { get; set; } public string PngPath { get; set; } } +#endif private void BtnExport_Click(object sender, EventArgs e) { +#if AVI_SUPPORT if (_mFrameInfos.Count == 0) { return; @@ -151,6 +159,7 @@ namespace BizHawk.Client.EmuHawk } avw.CloseFile(); +#endif } } } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/src/BizHawk.Client.EmuHawk/MainForm.Designer.cs index 8c11436c22..2be8134ba7 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -869,7 +869,6 @@ namespace BizHawk.Client.EmuHawk // SynclessRecordingMenuItem // this.SynclessRecordingMenuItem.Text = "S&yncless Recording Tools"; - this.SynclessRecordingMenuItem.Click += new System.EventHandler(this.SynclessRecordingMenuItem_Click); // // ScreenshotSubMenu // diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index 01c6e39e4f..1c3993f780 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -532,11 +532,6 @@ namespace BizHawk.Client.EmuHawk StopAv(); } - private void SynclessRecordingMenuItem_Click(object sender, EventArgs e) - { - new SynclessRecordingTools(Config, Game, this).Run(); - } - private void CaptureOSDMenuItem_Click(object sender, EventArgs e) { bool c = ((ToolStripMenuItem)sender).Checked; diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index dbb6e025e9..81e613c8ab 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -344,6 +344,11 @@ namespace BizHawk.Client.EmuHawk ZXSpectrumExportSnapshotMenuItemMenuItem.Enabled = false; ZXSpectrumExportSnapshotMenuItemMenuItem.Visible = false; #endif +#if AVI_SUPPORT + SynclessRecordingMenuItem.Click += (_, _) => new SynclessRecordingTools(Config, Game, this).Run(); +#else + SynclessRecordingMenuItem.Enabled = false; +#endif Game = GameInfo.NullInstance; _throttle = new Throttle(); @@ -3229,7 +3234,11 @@ namespace BizHawk.Client.EmuHawk try { +#if AVI_SUPPORT bool usingAvi = aw is AviWriter; // SO GROSS! +#else + const bool usingAvi = false; +#endif if (_dumpaudiosync) { diff --git a/src/BizHawk.Common/Win32/AVIWriterImports.cs b/src/BizHawk.Common/Win32/AVIWriterImports.cs index 015844908f..a81316faae 100644 --- a/src/BizHawk.Common/Win32/AVIWriterImports.cs +++ b/src/BizHawk.Common/Win32/AVIWriterImports.cs @@ -1,5 +1,6 @@ #nullable disable +#if AVI_SUPPORT using System; using System.Runtime.InteropServices; @@ -139,3 +140,4 @@ namespace BizHawk.Common public static extern int AVIStreamWrite(IntPtr pavi, int lStart, int lSamples, IntPtr lpBuffer, int cbBuffer, int dwFlags, IntPtr plSampWritten, out int plBytesWritten); } } +#endif diff --git a/src/MainSlnCommon.props b/src/MainSlnCommon.props index 638a1b414b..3917cc0b42 100644 --- a/src/MainSlnCommon.props +++ b/src/MainSlnCommon.props @@ -3,6 +3,7 @@ false $(ProjectDir)../../Common.ruleset + $(DefineConstants);AVI_SUPPORT $(ProjectDir)bin/doc_comments.xml NU1702 CS1573;CS1591