From bb24b226e4c9c3f3b72ebc20520d380400e77dd5 Mon Sep 17 00:00:00 2001 From: columbarius Date: Sun, 13 Jun 2021 20:33:34 +0200 Subject: [PATCH] screencast: respect the maximal framerate negotiated by pipewire --- include/screencast_common.h | 1 + src/screencast/pipewire_screencast.c | 1 + src/screencast/screencast.c | 1 + src/screencast/wlr_screencast.c | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/screencast_common.h b/include/screencast_common.h index 3aecc86..2c3ce75 100644 --- a/include/screencast_common.h +++ b/include/screencast_common.h @@ -92,6 +92,7 @@ struct xdpw_screencast_instance { uint32_t seq; uint32_t node_id; bool pwr_stream_state; + uint32_t framerate; // wlroots struct zwlr_screencopy_frame_v1 *frame_callback; diff --git a/src/screencast/pipewire_screencast.c b/src/screencast/pipewire_screencast.c index d25b9a3..07419d1 100644 --- a/src/screencast/pipewire_screencast.c +++ b/src/screencast/pipewire_screencast.c @@ -113,6 +113,7 @@ static void pwr_handle_stream_param_changed(void *data, uint32_t id, } spa_format_video_raw_parse(param, &cast->pwr_format); + cast->framerate = (uint32_t)(cast->pwr_format.max_framerate.num / cast->pwr_format.max_framerate.denom); params[0] = spa_pod_builder_add_object(&b, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, diff --git a/src/screencast/screencast.c b/src/screencast/screencast.c index eb07f70..aa01b22 100644 --- a/src/screencast/screencast.c +++ b/src/screencast/screencast.c @@ -56,6 +56,7 @@ void xdpw_screencast_instance_init(struct xdpw_screencast_context *ctx, } else { cast->max_framerate = (uint32_t)out->framerate; } + cast->framerate = cast->max_framerate; cast->with_cursor = with_cursor; cast->refcount = 1; logprint(INFO, "xdpw: screencast instance %p has %d references", cast, cast->refcount); diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index 19ea9c4..7e0d49d 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -52,7 +52,7 @@ void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) { return ; } - uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->max_framerate); + uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->framerate); if (delay_ns > 0) { xdpw_add_timer(cast->ctx->state, delay_ns, (xdpw_event_loop_timer_func_t) xdpw_wlr_register_cb, cast); @@ -144,7 +144,7 @@ static void wlr_frame_buffer_done(void *data, zwlr_screencopy_frame_v1_copy_with_damage(frame, cast->simple_frame.buffer); logprint(TRACE, "wlroots: frame copied"); - fps_limit_measure_start(&cast->fps_limit, cast->max_framerate); + fps_limit_measure_start(&cast->fps_limit, cast->framerate); } static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,