mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 23:45:58 +01:00
screencast: respect the maximal framerate negotiated by pipewire
This commit is contained in:
parent
976fa8374d
commit
bb24b226e4
4 changed files with 5 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue