diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index 9bee3f6dc1..1d27da5572 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -276,6 +276,9 @@ namespace BizHawk.Client.Common public int GifWriterDelay { get; set; } = -1; public bool VideoWriterAudioSync { get; set; } = true; + [JsonIgnore] + public bool VideoWriterAudioSyncEffective; + // Emulation core settings internal Dictionary CoreSettings { get; set; } = new Dictionary(); internal Dictionary CoreSyncSettings { get; set; } = new Dictionary(); @@ -368,5 +371,9 @@ namespace BizHawk.Client.Common public bool RASoundEffects { get; set; } = true; public bool RAAllowUnofficialCheevos { get; set; } public bool RAAutostart { get; set; } + + public bool AVWriterPad { get; set; } = false; + + public (int Width, int Height) AVWriterResize { get; set; } = (0, 0); } } diff --git a/src/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs b/src/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs index 699b307020..a1b9aa9192 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs @@ -61,15 +61,15 @@ namespace BizHawk.Client.EmuHawk IEnumerable list, T owner, IEmulator emulator, - Config config, - out int resizeW, - out int resizeH, - out bool pad, - ref bool audioSync) + Config config) where T : IMainFormForTools, IDialogParent { var dlg = new VideoWriterChooserForm(owner, emulator, config) { + checkBoxASync = { Checked = config.VideoWriterAudioSyncEffective }, + checkBoxPad = { Checked = config.AVWriterPad }, + numericTextBoxH = { Text = Math.Max(0, config.AVWriterResize.Height).ToString() }, + numericTextBoxW = { Text = Math.Max(0, config.AVWriterResize.Width).ToString() }, labelDescriptionBody = { Text = "" } }; @@ -95,8 +95,6 @@ namespace BizHawk.Client.EmuHawk c.Enabled = false; } - dlg.checkBoxASync.Checked = audioSync; - IVideoWriter ret = null; if (owner.ShowDialogAsChild(dlg).IsOk() && dlg.listBox1.SelectedIndex is not -1) @@ -106,20 +104,14 @@ namespace BizHawk.Client.EmuHawk config.VideoWriter = vwi.Attribs.ShortName; } - if (ret != null && dlg.checkBoxResize.Checked) + if (ret is not null) { - resizeW = dlg.numericTextBoxW.IntValue; - resizeH = dlg.numericTextBoxH.IntValue; + config.AVWriterResize = dlg.checkBoxResize.Checked + ? (dlg.numericTextBoxW.IntValue, dlg.numericTextBoxH.IntValue) + : (-1, -1); + config.AVWriterPad = dlg.checkBoxPad.Checked; + config.VideoWriterAudioSyncEffective = config.VideoWriterAudioSync = dlg.checkBoxASync.Checked; } - else - { - resizeW = -1; - resizeH = -1; - } - - pad = dlg.checkBoxPad.Checked; - audioSync = dlg.checkBoxASync.Checked; - dlg.Dispose(); return ret; } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index a93cf5a864..099dc7c4fa 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -606,11 +606,7 @@ namespace BizHawk.Client.EmuHawk LoadMostRecentROM(); } - if (_argParser.audiosync.HasValue) - { - Config.VideoWriterAudioSync = _argParser.audiosync.Value; - } - + Config.VideoWriterAudioSyncEffective = _argParser.audiosync ?? Config.VideoWriterAudioSync; _autoDumpLength = _argParser._autoDumpLength; if (_argParser.cmdMovie != null) { @@ -1705,10 +1701,6 @@ namespace BizHawk.Client.EmuHawk private ISoundProvider _aviSoundInputAsync; // Note: This sound provider must be in async mode! private SimpleSyncSoundProvider _dumpProxy; // an audio proxy used for dumping - private bool _dumpaudiosync; // set true to for experimental AV dumping - private int _avwriterResizew; - private int _avwriterResizeh; - private bool _avwriterpad; private bool _windowClosedAndSafeToExitProcess; private int _exitCode; @@ -3358,7 +3350,6 @@ namespace BizHawk.Client.EmuHawk videoWriterName = Config.VideoWriter; } - _dumpaudiosync = Config.VideoWriterAudioSync; if (unattended && !string.IsNullOrEmpty(videoWriterName)) { aw = VideoWriterInventory.GetVideoWriter(videoWriterName, this); @@ -3369,11 +3360,7 @@ namespace BizHawk.Client.EmuHawk VideoWriterInventory.GetAllWriters(), this, Emulator, - Config, - out _avwriterResizew, - out _avwriterResizeh, - out _avwriterpad, - ref _dumpaudiosync); + Config); } if (aw == null) @@ -3392,19 +3379,11 @@ namespace BizHawk.Client.EmuHawk const bool usingAvi = false; #endif - if (_dumpaudiosync) - { - aw = new VideoStretcher(aw); - } - else - { - aw = new AudioStretcher(aw); - } - + aw = Config.VideoWriterAudioSyncEffective ? new VideoStretcher(aw) : new AudioStretcher(aw); aw.SetMovieParameters(Emulator.VsyncNumerator(), Emulator.VsyncDenominator()); - if (_avwriterResizew > 0 && _avwriterResizeh > 0) + if (Config.AVWriterResize.Width > 0 && Config.AVWriterResize.Height > 0) { - aw.SetVideoParameters(_avwriterResizew, _avwriterResizeh); + aw.SetVideoParameters(Config.AVWriterResize.Width, Config.AVWriterResize.Height); } else { @@ -3492,7 +3471,7 @@ namespace BizHawk.Client.EmuHawk throw; } - if (_dumpaudiosync) + if (Config.VideoWriterAudioSyncEffective) { _currentSoundProvider.SetSyncMode(SyncSoundMode.Sync); } @@ -3567,7 +3546,7 @@ namespace BizHawk.Client.EmuHawk { IVideoProvider output; IDisposable disposableOutput = null; - if (_avwriterResizew > 0 && _avwriterResizeh > 0) + if (Config.AVWriterResize.Width > 0 && Config.AVWriterResize.Height > 0) { BitmapBuffer bbIn = null; Bitmap bmpIn = null; @@ -3579,11 +3558,11 @@ namespace BizHawk.Client.EmuHawk bbIn.DiscardAlpha(); - var bmpOut = new Bitmap(_avwriterResizew, _avwriterResizeh, PixelFormat.Format32bppArgb); + Bitmap bmpOut = new(width: Config.AVWriterResize.Width, height: Config.AVWriterResize.Height, PixelFormat.Format32bppArgb); bmpIn = bbIn.ToSysdrawingBitmap(); using (var g = Graphics.FromImage(bmpOut)) { - if (_avwriterpad) + if (Config.AVWriterPad) { g.Clear(Color.FromArgb(_currentVideoProvider.BackgroundColor)); g.DrawImageUnscaled(bmpIn, (bmpOut.Width - bmpIn.Width) / 2, (bmpOut.Height - bmpIn.Height) / 2); @@ -3627,7 +3606,7 @@ namespace BizHawk.Client.EmuHawk short[] samp; int nsamp; - if (_dumpaudiosync) + if (Config.VideoWriterAudioSyncEffective) { ((VideoStretcher) _currAviWriter).DumpAV(output, _currentSoundProvider, out samp, out nsamp); }