Skip to content

Commit

Permalink
screencast: use refcounting to restart wlroots loop after reneg
Browse files Browse the repository at this point in the history
this complements the previous commit, which won't restart the wlroots
loop after renegotiation. Restarting the stream on the first new
add_buffer call works, but maybe we can find a nicer solution here.
  • Loading branch information
columbarius committed Jun 15, 2021
1 parent fa8160b commit cb890d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/screencast_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/screencast/pipewire_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit cb890d1

Please sign in to comment.