Browse Source

win-capture: Shut down game cap. when not showing

Prevents game capture from acting as a global source.  This fixes an
issue where a game capture in another scene could capture a window and
prevent a separate game capture in the current scene from being able to
capture that same window.
jp9000 9 years ago
parent
commit
8681baeec3
1 changed files with 13 additions and 5 deletions
  1. 13 5
      plugins/win-capture/game-capture.c

+ 13 - 5
plugins/win-capture/game-capture.c

@@ -84,6 +84,7 @@ struct game_capture {
 	float                         fps_reset_time;
 	float                         retry_interval;
 	bool                          wait_for_target_startup : 1;
+	bool                          showing : 1;
 	bool                          active : 1;
 	bool                          capturing : 1;
 	bool                          activate_hook : 1;
@@ -1254,6 +1255,15 @@ static void game_capture_tick(void *data, float seconds)
 {
 	struct game_capture *gc = data;
 
+	if (!obs_source_showing(gc->source)) {
+		if (gc->showing) {
+			if (gc->active)
+				stop_capture(gc);
+			gc->showing = false;
+		}
+		return;
+	}
+
 	if (gc->hook_stop && object_signalled(gc->hook_stop)) {
 		stop_capture(gc);
 	}
@@ -1294,11 +1304,6 @@ static void game_capture_tick(void *data, float seconds)
 	gc->retry_time += seconds;
 
 	if (!gc->active) {
-		if (!obs_source_showing(gc->source)) {
-			gc->retry_time = 0.0f;
-			return;
-		}
-
 		if (!gc->error_acquiring &&
 		    gc->retry_time > gc->retry_interval) {
 			if (gc->config.capture_any_fullscreen ||
@@ -1332,6 +1337,9 @@ static void game_capture_tick(void *data, float seconds)
 			}
 		}
 	}
+
+	if (!gc->showing)
+		gc->showing = true;
 }
 
 static inline void game_capture_render_cursor(struct game_capture *gc)