diff --git a/include/screencast_common.h b/include/screencast_common.h index c0265ada..6aca0b1d 100644 --- a/include/screencast_common.h +++ b/include/screencast_common.h @@ -92,6 +92,7 @@ struct xdpw_screencast_instance { uint32_t node_id; bool pwr_stream_state; struct pw_buffer *current_pw_buffer; + int buffer_refcount; // wlroots struct zwlr_screencopy_frame_v1 *frame_callback; diff --git a/src/screencast/pipewire_screencast.c b/src/screencast/pipewire_screencast.c index 67e05c7b..7c6bdeaa 100644 --- a/src/screencast/pipewire_screencast.c +++ b/src/screencast/pipewire_screencast.c @@ -72,7 +72,7 @@ static void pwr_handle_stream_state_changed(void *data, switch (state) { case PW_STREAM_STATE_STREAMING: cast->pwr_stream_state = true; - xdpw_wlr_frame_start(cast); + xdpw_wlr_register_cb(cast); break; default: cast->pwr_stream_state = false; @@ -156,6 +156,12 @@ static void pwr_handle_stream_add_buffer(void *data, struct pw_buffer *buffer) { // create wl_buffer d[0].data = import_shm_buffer(cast, d[0].fd, cast->simple_frame.format, cast->simple_frame.width, cast->simple_frame.height, cast->simple_frame.stride); + + cast->buffer_refcount++; + } + // TODO: start stream again after renegotiation + if (cast->pwr_stream_state && cast->buffer_refcount == 1) { + xdpw_wlr_frame_start(cast); } }