Skip to content

Commit

Permalink
screencopy: only restart wlroots loop if stream is active
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Jun 17, 2021
1 parent 4ac6de2 commit d80992e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/screencast/pipewire_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 9 additions & 6 deletions src/screencast/wlr_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit d80992e

Please sign in to comment.