Skip to content

Commit

Permalink
fix: windowSize not being initialized
Browse files Browse the repository at this point in the history
rename static currentSize -> windowSize (makes more sense)
  • Loading branch information
lulzsun committed Aug 11, 2022
1 parent 95663c7 commit 2c5b2df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Classes/Recorders/LibObsRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, IntPtr> audioSources = new(), videoSources = new();
Dictionary<string, IntPtr> audioEncoders = new(), videoEncoders = new();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -143,7 +143,7 @@ public override async Task<bool> 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) {
Expand Down

0 comments on commit 2c5b2df

Please sign in to comment.