From 2c5b2dfa66338d87461682dbf5ad60dd347591d5 Mon Sep 17 00:00:00 2001 From: Jimmy Quach Date: Thu, 11 Aug 2022 15:47:32 -0700 Subject: [PATCH] fix: windowSize not being initialized rename static currentSize -> windowSize (makes more sense) --- Classes/Recorders/LibObsRecorder.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/Recorders/LibObsRecorder.cs b/Classes/Recorders/LibObsRecorder.cs index 06d2be31..0e54826f 100644 --- a/Classes/Recorders/LibObsRecorder.cs +++ b/Classes/Recorders/LibObsRecorder.cs @@ -17,7 +17,7 @@ public class LibObsRecorder : BaseRecorder { static IntPtr windowHandle = IntPtr.Zero; static IntPtr output = IntPtr.Zero; - static Rect currentSize; + static Rect windowSize; Dictionary audioSources = new(), videoSources = new(); Dictionary audioEncoders = new(), videoEncoders = new(); @@ -51,8 +51,8 @@ public override void Start() { if(signalGCHookSuccess != false && RecordingService.IsRecording) { // everytime the "Starting capture" signal occurs, there could be a possibility that the game window has resized // check to see if windowSize is different from currentSize, if so, restart recording with correct output resolution - Rect windowSize = GetWindowSize(windowHandle); - if ((windowSize.GetWidth() > 1 && windowSize.GetHeight() > 1) && // fullscreen tabbing check + Rect currentSize = GetWindowSize(windowHandle); + if ((currentSize.GetWidth() > 1 && currentSize.GetHeight() > 1) && // fullscreen tabbing check (currentSize.GetWidth() != windowSize.GetWidth() || currentSize.GetHeight() != windowSize.GetHeight())) { RestartRecording(); } @@ -143,7 +143,7 @@ public override async Task StartRecording() { var windowClassNameId = GetWindowTitle(windowHandle) + ":" + GetClassName(windowHandle) + ":" + Path.GetFileName(session.Exe); // get game's window size and change output to match - Rect windowSize = GetWindowSize(windowHandle); + windowSize = GetWindowSize(windowHandle); // sometimes, the inital window size might be in a middle of a transition, and gives us a weird dimension // this is a quick a dirty check: if there aren't more than 1120 pixels, we can assume it needs a retry while (windowSize.GetWidth() + windowSize.GetHeight() < 1120 && retryAttempt < maxRetryAttempts) {