screencast: respect the maximal framerate negotiated by pipewire

This commit is contained in:
columbarius 2021-06-13 20:33:34 +02:00 committed by Simon Ser
parent 976fa8374d
commit bb24b226e4
4 changed files with 5 additions and 2 deletions

View file

@ -92,6 +92,7 @@ struct xdpw_screencast_instance {
uint32_t seq; uint32_t seq;
uint32_t node_id; uint32_t node_id;
bool pwr_stream_state; bool pwr_stream_state;
uint32_t framerate;
// wlroots // wlroots
struct zwlr_screencopy_frame_v1 *frame_callback; struct zwlr_screencopy_frame_v1 *frame_callback;

View file

@ -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); 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, params[0] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,

View file

@ -56,6 +56,7 @@ void xdpw_screencast_instance_init(struct xdpw_screencast_context *ctx,
} else { } else {
cast->max_framerate = (uint32_t)out->framerate; cast->max_framerate = (uint32_t)out->framerate;
} }
cast->framerate = cast->max_framerate;
cast->with_cursor = with_cursor; cast->with_cursor = with_cursor;
cast->refcount = 1; cast->refcount = 1;
logprint(INFO, "xdpw: screencast instance %p has %d references", cast, cast->refcount); logprint(INFO, "xdpw: screencast instance %p has %d references", cast, cast->refcount);

View file

@ -52,7 +52,7 @@ void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
return ; 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) { if (delay_ns > 0) {
xdpw_add_timer(cast->ctx->state, delay_ns, xdpw_add_timer(cast->ctx->state, delay_ns,
(xdpw_event_loop_timer_func_t) xdpw_wlr_register_cb, cast); (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); zwlr_screencopy_frame_v1_copy_with_damage(frame, cast->simple_frame.buffer);
logprint(TRACE, "wlroots: frame copied"); 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, static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,