screencast: only restart wlroots loop if stream is active

This prevents the wlroots loop from running after the first roundtrip to
query the buffer informations from the screencopy protocol.
This commit is contained in:
columbarius 2021-06-16 18:35:37 +02:00
parent f77b751649
commit fc85f6738b
2 changed files with 11 additions and 6 deletions

View file

@ -72,6 +72,9 @@ static void pwr_handle_stream_state_changed(void *data,
switch (state) { switch (state) {
case PW_STREAM_STATE_STREAMING: case PW_STREAM_STATE_STREAMING:
cast->pwr_stream_state = true; cast->pwr_stream_state = true;
if (!cast->wlr_frame) {
xdpw_wlr_register_cb(cast);
}
break; break;
default: default:
cast->pwr_stream_state = false; cast->pwr_stream_state = false;

View file

@ -52,6 +52,7 @@ void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
return ; return ;
} }
if (cast->pwr_stream_state) {
uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->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,
@ -60,6 +61,7 @@ void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
xdpw_wlr_register_cb(cast); xdpw_wlr_register_cb(cast);
} }
} }
}
static struct wl_buffer *create_shm_buffer(struct xdpw_screencast_instance *cast, static struct wl_buffer *create_shm_buffer(struct xdpw_screencast_instance *cast,
enum wl_shm_format fmt, int width, int height, int stride, enum wl_shm_format fmt, int width, int height, int stride,