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
This commit is contained in:
YoshiRulz 2021-04-08 17:33:46 +10:00
parent 262fc72044
commit 193e9aa7dc
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
7 changed files with 30 additions and 9 deletions

View File

@ -1,4 +1,5 @@
using System; #if AVI_SUPPORT
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -460,10 +461,12 @@ namespace BizHawk.Client.EmuHawk
public static void DeallocateAVICOMPRESSOPTIONS(ref AVIWriterImports.AVICOMPRESSOPTIONS opts) public static void DeallocateAVICOMPRESSOPTIONS(ref AVIWriterImports.AVICOMPRESSOPTIONS opts)
{ {
#endif
#if false // test: increase stability by never freeing anything, ever #if false // test: increase stability by never freeing anything, ever
if (opts.lpParms != IntPtr.Zero) Win32Imports.HeapFree(Win32Imports.GetProcessHeap(), 0, opts.lpParms); if (opts.lpParms != IntPtr.Zero) Win32Imports.HeapFree(Win32Imports.GetProcessHeap(), 0, opts.lpParms);
if (opts.lpFormat != IntPtr.Zero) Win32Imports.HeapFree(Win32Imports.GetProcessHeap(), 0, opts.lpFormat); if (opts.lpFormat != IntPtr.Zero) Win32Imports.HeapFree(Win32Imports.GetProcessHeap(), 0, opts.lpFormat);
#endif #endif
#if AVI_SUPPORT
opts.lpParms = IntPtr.Zero; opts.lpParms = IntPtr.Zero;
opts.lpFormat = IntPtr.Zero; opts.lpFormat = IntPtr.Zero;
} }
@ -985,6 +988,7 @@ namespace BizHawk.Client.EmuHawk
public bool UsesVideo => true; public bool UsesVideo => true;
#endif
#if false // API has changed #if false // API has changed
private static void TestAVI() private static void TestAVI()
{ {
@ -1017,5 +1021,7 @@ namespace BizHawk.Client.EmuHawk
aw.CloseFile(); aw.CloseFile();
} }
#endif #endif
#if AVI_SUPPORT
} }
} }
#endif

View File

@ -12,13 +12,18 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class SynclessRecordingTools : Form, IDialogParent public partial class SynclessRecordingTools : Form, IDialogParent
{ {
private readonly List<FrameInfo> _mFrameInfos = new List<FrameInfo>();
private readonly Config _config; private readonly Config _config;
private readonly IGameInfo _game; private readonly IGameInfo _game;
private string _mSynclessConfigFile; #if AVI_SUPPORT
private readonly List<FrameInfo> _mFrameInfos = new List<FrameInfo>();
private string _mFramesDirectory; private string _mFramesDirectory;
private string _mSynclessConfigFile;
#endif
public IDialogController DialogController { get; } public IDialogController DialogController { get; }
public SynclessRecordingTools(Config config, IGameInfo game, IDialogController dialogController) public SynclessRecordingTools(Config config, IGameInfo game, IDialogController dialogController)
@ -29,6 +34,7 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
#if AVI_SUPPORT
public void Run() public void Run()
{ {
var ofd = new OpenFileDialog var ofd = new OpenFileDialog
@ -97,9 +103,11 @@ namespace BizHawk.Client.EmuHawk
public string WavPath { get; set; } public string WavPath { get; set; }
public string PngPath { get; set; } public string PngPath { get; set; }
} }
#endif
private void BtnExport_Click(object sender, EventArgs e) private void BtnExport_Click(object sender, EventArgs e)
{ {
#if AVI_SUPPORT
if (_mFrameInfos.Count == 0) if (_mFrameInfos.Count == 0)
{ {
return; return;
@ -151,6 +159,7 @@ namespace BizHawk.Client.EmuHawk
} }
avw.CloseFile(); avw.CloseFile();
#endif
} }
} }
} }

View File

@ -869,7 +869,6 @@ namespace BizHawk.Client.EmuHawk
// SynclessRecordingMenuItem // SynclessRecordingMenuItem
// //
this.SynclessRecordingMenuItem.Text = "S&yncless Recording Tools"; this.SynclessRecordingMenuItem.Text = "S&yncless Recording Tools";
this.SynclessRecordingMenuItem.Click += new System.EventHandler(this.SynclessRecordingMenuItem_Click);
// //
// ScreenshotSubMenu // ScreenshotSubMenu
// //

View File

@ -532,11 +532,6 @@ namespace BizHawk.Client.EmuHawk
StopAv(); StopAv();
} }
private void SynclessRecordingMenuItem_Click(object sender, EventArgs e)
{
new SynclessRecordingTools(Config, Game, this).Run();
}
private void CaptureOSDMenuItem_Click(object sender, EventArgs e) private void CaptureOSDMenuItem_Click(object sender, EventArgs e)
{ {
bool c = ((ToolStripMenuItem)sender).Checked; bool c = ((ToolStripMenuItem)sender).Checked;

View File

@ -344,6 +344,11 @@ namespace BizHawk.Client.EmuHawk
ZXSpectrumExportSnapshotMenuItemMenuItem.Enabled = false; ZXSpectrumExportSnapshotMenuItemMenuItem.Enabled = false;
ZXSpectrumExportSnapshotMenuItemMenuItem.Visible = false; ZXSpectrumExportSnapshotMenuItemMenuItem.Visible = false;
#endif #endif
#if AVI_SUPPORT
SynclessRecordingMenuItem.Click += (_, _) => new SynclessRecordingTools(Config, Game, this).Run();
#else
SynclessRecordingMenuItem.Enabled = false;
#endif
Game = GameInfo.NullInstance; Game = GameInfo.NullInstance;
_throttle = new Throttle(); _throttle = new Throttle();
@ -3229,7 +3234,11 @@ namespace BizHawk.Client.EmuHawk
try try
{ {
#if AVI_SUPPORT
bool usingAvi = aw is AviWriter; // SO GROSS! bool usingAvi = aw is AviWriter; // SO GROSS!
#else
const bool usingAvi = false;
#endif
if (_dumpaudiosync) if (_dumpaudiosync)
{ {

View File

@ -1,5 +1,6 @@
#nullable disable #nullable disable
#if AVI_SUPPORT
using System; using System;
using System.Runtime.InteropServices; 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); public static extern int AVIStreamWrite(IntPtr pavi, int lStart, int lSamples, IntPtr lpBuffer, int cbBuffer, int dwFlags, IntPtr plSampWritten, out int plBytesWritten);
} }
} }
#endif

View File

@ -3,6 +3,7 @@
<PropertyGroup> <PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CodeAnalysisRuleSet>$(ProjectDir)../../Common.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>$(ProjectDir)../../Common.ruleset</CodeAnalysisRuleSet>
<DefineConstants>$(DefineConstants);AVI_SUPPORT</DefineConstants>
<DocumentationFile>$(ProjectDir)bin/doc_comments.xml</DocumentationFile> <DocumentationFile>$(ProjectDir)bin/doc_comments.xml</DocumentationFile>
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages> <MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
<NoWarn>CS1573;CS1591</NoWarn> <NoWarn>CS1573;CS1591</NoWarn>