From 69223e3645ff336de47434f31b55288dd6026723 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 5 Jan 2015 00:45:47 -0800 Subject: [PATCH] win-capture: Retry hooks on most failures The design to not retry the hooks on most general error is just bad. There are plenty of legitimate cases where it should retry the hook. This changes it so that if a general failure occurs or if it isn't capturing when the inject helper exits, it retries and increases the length of time between retries. --- plugins/win-capture/game-capture.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index 3e3b211cb..fb6f4d7ff 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -79,6 +79,7 @@ struct game_capture { float fps_reset_time; float retry_interval; bool active : 1; + bool capturing : 1; bool activate_hook : 1; bool process_is_64bit : 1; bool error_acquiring : 1; @@ -196,6 +197,7 @@ static void stop_capture(struct game_capture *gc) gc->copy_texture = NULL; gc->active = false; + gc->capturing = false; } static inline void free_config(struct game_capture_config *config) @@ -941,13 +943,18 @@ static void game_capture_tick(void *data, float seconds) if (exit_code != 0) { warn("inject process failed: %d", exit_code); gc->error_acquiring = true; + + } else if (!gc->capturing) { + gc->retry_interval = 4.0f; + stop_capture(gc); } } if (gc->hook_ready && object_signalled(gc->hook_ready)) { - if (!start_capture(gc)) { + gc->capturing = start_capture(gc); + if (!gc->capturing) { + gc->retry_interval = 4.0f; stop_capture(gc); - gc->error_acquiring = true; } }