Browse Source

win-capture: Don't try to find window every frame

When window capture is not capturing a window, don't try to find the
window every frame.  Instead, just check once per frame.  The process of
finding a window has a lot of checks and requires a surprising amount of
processing.
jp9000 7 years ago
parent
commit
c372d26c02
1 changed files with 11 additions and 0 deletions
  1. 11 0
      plugins/win-capture/window-capture.c

+ 11 - 0
plugins/win-capture/window-capture.c

@@ -26,6 +26,7 @@ struct window_capture {
 	struct dc_capture    capture;
 
 	float                resize_timer;
+	float                check_window_timer;
 	float                cursor_check_time;
 
 	HWND                 window;
@@ -158,6 +159,16 @@ static void wc_tick(void *data, float seconds)
 		if (!wc->title && !wc->class)
 			return;
 
+		wc->check_window_timer += seconds;
+
+		if (wc->check_window_timer < 1.0f) {
+			if (wc->capture.valid)
+				dc_capture_free(&wc->capture);
+			return;
+		}
+
+		wc->check_window_timer = 0.0f;
+
 		wc->window = find_window(EXCLUDE_MINIMIZED, wc->priority,
 				wc->class, wc->title, wc->executable);
 		if (!wc->window) {