From d80992e8e4e253ebe18918f3cef9589c3e8d9a8b Mon Sep 17 00:00:00 2001 From: columbarius Date: Wed, 16 Jun 2021 18:35:37 +0200 Subject: [PATCH] screencopy: only restart wlroots loop if stream is active --- src/screencast/pipewire_screencast.c | 1 + src/screencast/wlr_screencast.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/screencast/pipewire_screencast.c b/src/screencast/pipewire_screencast.c index a6b4e8bf..ef8d7983 100644 --- a/src/screencast/pipewire_screencast.c +++ b/src/screencast/pipewire_screencast.c @@ -78,6 +78,7 @@ static void pwr_handle_stream_state_changed(void *data, switch (state) { case PW_STREAM_STATE_STREAMING: cast->pwr_stream_state = true; + xdpw_wlr_register_cb(cast); break; default: cast->pwr_stream_state = false; diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index ff7422ae..a31050a3 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -52,12 +52,15 @@ void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) { return ; } - uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->ctx->state->config->screencast_conf.max_fps); - if (delay_ns > 0) { - xdpw_add_timer(cast->ctx->state, delay_ns, - (xdpw_event_loop_timer_func_t) xdpw_wlr_register_cb, cast); - } else { - xdpw_wlr_register_cb(cast); + + if (cast->pwr_stream_state) { + uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->ctx->state->config->screencast_conf.max_fps); + if (delay_ns > 0) { + xdpw_add_timer(cast->ctx->state, delay_ns, + (xdpw_event_loop_timer_func_t) xdpw_wlr_register_cb, cast); + } else { + xdpw_wlr_register_cb(cast); + } } }