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 node_id;
bool pwr_stream_state;
uint32_t framerate;
// wlroots
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);
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,

View File

@ -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);

View File

@ -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,